blob: af910e0473417325d12029fd9f1d2713198b38b8 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Makoto Onuki7d1911f2017-06-09 12:30:09 -070019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060024import android.annotation.NonNull;
25import android.annotation.Nullable;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070026import android.annotation.SdkConstant;
27import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050028import android.annotation.SystemApi;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010029import android.annotation.UnsupportedAppUsage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050031import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060032import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.content.pm.PackageManager;
34import android.content.pm.ResolveInfo;
35import android.content.res.Resources;
36import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080037import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070038import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060039import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070040import android.os.Bundle;
41import android.os.IBinder;
42import android.os.Parcel;
43import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070044import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000045import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050046import android.os.ResultReceiver;
47import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070048import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010049import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070050import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070051import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070052import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070054import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000055import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050056import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057import android.util.AttributeSet;
58import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070059import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070060
Dianne Hackborn2269d1572010-02-24 19:54:22 -080061import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070062
Jason Monk2f68e8a2016-02-23 17:57:28 -050063import org.xmlpull.v1.XmlPullParser;
64import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070065import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066
67import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080068import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070069import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070070import java.lang.annotation.Retention;
71import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072import java.net.URISyntaxException;
73import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080074import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070075import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080076import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070077import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070078import java.util.Set;
79
80/**
81 * An intent is an abstract description of an operation to be performed. It
82 * can be used with {@link Context#startActivity(Intent) startActivity} to
83 * launch an {@link android.app.Activity},
84 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
85 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
86 * and {@link android.content.Context#startService} or
87 * {@link android.content.Context#bindService} to communicate with a
88 * background {@link android.app.Service}.
89 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070090 * <p>An Intent provides a facility for performing late runtime binding between the code in
91 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070092 * can be thought of as the glue between activities. It is basically a passive data structure
93 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070094 *
95 * <div class="special reference">
96 * <h3>Developer Guides</h3>
97 * <p>For information about how to create and resolve intents, read the
98 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
99 * developer guide.</p>
100 * </div>
101 *
102 * <a name="IntentStructure"></a>
103 * <h3>Intent Structure</h3>
104 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700105 *
106 * <ul>
107 * <li> <p><b>action</b> -- The general action to be performed, such as
108 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
109 * etc.</p>
110 * </li>
111 * <li> <p><b>data</b> -- The data to operate on, such as a person record
112 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
113 * </li>
114 * </ul>
115 *
116 *
117 * <p>Some examples of action/data pairs are:</p>
118 *
119 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700120 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * information about the person whose identifier is "1".</p>
122 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700123 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700124 * the phone dialer with the person filled in.</p>
125 * </li>
126 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
127 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700128 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700129 * a particular URI.</p>
130 * </li>
131 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
132 * the phone dialer with the given number filled in.</p>
133 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700134 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * information about the person whose identifier is "1".</p>
136 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700137 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700138 * a list of people, which the user can browse through. This example is a
139 * typical top-level entry into the Contacts application, showing you the
140 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700141 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700142 * being used to start an activity to display that person.</p>
143 * </li>
144 * </ul>
145 *
146 * <p>In addition to these primary attributes, there are a number of secondary
147 * attributes that you can also include with an intent:</p>
148 *
149 * <ul>
150 * <li> <p><b>category</b> -- Gives additional information about the action
151 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
152 * appear in the Launcher as a top-level application, while
153 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
154 * of alternative actions the user can perform on a piece of data.</p>
155 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
156 * intent data. Normally the type is inferred from the data itself.
157 * By setting this attribute, you disable that evaluation and force
158 * an explicit type.</p>
159 * <li> <p><b>component</b> -- Specifies an explicit name of a component
160 * class to use for the intent. Normally this is determined by looking
161 * at the other information in the intent (the action, data/type, and
162 * categories) and matching that with a component that can handle it.
163 * If this attribute is set then none of the evaluation is performed,
164 * and this component is used exactly as is. By specifying this attribute,
165 * all of the other Intent attributes become optional.</p>
166 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
167 * This can be used to provide extended information to the component.
168 * For example, if we have a action to send an e-mail message, we could
169 * also include extra pieces of data here to supply a subject, body,
170 * etc.</p>
171 * </ul>
172 *
173 * <p>Here are some examples of other operations you can specify as intents
174 * using these additional parameters:</p>
175 *
176 * <ul>
177 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
178 * Launch the home screen.</p>
179 * </li>
180 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
181 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
182 * vnd.android.cursor.item/phone}</i></b>
183 * -- Display the list of people's phone numbers, allowing the user to
184 * browse through them and pick one and return it to the parent activity.</p>
185 * </li>
186 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
187 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
188 * -- Display all pickers for data that can be opened with
189 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
190 * allowing the user to pick one of them and then some data inside of it
191 * and returning the resulting URI to the caller. This can be used,
192 * for example, in an e-mail application to allow the user to pick some
193 * data to include as an attachment.</p>
194 * </li>
195 * </ul>
196 *
197 * <p>There are a variety of standard Intent action and category constants
198 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700199 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700200 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700201 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700202 *
203 * <p>Put together, the set of actions, data types, categories, and extra data
204 * defines a language for the system allowing for the expression of phrases
205 * such as "call john smith's cell". As applications are added to the system,
206 * they can extend this language by adding new actions, types, and categories, or
207 * they can modify the behavior of existing phrases by supplying their own
208 * activities that handle them.</p>
209 *
210 * <a name="IntentResolution"></a>
211 * <h3>Intent Resolution</h3>
212 *
213 * <p>There are two primary forms of intents you will use.
214 *
215 * <ul>
216 * <li> <p><b>Explicit Intents</b> have specified a component (via
217 * {@link #setComponent} or {@link #setClass}), which provides the exact
218 * class to be run. Often these will not include any other information,
219 * simply being a way for an application to launch various internal
220 * activities it has as the user interacts with the application.
221 *
222 * <li> <p><b>Implicit Intents</b> have not specified a component;
223 * instead, they must include enough information for the system to
224 * determine which of the available components is best to run for that
225 * intent.
226 * </ul>
227 *
228 * <p>When using implicit intents, given such an arbitrary intent we need to
229 * know what to do with it. This is handled by the process of <em>Intent
230 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
231 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
232 * more activities/receivers) that can handle it.</p>
233 *
234 * <p>The intent resolution mechanism basically revolves around matching an
235 * Intent against all of the &lt;intent-filter&gt; descriptions in the
236 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
237 * objects explicitly registered with {@link Context#registerReceiver}.) More
238 * details on this can be found in the documentation on the {@link
239 * IntentFilter} class.</p>
240 *
241 * <p>There are three pieces of information in the Intent that are used for
242 * resolution: the action, type, and category. Using this information, a query
243 * is done on the {@link PackageManager} for a component that can handle the
244 * intent. The appropriate component is determined based on the intent
245 * information supplied in the <code>AndroidManifest.xml</code> file as
246 * follows:</p>
247 *
248 * <ul>
249 * <li> <p>The <b>action</b>, if given, must be listed by the component as
250 * one it handles.</p>
251 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
252 * already supplied in the Intent. Like the action, if a type is
253 * included in the intent (either explicitly or implicitly in its
254 * data), then this must be listed by the component as one it handles.</p>
255 * <li> For data that is not a <code>content:</code> URI and where no explicit
256 * type is included in the Intent, instead the <b>scheme</b> of the
257 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
258 * considered. Again like the action, if we are matching a scheme it
259 * must be listed by the component as one it can handle.
260 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
261 * by the activity as categories it handles. That is, if you include
262 * the categories {@link #CATEGORY_LAUNCHER} and
263 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
264 * with an intent that lists <em>both</em> of those categories.
265 * Activities will very often need to support the
266 * {@link #CATEGORY_DEFAULT} so that they can be found by
267 * {@link Context#startActivity Context.startActivity()}.</p>
268 * </ul>
269 *
270 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700271 * allows a user to browse through a list of notes data and view details about
272 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700273 * name with one specific to your own package.</p>
274 *
275 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
276 * package="<i>com.android.notepad</i>"&gt;
277 * &lt;application android:icon="@drawable/app_notes"
278 * android:label="@string/app_name"&gt;
279 *
280 * &lt;provider class=".NotePadProvider"
281 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
282 *
283 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
284 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700285 * &lt;action android:name="android.intent.action.MAIN" /&gt;
286 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.VIEW" /&gt;
290 * &lt;action android:name="android.intent.action.EDIT" /&gt;
291 * &lt;action android:name="android.intent.action.PICK" /&gt;
292 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
293 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700294 * &lt;/intent-filter&gt;
295 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
297 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
298 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700299 * &lt;/intent-filter&gt;
300 * &lt;/activity&gt;
301 *
302 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
303 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.VIEW" /&gt;
305 * &lt;action android:name="android.intent.action.EDIT" /&gt;
306 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
307 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700308 * &lt;/intent-filter&gt;
309 *
310 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="android.intent.action.INSERT" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700314 * &lt;/intent-filter&gt;
315 *
316 * &lt;/activity&gt;
317 *
318 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
319 * android:theme="@android:style/Theme.Dialog"&gt;
320 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700321 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
322 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
323 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
324 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
325 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700326 * &lt;/intent-filter&gt;
327 * &lt;/activity&gt;
328 *
329 * &lt;/application&gt;
330 * &lt;/manifest&gt;</pre>
331 *
332 * <p>The first activity,
333 * <code>com.android.notepad.NotesList</code>, serves as our main
334 * entry into the app. It can do three things as described by its three intent
335 * templates:
336 * <ol>
337 * <li><pre>
338 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700339 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
340 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700341 * &lt;/intent-filter&gt;</pre>
342 * <p>This provides a top-level entry into the NotePad application: the standard
343 * MAIN action is a main entry point (not requiring any other information in
344 * the Intent), and the LAUNCHER category says that this entry point should be
345 * listed in the application launcher.</p>
346 * <li><pre>
347 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700348 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
349 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
350 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
351 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700352 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * &lt;/intent-filter&gt;</pre>
354 * <p>This declares the things that the activity can do on a directory of
355 * notes. The type being supported is given with the &lt;type&gt; tag, where
356 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
357 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
358 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
359 * The activity allows the user to view or edit the directory of data (via
360 * the VIEW and EDIT actions), or to pick a particular note and return it
361 * to the caller (via the PICK action). Note also the DEFAULT category
362 * supplied here: this is <em>required</em> for the
363 * {@link Context#startActivity Context.startActivity} method to resolve your
364 * activity when its component name is not explicitly specified.</p>
365 * <li><pre>
366 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700367 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
368 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
369 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700370 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700371 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700372 * the user without needing to know where it came from. The data type
373 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
374 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
375 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
376 * The GET_CONTENT action is similar to the PICK action, where the activity
377 * will return to its caller a piece of data selected by the user. Here,
378 * however, the caller specifies the type of data they desire instead of
379 * the type of data the user will be picking from.</p>
380 * </ol>
381 *
382 * <p>Given these capabilities, the following intents will resolve to the
383 * NotesList activity:</p>
384 *
385 * <ul>
386 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
387 * activities that can be used as top-level entry points into an
388 * application.</p>
389 * <li> <p><b>{ action=android.app.action.MAIN,
390 * category=android.app.category.LAUNCHER }</b> is the actual intent
391 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700392 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700393 * data=content://com.google.provider.NotePad/notes }</b>
394 * displays a list of all the notes under
395 * "content://com.google.provider.NotePad/notes", which
396 * the user can browse through and see the details on.</p>
397 * <li> <p><b>{ action=android.app.action.PICK
398 * data=content://com.google.provider.NotePad/notes }</b>
399 * provides a list of the notes under
400 * "content://com.google.provider.NotePad/notes", from which
401 * the user can pick a note whose data URL is returned back to the caller.</p>
402 * <li> <p><b>{ action=android.app.action.GET_CONTENT
403 * type=vnd.android.cursor.item/vnd.google.note }</b>
404 * is similar to the pick action, but allows the caller to specify the
405 * kind of data they want back so that the system can find the appropriate
406 * activity to pick something of that data type.</p>
407 * </ul>
408 *
409 * <p>The second activity,
410 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
411 * note entry and allows them to edit it. It can do two things as described
412 * by its two intent templates:
413 * <ol>
414 * <li><pre>
415 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700416 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
417 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
418 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
419 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700420 * &lt;/intent-filter&gt;</pre>
421 * <p>The first, primary, purpose of this activity is to let the user interact
422 * with a single note, as decribed by the MIME type
423 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
424 * either VIEW a note or allow the user to EDIT it. Again we support the
425 * DEFAULT category to allow the activity to be launched without explicitly
426 * specifying its component.</p>
427 * <li><pre>
428 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700429 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700432 * &lt;/intent-filter&gt;</pre>
433 * <p>The secondary use of this activity is to insert a new note entry into
434 * an existing directory of notes. This is used when the user creates a new
435 * note: the INSERT action is executed on the directory of notes, causing
436 * this activity to run and have the user create the new note data which
437 * it then adds to the content provider.</p>
438 * </ol>
439 *
440 * <p>Given these capabilities, the following intents will resolve to the
441 * NoteEditor activity:</p>
442 *
443 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700444 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700445 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
446 * shows the user the content of note <var>{ID}</var>.</p>
447 * <li> <p><b>{ action=android.app.action.EDIT
448 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
449 * allows the user to edit the content of note <var>{ID}</var>.</p>
450 * <li> <p><b>{ action=android.app.action.INSERT
451 * data=content://com.google.provider.NotePad/notes }</b>
452 * creates a new, empty note in the notes list at
453 * "content://com.google.provider.NotePad/notes"
454 * and allows the user to edit it. If they keep their changes, the URI
455 * of the newly created note is returned to the caller.</p>
456 * </ul>
457 *
458 * <p>The last activity,
459 * <code>com.android.notepad.TitleEditor</code>, allows the user to
460 * edit the title of a note. This could be implemented as a class that the
461 * application directly invokes (by explicitly setting its component in
462 * the Intent), but here we show a way you can publish alternative
463 * operations on existing data:</p>
464 *
465 * <pre>
466 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700467 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
468 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
469 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
470 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
471 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700472 * &lt;/intent-filter&gt;</pre>
473 *
474 * <p>In the single intent template here, we
475 * have created our own private action called
476 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
477 * edit the title of a note. It must be invoked on a specific note
478 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
479 * view and edit actions, but here displays and edits the title contained
480 * in the note data.
481 *
482 * <p>In addition to supporting the default category as usual, our title editor
483 * also supports two other standard categories: ALTERNATIVE and
484 * SELECTED_ALTERNATIVE. Implementing
485 * these categories allows others to find the special action it provides
486 * without directly knowing about it, through the
487 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
488 * more often to build dynamic menu items with
489 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
490 * template here was also supply an explicit name for the template
491 * (via <code>android:label="@string/resolve_title"</code>) to better control
492 * what the user sees when presented with this activity as an alternative
493 * action to the data they are viewing.
494 *
495 * <p>Given these capabilities, the following intent will resolve to the
496 * TitleEditor activity:</p>
497 *
498 * <ul>
499 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
500 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
501 * displays and allows the user to edit the title associated
502 * with note <var>{ID}</var>.</p>
503 * </ul>
504 *
505 * <h3>Standard Activity Actions</h3>
506 *
507 * <p>These are the current standard actions that Intent defines for launching
508 * activities (usually through {@link Context#startActivity}. The most
509 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
510 * {@link #ACTION_EDIT}.
511 *
512 * <ul>
513 * <li> {@link #ACTION_MAIN}
514 * <li> {@link #ACTION_VIEW}
515 * <li> {@link #ACTION_ATTACH_DATA}
516 * <li> {@link #ACTION_EDIT}
517 * <li> {@link #ACTION_PICK}
518 * <li> {@link #ACTION_CHOOSER}
519 * <li> {@link #ACTION_GET_CONTENT}
520 * <li> {@link #ACTION_DIAL}
521 * <li> {@link #ACTION_CALL}
522 * <li> {@link #ACTION_SEND}
523 * <li> {@link #ACTION_SENDTO}
524 * <li> {@link #ACTION_ANSWER}
525 * <li> {@link #ACTION_INSERT}
526 * <li> {@link #ACTION_DELETE}
527 * <li> {@link #ACTION_RUN}
528 * <li> {@link #ACTION_SYNC}
529 * <li> {@link #ACTION_PICK_ACTIVITY}
530 * <li> {@link #ACTION_SEARCH}
531 * <li> {@link #ACTION_WEB_SEARCH}
532 * <li> {@link #ACTION_FACTORY_TEST}
533 * </ul>
534 *
535 * <h3>Standard Broadcast Actions</h3>
536 *
537 * <p>These are the current standard actions that Intent defines for receiving
538 * broadcasts (usually through {@link Context#registerReceiver} or a
539 * &lt;receiver&gt; tag in a manifest).
540 *
541 * <ul>
542 * <li> {@link #ACTION_TIME_TICK}
543 * <li> {@link #ACTION_TIME_CHANGED}
544 * <li> {@link #ACTION_TIMEZONE_CHANGED}
545 * <li> {@link #ACTION_BOOT_COMPLETED}
546 * <li> {@link #ACTION_PACKAGE_ADDED}
547 * <li> {@link #ACTION_PACKAGE_CHANGED}
548 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 * <li> {@link #ACTION_PACKAGE_RESTARTED}
550 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000551 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
552 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700553 * <li> {@link #ACTION_UID_REMOVED}
554 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700555 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700556 * <li> {@link #ACTION_POWER_DISCONNECTED}
557 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700558 * </ul>
559 *
560 * <h3>Standard Categories</h3>
561 *
562 * <p>These are the current standard categories that can be used to further
563 * clarify an Intent via {@link #addCategory}.
564 *
565 * <ul>
566 * <li> {@link #CATEGORY_DEFAULT}
567 * <li> {@link #CATEGORY_BROWSABLE}
568 * <li> {@link #CATEGORY_TAB}
569 * <li> {@link #CATEGORY_ALTERNATIVE}
570 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
571 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * <li> {@link #CATEGORY_HOME}
574 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400576 * <li> {@link #CATEGORY_CAR_DOCK}
577 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500578 * <li> {@link #CATEGORY_LE_DESK_DOCK}
579 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200580 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700581 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800582 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700583 * </ul>
584 *
585 * <h3>Standard Extra Data</h3>
586 *
587 * <p>These are the current standard fields that can be used as extra data via
588 * {@link #putExtra}.
589 *
590 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_ALARM_COUNT}
592 * <li> {@link #EXTRA_BCC}
593 * <li> {@link #EXTRA_CC}
594 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
595 * <li> {@link #EXTRA_DATA_REMOVED}
596 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500597 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
598 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_DOCK_STATE_CAR}
600 * <li> {@link #EXTRA_DOCK_STATE_DESK}
601 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
602 * <li> {@link #EXTRA_DONT_KILL_APP}
603 * <li> {@link #EXTRA_EMAIL}
604 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700607 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700609 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
611 * <li> {@link #EXTRA_REPLACING}
612 * <li> {@link #EXTRA_SHORTCUT_ICON}
613 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
614 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800616 * <li> {@link #EXTRA_SHORTCUT_NAME}
617 * <li> {@link #EXTRA_SUBJECT}
618 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800620 * <li> {@link #EXTRA_TITLE}
621 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 * </ul>
623 *
624 * <h3>Flags</h3>
625 *
626 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800627 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
628 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700629 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800630public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700631 private static final String ATTR_ACTION = "action";
632 private static final String TAG_CATEGORIES = "categories";
633 private static final String ATTR_CATEGORY = "category";
634 private static final String TAG_EXTRA = "extra";
635 private static final String ATTR_TYPE = "type";
636 private static final String ATTR_COMPONENT = "component";
637 private static final String ATTR_DATA = "data";
638 private static final String ATTR_FLAGS = "flags";
639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 // ---------------------------------------------------------------------
641 // ---------------------------------------------------------------------
642 // Standard intent activity actions (see action variable).
643
644 /**
645 * Activity Action: Start as a main entry point, does not expect to
646 * receive data.
647 * <p>Input: nothing
648 * <p>Output: nothing
649 */
650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
651 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700653 /**
654 * Activity Action: Display the data to the user. This is the most common
655 * action performed on data -- it is the generic action you can use on
656 * a piece of data to get the most reasonable thing to occur. For example,
657 * when used on a contacts entry it will view the entry; when used on a
658 * mailto: URI it will bring up a compose window filled with the information
659 * supplied by the URI; when used with a tel: URI it will invoke the
660 * dialer.
661 * <p>Input: {@link #getData} is URI from which to retrieve data.
662 * <p>Output: nothing.
663 */
664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
665 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800666
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700667 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700668 * Extra that can be included on activity intents coming from the storage UI
669 * when it launches sub-activities to manage various types of storage. For example,
670 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
671 * the images on the device, and in that case also include this extra to tell the
672 * app it is coming from the storage UI so should help the user manage storage of
673 * this type.
674 */
675 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
676
677 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700678 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
679 * performed on a piece of data.
680 */
681 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800682
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700683 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900684 * Activity Action: Quick view the data. Launches a quick viewer for
685 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900686 * <p>Activities handling this intent action should handle the vast majority of
687 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700688 * <p>Quick viewers must render the quick view image locally, and must not send
689 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900690 * <p>Input: {@link #getData} is a mandatory content URI of the item to
691 * preview. {@link #getClipData} contains an optional list of content URIs
692 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
693 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700694 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
695 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700696 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900697 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700698 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700699 */
700 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
701 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
702
703 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 * Used to indicate that some piece of data should be attached to some other
705 * place. For example, image data could be attached to a contact. It is up
706 * to the recipient to decide where the data should be attached; the intent
707 * does not specify the ultimate destination.
708 * <p>Input: {@link #getData} is URI of data to be attached.
709 * <p>Output: nothing.
710 */
711 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
712 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 /**
715 * Activity Action: Provide explicit editable access to the given data.
716 * <p>Input: {@link #getData} is URI of data to be edited.
717 * <p>Output: nothing.
718 */
719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
720 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800721
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700722 /**
723 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
724 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
725 * The extras can contain type specific data to pass through to the editing/creating
726 * activity.
727 * <p>Output: The URI of the item that was picked. This must be a content:
728 * URI so that any receiver can access it.
729 */
730 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
731 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800732
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700733 /**
734 * Activity Action: Pick an item from the data, returning what was selected.
735 * <p>Input: {@link #getData} is URI containing a directory of data
736 * (vnd.android.cursor.dir/*) from which to pick an item.
737 * <p>Output: The URI of the item that was picked.
738 */
739 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
740 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700742 /**
743 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800745 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
746 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700747 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
748 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800749 * (value: ShortcutIconResource).</p>
750 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800751 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700752 * @see #EXTRA_SHORTCUT_INTENT
753 * @see #EXTRA_SHORTCUT_NAME
754 * @see #EXTRA_SHORTCUT_ICON
755 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
756 * @see android.content.Intent.ShortcutIconResource
757 */
758 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
759 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
760
761 /**
762 * The name of the extra used to define the Intent of a shortcut.
763 *
764 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
769 /**
770 * The name of the extra used to define the name of a shortcut.
771 *
772 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
777 /**
778 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
779 *
780 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800781 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800783 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
785 /**
786 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
787 *
788 * @see #ACTION_CREATE_SHORTCUT
789 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800790 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700791 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800792 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700793 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
794 "android.intent.extra.shortcut.ICON_RESOURCE";
795
796 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500797 * An activity that provides a user interface for adjusting application preferences.
798 * Optional but recommended settings for all applications which have settings.
799 */
800 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
801 public static final String ACTION_APPLICATION_PREFERENCES
802 = "android.intent.action.APPLICATION_PREFERENCES";
803
804 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700805 * Activity Action: Launch an activity showing the app information.
806 * For applications which install other applications (such as app stores), it is recommended
807 * to handle this action for providing the app information to the user.
808 *
809 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
810 * to be displayed.
811 * <p>Output: Nothing.
812 */
813 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
814 public static final String ACTION_SHOW_APP_INFO
815 = "android.intent.action.SHOW_APP_INFO";
816
817 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800818 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700819 *
820 * @see Intent#ACTION_CREATE_SHORTCUT
821 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800822 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
823 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 */
825 public static class ShortcutIconResource implements Parcelable {
826 /**
827 * The package name of the application containing the icon.
828 */
829 public String packageName;
830
831 /**
832 * The resource name of the icon, including package, name and type.
833 */
834 public String resourceName;
835
836 /**
837 * Creates a new ShortcutIconResource for the specified context and resource
838 * identifier.
839 *
840 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700841 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700842 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700843 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700844 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700845 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700846 ShortcutIconResource icon = new ShortcutIconResource();
847 icon.packageName = context.getPackageName();
848 icon.resourceName = context.getResources().getResourceName(resourceId);
849 return icon;
850 }
851
852 /**
853 * Used to read a ShortcutIconResource from a Parcel.
854 */
855 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
856 new Parcelable.Creator<ShortcutIconResource>() {
857
858 public ShortcutIconResource createFromParcel(Parcel source) {
859 ShortcutIconResource icon = new ShortcutIconResource();
860 icon.packageName = source.readString();
861 icon.resourceName = source.readString();
862 return icon;
863 }
864
865 public ShortcutIconResource[] newArray(int size) {
866 return new ShortcutIconResource[size];
867 }
868 };
869
870 /**
871 * No special parcel contents.
872 */
873 public int describeContents() {
874 return 0;
875 }
876
877 public void writeToParcel(Parcel dest, int flags) {
878 dest.writeString(packageName);
879 dest.writeString(resourceName);
880 }
881
882 @Override
883 public String toString() {
884 return resourceName;
885 }
886 }
887
888 /**
889 * Activity Action: Display an activity chooser, allowing the user to pick
890 * what they want to before proceeding. This can be used as an alternative
891 * to the standard activity picker that is displayed by the system when
892 * you try to start an activity with multiple possible matches, with these
893 * differences in behavior:
894 * <ul>
895 * <li>You can specify the title that will appear in the activity chooser.
896 * <li>The user does not have the option to make one of the matching
897 * activities a preferred activity, and all possible activities will
898 * always be shown even if one of them is currently marked as the
899 * preferred activity.
900 * </ul>
901 * <p>
902 * This action should be used when the user will naturally expect to
903 * select an activity in order to proceed. An example if when not to use
904 * it is when the user clicks on a "mailto:" link. They would naturally
905 * expect to go directly to their mail app, so startActivity() should be
906 * called directly: it will
907 * either launch the current preferred app, or put up a dialog allowing the
908 * user to pick an app to use and optionally marking that as preferred.
909 * <p>
910 * In contrast, if the user is selecting a menu item to send a picture
911 * they are viewing to someone else, there are many different things they
912 * may want to do at this point: send it through e-mail, upload it to a
913 * web service, etc. In this case the CHOOSER action should be used, to
914 * always present to the user a list of the things they can do, with a
915 * nice title given by the caller such as "Send this photo with:".
916 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700917 * If you need to grant URI permissions through a chooser, you must specify
918 * the permissions to be granted on the ACTION_CHOOSER Intent
919 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
920 * {@link #setClipData} to specify the URIs to be granted as well as
921 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
922 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
923 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924 * As a convenience, an Intent of this form can be created with the
925 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700926 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700928 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
929 * and can optionally have a {@link #EXTRA_TITLE} field containing the
930 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700931 * <p>
932 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700933 */
934 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
935 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
936
937 /**
938 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
939 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700940 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
941 * target intent, also optionally supplying a title. If the target
942 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
943 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
944 * set in the returned chooser intent, with its ClipData set appropriately:
945 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500946 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700947 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700948 * @param target The Intent that the user will be selecting an activity
949 * to perform.
950 * @param title Optional title that will be displayed in the chooser.
951 * @return Return a new Intent object that you can hand to
952 * {@link Context#startActivity(Intent) Context.startActivity()} and
953 * related methods.
954 */
955 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700956 return createChooser(target, title, null);
957 }
958
959 /**
960 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
961 *
962 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
963 * target intent, also optionally supplying a title. If the target
964 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
965 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
966 * set in the returned chooser intent, with its ClipData set appropriately:
967 * either a direct reflection of {@link #getClipData()} if that is non-null,
968 * or a new ClipData built from {@link #getData()}.</p>
969 *
970 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
971 * when the user makes a choice. This can be useful if the calling application wants
972 * to remember the last chosen target and surface it as a more prominent or one-touch
973 * affordance elsewhere in the UI for next time.</p>
974 *
975 * @param target The Intent that the user will be selecting an activity
976 * to perform.
977 * @param title Optional title that will be displayed in the chooser.
978 * @param sender Optional IntentSender to be called when a choice is made.
979 * @return Return a new Intent object that you can hand to
980 * {@link Context#startActivity(Intent) Context.startActivity()} and
981 * related methods.
982 */
983 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700984 Intent intent = new Intent(ACTION_CHOOSER);
985 intent.putExtra(EXTRA_INTENT, target);
986 if (title != null) {
987 intent.putExtra(EXTRA_TITLE, title);
988 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700989
Adam Powell0b3c1122014-10-09 12:50:14 -0700990 if (sender != null) {
991 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
992 }
993
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700994 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700995 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
996 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
997 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700998 if (permFlags != 0) {
999 ClipData targetClipData = target.getClipData();
1000 if (targetClipData == null && target.getData() != null) {
1001 ClipData.Item item = new ClipData.Item(target.getData());
1002 String[] mimeTypes;
1003 if (target.getType() != null) {
1004 mimeTypes = new String[] { target.getType() };
1005 } else {
1006 mimeTypes = new String[] { };
1007 }
1008 targetClipData = new ClipData(null, mimeTypes, item);
1009 }
1010 if (targetClipData != null) {
1011 intent.setClipData(targetClipData);
1012 intent.addFlags(permFlags);
1013 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001014 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001015
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 return intent;
1017 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001018
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001019 /**
1020 * Activity Action: Allow the user to select a particular kind of data and
1021 * return it. This is different than {@link #ACTION_PICK} in that here we
1022 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001023 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001024 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001025 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001026 * etc.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * of data, such as a person contact, you set the MIME type to the kind of
1030 * data you want and launch it with {@link Context#startActivity(Intent)}.
1031 * The system will then launch the best application to select that kind
1032 * of data for you.
1033 * <p>
1034 * You may also be interested in any of a set of types of content the user
1035 * can pick. For example, an e-mail application that wants to allow the
1036 * user to add an attachment to an e-mail message can use this action to
1037 * bring up a list of all of the types of content the user can attach.
1038 * <p>
1039 * In this case, you should wrap the GET_CONTENT intent with a chooser
1040 * (through {@link #createChooser}), which will give the proper interface
1041 * for the user to pick how to send your data and allow you to specify
1042 * a prompt indicating what they are doing. You will usually specify a
1043 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1044 * broad range of content types the user can select from.
1045 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001046 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001047 * only pick from data that can be represented as a stream. This is
1048 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1049 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001050 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001051 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001052 * is locally available on the device. For example, if this extra is set
1053 * to true then an image picker should not show any pictures that are available
1054 * from a remote server but not already on the local device (thus requiring
1055 * they be downloaded when opened).
1056 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001057 * If the caller can handle multiple returned items (the user performing
1058 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1059 * to indicate this.
1060 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001061 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1062 * that no URI is supplied in the intent, as there are no constraints on
1063 * where the returned data originally comes from. You may also include the
1064 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001065 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001066 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1067 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001068 * <p>
1069 * Output: The URI of the item that was picked. This must be a content:
1070 * URI so that any receiver can access it.
1071 */
1072 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1073 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1074 /**
1075 * Activity Action: Dial a number as specified by the data. This shows a
1076 * UI with the number being dialed, allowing the user to explicitly
1077 * initiate the call.
1078 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1079 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1080 * number.
1081 * <p>Output: nothing.
1082 */
1083 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1084 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1085 /**
1086 * Activity Action: Perform a call to someone specified by the data.
1087 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1088 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1089 * number.
1090 * <p>Output: nothing.
1091 *
1092 * <p>Note: there will be restrictions on which applications can initiate a
1093 * call; most applications should use the {@link #ACTION_DIAL}.
1094 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1095 * numbers. Applications can <strong>dial</strong> emergency numbers using
1096 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001097 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001098 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001099 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001100 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001101 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_CALL = "android.intent.action.CALL";
1105 /**
1106 * Activity Action: Perform a call to an emergency number specified by the
1107 * data.
1108 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1109 * tel: URI of an explicit phone number.
1110 * <p>Output: nothing.
1111 * @hide
1112 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001113 @SystemApi
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001115 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1116 /**
1117 * Activity action: Perform a call to any number (emergency or not)
1118 * specified by the data.
1119 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1120 * tel: URI of an explicit phone number.
1121 * <p>Output: nothing.
1122 * @hide
1123 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001124 @SystemApi
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001126 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001127
Santos Cordon15a13782015-03-31 18:32:31 -07001128 /**
fionaxuadfe7002017-02-17 17:20:46 -08001129 * Activity Action: Main entry point for carrier setup apps.
1130 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1131 * carrier service and typically require
1132 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1133 * fulfill their duties.
1134 */
1135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1136 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1137 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001138 * Activity Action: Send a message to someone specified by the data.
1139 * <p>Input: {@link #getData} is URI describing the target.
1140 * <p>Output: nothing.
1141 */
1142 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1143 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1144 /**
1145 * Activity Action: Deliver some data to someone else. Who the data is
1146 * being delivered to is not specified; it is up to the receiver of this
1147 * action to ask the user where the data should be sent.
1148 * <p>
1149 * When launching a SEND intent, you should usually wrap it in a chooser
1150 * (through {@link #createChooser}), which will give the proper interface
1151 * for the user to pick how to send your data and allow you to specify
1152 * a prompt indicating what they are doing.
1153 * <p>
1154 * Input: {@link #getType} is the MIME type of the data being sent.
1155 * get*Extra can have either a {@link #EXTRA_TEXT}
1156 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1157 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1158 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1159 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001160 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1161 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1162 * your text with HTML formatting.
1163 * <p>
1164 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1165 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1166 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1167 * content: URIs and other advanced features of {@link ClipData}. If
1168 * using this approach, you still must supply the same data through the
1169 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1170 * for compatibility with old applications. If you don't set a ClipData,
1171 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001172 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001173 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1174 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1175 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1176 * be openable only as asset typed files using
1177 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1178 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001179 * Optional standard extras, which may be interpreted by some recipients as
1180 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1181 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1182 * <p>
1183 * Output: nothing.
1184 */
1185 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1186 public static final String ACTION_SEND = "android.intent.action.SEND";
1187 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001188 * Activity Action: Deliver multiple data to someone else.
1189 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001190 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001191 * <p>
1192 * Input: {@link #getType} is the MIME type of the data being sent.
1193 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001194 * #EXTRA_STREAM} field, containing the data to be sent. If using
1195 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1196 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001197 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001198 * Multiple types are supported, and receivers should handle mixed types
1199 * whenever possible. The right way for the receiver to check them is to
1200 * use the content resolver on each URI. The intent sender should try to
1201 * put the most concrete mime type in the intent type, but it can fall
1202 * back to {@literal <type>/*} or {@literal *}/* as needed.
1203 * <p>
1204 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1205 * be image/jpg, but if you are sending image/jpg and image/png, then the
1206 * intent's type should be image/*.
1207 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001208 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1209 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1210 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1211 * content: URIs and other advanced features of {@link ClipData}. If
1212 * using this approach, you still must supply the same data through the
1213 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1214 * for compatibility with old applications. If you don't set a ClipData,
1215 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1216 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001217 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1218 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1219 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1220 * be openable only as asset typed files using
1221 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1222 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001223 * Optional standard extras, which may be interpreted by some recipients as
1224 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1225 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1226 * <p>
1227 * Output: nothing.
1228 */
1229 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1230 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1231 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001232 * Activity Action: Handle an incoming phone call.
1233 * <p>Input: nothing.
1234 * <p>Output: nothing.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1238 /**
1239 * Activity Action: Insert an empty item into the given container.
1240 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1241 * in which to place the data.
1242 * <p>Output: URI of the new data that was created.
1243 */
1244 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1245 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1246 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001247 * Activity Action: Create a new item in the given container, initializing it
1248 * from the current contents of the clipboard.
1249 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1250 * in which to place the data.
1251 * <p>Output: URI of the new data that was created.
1252 */
1253 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1254 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1255 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001256 * Activity Action: Delete the given data from its container.
1257 * <p>Input: {@link #getData} is URI of data to be deleted.
1258 * <p>Output: nothing.
1259 */
1260 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1261 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1262 /**
1263 * Activity Action: Run the data, whatever that means.
1264 * <p>Input: ? (Note: this is currently specific to the test harness.)
1265 * <p>Output: nothing.
1266 */
1267 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1268 public static final String ACTION_RUN = "android.intent.action.RUN";
1269 /**
1270 * Activity Action: Perform a data synchronization.
1271 * <p>Input: ?
1272 * <p>Output: ?
1273 */
1274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1276 /**
1277 * Activity Action: Pick an activity given an intent, returning the class
1278 * selected.
1279 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1280 * used with {@link PackageManager#queryIntentActivities} to determine the
1281 * set of activities from which to pick.
1282 * <p>Output: Class name of the activity that was selected.
1283 */
1284 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1285 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1286 /**
1287 * Activity Action: Perform a search.
1288 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1289 * is the text to search for. If empty, simply
1290 * enter your search results Activity with the search UI activated.
1291 * <p>Output: nothing.
1292 */
1293 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1294 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1295 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001296 * Activity Action: Start the platform-defined tutorial
1297 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1298 * is the text to search for. If empty, simply
1299 * enter your search results Activity with the search UI activated.
1300 * <p>Output: nothing.
1301 */
1302 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1303 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001305 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001306 * <p>
1307 * Input: {@link android.app.SearchManager#QUERY
1308 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1309 * a url starts with http or https, the site will be opened. If it is plain
1310 * text, Google search will be applied.
1311 * <p>
1312 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001313 */
1314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1315 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001316
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001317 /**
Jim Miller07994402012-05-02 14:22:27 -07001318 * Activity Action: Perform assist action.
1319 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001320 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1321 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001322 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1323 * information.
Jim Miller07994402012-05-02 14:22:27 -07001324 * Output: nothing.
1325 */
1326 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1327 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001328
1329 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001330 * Activity Action: Perform voice assist action.
1331 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001332 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1333 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001334 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001335 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001336 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001337 */
Amith Yamasani16452032017-03-03 10:15:57 -08001338 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001339 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1340 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1341
1342 /**
Adam Skory7140a252013-09-11 12:04:58 +01001343 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1344 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001345 */
1346 public static final String EXTRA_ASSIST_PACKAGE
1347 = "android.intent.extra.ASSIST_PACKAGE";
1348
1349 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001350 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1351 * application package at the time the assist was invoked.
1352 */
1353 public static final String EXTRA_ASSIST_UID
1354 = "android.intent.extra.ASSIST_UID";
1355
1356 /**
Adam Skory7140a252013-09-11 12:04:58 +01001357 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1358 * information supplied by the current foreground app at the time of the assist request.
1359 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001360 */
1361 public static final String EXTRA_ASSIST_CONTEXT
1362 = "android.intent.extra.ASSIST_CONTEXT";
1363
Jim Miller07994402012-05-02 14:22:27 -07001364 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001365 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1366 * keyboard as the primary input device for assistance.
1367 */
1368 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1369 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1370
1371 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001372 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1373 * that was used to invoke the assist.
1374 */
1375 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1376 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1377
1378 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001379 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001380 * <p>Input: Nothing.
1381 * <p>Output: nothing.
1382 */
1383 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1384 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1385 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001386 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001387 * <p>Input: Nothing.
1388 * <p>Output: Nothing.
1389 */
1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1392
1393 /**
1394 * Activity Action: Show activity for reporting a bug.
1395 * <p>Input: Nothing.
1396 * <p>Output: Nothing.
1397 */
1398 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1399 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1400
1401 /**
1402 * Activity Action: Main entry point for factory tests. Only used when
1403 * the device is booting in factory test node. The implementing package
1404 * must be installed in the system image.
1405 * <p>Input: nothing
1406 * <p>Output: nothing
1407 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001409 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1410
1411 /**
1412 * Activity Action: The user pressed the "call" button to go to the dialer
1413 * or other appropriate UI for placing a call.
1414 * <p>Input: Nothing.
1415 * <p>Output: Nothing.
1416 */
1417 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1418 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1419
1420 /**
1421 * Activity Action: Start Voice Command.
1422 * <p>Input: Nothing.
1423 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001424 * <p class="note">
1425 * In some cases, a matching Activity may not exist, so ensure you
1426 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001430
1431 /**
1432 * Activity Action: Start action associated with long pressing on the
1433 * search key.
1434 * <p>Input: Nothing.
1435 * <p>Output: Nothing.
1436 */
1437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001439
Jacek Surazski86b6c532009-05-13 14:38:28 +02001440 /**
1441 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1442 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001443 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001444 * <p>Input: No data is specified. The bug report is passed in using
1445 * an {@link #EXTRA_BUG_REPORT} field.
1446 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001447 *
1448 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001449 */
1450 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1451 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001452
1453 /**
1454 * Activity Action: Show power usage information to the user.
1455 * <p>Input: Nothing.
1456 * <p>Output: Nothing.
1457 */
1458 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1459 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001460
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001461 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001462 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1463 * to run.
1464 * <p>Input: Nothing.
1465 * <p>Output: Nothing.
1466 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1467 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1468 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001469 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001470 */
1471 @Deprecated
1472 @SystemApi
1473 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1474 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1475
1476 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001477 * Activity Action: Setup wizard to launch after a platform update. This
1478 * activity should have a string meta-data field associated with it,
1479 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1480 * the platform for setup. The activity will be launched only if
1481 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1482 * same value.
1483 * <p>Input: Nothing.
1484 * <p>Output: Nothing.
1485 * @hide
1486 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001487 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001488 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1489 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001490
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001491 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001492 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1493 * <p>Input: Nothing.
1494 * <p>Output: Nothing.
1495 * @hide
1496 */
1497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1498 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001499 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001500
1501 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001502 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1503 * <p>Input: Nothing.
1504 * <p>Output: Nothing.
1505 * @hide
1506 */
1507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1508 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001509 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001510
1511 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001512 * Activity Action: Show settings for managing network data usage of a
1513 * specific application. Applications should define an activity that offers
1514 * options to control data usage.
1515 */
1516 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1517 public static final String ACTION_MANAGE_NETWORK_USAGE =
1518 "android.intent.action.MANAGE_NETWORK_USAGE";
1519
1520 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001521 * Activity Action: Launch application installer.
1522 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001523 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001524 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1525 * you can also use "package:<package-name>" to install an application for the
1526 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001527 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1528 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1529 * <p>
1530 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1531 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001532 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001533 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001534 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1535 * in order to launch the application installer.
1536 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001537 *
1538 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1539 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1540 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001541 *
1542 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001543 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001544 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001545 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1546 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1547
1548 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001549 * Activity Action: Activity to handle split installation failures.
1550 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1551 * but the split that contains the application isn't installed. When a split is
1552 * installed in this manner, the containing package usually doesn't know this is
1553 * happening. However, if an error occurs during installation, the containing
1554 * package can define a single activity handling this action to deal with such
1555 * failures.
1556 * <p>The activity handling this action must be in the base package.
1557 * <p>
1558 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1559 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1560 */
1561 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1562 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1563
1564 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001565 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001566 * <p class="note">
1567 * This is a protected intent that can only be sent by the system.
1568 * </p>
1569 *
1570 * @hide
1571 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1575 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576
1577 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001579 * <p>
1580 * The system will have a persistent connection to this service.
1581 * This is a protected intent that can only be sent by the system.
1582 * </p>
1583 *
1584 * @hide
1585 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001586 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001587 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001588 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1589 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001590
1591 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001592 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001593 *
1594 * <p class="note">
1595 * This is a protected intent that can only be sent by the system.
1596 * </p>
1597 *
1598 * @hide
1599 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001600 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001601 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001602 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1603 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001604
1605 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001606 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1607 * package. Specifies the installer package name; this package will receive the
1608 * {@link #ACTION_APP_ERROR} intent.
1609 */
1610 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1611 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1612
1613 /**
1614 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1615 * package. Specifies that the application being installed should not be
1616 * treated as coming from an unknown source, but as coming from the app
1617 * invoking the Intent. For this to work you must start the installer with
1618 * startActivityForResult().
1619 */
1620 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1621 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1622
1623 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001624 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1625 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001626 * data field originated from.
1627 */
rich cannings706e8ba2012-08-20 13:20:14 -07001628 public static final String EXTRA_ORIGINATING_URI
1629 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001630
1631 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001632 * This extra can be used with any Intent used to launch an activity, supplying information
1633 * about who is launching that activity. This field contains a {@link android.net.Uri}
1634 * object, typically an http: or https: URI of the web site that the referral came from;
1635 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1636 * a native application that it came from.
1637 *
1638 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1639 * instead of directly retrieving the extra. It is also valid for applications to
1640 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1641 * a string, not a Uri; the field here, if supplied, will always take precedence,
1642 * however.</p>
1643 *
1644 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001645 */
1646 public static final String EXTRA_REFERRER
1647 = "android.intent.extra.REFERRER";
1648
1649 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001650 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1651 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1652 * not be created, in particular when Intent extras are supplied through the
1653 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1654 * schemes.
1655 *
1656 * @see #EXTRA_REFERRER
1657 */
1658 public static final String EXTRA_REFERRER_NAME
1659 = "android.intent.extra.REFERRER_NAME";
1660
1661 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001662 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001663 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001664 * Currently only a system app that hosts the provider authority "downloads" or holds the
1665 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001666 * @hide
1667 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001668 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001669 public static final String EXTRA_ORIGINATING_UID
1670 = "android.intent.extra.ORIGINATING_UID";
1671
1672 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001673 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1674 * package. Tells the installer UI to skip the confirmation with the user
1675 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001676 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1677 * will no longer show an interstitial message about updating existing
1678 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001679 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001680 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001681 public static final String EXTRA_ALLOW_REPLACE
1682 = "android.intent.extra.ALLOW_REPLACE";
1683
1684 /**
1685 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1686 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1687 * return to the application the result code of the install/uninstall. The returned result
1688 * code will be {@link android.app.Activity#RESULT_OK} on success or
1689 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1690 */
1691 public static final String EXTRA_RETURN_RESULT
1692 = "android.intent.extra.RETURN_RESULT";
1693
1694 /**
1695 * Package manager install result code. @hide because result codes are not
1696 * yet ready to be exposed.
1697 */
1698 public static final String EXTRA_INSTALL_RESULT
1699 = "android.intent.extra.INSTALL_RESULT";
1700
1701 /**
1702 * Activity Action: Launch application uninstaller.
1703 * <p>
1704 * Input: The data must be a package: URI whose scheme specific part is
1705 * the package name of the current installed package to be uninstalled.
1706 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1707 * <p>
1708 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1709 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001710 * <p>
1711 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1712 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001713 *
1714 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1715 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001716 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001717 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001718 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1719 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1720
1721 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001722 * Specify whether the package should be uninstalled for all users.
1723 * @hide because these should not be part of normal application flow.
1724 */
1725 public static final String EXTRA_UNINSTALL_ALL_USERS
1726 = "android.intent.extra.UNINSTALL_ALL_USERS";
1727
1728 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001729 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1730 * describing the last run version of the platform that was setup.
1731 * @hide
1732 */
1733 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1734
Svet Ganov3695b8a2015-03-24 16:30:25 -07001735 /**
1736 * Activity action: Launch UI to manage the permissions of an app.
1737 * <p>
1738 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1739 * will be managed by the launched UI.
1740 * </p>
1741 * <p>
1742 * Output: Nothing.
1743 * </p>
1744 *
1745 * @see #EXTRA_PACKAGE_NAME
1746 *
1747 * @hide
1748 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001749 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001750 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1751 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1752 "android.intent.action.MANAGE_APP_PERMISSIONS";
1753
1754 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001755 * Activity action: Launch UI to manage permissions.
1756 * <p>
1757 * Input: Nothing.
1758 * </p>
1759 * <p>
1760 * Output: Nothing.
1761 * </p>
1762 *
1763 * @hide
1764 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001765 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001766 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1767 public static final String ACTION_MANAGE_PERMISSIONS =
1768 "android.intent.action.MANAGE_PERMISSIONS";
1769
1770 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001771 * Activity action: Launch UI to review permissions for an app.
1772 * The system uses this intent if permission review for apps not
1773 * supporting the new runtime permissions model is enabled. In
1774 * this mode a permission review is required before any of the
1775 * app components can run.
1776 * <p>
1777 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1778 * permissions will be reviewed (mandatory).
1779 * </p>
1780 * <p>
1781 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1782 * be fired after the permission review (optional).
1783 * </p>
1784 * <p>
1785 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1786 * be invoked after the permission review (optional).
1787 * </p>
1788 * <p>
1789 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1790 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1791 * </p>
1792 * <p>
1793 * Output: Nothing.
1794 * </p>
1795 *
1796 * @see #EXTRA_PACKAGE_NAME
1797 * @see #EXTRA_INTENT
1798 * @see #EXTRA_REMOTE_CALLBACK
1799 * @see #EXTRA_RESULT_NEEDED
1800 *
1801 * @hide
1802 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001803 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805 public static final String ACTION_REVIEW_PERMISSIONS =
1806 "android.intent.action.REVIEW_PERMISSIONS";
1807
1808 /**
1809 * Intent extra: A callback for reporting remote result as a bundle.
1810 * <p>
1811 * Type: IRemoteCallback
1812 * </p>
1813 *
1814 * @hide
1815 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001816 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001817 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1818
1819 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001820 * Intent extra: An app package name.
1821 * <p>
1822 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001823 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001824 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001825 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001826 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1827
1828 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001829 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1830 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1831 *
1832 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1833 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1834 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001835 *
1836 * @see #ACTION_MY_PACKAGE_SUSPENDED
1837 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1838 * @see PackageManager#isPackageSuspended()
1839 * @see PackageManager#getSuspendedPackageAppExtras()
1840 */
1841 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1842
1843 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001844 * Intent extra: An app split name.
1845 * <p>
1846 * Type: String
1847 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001848 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001849 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1850
1851 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001852 * Intent extra: A {@link ComponentName} value.
1853 * <p>
1854 * Type: String
1855 * </p>
1856 */
1857 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1858
1859 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001860 * Intent extra: An extra for specifying whether a result is needed.
1861 * <p>
1862 * Type: boolean
1863 * </p>
1864 *
1865 * @hide
1866 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001867 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001868 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1869
1870 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001871 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1872 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1873 *
1874 * @see PackageManager#isPackageSuspended()
1875 * @see #ACTION_PACKAGES_SUSPENDED
1876 *
1877 * @hide
1878 */
1879 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1880
1881 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001882 * Activity action: Launch UI to manage which apps have a given permission.
1883 * <p>
1884 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1885 * to which will be managed by the launched UI.
1886 * </p>
1887 * <p>
1888 * Output: Nothing.
1889 * </p>
1890 *
1891 * @see #EXTRA_PERMISSION_NAME
1892 *
1893 * @hide
1894 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001895 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001896 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1897 public static final String ACTION_MANAGE_PERMISSION_APPS =
1898 "android.intent.action.MANAGE_PERMISSION_APPS";
1899
1900 /**
1901 * Intent extra: The name of a permission.
1902 * <p>
1903 * Type: String
1904 * </p>
1905 *
1906 * @hide
1907 */
1908 @SystemApi
1909 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1910
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001911 // ---------------------------------------------------------------------
1912 // ---------------------------------------------------------------------
1913 // Standard intent broadcast actions (see action variable).
1914
1915 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001916 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1917 * <p>
1918 * For historical reasons, the name of this broadcast action refers to the power
1919 * state of the screen but it is actually sent in response to changes in the
1920 * overall interactive state of the device.
1921 * </p><p>
1922 * This broadcast is sent when the device becomes non-interactive which may have
1923 * nothing to do with the screen turning off. To determine the
1924 * actual state of the screen, use {@link android.view.Display#getState}.
1925 * </p><p>
1926 * See {@link android.os.PowerManager#isInteractive} for details.
1927 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001928 * You <em>cannot</em> receive this through components declared in
1929 * manifests, only by explicitly registering for it with
1930 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1931 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001932 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001933 * <p class="note">This is a protected intent that can only be sent
1934 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001935 */
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001938
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001939 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001940 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1941 * <p>
1942 * For historical reasons, the name of this broadcast action refers to the power
1943 * state of the screen but it is actually sent in response to changes in the
1944 * overall interactive state of the device.
1945 * </p><p>
1946 * This broadcast is sent when the device becomes interactive which may have
1947 * nothing to do with the screen turning on. To determine the
1948 * actual state of the screen, use {@link android.view.Display#getState}.
1949 * </p><p>
1950 * See {@link android.os.PowerManager#isInteractive} for details.
1951 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001952 * You <em>cannot</em> receive this through components declared in
1953 * manifests, only by explicitly registering for it with
1954 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1955 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001956 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001957 * <p class="note">This is a protected intent that can only be sent
1958 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001962
1963 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001964 * Broadcast Action: Sent after the system stops dreaming.
1965 *
1966 * <p class="note">This is a protected intent that can only be sent by the system.
1967 * It is only sent to registered receivers.</p>
1968 */
1969 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1970 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1971
1972 /**
1973 * Broadcast Action: Sent after the system starts dreaming.
1974 *
1975 * <p class="note">This is a protected intent that can only be sent by the system.
1976 * It is only sent to registered receivers.</p>
1977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1979 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1980
1981 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001982 * 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 -07001983 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001984 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001985 * <p class="note">This is a protected intent that can only be sent
1986 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001987 */
1988 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001989 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001990
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 /**
1992 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001993 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001994 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1996 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001997 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001998 * <p class="note">This is a protected intent that can only be sent
1999 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2003 /**
2004 * Broadcast Action: The time was set.
2005 */
2006 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2007 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2008 /**
2009 * Broadcast Action: The date has changed.
2010 */
2011 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2012 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2013 /**
2014 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2015 * <ul>
2016 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2017 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002018 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002019 * <p class="note">This is a protected intent that can only be sent
2020 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2024 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002025 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2026 * DNS entries should be tossed.
2027 * @hide
2028 */
2029 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2030 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2031 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002032 * Alarm Changed Action: This is broadcast when the AlarmClock
2033 * application's alarm is set or unset. It is used by the
2034 * AlarmClock application and the StatusBar service.
2035 * @hide
2036 */
2037 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002038 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002039 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002040
2041 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002042 * Broadcast Action: This is broadcast once, after the user has finished
2043 * booting, but while still in the "locked" state. It can be used to perform
2044 * application-specific initialization, such as installing alarms. You must
2045 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2046 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002047 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002048 * This broadcast is sent immediately at boot by all devices (regardless of
2049 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2050 * higher. Upon receipt of this broadcast, the user is still locked and only
2051 * device-protected storage can be accessed safely. If you want to access
2052 * credential-protected storage, you need to wait for the user to be
2053 * unlocked (typically by entering their lock pattern or PIN for the first
2054 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2055 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2056 * <p>
2057 * To receive this broadcast, your receiver component must be marked as
2058 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002059 * <p class="note">
2060 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002061 *
2062 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002063 */
2064 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2065 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2066
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002067 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002068 * Broadcast Action: This is broadcast once, after the user has finished
2069 * booting. It can be used to perform application-specific initialization,
2070 * such as installing alarms. You must hold the
2071 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2072 * order to receive this broadcast.
2073 * <p>
2074 * This broadcast is sent at boot by all devices (both with and without
2075 * direct boot support). Upon receipt of this broadcast, the user is
2076 * unlocked and both device-protected and credential-protected storage can
2077 * accessed safely.
2078 * <p>
2079 * If you need to run while the user is still locked (before they've entered
2080 * their lock pattern or PIN for the first time), you can listen for the
2081 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2082 * <p class="note">
2083 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002084 */
2085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002086 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002087 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002088
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002089 /**
2090 * Broadcast Action: This is broadcast when a user action should request a
2091 * temporary system dialog to dismiss. Some examples of temporary system
2092 * dialogs are the notification window-shade and the recent tasks dialog.
2093 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002095 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2096 /**
2097 * Broadcast Action: Trigger the download and eventual installation
2098 * of a package.
2099 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002100 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002101 * <p class="note">This is a protected intent that can only be sent
2102 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002103 *
2104 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002105 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002106 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002107 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2108 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2109 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002110 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002111 * device. The data contains the name of the package. Note that the
2112 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002113 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002114 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002115 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2116 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002117 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2118 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002119 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002120 * <p class="note">This is a protected intent that can only be sent
2121 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002122 */
2123 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2124 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2125 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002126 * Broadcast Action: A new version of an application package has been
2127 * installed, replacing an existing version that was previously installed.
2128 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002129 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002130 * <ul>
2131 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2132 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002133 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002134 * <p class="note">This is a protected intent that can only be sent
2135 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002136 */
2137 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2138 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2139 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002140 * Broadcast Action: A new version of your application has been installed
2141 * over an existing one. This is only sent to the application that was
2142 * replaced. It does not contain any additional data; to receive it, just
2143 * use an intent filter for this action.
2144 *
2145 * <p class="note">This is a protected intent that can only be sent
2146 * by the system.
2147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2150 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002151 * Broadcast Action: An existing application package has been removed from
2152 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002153 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002154 * <ul>
2155 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2156 * to the package.
2157 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2158 * application -- data and code -- is being removed.
2159 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2160 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2161 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002162 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002163 * <p class="note">This is a protected intent that can only be sent
2164 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2168 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002169 * Broadcast Action: An existing application package has been completely
2170 * removed from the device. The data contains the name of the package.
2171 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2172 * {@link #EXTRA_DATA_REMOVED} is true and
2173 * {@link #EXTRA_REPLACING} is false of that broadcast.
2174 *
2175 * <ul>
2176 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2177 * to the package.
2178 * </ul>
2179 *
2180 * <p class="note">This is a protected intent that can only be sent
2181 * by the system.
2182 */
2183 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2184 public static final String ACTION_PACKAGE_FULLY_REMOVED
2185 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2186 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002187 * Broadcast Action: An existing application package has been changed (for
2188 * example, a component has been enabled or disabled). The data contains
2189 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002190 * <ul>
2191 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002192 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002193 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002194 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2195 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002196 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002197 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002198 * <p class="note">This is a protected intent that can only be sent
2199 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002200 */
2201 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2202 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2203 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002204 * @hide
2205 * Broadcast Action: Ask system services if there is any reason to
2206 * restart the given package. The data contains the name of the
2207 * package.
2208 * <ul>
2209 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2210 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2211 * </ul>
2212 *
2213 * <p class="note">This is a protected intent that can only be sent
2214 * by the system.
2215 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002216 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2219 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002220 * Broadcast Action: The user has restarted a package, and all of its
2221 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002222 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002223 * be removed. Note that the restarted package does <em>not</em>
2224 * receive this broadcast.
2225 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 * <ul>
2227 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2228 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002229 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002230 * <p class="note">This is a protected intent that can only be sent
2231 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002232 */
2233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2234 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2235 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002236 * Broadcast Action: The user has cleared the data of a package. This should
2237 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002238 * its persistent data is erased and this broadcast sent.
2239 * Note that the cleared package does <em>not</em>
2240 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002241 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002242 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2243 * package whose data was cleared is an uninstalled instant app, then the UID
2244 * will be -1. The platform keeps some meta-data associated with instant apps
2245 * after they are uninstalled.
2246 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2247 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002248 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002249 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002250 * <p class="note">This is a protected intent that can only be sent
2251 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002252 */
2253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2254 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2255 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002256 * Broadcast Action: Packages have been suspended.
2257 * <p>Includes the following extras:
2258 * <ul>
2259 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002260 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002261 * </ul>
2262 *
2263 * <p class="note">This is a protected intent that can only be sent
2264 * by the system. It is only sent to registered receivers.
2265 */
2266 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2267 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2268 /**
2269 * Broadcast Action: Packages have been unsuspended.
2270 * <p>Includes the following extras:
2271 * <ul>
2272 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002273 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002274 * </ul>
2275 *
2276 * <p class="note">This is a protected intent that can only be sent
2277 * by the system. It is only sent to registered receivers.
2278 */
2279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2280 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002281
2282 /**
2283 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002284 * whenever a package is put into a suspended state or any of its app extras change while in the
2285 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002286 * <p> Optionally includes the following extras:
2287 * <ul>
2288 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2289 * useful information for the app being suspended.
2290 * </ul>
2291 * <p class="note">This is a protected intent that can only be sent
2292 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2293 * the manifest.</em>
2294 *
2295 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2296 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2297 * @see PackageManager#isPackageSuspended()
2298 * @see PackageManager#getSuspendedPackageAppExtras()
2299 */
2300 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2301 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2302
2303 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002304 * Activity Action: Started to show more details about why an application was suspended.
2305 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002306 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2307 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002308 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002309 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2310 * handling this intent and protect it with
2311 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2312 *
2313 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2314 *
2315 * <p class="note">This is a protected intent that can only be sent
2316 * by the system.
2317 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002318 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2319 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002320 * @see PackageManager#isPackageSuspended()
2321 * @see #ACTION_PACKAGES_SUSPENDED
2322 *
2323 * @hide
2324 */
2325 @SystemApi
2326 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2327 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2328 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2329
2330 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002331 * Broadcast Action: Sent to a package that has been unsuspended.
2332 *
2333 * <p class="note">This is a protected intent that can only be sent
2334 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2335 * the manifest.</em>
2336 *
2337 * @see #ACTION_MY_PACKAGE_SUSPENDED
2338 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2339 * @see PackageManager#isPackageSuspended()
2340 * @see PackageManager#getSuspendedPackageAppExtras()
2341 */
2342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2343 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2344
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002345 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002346 * Broadcast Action: A user ID has been removed from the system. The user
2347 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002348 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002349 * <p class="note">This is a protected intent that can only be sent
2350 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002351 */
2352 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2353 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002354
2355 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002356 * Broadcast Action: Sent to the installer package of an application when
2357 * that application is first launched (that is the first time it is moved
2358 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002359 *
2360 * <p class="note">This is a protected intent that can only be sent
2361 * by the system.
2362 */
2363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2364 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2365
2366 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002367 * Broadcast Action: Sent to the system package verifier when a package
2368 * needs to be verified. The data contains the package URI.
2369 * <p class="note">
2370 * This is a protected intent that can only be sent by the system.
2371 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2374 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2375
2376 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002377 * Broadcast Action: Sent to the system package verifier when a package is
2378 * verified. The data contains the package URI.
2379 * <p class="note">
2380 * This is a protected intent that can only be sent by the system.
2381 */
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2384
2385 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002386 * Broadcast Action: Sent to the system intent filter verifier when an
2387 * intent filter needs to be verified. The data contains the filter data
2388 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002389 * <p class="note">
2390 * This is a protected intent that can only be sent by the system.
2391 * </p>
2392 *
2393 * @hide
2394 */
2395 @SystemApi
2396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2397 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2398
2399 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002400 * Broadcast Action: Resources for a set of packages (which were
2401 * previously unavailable) are currently
2402 * available since the media on which they exist is available.
2403 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2404 * list of packages whose availability changed.
2405 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2406 * list of uids of packages whose availability changed.
2407 * Note that the
2408 * packages in this list do <em>not</em> receive this broadcast.
2409 * The specified set of packages are now available on the system.
2410 * <p>Includes the following extras:
2411 * <ul>
2412 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2413 * whose resources(were previously unavailable) are currently available.
2414 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2415 * packages whose resources(were previously unavailable)
2416 * are currently available.
2417 * </ul>
2418 *
2419 * <p class="note">This is a protected intent that can only be sent
2420 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002421 */
2422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002423 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2424 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002425
2426 /**
2427 * Broadcast Action: Resources for a set of packages are currently
2428 * unavailable since the media on which they exist is unavailable.
2429 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2430 * list of packages whose availability changed.
2431 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2432 * list of uids of packages whose availability changed.
2433 * The specified set of packages can no longer be
2434 * launched and are practically unavailable on the system.
2435 * <p>Inclues the following extras:
2436 * <ul>
2437 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2438 * whose resources are no longer available.
2439 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2440 * whose resources are no longer available.
2441 * </ul>
2442 *
2443 * <p class="note">This is a protected intent that can only be sent
2444 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002445 */
2446 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002447 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002448 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002449
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002451 * Broadcast Action: preferred activities have changed *explicitly*.
2452 *
2453 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2454 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2455 * be sent.
2456 *
2457 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2458 *
2459 * @hide
2460 */
2461 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2462 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2463 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2464
2465
2466 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002467 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002468 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002469 * This should <em>only</em> be used to determine when the wallpaper
2470 * has changed to show the new wallpaper to the user. You should certainly
2471 * never, in response to this, change the wallpaper or other attributes of
2472 * it such as the suggested size. That would be crazy, right? You'd cause
2473 * all kinds of loops, especially if other apps are doing similar things,
2474 * right? Of course. So please don't do this.
2475 *
2476 * @deprecated Modern applications should use
2477 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2478 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2479 * shown behind their UI, rather than watching for this broadcast and
2480 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002481 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002482 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002483 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2484 /**
2485 * Broadcast Action: The current device {@link android.content.res.Configuration}
2486 * (orientation, locale, etc) has changed. When such a change happens, the
2487 * UIs (view hierarchy) will need to be rebuilt based on this new
2488 * information; for the most part, applications don't need to worry about
2489 * this, because the system will take care of stopping and restarting the
2490 * application to make sure it sees the new changes. Some system code that
2491 * can not be restarted will need to watch for this action and handle it
2492 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002493 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002494 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002495 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002496 * in manifests, only by explicitly registering for it with
2497 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2498 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002499 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002500 * <p class="note">This is a protected intent that can only be sent
2501 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002502 *
2503 * @see android.content.res.Configuration
2504 */
2505 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2506 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002507
2508 /**
2509 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2510 * such that the device may be eligible for the installation of additional configuration splits.
2511 * Configuration properties that can trigger this broadcast include locale and display density.
2512 *
2513 * <p class="note">
2514 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2515 * components declared in manifests. However, the receiver <em>must</em> hold the
2516 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2517 *
2518 * <p class="note">
2519 * This is a protected intent that can only be sent by the system.
2520 *
2521 * @hide
2522 */
2523 @SystemApi
2524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2525 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2526 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002527 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002528 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002529 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002530 * <p class="note">This is a protected intent that can only be sent
2531 * by the system.
2532 */
2533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2534 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2535 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002536 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2537 * charging state, level, and other information about the battery.
2538 * See {@link android.os.BatteryManager} for documentation on the
2539 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002540 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002541 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002542 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002543 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002544 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002545 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2546 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2547 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2548 * broadcasts that are sent and can be received through manifest
2549 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002550 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002551 * <p class="note">This is a protected intent that can only be sent
2552 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002553 */
2554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002556
2557
2558 /**
2559 * Broadcast Action: Sent when the current battery level changes.
2560 *
2561 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2562 * instances representing individual battery level changes with associated
2563 * extras from {@link #ACTION_BATTERY_CHANGED}.
2564 *
2565 * <p class="note">
2566 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2567 *
2568 * @hide
2569 */
2570 @SystemApi
2571 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2572 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002573 /**
2574 * Broadcast Action: Indicates low battery condition on the device.
2575 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002576 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002577 * <p class="note">This is a protected intent that can only be sent
2578 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579 */
2580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2581 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2582 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002583 * Broadcast Action: Indicates the battery is now okay after being low.
2584 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2585 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002586 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002587 * <p class="note">This is a protected intent that can only be sent
2588 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2592 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002593 * Broadcast Action: External power has been connected to the device.
2594 * This is intended for applications that wish to register specifically to this notification.
2595 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2596 * stay active to receive this notification. This action can be used to implement actions
2597 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002598 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002599 * <p class="note">This is a protected intent that can only be sent
2600 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002601 */
2602 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002603 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002604 /**
2605 * Broadcast Action: External power has been removed from the device.
2606 * This is intended for applications that wish to register specifically to this notification.
2607 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2608 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002609 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002610 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002611 * <p class="note">This is a protected intent that can only be sent
2612 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002613 */
2614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002615 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002616 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002617 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002618 * Broadcast Action: Device is shutting down.
2619 * This is broadcast when the device is being shut down (completely turned
2620 * off, not sleeping). Once the broadcast is complete, the final shutdown
2621 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002622 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002623 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2624 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2625 * Context.registerReceiver}.
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 Hackborn57a7f592013-07-22 18:21:32 -07002629 * <p>May include the following extras:
2630 * <ul>
2631 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2632 * shutdown is only for userspace processes. If not set, assumed to be false.
2633 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002634 */
2635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002636 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002637 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002638 * Activity Action: Start this activity to request system shutdown.
2639 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002640 * to request confirmation from the user before shutting down. The optional boolean
2641 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2642 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002643 *
2644 * <p class="note">This is a protected intent that can only be sent
2645 * by the system.
2646 *
2647 * {@hide}
2648 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002649 public static final String ACTION_REQUEST_SHUTDOWN
2650 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002651 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002652 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002653 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002654 * <p class="note">
2655 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002656 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002657 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2658 * or above, this broadcast will no longer be delivered to any
2659 * {@link BroadcastReceiver} defined in your manifest. Instead,
2660 * apps are strongly encouraged to use the improved
2661 * {@link Context#getCacheDir()} behavior so the system can
2662 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002665 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002666 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2667 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002668 * Broadcast Action: Indicates low storage space condition on the device no
2669 * longer exists
2670 * <p class="note">
2671 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002672 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002673 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2674 * or above, this broadcast will no longer be delivered to any
2675 * {@link BroadcastReceiver} defined in your manifest. Instead,
2676 * apps are strongly encouraged to use the improved
2677 * {@link Context#getCacheDir()} behavior so the system can
2678 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679 */
2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002681 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002682 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2683 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002684 * Broadcast Action: A sticky broadcast that indicates a storage space full
2685 * condition on the device. This is intended for activities that want to be
2686 * able to fill the data partition completely, leaving only enough free
2687 * space to prevent system-wide SQLite failures.
2688 * <p class="note">
2689 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002690 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002691 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2692 * or above, this broadcast will no longer be delivered to any
2693 * {@link BroadcastReceiver} defined in your manifest. Instead,
2694 * apps are strongly encouraged to use the improved
2695 * {@link Context#getCacheDir()} behavior so the system can
2696 * automatically free up storage when needed.
2697 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002698 */
2699 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002700 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002701 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2702 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002703 * Broadcast Action: Indicates storage space full condition on the device no
2704 * longer exists.
2705 * <p class="note">
2706 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002707 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002708 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2709 * or above, this broadcast will no longer be delivered to any
2710 * {@link BroadcastReceiver} defined in your manifest. Instead,
2711 * apps are strongly encouraged to use the improved
2712 * {@link Context#getCacheDir()} behavior so the system can
2713 * automatically free up storage when needed.
2714 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002715 */
2716 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002717 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002718 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2719 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002720 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2721 * and package management should be started.
2722 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2723 * notification.
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2727 /**
2728 * Broadcast Action: The device has entered USB Mass Storage mode.
2729 * This is used mainly for the USB Settings panel.
2730 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2731 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002732 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002734 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2737
2738 /**
2739 * Broadcast Action: The device has exited USB Mass Storage mode.
2740 * This is used mainly for the USB Settings panel.
2741 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2742 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002743 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002744 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002745 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002747 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2748
2749 /**
2750 * Broadcast Action: External media has been removed.
2751 * The path to the mount point for the removed media is contained in the Intent.mData field.
2752 */
2753 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2754 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2755
2756 /**
2757 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002758 * 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 -07002759 */
2760 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2761 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2762
2763 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002764 * Broadcast Action: External media is present, and being disk-checked
2765 * 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 -08002766 */
2767 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2768 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2769
2770 /**
2771 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2772 * 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 -08002773 */
2774 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2775 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2776
2777 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002779 * 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 -07002780 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2781 * media was mounted read only.
2782 */
2783 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2784 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2785
2786 /**
2787 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002788 * 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 -07002789 */
2790 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2791 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2792
2793 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002794 * Broadcast Action: External media is no longer being shared via USB mass storage.
2795 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2796 *
2797 * @hide
2798 */
2799 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2800
2801 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2803 * The path to the mount point for the removed media is contained in the Intent.mData field.
2804 */
2805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2806 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2807
2808 /**
2809 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002810 * 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 -07002811 */
2812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2813 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2814
2815 /**
2816 * Broadcast Action: User has expressed the desire to remove the external storage media.
2817 * Applications should close all files they have open within the mount point when they receive this intent.
2818 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2819 */
2820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2821 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2822
2823 /**
2824 * Broadcast Action: The media scanner has started scanning a directory.
2825 * The path to the directory being scanned is contained in the Intent.mData field.
2826 */
2827 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2828 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2829
2830 /**
2831 * Broadcast Action: The media scanner has finished scanning a directory.
2832 * The path to the scanned directory is contained in the Intent.mData field.
2833 */
2834 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2835 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2836
2837 /**
2838 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2839 * The path to the file is contained in the Intent.mData field.
2840 */
2841 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2842 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2843
2844 /**
2845 * Broadcast Action: The "Media Button" was pressed. Includes a single
2846 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2847 * caused the broadcast.
2848 */
2849 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2850 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2851
2852 /**
2853 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2854 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2855 * caused the broadcast.
2856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2859
2860 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2861 // location; they are not general-purpose actions.
2862
2863 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002864 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 */
2866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2867 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2868 "android.intent.action.GTALK_CONNECTED";
2869
2870 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002871 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002872 */
2873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2874 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2875 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002876
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002877 /**
2878 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002879 */
2880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2881 public static final String ACTION_INPUT_METHOD_CHANGED =
2882 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002883
2884 /**
2885 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2886 * more radios have been turned off or on. The intent will have the following extra value:</p>
2887 * <ul>
2888 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2889 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2890 * turned off</li>
2891 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002892 *
Peng Xua35b5532016-01-20 00:05:45 -08002893 * <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 -07002894 */
2895 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2896 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2897
2898 /**
2899 * Broadcast Action: Some content providers have parts of their namespace
2900 * where they publish new events or items that the user may be especially
2901 * interested in. For these things, they may broadcast this action when the
2902 * set of interesting items change.
2903 *
2904 * For example, GmailProvider sends this notification when the set of unread
2905 * mail in the inbox changes.
2906 *
2907 * <p>The data of the intent identifies which part of which provider
2908 * changed. When queried through the content resolver, the data URI will
2909 * return the data set in question.
2910 *
2911 * <p>The intent will have the following extra values:
2912 * <ul>
2913 * <li><em>count</em> - The number of items in the data set. This is the
2914 * same as the number of items in the cursor returned by querying the
2915 * data URI. </li>
2916 * </ul>
2917 *
2918 * This intent will be sent at boot (if the count is non-zero) and when the
2919 * data set changes. It is possible for the data set to change without the
2920 * count changing (for example, if a new unread message arrives in the same
2921 * sync operation in which a message is archived). The phone should still
2922 * ring/vibrate/etc as normal in this case.
2923 */
2924 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2925 public static final String ACTION_PROVIDER_CHANGED =
2926 "android.intent.action.PROVIDER_CHANGED";
2927
2928 /**
2929 * Broadcast Action: Wired Headset plugged in or unplugged.
2930 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002931 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2932 * and documentation.
2933 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002934 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002935 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002936 */
2937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002938 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002939
2940 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002941 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2942 * <ul>
2943 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2944 * </ul>
2945 *
2946 * <p class="note">This is a protected intent that can only be sent
2947 * by the system.
2948 *
2949 * @hide
2950 */
2951 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2952 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2953 = "android.intent.action.ADVANCED_SETTINGS";
2954
2955 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002956 * Broadcast Action: Sent after application restrictions are changed.
2957 *
2958 * <p class="note">This is a protected intent that can only be sent
2959 * by the system.</p>
2960 */
2961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2962 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2963 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2964
2965 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002966 * Broadcast Action: An outgoing call is about to be placed.
2967 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002968 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002969 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002970 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002971 * the phone number originally intended to be dialed.</li>
2972 * </ul>
2973 * <p>Once the broadcast is finished, the resultData is used as the actual
2974 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002975 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002976 * outgoing call in turn: for example, a parental control application
2977 * might verify that the user is authorized to place the call at that
2978 * time, then a number-rewriting application might add an area code if
2979 * one was not specified.</p>
2980 * <p>For consistency, any receiver whose purpose is to prohibit phone
2981 * calls should have a priority of 0, to ensure it will see the final
2982 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002983 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002984 * should have a positive priority.
2985 * Negative priorities are reserved for the system for this broadcast;
2986 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002987 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2988 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002989 * <p>Emergency calls cannot be intercepted using this mechanism, and
2990 * other calls cannot be modified to call emergency numbers using this
2991 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002992 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2993 * call to use their own service instead. Those apps should first prevent
2994 * the call from being placed by setting resultData to <code>null</code>
2995 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002996 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002997 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2998 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002999 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003000 * <p class="note">This is a protected intent that can only be sent
3001 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003002 */
3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3004 public static final String ACTION_NEW_OUTGOING_CALL =
3005 "android.intent.action.NEW_OUTGOING_CALL";
3006
3007 /**
3008 * Broadcast Action: Have the device reboot. This is only for use by
3009 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003010 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003011 * <p class="note">This is a protected intent that can only be sent
3012 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003013 */
3014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3015 public static final String ACTION_REBOOT =
3016 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003017
Wei Huang97ecc9c2009-05-11 17:44:20 -07003018 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003019 * Broadcast Action: A sticky broadcast for changes in the physical
3020 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003021 *
3022 * <p>The intent will have the following extra values:
3023 * <ul>
3024 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003025 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003026 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003027 * <p>This is intended for monitoring the current physical dock state.
3028 * See {@link android.app.UiModeManager} for the normal API dealing with
3029 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003030 */
3031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3032 public static final String ACTION_DOCK_EVENT =
3033 "android.intent.action.DOCK_EVENT";
3034
3035 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003036 * Broadcast Action: A broadcast when idle maintenance can be started.
3037 * This means that the user is not interacting with the device and is
3038 * not expected to do so soon. Typical use of the idle maintenance is
3039 * to perform somehow expensive tasks that can be postponed at a moment
3040 * when they will not degrade user experience.
3041 * <p>
3042 * <p class="note">In order to keep the device responsive in case of an
3043 * unexpected user interaction, implementations of a maintenance task
3044 * should be interruptible. In such a scenario a broadcast with action
3045 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3046 * should not do the maintenance work in
3047 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3048 * maintenance service by {@link Context#startService(Intent)}. Also
3049 * you should hold a wake lock while your maintenance service is running
3050 * to prevent the device going to sleep.
3051 * </p>
3052 * <p>
3053 * <p class="note">This is a protected intent that can only be sent by
3054 * the system.
3055 * </p>
3056 *
3057 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003058 *
3059 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003060 */
3061 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3062 public static final String ACTION_IDLE_MAINTENANCE_START =
3063 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3064
3065 /**
3066 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3067 * This means that the user was not interacting with the device as a result
3068 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3069 * was sent and now the user started interacting with the device. Typical
3070 * use of the idle maintenance is to perform somehow expensive tasks that
3071 * can be postponed at a moment when they will not degrade user experience.
3072 * <p>
3073 * <p class="note">In order to keep the device responsive in case of an
3074 * unexpected user interaction, implementations of a maintenance task
3075 * should be interruptible. Hence, on receiving a broadcast with this
3076 * action, the maintenance task should be interrupted as soon as possible.
3077 * In other words, you should not do the maintenance work in
3078 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3079 * maintenance service that was started on receiving of
3080 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3081 * lock you acquired when your maintenance service started.
3082 * </p>
3083 * <p class="note">This is a protected intent that can only be sent
3084 * by the system.
3085 *
3086 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003087 *
3088 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003089 */
3090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3091 public static final String ACTION_IDLE_MAINTENANCE_END =
3092 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3093
3094 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003095 * Broadcast Action: a remote intent is to be broadcasted.
3096 *
3097 * A remote intent is used for remote RPC between devices. The remote intent
3098 * is serialized and sent from one device to another device. The receiving
3099 * device parses the remote intent and broadcasts it. Note that anyone can
3100 * broadcast a remote intent. However, if the intent receiver of the remote intent
3101 * does not trust intent broadcasts from arbitrary intent senders, it should require
3102 * the sender to hold certain permissions so only trusted sender's broadcast will be
3103 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003104 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003105 */
3106 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003107 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003108
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003109 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003110 * Broadcast Action: This is broadcast once when the user is booting after a
3111 * system update. It can be used to perform cleanup or upgrades after a
3112 * system update.
3113 * <p>
3114 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3115 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3116 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3117 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003118 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003119 * @hide
3120 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003121 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003122 public static final String ACTION_PRE_BOOT_COMPLETED =
3123 "android.intent.action.PRE_BOOT_COMPLETED";
3124
Amith Yamasani13593602012-03-22 16:16:17 -07003125 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003126 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003127 * on restricted users. The broadcast intent contains an extra
3128 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3129 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3130 * String[] depending on the restriction type.<p/>
3131 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003132 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3133 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3134 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003135 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3136 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003137 * @see RestrictionEntry
3138 */
3139 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3140 "android.intent.action.GET_RESTRICTION_ENTRIES";
3141
3142 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003143 * Sent the first time a user is starting, to allow system apps to
3144 * perform one time initialization. (This will not be seen by third
3145 * party applications because a newly initialized user does not have any
3146 * third party applications installed for it.) This is sent early in
3147 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003148 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3149 * broadcast, since it is part of a visible user interaction; be as quick
3150 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003151 */
3152 public static final String ACTION_USER_INITIALIZE =
3153 "android.intent.action.USER_INITIALIZE";
3154
3155 /**
3156 * Sent when a user switch is happening, causing the process's user to be
3157 * brought to the foreground. This is only sent to receivers registered
3158 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3159 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003160 * foreground. This is sent as a foreground
3161 * broadcast, since it is part of a visible user interaction; be as quick
3162 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003163 */
3164 public static final String ACTION_USER_FOREGROUND =
3165 "android.intent.action.USER_FOREGROUND";
3166
3167 /**
3168 * Sent when a user switch is happening, causing the process's user to be
3169 * sent to the background. This is only sent to receivers registered
3170 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3171 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003172 * background. This is sent as a foreground
3173 * broadcast, since it is part of a visible user interaction; be as quick
3174 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003175 */
3176 public static final String ACTION_USER_BACKGROUND =
3177 "android.intent.action.USER_BACKGROUND";
3178
3179 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003180 * Broadcast sent to the system when a user is added. Carries an extra
3181 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3182 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003183 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003184 * @hide
3185 */
3186 public static final String ACTION_USER_ADDED =
3187 "android.intent.action.USER_ADDED";
3188
3189 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003190 * Broadcast sent by the system when a user is started. Carries an extra
3191 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003192 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003193 * that has been started. This is sent as a foreground
3194 * broadcast, since it is part of a visible user interaction; be as quick
3195 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003196 * @hide
3197 */
3198 public static final String ACTION_USER_STARTED =
3199 "android.intent.action.USER_STARTED";
3200
3201 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003202 * Broadcast sent when a user is in the process of starting. Carries an extra
3203 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3204 * sent to registered receivers, not manifest receivers. It is sent to all
3205 * users (including the one that is being started). You must hold
3206 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3207 * this broadcast. This is sent as a background broadcast, since
3208 * its result is not part of the primary UX flow; to safely keep track of
3209 * started/stopped state of a user you can use this in conjunction with
3210 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3211 * other user state broadcasts since those are foreground broadcasts so can
3212 * execute in a different order.
3213 * @hide
3214 */
3215 public static final String ACTION_USER_STARTING =
3216 "android.intent.action.USER_STARTING";
3217
3218 /**
3219 * Broadcast sent when a user is going to be stopped. Carries an extra
3220 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3221 * sent to registered receivers, not manifest receivers. It is sent to all
3222 * users (including the one that is being stopped). You must hold
3223 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3224 * this broadcast. The user will not stop until all receivers have
3225 * handled the broadcast. This is sent as a background broadcast, since
3226 * its result is not part of the primary UX flow; to safely keep track of
3227 * started/stopped state of a user you can use this in conjunction with
3228 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3229 * other user state broadcasts since those are foreground broadcasts so can
3230 * execute in a different order.
3231 * @hide
3232 */
3233 public static final String ACTION_USER_STOPPING =
3234 "android.intent.action.USER_STOPPING";
3235
3236 /**
3237 * Broadcast sent to the system when a user is stopped. Carries an extra
3238 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3239 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3240 * specific package. This is only sent to registered receivers, not manifest
3241 * receivers. It is sent to all running users <em>except</em> the one that
3242 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003243 * @hide
3244 */
3245 public static final String ACTION_USER_STOPPED =
3246 "android.intent.action.USER_STOPPED";
3247
3248 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003249 * 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 -07003250 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003251 * one that has been removed. The user will not be completely removed until all receivers have
3252 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003253 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003254 * @hide
3255 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003256 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003257 public static final String ACTION_USER_REMOVED =
3258 "android.intent.action.USER_REMOVED";
3259
3260 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003261 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003262 * the userHandle of the user to become the current one. This is only sent to
3263 * registered receivers, not manifest receivers. It is sent to all running users.
3264 * You must hold
3265 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003266 * @hide
3267 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003268 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003269 public static final String ACTION_USER_SWITCHED =
3270 "android.intent.action.USER_SWITCHED";
3271
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003272 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003273 * Broadcast Action: Sent when the credential-encrypted private storage has
3274 * become unlocked for the target user. This is only sent to registered
3275 * receivers, not manifest receivers.
3276 */
3277 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3278 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3279
3280 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003281 * Broadcast sent to the system when a user's information changes. Carries an extra
3282 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003283 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003284 * @hide
3285 */
3286 public static final String ACTION_USER_INFO_CHANGED =
3287 "android.intent.action.USER_INFO_CHANGED";
3288
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003289 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003290 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3291 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003292 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3293 * that need to display merged content across both primary and managed profiles need to
3294 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003295 * not manifest receivers.
3296 */
3297 public static final String ACTION_MANAGED_PROFILE_ADDED =
3298 "android.intent.action.MANAGED_PROFILE_ADDED";
3299
3300 /**
3301 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003302 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3303 * Only applications (for example Launchers) that need to display merged content across both
3304 * primary and managed profiles need to worry about this broadcast. This is only sent to
3305 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003306 */
3307 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3308 "android.intent.action.MANAGED_PROFILE_REMOVED";
3309
3310 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003311 * Broadcast sent to the primary user when the credential-encrypted private storage for
3312 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3313 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3314 * Launchers) that need to display merged content across both primary and managed profiles
3315 * need to worry about this broadcast. This is only sent to registered receivers,
3316 * not manifest receivers.
3317 */
3318 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3319 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3320
3321 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003322 * Broadcast sent to the primary user when an associated managed profile has become available.
3323 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003324 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3325 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3326 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003327 */
Rubin Xue95057a2016-04-01 16:49:25 +01003328 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3329 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3330
3331 /**
3332 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3333 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3334 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3335 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3336 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3337 */
3338 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3339 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003340
3341 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003342 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3343 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3344 * the device was locked or unlocked.
3345 *
3346 * This is only sent to registered receivers.
3347 *
3348 * @hide
3349 */
3350 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3351 "android.intent.action.DEVICE_LOCKED_CHANGED";
3352
3353 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003354 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3355 */
3356 public static final String ACTION_QUICK_CLOCK =
3357 "android.intent.action.QUICK_CLOCK";
3358
Michael Wright0087a142013-02-05 16:29:39 -08003359 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003360 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003361 * @hide
3362 */
3363 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003364 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003365
Justin Kohd378ad72013-04-01 12:18:26 -07003366 /**
3367 * Broadcast Action: A global button was pressed. Includes a single
3368 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3369 * caused the broadcast.
3370 * @hide
3371 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003372 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003373 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3374
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003375 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003376 * Broadcast Action: Sent when media resource is granted.
3377 * <p>
3378 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3379 * granted.
3380 * </p>
3381 * <p class="note">
3382 * This is a protected intent that can only be sent by the system.
3383 * </p>
3384 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003385 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003386 * </p>
3387 *
3388 * @hide
3389 */
3390 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3391 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3392
3393 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003394 * Broadcast Action: An overlay package has changed. The data contains the
3395 * name of the overlay package which has changed. This is broadcast on all
3396 * changes to the OverlayInfo returned by {@link
3397 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3398 * most common change is a state change that will change whether the
3399 * overlay is enabled or not.
3400 * @hide
3401 */
3402 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3403
3404 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003405 * Activity Action: Allow the user to select and return one or more existing
3406 * documents. When invoked, the system will display the various
3407 * {@link DocumentsProvider} instances installed on the device, letting the
3408 * user interactively navigate through them. These documents include local
3409 * media, such as photos and video, and documents provided by installed
3410 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003411 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003412 * Each document is represented as a {@code content://} URI backed by a
3413 * {@link DocumentsProvider}, which can be opened as a stream with
3414 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3415 * {@link android.provider.DocumentsContract.Document} metadata.
3416 * <p>
3417 * All selected documents are returned to the calling application with
3418 * persistable read and write permission grants. If you want to maintain
3419 * access to the documents across device reboots, you need to explicitly
3420 * take the persistable permissions using
3421 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3422 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003423 * Callers must indicate the acceptable document MIME types through
3424 * {@link #setType(String)}. For example, to select photos, use
3425 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3426 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3427 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003428 * <p>
3429 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003430 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3431 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003432 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003433 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3434 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003435 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003436 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003437 * Callers can set a document URI through
3438 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3439 * location of documents navigator. System will do its best to launch the
3440 * navigator in the specified document if it's a folder, or the folder that
3441 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003442 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003443 * Output: The URI of the item that was picked, returned in
3444 * {@link #getData()}. This must be a {@code content://} URI so that any
3445 * receiver can access it. If multiple documents were selected, they are
3446 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003447 *
3448 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003449 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003450 * @see #ACTION_CREATE_DOCUMENT
3451 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003452 */
3453 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3454 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3455
3456 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003457 * Activity Action: Allow the user to create a new document. When invoked,
3458 * the system will display the various {@link DocumentsProvider} instances
3459 * installed on the device, letting the user navigate through them. The
3460 * returned document may be a newly created document with no content, or it
3461 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003462 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003463 * Each document is represented as a {@code content://} URI backed by a
3464 * {@link DocumentsProvider}, which can be opened as a stream with
3465 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3466 * {@link android.provider.DocumentsContract.Document} metadata.
3467 * <p>
3468 * Callers must indicate the concrete MIME type of the document being
3469 * created by setting {@link #setType(String)}. This MIME type cannot be
3470 * changed after the document is created.
3471 * <p>
3472 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3473 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003474 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003475 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3476 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003477 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003478 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003479 * Callers can set a document URI through
3480 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3481 * location of documents navigator. System will do its best to launch the
3482 * navigator in the specified document if it's a folder, or the folder that
3483 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003484 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003485 * Output: The URI of the item that was created. This must be a
3486 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003487 *
3488 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003489 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003490 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003491 * @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_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3495
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003496 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003497 * Activity Action: Allow the user to pick a directory subtree. When
3498 * invoked, the system will display the various {@link DocumentsProvider}
3499 * instances installed on the device, letting the user navigate through
3500 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003501 * <p>
3502 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003503 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3504 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3505 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003506 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003507 * Callers can set a document URI through
3508 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3509 * location of documents navigator. System will do its best to launch the
3510 * navigator in the specified document if it's a folder, or the folder that
3511 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003512 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003513 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003514 *
3515 * @see DocumentsContract
3516 */
3517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003518 public static final String
3519 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003520
Felipe Lemec7b1f892016-01-15 15:02:31 -08003521 /**
Peng Xua35b5532016-01-20 00:05:45 -08003522 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3523 * exisiting sensor being disconnected.
3524 *
3525 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3526 *
3527 * {@hide}
3528 */
3529 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3530 public static final String
3531 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3532
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003533 /**
Sam Line707f832017-04-13 17:00:55 -07003534 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003535 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003536 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003537 */
3538 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003539 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003540 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3541
Christopher Tate6597e342015-02-17 12:15:25 -08003542 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003543 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3544 * is about to be performed.
3545 * @hide
3546 */
3547 @SystemApi
3548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3549 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3550 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3551
3552 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003553 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3554 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3555 *
3556 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3557 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003558 * @hide
3559 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003560 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003561 public static final String EXTRA_FORCE_MASTER_CLEAR =
3562 "android.intent.extra.FORCE_MASTER_CLEAR";
3563
3564 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003565 * A broadcast action to trigger a factory reset.
3566 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003567 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3568 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003569 *
3570 * <p>Not for use by third-party applications.
3571 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003572 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003573 *
3574 * {@hide}
3575 */
3576 @SystemApi
3577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3578 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3579
3580 /**
3581 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3582 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3583 *
3584 * <p>Not for use by third-party applications.
3585 *
3586 * @hide
3587 */
3588 @SystemApi
3589 public static final String EXTRA_FORCE_FACTORY_RESET =
3590 "android.intent.extra.FORCE_FACTORY_RESET";
3591
3592 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003593 * Broadcast action: report that a settings element is being restored from backup. The intent
3594 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3595 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3596 * is the value of that settings entry prior to the restore operation, and
3597 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3598 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3599 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003600 *
3601 * <p>This broadcast is sent only for settings provider entries known to require special handling
3602 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3603 * the provider's backup agent implementation.
3604 *
3605 * @see #EXTRA_SETTING_NAME
3606 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3607 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003608 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003609 * {@hide}
3610 */
3611 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3612
3613 /** {@hide} */
3614 public static final String EXTRA_SETTING_NAME = "setting_name";
3615 /** {@hide} */
3616 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3617 /** {@hide} */
3618 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003619 /** {@hide} */
3620 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003621
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003622 /**
3623 * Activity Action: Process a piece of text.
3624 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3625 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3626 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3627 */
3628 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3629 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003630
3631 /**
3632 * Broadcast Action: The sim card state has changed.
3633 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3634 * because TelephonyIntents is an internal class.
3635 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003636 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3637 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003638 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003639 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003640 @SystemApi
3641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3642 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3643
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003644 /**
fionaxu90fee272017-03-31 12:45:12 -07003645 * Broadcast Action: indicate that the phone service state has changed.
3646 * The intent will have the following extra values:</p>
3647 * <p>
3648 * @see #EXTRA_VOICE_REG_STATE
3649 * @see #EXTRA_DATA_REG_STATE
3650 * @see #EXTRA_VOICE_ROAMING_TYPE
3651 * @see #EXTRA_DATA_ROAMING_TYPE
3652 * @see #EXTRA_OPERATOR_ALPHA_LONG
3653 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3654 * @see #EXTRA_OPERATOR_NUMERIC
3655 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3656 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3657 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3658 * @see #EXTRA_MANUAL
3659 * @see #EXTRA_VOICE_RADIO_TECH
3660 * @see #EXTRA_DATA_RADIO_TECH
3661 * @see #EXTRA_CSS_INDICATOR
3662 * @see #EXTRA_NETWORK_ID
3663 * @see #EXTRA_SYSTEM_ID
3664 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3665 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3666 * @see #EXTRA_EMERGENCY_ONLY
3667 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3668 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3669 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3670 *
3671 * <p class="note">
3672 * Requires the READ_PHONE_STATE permission.
3673 *
3674 * <p class="note">This is a protected intent that can only be sent by the system.
3675 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003676 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003677 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3678 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3679 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3680 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003681 */
3682 @Deprecated
3683 @SystemApi
3684 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3685 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3686
3687 /**
3688 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3689 * state.
3690 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3691 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3692 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3693 * @see android.telephony.ServiceState#STATE_POWER_OFF
3694 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003695 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003696 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003697 */
3698 @Deprecated
3699 @SystemApi
3700 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3701
3702 /**
3703 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3704 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3705 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3706 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3707 * @see android.telephony.ServiceState#STATE_POWER_OFF
3708 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003709 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003710 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003711 */
3712 @Deprecated
3713 @SystemApi
3714 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3715
3716 /**
3717 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3718 * type.
3719 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003720 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003721 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003722 */
3723 @Deprecated
3724 @SystemApi
3725 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3726
3727 /**
3728 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3729 * type.
3730 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003731 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003732 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003733 */
3734 @Deprecated
3735 @SystemApi
3736 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3737
3738 /**
3739 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3740 * registered voice operator name in long alphanumeric format.
3741 * {@code null} if the operator name is not known or unregistered.
3742 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003743 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003744 * @deprecated Use
3745 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003746 */
3747 @Deprecated
3748 @SystemApi
3749 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3750
3751 /**
3752 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3753 * registered voice operator name in short alphanumeric format.
3754 * {@code null} if the operator name is not known or unregistered.
3755 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003756 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003757 * @deprecated Use
3758 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003759 */
3760 @Deprecated
3761 @SystemApi
3762 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3763
3764 /**
3765 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3766 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3767 * network.
3768 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003769 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003770 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003771 */
3772 @Deprecated
3773 @SystemApi
3774 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3775
3776 /**
3777 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3778 * registered data operator name in long alphanumeric format.
3779 * {@code null} if the operator name is not known or unregistered.
3780 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003781 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003782 * @deprecated Use
3783 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003784 */
3785 @Deprecated
3786 @SystemApi
3787 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3788
3789 /**
3790 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3791 * registered data operator name in short alphanumeric format.
3792 * {@code null} if the operator name is not known or unregistered.
3793 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003794 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003795 * @deprecated Use
3796 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003797 */
3798 @Deprecated
3799 @SystemApi
3800 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3801
3802 /**
3803 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3804 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3805 * data operator.
3806 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003807 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003808 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003809 */
3810 @Deprecated
3811 @SystemApi
3812 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3813
3814 /**
3815 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3816 * network selection mode is manual.
3817 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3818 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003819 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003820 * @deprecated Use
3821 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003822 */
3823 @Deprecated
3824 @SystemApi
3825 public static final String EXTRA_MANUAL = "manual";
3826
3827 /**
3828 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3829 * radio technology.
3830 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003831 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003832 * @deprecated Use
3833 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003834 */
3835 @Deprecated
3836 @SystemApi
3837 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3838
3839 /**
3840 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3841 * radio technology.
3842 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003843 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003844 * @deprecated Use
3845 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003846 */
3847 @Deprecated
3848 @SystemApi
3849 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3850
3851 /**
3852 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3853 * support on CDMA network.
3854 * Will be {@code true} if support, {@code false} otherwise.
3855 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003856 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003857 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003858 */
3859 @Deprecated
3860 @SystemApi
3861 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3862
3863 /**
3864 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3865 * id. {@code Integer.MAX_VALUE} if unknown.
3866 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003867 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003868 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003869 */
3870 @Deprecated
3871 @SystemApi
3872 public static final String EXTRA_NETWORK_ID = "networkId";
3873
3874 /**
3875 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3876 * {@code Integer.MAX_VALUE} if unknown.
3877 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003878 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003879 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003880 */
3881 @Deprecated
3882 @SystemApi
3883 public static final String EXTRA_SYSTEM_ID = "systemId";
3884
3885 /**
3886 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3887 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3888 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003889 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003890 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003891 */
3892 @Deprecated
3893 @SystemApi
3894 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3895
3896 /**
3897 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3898 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3899 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003900 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003901 * @deprecated Use
3902 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003903 */
3904 @Deprecated
3905 @SystemApi
3906 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3907
3908 /**
3909 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3910 * only mode.
3911 * {@code true} if in emergency only mode, {@code false} otherwise.
3912 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003913 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003914 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003915 */
3916 @Deprecated
3917 @SystemApi
3918 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3919
3920 /**
3921 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3922 * registration state is roaming.
3923 * {@code true} if registration indicates roaming, {@code false} otherwise
3924 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003925 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003926 * @deprecated Use
3927 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003928 */
3929 @Deprecated
3930 @SystemApi
3931 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3932 "isDataRoamingFromRegistration";
3933
3934 /**
3935 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3936 * aggregation is in use.
3937 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3938 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003939 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003940 * @deprecated Use
3941 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003942 */
3943 @Deprecated
3944 @SystemApi
3945 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3946
3947 /**
3948 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3949 * is reduced from the rsrp threshold while calculating signal strength level.
3950 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003951 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003952 */
3953 @Deprecated
3954 @SystemApi
3955 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3956
3957 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003958 * The name of the extra used to define the text to be processed, as a
3959 * CharSequence. Note that this may be a styled CharSequence, so you must use
3960 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003961 */
3962 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3963 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003964 * 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 +00003965 */
3966 public static final String EXTRA_PROCESS_TEXT_READONLY =
3967 "android.intent.extra.PROCESS_TEXT_READONLY";
3968
Bryce Leebc58f592015-09-25 16:43:01 -07003969 /**
3970 * Broadcast action: reports when a new thermal event has been reached. When the device
3971 * is reaching its maximum temperatue, the thermal level reported
3972 * {@hide}
3973 */
3974 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3975 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3976
3977 /** {@hide} */
3978 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3979
3980 /**
3981 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003982 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003983 * {@hide}
3984 */
3985 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3986
3987 /**
3988 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003989 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003990 * {@hide}
3991 */
3992 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3993
3994 /**
3995 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003996 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003997 * {@hide}
3998 */
3999 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4000
lpeter318abc92018-05-04 16:13:14 +08004001 /**
4002 * Broadcast Action: Indicates the dock in idle state while device is docked.
4003 *
4004 * <p class="note">This is a protected intent that can only be sent
4005 * by the system.
4006 *
4007 * @hide
4008 */
4009 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4010
4011 /**
4012 * Broadcast Action: Indicates the dock in active state while device is docked.
4013 *
4014 * <p class="note">This is a protected intent that can only be sent
4015 * by the system.
4016 *
4017 * @hide
4018 */
4019 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4020
Bryce Leebc58f592015-09-25 16:43:01 -07004021
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004022 // ---------------------------------------------------------------------
4023 // ---------------------------------------------------------------------
4024 // Standard intent categories (see addCategory()).
4025
4026 /**
4027 * Set if the activity should be an option for the default action
4028 * (center press) to perform on a piece of data. Setting this will
4029 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004030 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004031 * Intent when initiating an action -- it is for use in intent filters
4032 * specified in packages.
4033 */
4034 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4035 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4036 /**
4037 * Activities that can be safely invoked from a browser must support this
4038 * category. For example, if the user is viewing a web page or an e-mail
4039 * and clicks on a link in the text, the Intent generated execute that
4040 * link will require the BROWSABLE category, so that only activities
4041 * supporting this category will be considered as possible actions. By
4042 * supporting this category, you are promising that there is nothing
4043 * damaging (without user intervention) that can happen by invoking any
4044 * matching Intent.
4045 */
4046 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4047 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4048 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004049 * Categories for activities that can participate in voice interaction.
4050 * An activity that supports this category must be prepared to run with
4051 * no UI shown at all (though in some case it may have a UI shown), and
4052 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4053 */
4054 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4055 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4056 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004057 * Set if the activity should be considered as an alternative action to
4058 * the data the user is currently viewing. See also
4059 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4060 * applies to the selection in a list of items.
4061 *
4062 * <p>Supporting this category means that you would like your activity to be
4063 * displayed in the set of alternative things the user can do, usually as
4064 * part of the current activity's options menu. You will usually want to
4065 * include a specific label in the &lt;intent-filter&gt; of this action
4066 * describing to the user what it does.
4067 *
4068 * <p>The action of IntentFilter with this category is important in that it
4069 * describes the specific action the target will perform. This generally
4070 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4071 * a specific name such as "com.android.camera.action.CROP. Only one
4072 * alternative of any particular action will be shown to the user, so using
4073 * a specific action like this makes sure that your alternative will be
4074 * displayed while also allowing other applications to provide their own
4075 * overrides of that particular action.
4076 */
4077 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4078 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4079 /**
4080 * Set if the activity should be considered as an alternative selection
4081 * action to the data the user has currently selected. This is like
4082 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4083 * of items from which the user can select, giving them alternatives to the
4084 * default action that will be performed on it.
4085 */
4086 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4087 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4088 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004089 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004090 */
4091 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4092 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4093 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004094 * Should be displayed in the top-level launcher.
4095 */
4096 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4097 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4098 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004099 * Indicates an activity optimized for Leanback mode, and that should
4100 * be displayed in the Leanback launcher.
4101 */
4102 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4103 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4104 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004105 * Indicates the preferred entry-point activity when an application is launched from a Car
4106 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4107 * fallback, or exclude the application entirely.
4108 * @hide
4109 */
4110 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4111 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4112 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004113 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4114 * @hide
4115 */
4116 @SystemApi
4117 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4118 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004119 * Provides information about the package it is in; typically used if
4120 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4121 * a front-door to the user without having to be shown in the all apps list.
4122 */
4123 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4124 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4125 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004126 * This is the home activity, that is the first activity that is displayed
4127 * when the device boots.
4128 */
4129 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4130 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4131 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004132 * This is the home activity that is displayed when the device is finished setting up and ready
4133 * for use.
4134 * @hide
4135 */
4136 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4137 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4138 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004139 * This is the setup wizard activity, that is the first activity that is displayed
4140 * when the user sets up the device for the first time.
4141 * @hide
4142 */
4143 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4144 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4145 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004146 * This is the home activity, that is the activity that serves as the launcher app
4147 * from there the user can start other apps. Often components with lower/higher
4148 * priority intent filters handle the home intent, for example SetupWizard, to
4149 * setup the device and we need to be able to distinguish the home app from these
4150 * setup helpers.
4151 * @hide
4152 */
4153 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4154 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4155 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004156 * This activity is a preference panel.
4157 */
4158 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4159 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4160 /**
4161 * This activity is a development preference panel.
4162 */
4163 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4164 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4165 /**
4166 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004167 */
4168 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4169 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4170 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004171 * This activity allows the user to browse and download new applications.
4172 */
4173 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4174 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4175 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004176 * This activity may be exercised by the monkey or other automated test tools.
4177 */
4178 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4179 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4180 /**
4181 * To be used as a test (not part of the normal user experience).
4182 */
4183 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4184 /**
4185 * To be used as a unit test (run through the Test Harness).
4186 */
4187 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4188 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004189 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004190 * experience).
4191 */
4192 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004193
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004194 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004195 * Used to indicate that an intent only wants URIs that can be opened with
4196 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4197 * must support at least the columns defined in {@link OpenableColumns} when
4198 * queried.
4199 *
4200 * @see #ACTION_GET_CONTENT
4201 * @see #ACTION_OPEN_DOCUMENT
4202 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004203 */
4204 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4205 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4206
4207 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004208 * Used to indicate that an intent filter can accept files which are not necessarily
4209 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4210 * at least streamable via
4211 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4212 * using one of the stream types exposed via
4213 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4214 *
4215 * @see #ACTION_SEND
4216 * @see #ACTION_SEND_MULTIPLE
4217 */
4218 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4219 public static final String CATEGORY_TYPED_OPENABLE =
4220 "android.intent.category.TYPED_OPENABLE";
4221
4222 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004223 * To be used as code under test for framework instrumentation tests.
4224 */
4225 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4226 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004227 /**
4228 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004229 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4230 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004231 */
4232 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4233 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4234 /**
4235 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004236 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4237 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004238 */
4239 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4240 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004241 /**
4242 * An activity to run when device is inserted into a analog (low end) dock.
4243 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4244 * information, see {@link android.app.UiModeManager}.
4245 */
4246 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4247 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4248
4249 /**
4250 * An activity to run when device is inserted into a digital (high end) dock.
4251 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4252 * information, see {@link android.app.UiModeManager}.
4253 */
4254 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4255 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004256
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004257 /**
4258 * Used to indicate that the activity can be used in a car environment.
4259 */
4260 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4261 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4262
Zak Cohendb6ca492017-01-26 14:09:00 -08004263 /**
4264 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4265 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4266 * information, see {@link android.app.UiModeManager}.
4267 */
4268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4269 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004270 // ---------------------------------------------------------------------
4271 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004272 // Application launch intent categories (see addCategory()).
4273
4274 /**
4275 * Used with {@link #ACTION_MAIN} to launch the browser application.
4276 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004277 * <p>NOTE: This should not be used as the primary key of an Intent,
4278 * since it will not result in the app launching with the correct
4279 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004280 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004281 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004282 */
4283 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4284 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4285
4286 /**
4287 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4288 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004289 * <p>NOTE: This should not be used as the primary key of an Intent,
4290 * since it will not result in the app launching with the correct
4291 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004292 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004293 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004294 */
4295 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4296 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4297
4298 /**
4299 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4300 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004301 * <p>NOTE: This should not be used as the primary key of an Intent,
4302 * since it will not result in the app launching with the correct
4303 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004304 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004305 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004306 */
4307 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4308 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4309
4310 /**
4311 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4312 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004313 * <p>NOTE: This should not be used as the primary key of an Intent,
4314 * since it will not result in the app launching with the correct
4315 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004316 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004317 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004318 */
4319 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4320 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4321
4322 /**
4323 * Used with {@link #ACTION_MAIN} to launch the email application.
4324 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004325 * <p>NOTE: This should not be used as the primary key of an Intent,
4326 * since it will not result in the app launching with the correct
4327 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004328 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004329 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004330 */
4331 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4332 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4333
4334 /**
4335 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4336 * The activity should be able to view and manipulate image and video files
4337 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004338 * <p>NOTE: This should not be used as the primary key of an Intent,
4339 * since it will not result in the app launching with the correct
4340 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004341 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004342 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004343 */
4344 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4345 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4346
4347 /**
4348 * Used with {@link #ACTION_MAIN} to launch the maps application.
4349 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004350 * <p>NOTE: This should not be used as the primary key of an Intent,
4351 * since it will not result in the app launching with the correct
4352 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004353 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004354 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004355 */
4356 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4357 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4358
4359 /**
4360 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4361 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004362 * <p>NOTE: This should not be used as the primary key of an Intent,
4363 * since it will not result in the app launching with the correct
4364 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004365 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004366 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004367 */
4368 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4369 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4370
4371 /**
4372 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004373 * The activity should be able to play, browse, or manipulate music files
4374 * stored on the device.
4375 * <p>NOTE: This should not be used as the primary key of an Intent,
4376 * since it will not result in the app launching with the correct
4377 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004378 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004379 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004380 */
4381 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4382 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4383
4384 // ---------------------------------------------------------------------
4385 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004386 // Standard extra data keys.
4387
4388 /**
4389 * The initial data to place in a newly created record. Use with
4390 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4391 * fields as would be given to the underlying ContentProvider.insert()
4392 * call.
4393 */
4394 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4395
4396 /**
4397 * A constant CharSequence that is associated with the Intent, used with
4398 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4399 * this may be a styled CharSequence, so you must use
4400 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4401 * retrieve it.
4402 */
4403 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4404
4405 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004406 * A constant String that is associated with the Intent, used with
4407 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4408 * as HTML formatted text. Note that you <em>must</em> also supply
4409 * {@link #EXTRA_TEXT}.
4410 */
4411 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4412
4413 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004414 * A content: URI holding a stream of data associated with the Intent,
4415 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004416 */
4417 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4418
4419 /**
4420 * A String[] holding e-mail addresses that should be delivered to.
4421 */
4422 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4423
4424 /**
4425 * A String[] holding e-mail addresses that should be carbon copied.
4426 */
4427 public static final String EXTRA_CC = "android.intent.extra.CC";
4428
4429 /**
4430 * A String[] holding e-mail addresses that should be blind carbon copied.
4431 */
4432 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4433
4434 /**
4435 * A constant string holding the desired subject line of a message.
4436 */
4437 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4438
4439 /**
4440 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004441 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004442 */
4443 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4444
4445 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004446 * An int representing the user id to be used.
4447 *
4448 * @hide
4449 */
Philip P. Moltmann4e615e62018-08-28 14:57:49 -07004450 @SystemApi
Clara Bayarrif7fea162015-10-22 16:09:52 +01004451 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4452
4453 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004454 * An int representing the task id to be retrieved. This is used when a launch from recents is
4455 * intercepted by another action such as credentials confirmation to remember which task should
4456 * be resumed when complete.
4457 *
4458 * @hide
4459 */
4460 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4461
4462 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004463 * An Intent[] describing additional, alternate choices you would like shown with
4464 * {@link #ACTION_CHOOSER}.
4465 *
4466 * <p>An app may be capable of providing several different payload types to complete a
4467 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4468 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4469 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4470 * photo data or a hosted link where the photos can be viewed.</p>
4471 *
4472 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4473 * first/primary/preferred intent in the set. Additional intents specified in
4474 * this extra are ordered; by default intents that appear earlier in the array will be
4475 * preferred over intents that appear later in the array as matches for the same
4476 * target component. To alter this preference, a calling app may also supply
4477 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4478 */
4479 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4480
4481 /**
Adam Powell52c39212016-04-07 15:14:18 -07004482 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4483 * and omitted from a list of components presented to the user.
4484 *
4485 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4486 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4487 * from your own package or other apps from your organization if the idea of sending to those
4488 * targets would be redundant with other app functionality. Filtered components will not
4489 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4490 */
4491 public static final String EXTRA_EXCLUDE_COMPONENTS
4492 = "android.intent.extra.EXCLUDE_COMPONENTS";
4493
4494 /**
4495 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4496 * describing additional high-priority deep-link targets for the chooser to present to the user.
4497 *
4498 * <p>Targets provided in this way will be presented inline with all other targets provided
4499 * by services from other apps. They will be prioritized before other service targets, but
4500 * after those targets provided by sources that the user has manually pinned to the front.</p>
4501 *
4502 * @see #ACTION_CHOOSER
4503 */
4504 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4505
4506 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004507 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4508 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4509 *
4510 * <p>An app preparing an action for another app to complete may wish to allow the user to
4511 * disambiguate between several options for completing the action based on the chosen target
4512 * or otherwise refine the action before it is invoked.
4513 * </p>
4514 *
4515 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4516 * <ul>
4517 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4518 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4519 * chosen target beyond the first</li>
4520 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4521 * should fill in and send once the disambiguation is complete</li>
4522 * </ul>
4523 */
4524 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4525 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4526
4527 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004528 * An {@code ArrayList} of {@code String} annotations describing content for
4529 * {@link #ACTION_CHOOSER}.
4530 *
4531 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4532 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4533 *
4534 * <p>Annotations should describe the major components or topics of the content. It is up to
4535 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4536 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004537 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4538 * character. Performance on customized annotations can suffer, if they are rarely used for
4539 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4540 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004541 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004542 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004543 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004544 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004545 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004546 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004547 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004548 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004549 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004550 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4551 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4552 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4553 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4554 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004555 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004556 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4557 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004558 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004559 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004560 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004561 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004562 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004563 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004564 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004565 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004566 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004567 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004568 * Christmas and Thanksgiving.</li>
4569 * </ul>
4570 */
4571 public static final String EXTRA_CONTENT_ANNOTATIONS
4572 = "android.intent.extra.CONTENT_ANNOTATIONS";
4573
4574 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004575 * A {@link ResultReceiver} used to return data back to the sender.
4576 *
4577 * <p>Used to complete an app-specific
4578 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4579 *
4580 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4581 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4582 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4583 * when the user selects a target component from the chooser. It is up to the recipient
4584 * to send a result to this ResultReceiver to signal that disambiguation is complete
4585 * and that the chooser should invoke the user's choice.</p>
4586 *
4587 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4588 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4589 * to match and fill in the final Intent or ChooserTarget before starting it.
4590 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4591 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4592 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4593 *
4594 * <p>The result code passed to the ResultReceiver should be
4595 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4596 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4597 * the chooser should finish without starting a target.</p>
4598 */
4599 public static final String EXTRA_RESULT_RECEIVER
4600 = "android.intent.extra.RESULT_RECEIVER";
4601
4602 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004604 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004605 */
4606 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4607
4608 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004609 * A Parcelable[] of {@link Intent} or
4610 * {@link android.content.pm.LabeledIntent} objects as set with
4611 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4612 * a the front of the list of choices, when shown to the user with a
4613 * {@link #ACTION_CHOOSER}.
4614 */
4615 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4616
4617 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004618 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004619 * @hide
4620 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004621 @SystemApi
4622 public static final String EXTRA_INSTANT_APP_SUCCESS =
4623 "android.intent.extra.INSTANT_APP_SUCCESS";
4624
4625 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004626 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004627 * @hide
4628 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004629 @SystemApi
4630 public static final String EXTRA_INSTANT_APP_FAILURE =
4631 "android.intent.extra.INSTANT_APP_FAILURE";
4632
4633 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004634 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004635 * @hide
4636 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004637 @SystemApi
4638 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4639 "android.intent.extra.INSTANT_APP_HOSTNAME";
4640
4641 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004642 * An opaque token to track instant app resolution.
4643 * @hide
4644 */
4645 @SystemApi
4646 public static final String EXTRA_INSTANT_APP_TOKEN =
4647 "android.intent.extra.INSTANT_APP_TOKEN";
4648
4649 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004650 * The action that triggered an instant application resolution.
4651 * @hide
4652 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004653 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004654 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4655
4656 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004657 * An array of {@link Bundle}s containing details about resolved instant apps..
4658 * @hide
4659 */
4660 @SystemApi
4661 public static final String EXTRA_INSTANT_APP_BUNDLES =
4662 "android.intent.extra.INSTANT_APP_BUNDLES";
4663
4664 /**
4665 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004666 * installed. This data is populated from the response to
4667 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4668 * instant application resolver.
4669 * @hide
4670 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004671 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004672 public static final String EXTRA_INSTANT_APP_EXTRAS =
4673 "android.intent.extra.INSTANT_APP_EXTRAS";
4674
4675 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004676 * A boolean value indicating that the instant app resolver was unable to state with certainty
4677 * that it did or did not have an app for the sanitized {@link Intent} defined at
4678 * {@link #EXTRA_INTENT}.
4679 * @hide
4680 */
4681 @SystemApi
4682 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4683 "android.intent.extra.UNKNOWN_INSTANT_APP";
4684
4685 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004686 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004687 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004688 * @hide
4689 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004690 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004691 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4692
4693 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004694 * The version code of the app to install components from.
4695 * @hide
4696 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004697 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004698 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4699
4700 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004701 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004702 * @hide
4703 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004704 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004705 public static final String EXTRA_CALLING_PACKAGE
4706 = "android.intent.extra.CALLING_PACKAGE";
4707
4708 /**
4709 * Optional calling app provided bundle containing additional launch information the
4710 * installer may use.
4711 * @hide
4712 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004713 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004714 public static final String EXTRA_VERIFICATION_BUNDLE
4715 = "android.intent.extra.VERIFICATION_BUNDLE";
4716
4717 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004718 * A Bundle forming a mapping of potential target package names to different extras Bundles
4719 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4720 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4721 * be currently installed on the device.
4722 *
4723 * <p>An application may choose to provide alternate extras for the case where a user
4724 * selects an activity from a predetermined set of target packages. If the activity
4725 * the user selects from the chooser belongs to a package with its package name as
4726 * a key in this bundle, the corresponding extras for that package will be merged with
4727 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4728 * extra has the same key as an extra already present in the intent it will overwrite
4729 * the extra from the intent.</p>
4730 *
4731 * <p><em>Examples:</em>
4732 * <ul>
4733 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4734 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4735 * parameters for that target.</li>
4736 * <li>An application may offer additional metadata for known targets of a given intent
4737 * to pass along information only relevant to that target such as account or content
4738 * identifiers already known to that application.</li>
4739 * </ul></p>
4740 */
4741 public static final String EXTRA_REPLACEMENT_EXTRAS =
4742 "android.intent.extra.REPLACEMENT_EXTRAS";
4743
4744 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004745 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4746 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4747 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4748 * {@link ComponentName} of the chosen component.
4749 *
4750 * <p>In some situations this callback may never come, for example if the user abandons
4751 * the chooser, switches to another task or any number of other reasons. Apps should not
4752 * be written assuming that this callback will always occur.</p>
4753 */
4754 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4755 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4756
4757 /**
4758 * The {@link ComponentName} chosen by the user to complete an action.
4759 *
4760 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4761 */
4762 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4763
4764 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765 * A {@link android.view.KeyEvent} object containing the event that
4766 * triggered the creation of the Intent it is in.
4767 */
4768 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4769
4770 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004771 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4772 * before shutting down.
4773 *
4774 * {@hide}
4775 */
4776 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4777
4778 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004779 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4780 * requested by the user.
4781 *
4782 * {@hide}
4783 */
4784 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4785 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4786
4787 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004788 * 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 -07004789 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4790 * of restarting the application.
4791 */
4792 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4793
4794 /**
4795 * A String holding the phone number originally entered in
4796 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4797 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4798 */
4799 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004800
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004801 /**
4802 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4803 * intents to supply the uid the package had been assigned. Also an optional
4804 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4805 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4806 * purpose.
4807 */
4808 public static final String EXTRA_UID = "android.intent.extra.UID";
4809
4810 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004811 * @hide String array of package names.
4812 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004813 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004814 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4815
4816 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004817 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4818 * intents to indicate whether this represents a full uninstall (removing
4819 * both the code and its data) or a partial uninstall (leaving its data,
4820 * implying that this is an update).
4821 */
4822 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004823
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004824 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004825 * @hide
4826 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4827 * intents to indicate that at this point the package has been removed for
4828 * all users on the device.
4829 */
4830 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4831 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4832
4833 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004834 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4835 * intents to indicate that this is a replacement of the package, so this
4836 * broadcast will immediately be followed by an add broadcast for a
4837 * different version of the same package.
4838 */
4839 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004840
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004841 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004842 * Used as an int extra field in {@link android.app.AlarmManager} intents
4843 * to tell the application being invoked how many pending alarms are being
4844 * delievered with the intent. For one-shot alarms this will always be 1.
4845 * For recurring alarms, this might be greater than 1 if the device was
4846 * asleep or powered off at the time an earlier alarm would have been
4847 * delivered.
4848 */
4849 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004850
Jacek Surazski86b6c532009-05-13 14:38:28 +02004851 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004852 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4853 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004854 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4855 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004856 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4857 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4858 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004859 */
4860 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4861
4862 /**
4863 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4864 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004865 */
4866 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4867
4868 /**
4869 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4870 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004871 */
4872 public static final int EXTRA_DOCK_STATE_DESK = 1;
4873
4874 /**
4875 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4876 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004877 */
4878 public static final int EXTRA_DOCK_STATE_CAR = 2;
4879
4880 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004881 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4882 * to represent that the phone is in a analog (low end) dock.
4883 */
4884 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4885
4886 /**
4887 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4888 * to represent that the phone is in a digital (high end) dock.
4889 */
4890 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4891
4892 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004893 * Boolean that can be supplied as meta-data with a dock activity, to
4894 * indicate that the dock should take over the home key when it is active.
4895 */
4896 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004897
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004898 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004899 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4900 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004901 */
4902 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4903
4904 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004905 * Used in the extra field in the remote intent. It's astring token passed with the
4906 * remote intent.
4907 */
4908 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4909 "android.intent.extra.remote_intent_token";
4910
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004911 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004912 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004913 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004914 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004915 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004916 "android.intent.extra.changed_component_name";
4917
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004918 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004919 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004920 * and contains a string array of all of the components that have changed. If
4921 * the state of the overall package has changed, then it will contain an entry
4922 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004923 */
4924 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4925 "android.intent.extra.changed_component_name_list";
4926
4927 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004928 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004929 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004930 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4931 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4932 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004933 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004934 */
4935 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4936 "android.intent.extra.changed_package_list";
4937
4938 /**
4939 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004940 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4941 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004942 * and contains an integer array of uids of all of the components
4943 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004944 */
4945 public static final String EXTRA_CHANGED_UID_LIST =
4946 "android.intent.extra.changed_uid_list";
4947
4948 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004949 * @hide
4950 * Magic extra system code can use when binding, to give a label for
4951 * who it is that has bound to a service. This is an integer giving
4952 * a framework string resource that can be displayed to the user.
4953 */
4954 public static final String EXTRA_CLIENT_LABEL =
4955 "android.intent.extra.client_label";
4956
4957 /**
4958 * @hide
4959 * Magic extra system code can use when binding, to give a PendingIntent object
4960 * that can be launched for the user to disable the system's use of this
4961 * service.
4962 */
4963 public static final String EXTRA_CLIENT_INTENT =
4964 "android.intent.extra.client_intent";
4965
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004966 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004967 * Extra used to indicate that an intent should only return data that is on
4968 * the local device. This is a boolean extra; the default is false. If true,
4969 * an implementation should only allow the user to select data that is
4970 * already on the device, not requiring it be downloaded from a remote
4971 * service when opened.
4972 *
4973 * @see #ACTION_GET_CONTENT
4974 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004975 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004976 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004977 */
4978 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004979 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004980
Amith Yamasani13593602012-03-22 16:16:17 -07004981 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004982 * Extra used to indicate that an intent can allow the user to select and
4983 * return multiple items. This is a boolean extra; the default is false. If
4984 * true, an implementation is allowed to present the user with a UI where
4985 * they can pick multiple items that are all returned to the caller. When
4986 * this happens, they should be returned as the {@link #getClipData()} part
4987 * of the result Intent.
4988 *
4989 * @see #ACTION_GET_CONTENT
4990 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004991 */
4992 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004993 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004994
4995 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004996 * The integer userHandle carried with broadcast intents related to addition, removal and
4997 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4998 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4999 *
Amith Yamasani13593602012-03-22 16:16:17 -07005000 * @hide
5001 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005002 public static final String EXTRA_USER_HANDLE =
5003 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005004
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005005 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005006 * The UserHandle carried with broadcasts intents related to addition and removal of managed
5007 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
5008 */
5009 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005010 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005011
5012 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005013 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005014 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5015 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005016 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005017 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5018
5019 /**
5020 * Extra sent in the intent to the BroadcastReceiver that handles
5021 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5022 * the restrictions as key/value pairs.
5023 */
5024 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5025 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005026
Amith Yamasani86118ba2013-03-28 14:33:16 -07005027 /**
5028 * Extra used in the response from a BroadcastReceiver that handles
5029 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5030 */
5031 public static final String EXTRA_RESTRICTIONS_INTENT =
5032 "android.intent.extra.restrictions_intent";
5033
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005034 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005035 * Extra used to communicate a set of acceptable MIME types. The type of the
5036 * extra is {@code String[]}. Values may be a combination of concrete MIME
5037 * types (such as "image/png") and/or partial MIME types (such as
5038 * "audio/*").
5039 *
5040 * @see #ACTION_GET_CONTENT
5041 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005042 */
5043 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5044
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005045 /**
5046 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5047 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005048 * When this is true, hardware devices can use this information to determine that
5049 * they shouldn't do a complete shutdown of their device since this is not a
5050 * complete shutdown down to the kernel, but only user space restarting.
5051 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005052 */
5053 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5054 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5055
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005056 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005057 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5058 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5059 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5060 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005061 *
5062 * @hide for internal use only.
5063 */
5064 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5065 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005066 /** @hide */
5067 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5068 /** @hide */
5069 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5070 /** @hide */
5071 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005072
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005073 /**
5074 * Intent extra: the reason that the operation associated with this intent is being performed.
5075 *
5076 * <p>Type: String
5077 * @hide
5078 */
5079 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005080 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5081
qingxi240c2bb2017-04-12 17:31:18 -07005082 /**
5083 * {@hide}
5084 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5085 */
Rubin Xue8490f12015-06-25 12:17:48 +01005086 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5087
Santos Cordon15a13782015-03-31 18:32:31 -07005088 /**
qingxi240c2bb2017-04-12 17:31:18 -07005089 * {@hide}
5090 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5091 * reset for the device with eSIM. This extra will be sent together with
5092 * {@link #ACTION_FACTORY_RESET}
5093 */
5094 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5095
5096 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005097 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5098 * activation request.
5099 * TODO: Add information about the structure and response data used with the pending intent.
5100 * @hide
5101 */
5102 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5103 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5104
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005105 /**
5106 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005107 *
5108 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005109 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005110 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005111 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5112
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005113 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005114 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5115 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5116 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005117 *
5118 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005119 * @see #ACTION_QUICK_VIEW
5120 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005121 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005122 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005123 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5124 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005125
5126 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005127 * An optional extra of {@code String[]} indicating which quick view features should be made
5128 * available to the user in the quick view UI while handing a
5129 * {@link Intent#ACTION_QUICK_VIEW} intent.
5130 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5131 * Quick viewer can implement features not listed below.
5132 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005133 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5134 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5135 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005136 * <p>
5137 * Requirements:
5138 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5139 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5140 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5141 * internal policies.
5142 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5143 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5144 * disable or hide features.
5145 *
5146 * @see #ACTION_QUICK_VIEW
5147 */
5148 public static final String EXTRA_QUICK_VIEW_FEATURES =
5149 "android.intent.extra.QUICK_VIEW_FEATURES";
5150
5151 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005152 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005153 * When a profile goes into quiet mode, all apps in the profile are killed and the
5154 * profile user is stopped. Widgets originating from the profile are masked, and app
5155 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005156 */
5157 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005158
5159 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005160 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005161 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005162 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5163 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005164 *
5165 * @hide
5166 */
5167 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5168 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5169
5170 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005171 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5172 * whether to show the chooser or not when there is only one application available
5173 * to choose from.
5174 *
5175 * @hide
5176 */
5177 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5178 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5179
5180 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005181 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005182 * to represent that a video codec is allowed to use.
5183 *
5184 * @hide
5185 */
5186 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5187
5188 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005189 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005190 * to represent that a audio codec is allowed to use.
5191 *
5192 * @hide
5193 */
5194 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5195
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005196 // ---------------------------------------------------------------------
5197 // ---------------------------------------------------------------------
5198 // Intent flags (see mFlags variable).
5199
Tor Norbyed9273d62013-05-30 15:59:53 -07005200 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005201 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005202 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5203 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005204 @Retention(RetentionPolicy.SOURCE)
5205 public @interface GrantUriMode {}
5206
Jeff Sharkey846318a2014-04-04 12:12:41 -07005207 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005208 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005209 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5210 @Retention(RetentionPolicy.SOURCE)
5211 public @interface AccessUriMode {}
5212
5213 /**
5214 * Test if given mode flags specify an access mode, which must be at least
5215 * read and/or write.
5216 *
5217 * @hide
5218 */
5219 public static boolean isAccessUriMode(int modeFlags) {
5220 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5221 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5222 }
5223
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005224 /** @hide */
5225 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5226 FLAG_GRANT_READ_URI_PERMISSION,
5227 FLAG_GRANT_WRITE_URI_PERMISSION,
5228 FLAG_FROM_BACKGROUND,
5229 FLAG_DEBUG_LOG_RESOLUTION,
5230 FLAG_EXCLUDE_STOPPED_PACKAGES,
5231 FLAG_INCLUDE_STOPPED_PACKAGES,
5232 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5233 FLAG_GRANT_PREFIX_URI_PERMISSION,
5234 FLAG_DEBUG_TRIAGED_MISSING,
5235 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005236 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005237 FLAG_ACTIVITY_NO_HISTORY,
5238 FLAG_ACTIVITY_SINGLE_TOP,
5239 FLAG_ACTIVITY_NEW_TASK,
5240 FLAG_ACTIVITY_MULTIPLE_TASK,
5241 FLAG_ACTIVITY_CLEAR_TOP,
5242 FLAG_ACTIVITY_FORWARD_RESULT,
5243 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5244 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5245 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5246 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5247 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5248 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5249 FLAG_ACTIVITY_NEW_DOCUMENT,
5250 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5251 FLAG_ACTIVITY_NO_USER_ACTION,
5252 FLAG_ACTIVITY_REORDER_TO_FRONT,
5253 FLAG_ACTIVITY_NO_ANIMATION,
5254 FLAG_ACTIVITY_CLEAR_TASK,
5255 FLAG_ACTIVITY_TASK_ON_HOME,
5256 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5257 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5258 FLAG_RECEIVER_REGISTERED_ONLY,
5259 FLAG_RECEIVER_REPLACE_PENDING,
5260 FLAG_RECEIVER_FOREGROUND,
5261 FLAG_RECEIVER_NO_ABORT,
5262 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5263 FLAG_RECEIVER_BOOT_UPGRADE,
5264 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5265 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5266 FLAG_RECEIVER_FROM_SHELL,
5267 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5268 })
5269 @Retention(RetentionPolicy.SOURCE)
5270 public @interface Flags {}
5271
5272 /** @hide */
5273 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5274 FLAG_FROM_BACKGROUND,
5275 FLAG_DEBUG_LOG_RESOLUTION,
5276 FLAG_EXCLUDE_STOPPED_PACKAGES,
5277 FLAG_INCLUDE_STOPPED_PACKAGES,
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 MutableFlags {}
5315
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005316 /**
5317 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005318 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005319 * specified in its ClipData. When applying to an Intent's ClipData,
5320 * all URIs as well as recursive traversals through data or other ClipData
5321 * in Intent items will be granted; only the grant flags of the top-level
5322 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005323 */
5324 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5325 /**
5326 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005327 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005328 * specified in its ClipData. When applying to an Intent's ClipData,
5329 * all URIs as well as recursive traversals through data or other ClipData
5330 * in Intent items will be granted; only the grant flags of the top-level
5331 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005332 */
5333 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5334 /**
5335 * Can be set by the caller to indicate that this Intent is coming from
5336 * a background operation, not from direct user interaction.
5337 */
5338 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5339 /**
5340 * A flag you can enable for debugging: when set, log messages will be
5341 * printed during the resolution of this intent to show you what has
5342 * been found to create the final resolved list.
5343 */
5344 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005345 /**
5346 * If set, this intent will not match any components in packages that
5347 * are currently stopped. If this is not set, then the default behavior
5348 * is to include such applications in the result.
5349 */
5350 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5351 /**
5352 * If set, this intent will always match any components in packages that
5353 * are currently stopped. This is the default behavior when
5354 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5355 * flags are set, this one wins (it allows overriding of exclude for
5356 * places where the framework may automatically set the exclude flag).
5357 */
5358 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359
5360 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005361 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005362 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005363 * persisted across device reboots until explicitly revoked with
5364 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5365 * grant for possible persisting; the receiving application must call
5366 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5367 * actually persist.
5368 *
5369 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5370 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5371 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005372 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005373 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005374 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005375
5376 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005377 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5378 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5379 * applies to any URI that is a prefix match against the original granted
5380 * URI. (Without this flag, the URI must match exactly for access to be
5381 * granted.) Another URI is considered a prefix match only when scheme,
5382 * authority, and all path segments defined by the prefix are an exact
5383 * match.
5384 */
5385 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5386
5387 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005388 * Flag used to automatically match intents based on their Direct Boot
5389 * awareness and the current user state.
5390 * <p>
5391 * Since the default behavior is to automatically apply the current user
5392 * state, this is effectively a sentinel value that doesn't change the
5393 * output of any queries based on its presence or absence.
5394 * <p>
5395 * Instead, this value can be useful in conjunction with
5396 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5397 * to detect when a caller is relying on implicit automatic matching,
5398 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005399 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005400 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5401
5402 /** {@hide} */
5403 @Deprecated
5404 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005405
5406 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005407 * Internal flag used to indicate ephemeral applications should not be
5408 * considered when resolving the intent.
5409 *
5410 * @hide
5411 */
5412 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5413
5414 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005415 * If set, the new activity is not kept in the history stack. As soon as
5416 * the user navigates away from it, the activity is finished. This may also
5417 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5418 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005419 *
5420 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5421 * is never invoked when the current activity starts a new activity which
5422 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005423 */
5424 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5425 /**
5426 * If set, the activity will not be launched if it is already running
5427 * at the top of the history stack.
5428 */
5429 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5430 /**
5431 * If set, this activity will become the start of a new task on this
5432 * history stack. A task (from the activity that started it to the
5433 * next task activity) defines an atomic group of activities that the
5434 * user can move to. Tasks can be moved to the foreground and background;
5435 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005436 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005437 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5438 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 *
5440 * <p>This flag is generally used by activities that want
5441 * to present a "launcher" style behavior: they give the user a list of
5442 * separate things that can be done, which otherwise run completely
5443 * independently of the activity launching them.
5444 *
5445 * <p>When using this flag, if a task is already running for the activity
5446 * you are now starting, then a new activity will not be started; instead,
5447 * the current task will simply be brought to the front of the screen with
5448 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5449 * to disable this behavior.
5450 *
5451 * <p>This flag can not be used when the caller is requesting a result from
5452 * the activity being launched.
5453 */
5454 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5455 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005456 * This flag is used to create a new task and launch an activity into it.
5457 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5458 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5459 * search through existing tasks for ones matching this Intent. Only if no such
5460 * task is found would a new task be created. When paired with
5461 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5462 * the search for a matching task and unconditionally start a new task.
5463 *
5464 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5465 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 * top-level application launcher.</strong> Used in conjunction with
5467 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5468 * behavior of bringing an existing task to the foreground. When set,
5469 * a new task is <em>always</em> started to host the Activity for the
5470 * Intent, regardless of whether there is already an existing task running
5471 * the same thing.
5472 *
5473 * <p><strong>Because the default system does not include graphical task management,
5474 * you should not use this flag unless you provide some way for a user to
5475 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005476 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005477 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5478 * creating new document tasks.
5479 *
5480 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005481 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005482 *
Scott Main7aee61f2011-02-08 11:25:01 -08005483 * <p>See
5484 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5485 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005486 *
5487 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5488 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005489 */
5490 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5491 /**
5492 * If set, and the activity being launched is already running in the
5493 * current task, then instead of launching a new instance of that activity,
5494 * all of the other activities on top of it will be closed and this Intent
5495 * will be delivered to the (now on top) old activity as a new Intent.
5496 *
5497 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5498 * If D calls startActivity() with an Intent that resolves to the component
5499 * of activity B, then C and D will be finished and B receive the given
5500 * Intent, resulting in the stack now being: A, B.
5501 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005502 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005503 * either receive the new intent you are starting here in its
5504 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005505 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005506 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5507 * the same intent, then it will be finished and re-created; for all other
5508 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5509 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005510 *
5511 * <p>This launch mode can also be used to good effect in conjunction with
5512 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5513 * of a task, it will bring any currently running instance of that task
5514 * to the foreground, and then clear it to its root state. This is
5515 * especially useful, for example, when launching an activity from the
5516 * notification manager.
5517 *
Scott Main7aee61f2011-02-08 11:25:01 -08005518 * <p>See
5519 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5520 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005521 */
5522 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5523 /**
5524 * If set and this intent is being used to launch a new activity from an
5525 * existing one, then the reply target of the existing activity will be
5526 * transfered to the new activity. This way the new activity can call
5527 * {@link android.app.Activity#setResult} and have that result sent back to
5528 * the reply target of the original activity.
5529 */
5530 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5531 /**
5532 * If set and this intent is being used to launch a new activity from an
5533 * existing one, the current activity will not be counted as the top
5534 * activity for deciding whether the new intent should be delivered to
5535 * the top instead of starting a new one. The previous activity will
5536 * be used as the top, with the assumption being that the current activity
5537 * will finish itself immediately.
5538 */
5539 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5540 /**
5541 * If set, the new activity is not kept in the list of recently launched
5542 * activities.
5543 */
5544 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5545 /**
5546 * This flag is not normally set by application code, but set for you by
5547 * the system as described in the
5548 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5549 * launchMode} documentation for the singleTask mode.
5550 */
5551 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5552 /**
5553 * If set, and this activity is either being started in a new task or
5554 * bringing to the top an existing task, then it will be launched as
5555 * the front door of the task. This will result in the application of
5556 * any affinities needed to have that task in the proper state (either
5557 * moving activities to or from it), or simply resetting that task to
5558 * its initial state if needed.
5559 */
5560 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5561 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005562 * This flag is not normally set by application code, but set for you by
5563 * the system if this activity is being launched from history
5564 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005565 */
5566 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005567 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005568 * @deprecated As of API 21 this performs identically to
5569 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005570 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005571 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005572 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005573 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005574 * This flag is used to open a document into a new task rooted at the activity launched
5575 * by this Intent. Through the use of this flag, or its equivalent attribute,
5576 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005577 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005578 *
Craig Mautner026596b2014-05-21 15:35:44 -07005579 * <p>The use of the activity attribute form of this,
5580 * {@link android.R.attr#documentLaunchMode}, is
5581 * preferred over the Intent flag described here. The attribute form allows the
5582 * Activity to specify multiple document behavior for all launchers of the Activity
5583 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005584 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005585 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5586 * it is kept after the activity is finished is different than the use of
5587 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5588 * this flag is being used to create a new recents entry, then by default that entry
5589 * will be removed once the activity is finished. You can modify this behavior with
5590 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5591 *
Craig Mautner026596b2014-05-21 15:35:44 -07005592 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5593 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5594 * equivalent of the Activity manifest specifying {@link
5595 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5596 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5597 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005598 *
Craig Mautner026596b2014-05-21 15:35:44 -07005599 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005600 *
Craig Mautner026596b2014-05-21 15:35:44 -07005601 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005602 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5603 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005604 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005605 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005606 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005607 * callback from occurring on the current frontmost activity before it is
5608 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005609 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005610 * <p>Typically, an activity can rely on that callback to indicate that an
5611 * explicit user action has caused their activity to be moved out of the
5612 * foreground. The callback marks an appropriate point in the activity's
5613 * lifecycle for it to dismiss any notifications that it intends to display
5614 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005615 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005616 * <p>If an activity is ever started via any non-user-driven events such as
5617 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5618 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005619 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005620 */
5621 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005622 /**
5623 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5624 * this flag will cause the launched activity to be brought to the front of its
5625 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005626 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005627 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5628 * If D calls startActivity() with an Intent that resolves to the component
5629 * of activity B, then B will be brought to the front of the history stack,
5630 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005631 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005632 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005633 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005634 */
5635 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005636 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005637 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5638 * this flag will prevent the system from applying an activity transition
5639 * animation to go to the next activity state. This doesn't mean an
5640 * animation will never run -- if another activity change happens that doesn't
5641 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005642 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005643 * when you are going to do a series of activity operations but the
5644 * animation seen by the user shouldn't be driven by the first activity
5645 * change but rather a later one.
5646 */
5647 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5648 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005649 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5650 * this flag will cause any existing task that would be associated with the
5651 * activity to be cleared before the activity is started. That is, the activity
5652 * becomes the new root of an otherwise empty task, and any old activities
5653 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5654 */
5655 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5656 /**
5657 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5658 * this flag will cause a newly launching task to be placed on top of the current
5659 * home activity task (if there is one). That is, pressing back from the task
5660 * will always return the user to home even if that was not the last activity they
5661 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5662 */
5663 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5664 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005665 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5666 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005667 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005668 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005669 * this flag. When set and the task's activity is finished, the recents
5670 * entry will remain in the interface for the user to re-launch it, like a
5671 * recents entry for a top-level application.
5672 * <p>
5673 * The receiving activity can override this request with
5674 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5675 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005676 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005677 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005678 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005679
5680 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005681 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5682 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005683 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5684 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005685 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005686 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005687
Patrick Baumann577d4022018-01-31 16:55:10 +00005688
5689 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005690 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5691 * this flag will attempt to launch an instant app if no full app on the device can already
5692 * handle the intent.
5693 * <p>
5694 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5695 * are supported:
5696 * <ul>
5697 * <li>{@link Intent#setAction(String)}</li>
5698 * <li>{@link Intent#addCategory(String)}</li>
5699 * <li>{@link Intent#setData(Uri)}</li>
5700 * <li>{@link Intent#setType(String)}</li>
5701 * <li>{@link Intent#setPackage(String)}</li>
5702 * <li>{@link Intent#addFlags(int)}</li>
5703 * </ul>
5704 * <p>
5705 * In the case that no instant app can be found, the installer will be launched to notify the
5706 * user that the intent could not be resolved. On devices that do not support instant apps,
5707 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005708 */
5709 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5710
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005711 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005712 * If set, when sending a broadcast only registered receivers will be
5713 * called -- no BroadcastReceiver components will be launched.
5714 */
5715 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005716 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005717 * If set, when sending a broadcast the new broadcast will replace
5718 * any existing pending broadcast that matches it. Matching is defined
5719 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5720 * true for the intents of the two broadcasts. When a match is found,
5721 * the new broadcast (and receivers associated with it) will replace the
5722 * existing one in the pending broadcast list, remaining at the same
5723 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005724 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005725 * <p>This flag is most typically used with sticky broadcasts, which
5726 * only care about delivering the most recent values of the broadcast
5727 * to their receivers.
5728 */
5729 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5730 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005731 * If set, when sending a broadcast the recipient is allowed to run at
5732 * foreground priority, with a shorter timeout interval. During normal
5733 * broadcasts the receivers are not automatically hoisted out of the
5734 * background priority class.
5735 */
5736 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5737 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005738 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5739 * They can still propagate results through to later receivers, but they can not prevent
5740 * later receivers from seeing the broadcast.
5741 */
5742 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5743 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005744 * If set, when sending a broadcast <i>before boot has completed</i> only
5745 * registered receivers will be called -- no BroadcastReceiver components
5746 * will be launched. Sticky intent state will be recorded properly even
5747 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5748 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005749 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005750 * <p>This flag is only for use by system sevices as a convenience to
5751 * avoid having to implement a more complex mechanism around detection
5752 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005753 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005754 * @hide
5755 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005756 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005757 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005758 /**
5759 * Set when this broadcast is for a boot upgrade, a special mode that
5760 * allows the broadcast to be sent before the system is ready and launches
5761 * the app process with no providers running in it.
5762 * @hide
5763 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005764 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005765 /**
5766 * If set, the broadcast will always go to manifest receivers in background (cached
5767 * or not running) apps, regardless of whether that would be done by default. By
5768 * default they will only receive broadcasts if the broadcast has specified an
5769 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005770 *
5771 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5772 * the broadcast code there must also be changed to match.
5773 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005774 * @hide
5775 */
5776 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5777 /**
5778 * If set, the broadcast will never go to manifest receivers in background (cached
5779 * or not running) apps, regardless of whether that would be done by default. By
5780 * default they will receive broadcasts if the broadcast has specified an
5781 * explicit component or package name.
5782 * @hide
5783 */
5784 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005785 /**
5786 * If set, this broadcast is being sent from the shell.
5787 * @hide
5788 */
5789 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005791 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005792 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5793 * will not receive broadcasts.
5794 *
5795 * <em>This flag has no effect when used by an Instant App.</em>
5796 */
5797 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5798
5799 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005800 * @hide Flags that can't be changed with PendingIntent.
5801 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005802 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5803 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5804 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005805
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005806 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005807 // ---------------------------------------------------------------------
5808 // toUri() and parseUri() options.
5809
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005810 /** @hide */
5811 @IntDef(flag = true, prefix = { "URI_" }, value = {
5812 URI_ALLOW_UNSAFE,
5813 URI_ANDROID_APP_SCHEME,
5814 URI_INTENT_SCHEME,
5815 })
5816 @Retention(RetentionPolicy.SOURCE)
5817 public @interface UriFlags {}
5818
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005819 /**
5820 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5821 * always has the "intent:" scheme. This syntax can be used when you want
5822 * to later disambiguate between URIs that are intended to describe an
5823 * Intent vs. all others that should be treated as raw URIs. When used
5824 * with {@link #parseUri}, any other scheme will result in a generic
5825 * VIEW action for that raw URI.
5826 */
5827 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005828
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005829 /**
5830 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5831 * always has the "android-app:" scheme. This is a variation of
5832 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5833 * http/https URI being delivered to a specific package name. The format
5834 * is:
5835 *
5836 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005837 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005838 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005839 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5840 * you must also include a scheme; including a path also requires both a host and a scheme.
5841 * The final #Intent; fragment can be used without a scheme, host, or path.
5842 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005843 * used with intents that have a {@link #setSelector}, since the base intent
5844 * will always have an explicit package name.</p>
5845 *
5846 * <p>Some examples of how this scheme maps to Intent objects:</p>
5847 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5848 * <colgroup align="left" />
5849 * <colgroup align="left" />
5850 * <thead>
5851 * <tr><th>URI</th> <th>Intent</th></tr>
5852 * </thead>
5853 *
5854 * <tbody>
5855 * <tr><td><code>android-app://com.example.app</code></td>
5856 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5857 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5858 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5859 * </table></td>
5860 * </tr>
5861 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5862 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5863 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5864 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5865 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5866 * </table></td>
5867 * </tr>
5868 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5869 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5870 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5871 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5872 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5873 * </table></td>
5874 * </tr>
5875 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5876 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5877 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5878 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5879 * </table></td>
5880 * </tr>
5881 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5882 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5883 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5884 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5885 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5886 * </table></td>
5887 * </tr>
5888 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
5889 * <td><table border="" style="margin:0" >
5890 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5891 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5892 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5893 * </table></td>
5894 * </tr>
5895 * </tbody>
5896 * </table>
5897 */
5898 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5899
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005900 /**
5901 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5902 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5903 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5904 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5905 * generated Intent can not cause unexpected data access to happen.
5906 *
5907 * <p>If you do not trust the source of the URI being parsed, you should still do further
5908 * processing to protect yourself from it. In particular, when using it to start an
5909 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5910 * that can handle it.</p>
5911 */
5912 public static final int URI_ALLOW_UNSAFE = 1<<2;
5913
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005914 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005915
5916 private String mAction;
5917 private Uri mData;
5918 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005919 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005920 private ComponentName mComponent;
5921 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005922 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005923 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005924 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005925 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005926 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005927 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005928 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005929 /** Token to track instant app launches. Local only; do not copy cross-process. */
5930 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005931
5932 // ---------------------------------------------------------------------
5933
Makoto Onuki97f82f22017-05-31 16:20:21 -07005934 private static final int COPY_MODE_ALL = 0;
5935 private static final int COPY_MODE_FILTER = 1;
5936 private static final int COPY_MODE_HISTORY = 2;
5937
5938 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005939 @IntDef(prefix = { "COPY_MODE_" }, value = {
5940 COPY_MODE_ALL,
5941 COPY_MODE_FILTER,
5942 COPY_MODE_HISTORY
5943 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005944 @Retention(RetentionPolicy.SOURCE)
5945 public @interface CopyMode {}
5946
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005947 /**
5948 * Create an empty intent.
5949 */
5950 public Intent() {
5951 }
5952
5953 /**
5954 * Copy constructor.
5955 */
5956 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005957 this(o, COPY_MODE_ALL);
5958 }
5959
5960 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005961 this.mAction = o.mAction;
5962 this.mData = o.mData;
5963 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005964 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005965 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005966
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005967 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005968 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005969 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005970
5971 if (copyMode != COPY_MODE_FILTER) {
5972 this.mFlags = o.mFlags;
5973 this.mContentUserHint = o.mContentUserHint;
5974 this.mLaunchToken = o.mLaunchToken;
5975 if (o.mSourceBounds != null) {
5976 this.mSourceBounds = new Rect(o.mSourceBounds);
5977 }
5978 if (o.mSelector != null) {
5979 this.mSelector = new Intent(o.mSelector);
5980 }
5981
5982 if (copyMode != COPY_MODE_HISTORY) {
5983 if (o.mExtras != null) {
5984 this.mExtras = new Bundle(o.mExtras);
5985 }
5986 if (o.mClipData != null) {
5987 this.mClipData = new ClipData(o.mClipData);
5988 }
5989 } else {
5990 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5991 this.mExtras = Bundle.STRIPPED;
5992 }
5993
5994 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5995 // history.
5996 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005997 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005998 }
5999
6000 @Override
6001 public Object clone() {
6002 return new Intent(this);
6003 }
6004
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 /**
6006 * Make a clone of only the parts of the Intent that are relevant for
6007 * filter matching: the action, data, type, component, and categories.
6008 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006009 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006010 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006011 }
6012
6013 /**
6014 * Create an intent with a given action. All other fields (data, type,
6015 * class) are null. Note that the action <em>must</em> be in a
6016 * namespace because Intents are used globally in the system -- for
6017 * example the system VIEW action is android.intent.action.VIEW; an
6018 * application's custom action would be something like
6019 * com.google.app.myapp.CUSTOM_ACTION.
6020 *
6021 * @param action The Intent action, such as ACTION_VIEW.
6022 */
6023 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006024 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006025 }
6026
6027 /**
6028 * Create an intent with a given action and for a given data url. Note
6029 * that the action <em>must</em> be in a namespace because Intents are
6030 * used globally in the system -- for example the system VIEW action is
6031 * android.intent.action.VIEW; an application's custom action would be
6032 * something like com.google.app.myapp.CUSTOM_ACTION.
6033 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006034 * <p><em>Note: scheme and host name matching in the Android framework is
6035 * case-sensitive, unlike the formal RFC. As a result,
6036 * you should always ensure that you write your Uri with these elements
6037 * using lower case letters, and normalize any Uris you receive from
6038 * outside of Android to ensure the scheme and host is lower case.</em></p>
6039 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006040 * @param action The Intent action, such as ACTION_VIEW.
6041 * @param uri The Intent data URI.
6042 */
6043 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006044 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006045 mData = uri;
6046 }
6047
6048 /**
6049 * Create an intent for a specific component. All other fields (action, data,
6050 * type, class) are null, though they can be modified later with explicit
6051 * calls. This provides a convenient way to create an intent that is
6052 * intended to execute a hard-coded class name, rather than relying on the
6053 * system to find an appropriate class for you; see {@link #setComponent}
6054 * for more information on the repercussions of this.
6055 *
6056 * @param packageContext A Context of the application package implementing
6057 * this class.
6058 * @param cls The component class that is to be used for the intent.
6059 *
6060 * @see #setClass
6061 * @see #setComponent
6062 * @see #Intent(String, android.net.Uri , Context, Class)
6063 */
6064 public Intent(Context packageContext, Class<?> cls) {
6065 mComponent = new ComponentName(packageContext, cls);
6066 }
6067
6068 /**
6069 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006070 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006071 * construct the Intent and then calling {@link #setClass} to set its
6072 * class.
6073 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006074 * <p><em>Note: scheme and host name matching in the Android framework is
6075 * case-sensitive, unlike the formal RFC. As a result,
6076 * you should always ensure that you write your Uri with these elements
6077 * using lower case letters, and normalize any Uris you receive from
6078 * outside of Android to ensure the scheme and host is lower case.</em></p>
6079 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006080 * @param action The Intent action, such as ACTION_VIEW.
6081 * @param uri The Intent data URI.
6082 * @param packageContext A Context of the application package implementing
6083 * this class.
6084 * @param cls The component class that is to be used for the intent.
6085 *
6086 * @see #Intent(String, android.net.Uri)
6087 * @see #Intent(Context, Class)
6088 * @see #setClass
6089 * @see #setComponent
6090 */
6091 public Intent(String action, Uri uri,
6092 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006093 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006094 mData = uri;
6095 mComponent = new ComponentName(packageContext, cls);
6096 }
6097
6098 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006099 * Create an intent to launch the main (root) activity of a task. This
6100 * is the Intent that is started when the application's is launched from
6101 * Home. For anything else that wants to launch an application in the
6102 * same way, it is important that they use an Intent structured the same
6103 * way, and can use this function to ensure this is the case.
6104 *
6105 * <p>The returned Intent has the given Activity component as its explicit
6106 * component, {@link #ACTION_MAIN} as its action, and includes the
6107 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6108 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6109 * to do that through {@link #addFlags(int)} on the returned Intent.
6110 *
6111 * @param mainActivity The main activity component that this Intent will
6112 * launch.
6113 * @return Returns a newly created Intent that can be used to launch the
6114 * activity as a main application entry.
6115 *
6116 * @see #setClass
6117 * @see #setComponent
6118 */
6119 public static Intent makeMainActivity(ComponentName mainActivity) {
6120 Intent intent = new Intent(ACTION_MAIN);
6121 intent.setComponent(mainActivity);
6122 intent.addCategory(CATEGORY_LAUNCHER);
6123 return intent;
6124 }
6125
6126 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006127 * Make an Intent for the main activity of an application, without
6128 * specifying a specific activity to run but giving a selector to find
6129 * the activity. This results in a final Intent that is structured
6130 * the same as when the application is launched from
6131 * Home. For anything else that wants to launch an application in the
6132 * same way, it is important that they use an Intent structured the same
6133 * way, and can use this function to ensure this is the case.
6134 *
6135 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6136 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6137 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6138 * to do that through {@link #addFlags(int)} on the returned Intent.
6139 *
6140 * @param selectorAction The action name of the Intent's selector.
6141 * @param selectorCategory The name of a category to add to the Intent's
6142 * selector.
6143 * @return Returns a newly created Intent that can be used to launch the
6144 * activity as a main application entry.
6145 *
6146 * @see #setSelector(Intent)
6147 */
6148 public static Intent makeMainSelectorActivity(String selectorAction,
6149 String selectorCategory) {
6150 Intent intent = new Intent(ACTION_MAIN);
6151 intent.addCategory(CATEGORY_LAUNCHER);
6152 Intent selector = new Intent();
6153 selector.setAction(selectorAction);
6154 selector.addCategory(selectorCategory);
6155 intent.setSelector(selector);
6156 return intent;
6157 }
6158
6159 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006160 * Make an Intent that can be used to re-launch an application's task
6161 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6162 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6163 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6164 *
6165 * @param mainActivity The activity component that is the root of the
6166 * task; this is the activity that has been published in the application's
6167 * manifest as the main launcher icon.
6168 *
6169 * @return Returns a newly created Intent that can be used to relaunch the
6170 * activity's task in its root state.
6171 */
6172 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6173 Intent intent = makeMainActivity(mainActivity);
6174 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6175 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6176 return intent;
6177 }
6178
6179 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006180 * Call {@link #parseUri} with 0 flags.
6181 * @deprecated Use {@link #parseUri} instead.
6182 */
6183 @Deprecated
6184 public static Intent getIntent(String uri) throws URISyntaxException {
6185 return parseUri(uri, 0);
6186 }
Tom Taylord4a47292009-12-21 13:59:18 -08006187
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006188 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006189 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006190 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006191 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006192 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006193 *
6194 * <p>The URI given here must not be relative -- that is, it must include
6195 * the scheme and full path.
6196 *
6197 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006198 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006199 *
6200 * @return Intent The newly created Intent object.
6201 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006202 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6203 * it bad (as parsed by the Uri class) or the Intent data within the
6204 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006205 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006206 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006207 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006208 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006209 int i = 0;
6210 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006211 final boolean androidApp = uri.startsWith("android-app:");
6212
6213 // Validate intent scheme if requested.
6214 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6215 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006216 Intent intent = new Intent(ACTION_VIEW);
6217 try {
6218 intent.setData(Uri.parse(uri));
6219 } catch (IllegalArgumentException e) {
6220 throw new URISyntaxException(uri, e.getMessage());
6221 }
6222 return intent;
6223 }
6224 }
Tom Taylord4a47292009-12-21 13:59:18 -08006225
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006226 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006227 // simple case
6228 if (i == -1) {
6229 if (!androidApp) {
6230 return new Intent(ACTION_VIEW, Uri.parse(uri));
6231 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006232
6233 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006234 } else if (!uri.startsWith("#Intent;", i)) {
6235 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006236 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006237 } else {
6238 i = -1;
6239 }
6240 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006241
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006242 // new format
6243 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006244 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006245 boolean explicitAction = false;
6246 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006247
6248 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006249 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006250 String data;
6251 if (i >= 0) {
6252 data = uri.substring(0, i);
6253 i += 8; // length of "#Intent;"
6254 } else {
6255 data = uri;
6256 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006257
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006258 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006259 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006260 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006261 if (eq < 0) eq = i-1;
6262 int semi = uri.indexOf(';', i);
6263 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006264
6265 // action
6266 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006267 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006268 if (!inSelector) {
6269 explicitAction = true;
6270 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006271 }
6272
6273 // categories
6274 else if (uri.startsWith("category=", i)) {
6275 intent.addCategory(value);
6276 }
6277
6278 // type
6279 else if (uri.startsWith("type=", i)) {
6280 intent.mType = value;
6281 }
6282
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006283 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006284 else if (uri.startsWith("launchFlags=", i)) {
6285 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006286 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6287 intent.mFlags &= ~IMMUTABLE_FLAGS;
6288 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006289 }
6290
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006291 // package
6292 else if (uri.startsWith("package=", i)) {
6293 intent.mPackage = value;
6294 }
6295
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006296 // component
6297 else if (uri.startsWith("component=", i)) {
6298 intent.mComponent = ComponentName.unflattenFromString(value);
6299 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006300
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006301 // scheme
6302 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006303 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006304 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006305 } else {
6306 scheme = value;
6307 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006308 }
6309
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006310 // source bounds
6311 else if (uri.startsWith("sourceBounds=", i)) {
6312 intent.mSourceBounds = Rect.unflattenFromString(value);
6313 }
6314
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006315 // selector
6316 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6317 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006318 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006319 }
6320
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006321 // extra
6322 else {
6323 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006324 // create Bundle if it doesn't already exist
6325 if (intent.mExtras == null) intent.mExtras = new Bundle();
6326 Bundle b = intent.mExtras;
6327 // add EXTRA
6328 if (uri.startsWith("S.", i)) b.putString(key, value);
6329 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6330 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6331 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6332 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6333 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6334 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6335 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6336 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6337 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6338 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006339
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006340 // move to the next item
6341 i = semi + 1;
6342 }
6343
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006344 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006345 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006346 if (baseIntent.mPackage == null) {
6347 baseIntent.setSelector(intent);
6348 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006349 intent = baseIntent;
6350 }
6351
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006352 if (data != null) {
6353 if (data.startsWith("intent:")) {
6354 data = data.substring(7);
6355 if (scheme != null) {
6356 data = scheme + ':' + data;
6357 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006358 } else if (data.startsWith("android-app:")) {
6359 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6360 // Correctly formed android-app, first part is package name.
6361 int end = data.indexOf('/', 14);
6362 if (end < 0) {
6363 // All we have is a package name.
6364 intent.mPackage = data.substring(14);
6365 if (!explicitAction) {
6366 intent.setAction(ACTION_MAIN);
6367 }
6368 data = "";
6369 } else {
6370 // Target the Intent at the given package name always.
6371 String authority = null;
6372 intent.mPackage = data.substring(14, end);
6373 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006374 if ((end+1) < data.length()) {
6375 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6376 // Found a scheme, remember it.
6377 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006378 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006379 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6380 // Found a authority, remember it.
6381 authority = data.substring(end+1, newEnd);
6382 end = newEnd;
6383 }
6384 } else {
6385 // All we have is a scheme.
6386 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006387 }
6388 }
6389 if (scheme == null) {
6390 // If there was no scheme, then this just targets the package.
6391 if (!explicitAction) {
6392 intent.setAction(ACTION_MAIN);
6393 }
6394 data = "";
6395 } else if (authority == null) {
6396 data = scheme + ":";
6397 } else {
6398 data = scheme + "://" + authority + data.substring(end);
6399 }
6400 }
6401 } else {
6402 data = "";
6403 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006404 }
Tom Taylord4a47292009-12-21 13:59:18 -08006405
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006406 if (data.length() > 0) {
6407 try {
6408 intent.mData = Uri.parse(data);
6409 } catch (IllegalArgumentException e) {
6410 throw new URISyntaxException(uri, e.getMessage());
6411 }
6412 }
6413 }
Tom Taylord4a47292009-12-21 13:59:18 -08006414
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006415 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006416
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006417 } catch (IndexOutOfBoundsException e) {
6418 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6419 }
6420 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006421
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006422 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006423 return getIntentOld(uri, 0);
6424 }
6425
6426 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006427 Intent intent;
6428
6429 int i = uri.lastIndexOf('#');
6430 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006431 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006432 final int intentFragmentStart = i;
6433 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006434
6435 i++;
6436
6437 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006438 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006439 i += 7;
6440 int j = uri.indexOf(')', i);
6441 action = uri.substring(i, j);
6442 i = j + 1;
6443 }
6444
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006445 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006446
6447 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006448 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006449 i += 11;
6450 int j = uri.indexOf(')', i);
6451 while (i < j) {
6452 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006453 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006454 if (i < sep) {
6455 intent.addCategory(uri.substring(i, sep));
6456 }
6457 i = sep + 1;
6458 }
6459 i = j + 1;
6460 }
6461
6462 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006463 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006464 i += 5;
6465 int j = uri.indexOf(')', i);
6466 intent.mType = uri.substring(i, j);
6467 i = j + 1;
6468 }
6469
6470 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006471 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006472 i += 12;
6473 int j = uri.indexOf(')', i);
6474 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006475 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6476 intent.mFlags &= ~IMMUTABLE_FLAGS;
6477 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006478 i = j + 1;
6479 }
6480
6481 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006482 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006483 i += 10;
6484 int j = uri.indexOf(')', i);
6485 int sep = uri.indexOf('!', i);
6486 if (sep >= 0 && sep < j) {
6487 String pkg = uri.substring(i, sep);
6488 String cls = uri.substring(sep + 1, j);
6489 intent.mComponent = new ComponentName(pkg, cls);
6490 }
6491 i = j + 1;
6492 }
6493
6494 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006495 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006496 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006497
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006498 final int closeParen = uri.indexOf(')', i);
6499 if (closeParen == -1) throw new URISyntaxException(uri,
6500 "EXTRA missing trailing ')'", i);
6501
6502 while (i < closeParen) {
6503 // fetch the key value
6504 int j = uri.indexOf('=', i);
6505 if (j <= i + 1 || i >= closeParen) {
6506 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6507 }
6508 char type = uri.charAt(i);
6509 i++;
6510 String key = uri.substring(i, j);
6511 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006512
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006513 // get type-value
6514 j = uri.indexOf('!', i);
6515 if (j == -1 || j >= closeParen) j = closeParen;
6516 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6517 String value = uri.substring(i, j);
6518 i = j;
6519
6520 // create Bundle if it doesn't already exist
6521 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006522
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006523 // add item to bundle
6524 try {
6525 switch (type) {
6526 case 'S':
6527 intent.mExtras.putString(key, Uri.decode(value));
6528 break;
6529 case 'B':
6530 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6531 break;
6532 case 'b':
6533 intent.mExtras.putByte(key, Byte.parseByte(value));
6534 break;
6535 case 'c':
6536 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6537 break;
6538 case 'd':
6539 intent.mExtras.putDouble(key, Double.parseDouble(value));
6540 break;
6541 case 'f':
6542 intent.mExtras.putFloat(key, Float.parseFloat(value));
6543 break;
6544 case 'i':
6545 intent.mExtras.putInt(key, Integer.parseInt(value));
6546 break;
6547 case 'l':
6548 intent.mExtras.putLong(key, Long.parseLong(value));
6549 break;
6550 case 's':
6551 intent.mExtras.putShort(key, Short.parseShort(value));
6552 break;
6553 default:
6554 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6555 }
6556 } catch (NumberFormatException e) {
6557 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6558 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006559
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006560 char ch = uri.charAt(i);
6561 if (ch == ')') break;
6562 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6563 i++;
6564 }
6565 }
6566
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006567 if (isIntentFragment) {
6568 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6569 } else {
6570 intent.mData = Uri.parse(uri);
6571 }
Tom Taylord4a47292009-12-21 13:59:18 -08006572
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006573 if (intent.mAction == null) {
6574 // By default, if no action is specified, then use VIEW.
6575 intent.mAction = ACTION_VIEW;
6576 }
6577
6578 } else {
6579 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6580 }
6581
6582 return intent;
6583 }
6584
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006585 /** @hide */
6586 public interface CommandOptionHandler {
6587 boolean handleOption(String opt, ShellCommand cmd);
6588 }
6589
6590 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006591 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006592 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6593 throws URISyntaxException {
6594 Intent intent = new Intent();
6595 Intent baseIntent = intent;
6596 boolean hasIntentInfo = false;
6597
6598 Uri data = null;
6599 String type = null;
6600
6601 String opt;
6602 while ((opt=cmd.getNextOption()) != null) {
6603 switch (opt) {
6604 case "-a":
6605 intent.setAction(cmd.getNextArgRequired());
6606 if (intent == baseIntent) {
6607 hasIntentInfo = true;
6608 }
6609 break;
6610 case "-d":
6611 data = Uri.parse(cmd.getNextArgRequired());
6612 if (intent == baseIntent) {
6613 hasIntentInfo = true;
6614 }
6615 break;
6616 case "-t":
6617 type = cmd.getNextArgRequired();
6618 if (intent == baseIntent) {
6619 hasIntentInfo = true;
6620 }
6621 break;
6622 case "-c":
6623 intent.addCategory(cmd.getNextArgRequired());
6624 if (intent == baseIntent) {
6625 hasIntentInfo = true;
6626 }
6627 break;
6628 case "-e":
6629 case "--es": {
6630 String key = cmd.getNextArgRequired();
6631 String value = cmd.getNextArgRequired();
6632 intent.putExtra(key, value);
6633 }
6634 break;
6635 case "--esn": {
6636 String key = cmd.getNextArgRequired();
6637 intent.putExtra(key, (String) null);
6638 }
6639 break;
6640 case "--ei": {
6641 String key = cmd.getNextArgRequired();
6642 String value = cmd.getNextArgRequired();
6643 intent.putExtra(key, Integer.decode(value));
6644 }
6645 break;
6646 case "--eu": {
6647 String key = cmd.getNextArgRequired();
6648 String value = cmd.getNextArgRequired();
6649 intent.putExtra(key, Uri.parse(value));
6650 }
6651 break;
6652 case "--ecn": {
6653 String key = cmd.getNextArgRequired();
6654 String value = cmd.getNextArgRequired();
6655 ComponentName cn = ComponentName.unflattenFromString(value);
6656 if (cn == null)
6657 throw new IllegalArgumentException("Bad component name: " + value);
6658 intent.putExtra(key, cn);
6659 }
6660 break;
6661 case "--eia": {
6662 String key = cmd.getNextArgRequired();
6663 String value = cmd.getNextArgRequired();
6664 String[] strings = value.split(",");
6665 int[] list = new int[strings.length];
6666 for (int i = 0; i < strings.length; i++) {
6667 list[i] = Integer.decode(strings[i]);
6668 }
6669 intent.putExtra(key, list);
6670 }
6671 break;
6672 case "--eial": {
6673 String key = cmd.getNextArgRequired();
6674 String value = cmd.getNextArgRequired();
6675 String[] strings = value.split(",");
6676 ArrayList<Integer> list = new ArrayList<>(strings.length);
6677 for (int i = 0; i < strings.length; i++) {
6678 list.add(Integer.decode(strings[i]));
6679 }
6680 intent.putExtra(key, list);
6681 }
6682 break;
6683 case "--el": {
6684 String key = cmd.getNextArgRequired();
6685 String value = cmd.getNextArgRequired();
6686 intent.putExtra(key, Long.valueOf(value));
6687 }
6688 break;
6689 case "--ela": {
6690 String key = cmd.getNextArgRequired();
6691 String value = cmd.getNextArgRequired();
6692 String[] strings = value.split(",");
6693 long[] list = new long[strings.length];
6694 for (int i = 0; i < strings.length; i++) {
6695 list[i] = Long.valueOf(strings[i]);
6696 }
6697 intent.putExtra(key, list);
6698 hasIntentInfo = true;
6699 }
6700 break;
6701 case "--elal": {
6702 String key = cmd.getNextArgRequired();
6703 String value = cmd.getNextArgRequired();
6704 String[] strings = value.split(",");
6705 ArrayList<Long> list = new ArrayList<>(strings.length);
6706 for (int i = 0; i < strings.length; i++) {
6707 list.add(Long.valueOf(strings[i]));
6708 }
6709 intent.putExtra(key, list);
6710 hasIntentInfo = true;
6711 }
6712 break;
6713 case "--ef": {
6714 String key = cmd.getNextArgRequired();
6715 String value = cmd.getNextArgRequired();
6716 intent.putExtra(key, Float.valueOf(value));
6717 hasIntentInfo = true;
6718 }
6719 break;
6720 case "--efa": {
6721 String key = cmd.getNextArgRequired();
6722 String value = cmd.getNextArgRequired();
6723 String[] strings = value.split(",");
6724 float[] list = new float[strings.length];
6725 for (int i = 0; i < strings.length; i++) {
6726 list[i] = Float.valueOf(strings[i]);
6727 }
6728 intent.putExtra(key, list);
6729 hasIntentInfo = true;
6730 }
6731 break;
6732 case "--efal": {
6733 String key = cmd.getNextArgRequired();
6734 String value = cmd.getNextArgRequired();
6735 String[] strings = value.split(",");
6736 ArrayList<Float> list = new ArrayList<>(strings.length);
6737 for (int i = 0; i < strings.length; i++) {
6738 list.add(Float.valueOf(strings[i]));
6739 }
6740 intent.putExtra(key, list);
6741 hasIntentInfo = true;
6742 }
6743 break;
6744 case "--esa": {
6745 String key = cmd.getNextArgRequired();
6746 String value = cmd.getNextArgRequired();
6747 // Split on commas unless they are preceeded by an escape.
6748 // The escape character must be escaped for the string and
6749 // again for the regex, thus four escape characters become one.
6750 String[] strings = value.split("(?<!\\\\),");
6751 intent.putExtra(key, strings);
6752 hasIntentInfo = true;
6753 }
6754 break;
6755 case "--esal": {
6756 String key = cmd.getNextArgRequired();
6757 String value = cmd.getNextArgRequired();
6758 // Split on commas unless they are preceeded by an escape.
6759 // The escape character must be escaped for the string and
6760 // again for the regex, thus four escape characters become one.
6761 String[] strings = value.split("(?<!\\\\),");
6762 ArrayList<String> list = new ArrayList<>(strings.length);
6763 for (int i = 0; i < strings.length; i++) {
6764 list.add(strings[i]);
6765 }
6766 intent.putExtra(key, list);
6767 hasIntentInfo = true;
6768 }
6769 break;
6770 case "--ez": {
6771 String key = cmd.getNextArgRequired();
6772 String value = cmd.getNextArgRequired().toLowerCase();
6773 // Boolean.valueOf() results in false for anything that is not "true", which is
6774 // error-prone in shell commands
6775 boolean arg;
6776 if ("true".equals(value) || "t".equals(value)) {
6777 arg = true;
6778 } else if ("false".equals(value) || "f".equals(value)) {
6779 arg = false;
6780 } else {
6781 try {
6782 arg = Integer.decode(value) != 0;
6783 } catch (NumberFormatException ex) {
6784 throw new IllegalArgumentException("Invalid boolean value: " + value);
6785 }
6786 }
6787
6788 intent.putExtra(key, arg);
6789 }
6790 break;
6791 case "-n": {
6792 String str = cmd.getNextArgRequired();
6793 ComponentName cn = ComponentName.unflattenFromString(str);
6794 if (cn == null)
6795 throw new IllegalArgumentException("Bad component name: " + str);
6796 intent.setComponent(cn);
6797 if (intent == baseIntent) {
6798 hasIntentInfo = true;
6799 }
6800 }
6801 break;
6802 case "-p": {
6803 String str = cmd.getNextArgRequired();
6804 intent.setPackage(str);
6805 if (intent == baseIntent) {
6806 hasIntentInfo = true;
6807 }
6808 }
6809 break;
6810 case "-f":
6811 String str = cmd.getNextArgRequired();
6812 intent.setFlags(Integer.decode(str).intValue());
6813 break;
6814 case "--grant-read-uri-permission":
6815 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6816 break;
6817 case "--grant-write-uri-permission":
6818 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6819 break;
6820 case "--grant-persistable-uri-permission":
6821 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6822 break;
6823 case "--grant-prefix-uri-permission":
6824 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6825 break;
6826 case "--exclude-stopped-packages":
6827 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6828 break;
6829 case "--include-stopped-packages":
6830 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6831 break;
6832 case "--debug-log-resolution":
6833 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6834 break;
6835 case "--activity-brought-to-front":
6836 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6837 break;
6838 case "--activity-clear-top":
6839 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6840 break;
6841 case "--activity-clear-when-task-reset":
6842 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6843 break;
6844 case "--activity-exclude-from-recents":
6845 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6846 break;
6847 case "--activity-launched-from-history":
6848 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6849 break;
6850 case "--activity-multiple-task":
6851 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6852 break;
6853 case "--activity-no-animation":
6854 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6855 break;
6856 case "--activity-no-history":
6857 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6858 break;
6859 case "--activity-no-user-action":
6860 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6861 break;
6862 case "--activity-previous-is-top":
6863 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6864 break;
6865 case "--activity-reorder-to-front":
6866 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6867 break;
6868 case "--activity-reset-task-if-needed":
6869 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6870 break;
6871 case "--activity-single-top":
6872 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6873 break;
6874 case "--activity-clear-task":
6875 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6876 break;
6877 case "--activity-task-on-home":
6878 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6879 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006880 case "--activity-match-external":
6881 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6882 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006883 case "--receiver-registered-only":
6884 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6885 break;
6886 case "--receiver-replace-pending":
6887 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6888 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006889 case "--receiver-foreground":
6890 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6891 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006892 case "--receiver-no-abort":
6893 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6894 break;
6895 case "--receiver-include-background":
6896 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6897 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006898 case "--selector":
6899 intent.setDataAndType(data, type);
6900 intent = new Intent();
6901 break;
6902 default:
6903 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6904 // Okay, caller handled this option.
6905 } else {
6906 throw new IllegalArgumentException("Unknown option: " + opt);
6907 }
6908 break;
6909 }
6910 }
6911 intent.setDataAndType(data, type);
6912
6913 final boolean hasSelector = intent != baseIntent;
6914 if (hasSelector) {
6915 // A selector was specified; fix up.
6916 baseIntent.setSelector(intent);
6917 intent = baseIntent;
6918 }
6919
6920 String arg = cmd.getNextArg();
6921 baseIntent = null;
6922 if (arg == null) {
6923 if (hasSelector) {
6924 // If a selector has been specified, and no arguments
6925 // have been supplied for the main Intent, then we can
6926 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6927 // need to have a component name specified yet, the
6928 // selector will take care of that.
6929 baseIntent = new Intent(Intent.ACTION_MAIN);
6930 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6931 }
6932 } else if (arg.indexOf(':') >= 0) {
6933 // The argument is a URI. Fully parse it, and use that result
6934 // to fill in any data not specified so far.
6935 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6936 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6937 } else if (arg.indexOf('/') >= 0) {
6938 // The argument is a component name. Build an Intent to launch
6939 // it.
6940 baseIntent = new Intent(Intent.ACTION_MAIN);
6941 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6942 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6943 } else {
6944 // Assume the argument is a package name.
6945 baseIntent = new Intent(Intent.ACTION_MAIN);
6946 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6947 baseIntent.setPackage(arg);
6948 }
6949 if (baseIntent != null) {
6950 Bundle extras = intent.getExtras();
6951 intent.replaceExtras((Bundle)null);
6952 Bundle uriExtras = baseIntent.getExtras();
6953 baseIntent.replaceExtras((Bundle)null);
6954 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6955 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6956 for (String c : cats) {
6957 baseIntent.removeCategory(c);
6958 }
6959 }
6960 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6961 if (extras == null) {
6962 extras = uriExtras;
6963 } else if (uriExtras != null) {
6964 uriExtras.putAll(extras);
6965 extras = uriExtras;
6966 }
6967 intent.replaceExtras(extras);
6968 hasIntentInfo = true;
6969 }
6970
6971 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6972 return intent;
6973 }
6974
6975 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006976 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006977 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6978 final String[] lines = new String[] {
6979 "<INTENT> specifications include these flags and arguments:",
6980 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6981 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07006982 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006983 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6984 " [--esn <EXTRA_KEY> ...]",
6985 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6986 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6987 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6988 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6989 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6990 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6991 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6992 " (mutiple extras passed as Integer[])",
6993 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6994 " (mutiple extras passed as List<Integer>)",
6995 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6996 " (mutiple extras passed as Long[])",
6997 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6998 " (mutiple extras passed as List<Long>)",
6999 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7000 " (mutiple extras passed as Float[])",
7001 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7002 " (mutiple extras passed as List<Float>)",
7003 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7004 " (mutiple extras passed as String[]; to embed a comma into a string,",
7005 " escape it using \"\\,\")",
7006 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7007 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7008 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007009 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007010 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7011 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7012 " [--debug-log-resolution] [--exclude-stopped-packages]",
7013 " [--include-stopped-packages]",
7014 " [--activity-brought-to-front] [--activity-clear-top]",
7015 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7016 " [--activity-launched-from-history] [--activity-multiple-task]",
7017 " [--activity-no-animation] [--activity-no-history]",
7018 " [--activity-no-user-action] [--activity-previous-is-top]",
7019 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7020 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007021 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007022 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007023 " [--receiver-foreground] [--receiver-no-abort]",
7024 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007025 " [--selector]",
7026 " [<URI> | <PACKAGE> | <COMPONENT>]"
7027 };
7028 for (String line : lines) {
7029 pw.print(prefix);
7030 pw.println(line);
7031 }
7032 }
7033
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007034 /**
7035 * Retrieve the general action to be performed, such as
7036 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7037 * the information in the intent should be interpreted -- most importantly,
7038 * what to do with the data returned by {@link #getData}.
7039 *
7040 * @return The action of this intent or null if none is specified.
7041 *
7042 * @see #setAction
7043 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007044 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007045 return mAction;
7046 }
7047
7048 /**
7049 * Retrieve data this intent is operating on. This URI specifies the name
7050 * of the data; often it uses the content: scheme, specifying data in a
7051 * content provider. Other schemes may be handled by specific activities,
7052 * such as http: by the web browser.
7053 *
7054 * @return The URI of the data this intent is targeting or null.
7055 *
7056 * @see #getScheme
7057 * @see #setData
7058 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007059 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007060 return mData;
7061 }
7062
7063 /**
7064 * The same as {@link #getData()}, but returns the URI as an encoded
7065 * String.
7066 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007067 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007068 return mData != null ? mData.toString() : null;
7069 }
7070
7071 /**
7072 * Return the scheme portion of the intent's data. If the data is null or
7073 * does not include a scheme, null is returned. Otherwise, the scheme
7074 * prefix without the final ':' is returned, i.e. "http".
7075 *
7076 * <p>This is the same as calling getData().getScheme() (and checking for
7077 * null data).
7078 *
7079 * @return The scheme of this intent.
7080 *
7081 * @see #getData
7082 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007083 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007084 return mData != null ? mData.getScheme() : null;
7085 }
7086
7087 /**
7088 * Retrieve any explicit MIME type included in the intent. This is usually
7089 * null, as the type is determined by the intent data.
7090 *
7091 * @return If a type was manually set, it is returned; else null is
7092 * returned.
7093 *
7094 * @see #resolveType(ContentResolver)
7095 * @see #setType
7096 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007097 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007098 return mType;
7099 }
7100
7101 /**
7102 * Return the MIME data type of this intent. If the type field is
7103 * explicitly set, that is simply returned. Otherwise, if the data is set,
7104 * the type of that data is returned. If neither fields are set, a null is
7105 * returned.
7106 *
7107 * @return The MIME type of this intent.
7108 *
7109 * @see #getType
7110 * @see #resolveType(ContentResolver)
7111 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007112 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007113 return resolveType(context.getContentResolver());
7114 }
7115
7116 /**
7117 * Return the MIME data type of this intent. If the type field is
7118 * explicitly set, that is simply returned. Otherwise, if the data is set,
7119 * the type of that data is returned. If neither fields are set, a null is
7120 * returned.
7121 *
7122 * @param resolver A ContentResolver that can be used to determine the MIME
7123 * type of the intent's data.
7124 *
7125 * @return The MIME type of this intent.
7126 *
7127 * @see #getType
7128 * @see #resolveType(Context)
7129 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007130 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007131 if (mType != null) {
7132 return mType;
7133 }
7134 if (mData != null) {
7135 if ("content".equals(mData.getScheme())) {
7136 return resolver.getType(mData);
7137 }
7138 }
7139 return null;
7140 }
7141
7142 /**
7143 * Return the MIME data type of this intent, only if it will be needed for
7144 * intent resolution. This is not generally useful for application code;
7145 * it is used by the frameworks for communicating with back-end system
7146 * services.
7147 *
7148 * @param resolver A ContentResolver that can be used to determine the MIME
7149 * type of the intent's data.
7150 *
7151 * @return The MIME type of this intent, or null if it is unknown or not
7152 * needed.
7153 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007154 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007155 if (mComponent != null) {
7156 return mType;
7157 }
7158 return resolveType(resolver);
7159 }
7160
7161 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007162 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007163 *
7164 * @param category The category to check.
7165 *
7166 * @return boolean True if the intent contains the category, else false.
7167 *
7168 * @see #getCategories
7169 * @see #addCategory
7170 */
7171 public boolean hasCategory(String category) {
7172 return mCategories != null && mCategories.contains(category);
7173 }
7174
7175 /**
7176 * Return the set of all categories in the intent. If there are no categories,
7177 * returns NULL.
7178 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007179 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007180 *
7181 * @see #hasCategory
7182 * @see #addCategory
7183 */
7184 public Set<String> getCategories() {
7185 return mCategories;
7186 }
7187
7188 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007189 * Return the specific selector associated with this Intent. If there is
7190 * none, returns null. See {@link #setSelector} for more information.
7191 *
7192 * @see #setSelector
7193 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007194 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007195 return mSelector;
7196 }
7197
7198 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007199 * Return the {@link ClipData} associated with this Intent. If there is
7200 * none, returns null. See {@link #setClipData} for more information.
7201 *
John Spurlock125d1332013-11-25 11:58:37 -05007202 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007203 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007204 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007205 return mClipData;
7206 }
7207
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007208 /** @hide */
7209 public int getContentUserHint() {
7210 return mContentUserHint;
7211 }
7212
Todd Kennedyb3b431302017-03-20 16:05:48 -07007213 /** @hide */
7214 public String getLaunchToken() {
7215 return mLaunchToken;
7216 }
7217
7218 /** @hide */
7219 public void setLaunchToken(String launchToken) {
7220 mLaunchToken = launchToken;
7221 }
7222
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007223 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007224 * Sets the ClassLoader that will be used when unmarshalling
7225 * any Parcelable values from the extras of this Intent.
7226 *
7227 * @param loader a ClassLoader, or null to use the default loader
7228 * at the time of unmarshalling.
7229 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007230 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007231 if (mExtras != null) {
7232 mExtras.setClassLoader(loader);
7233 }
7234 }
7235
7236 /**
7237 * Returns true if an extra value is associated with the given name.
7238 * @param name the extra's name
7239 * @return true if the given extra is present.
7240 */
7241 public boolean hasExtra(String name) {
7242 return mExtras != null && mExtras.containsKey(name);
7243 }
7244
7245 /**
7246 * Returns true if the Intent's extras contain a parcelled file descriptor.
7247 * @return true if the Intent contains a parcelled file descriptor.
7248 */
7249 public boolean hasFileDescriptors() {
7250 return mExtras != null && mExtras.hasFileDescriptors();
7251 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007252
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007253 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007254 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007255 public void setAllowFds(boolean allowFds) {
7256 if (mExtras != null) {
7257 mExtras.setAllowFds(allowFds);
7258 }
7259 }
7260
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007261 /** {@hide} */
7262 public void setDefusable(boolean defusable) {
7263 if (mExtras != null) {
7264 mExtras.setDefusable(defusable);
7265 }
7266 }
7267
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007268 /**
7269 * Retrieve extended data from the intent.
7270 *
7271 * @param name The name of the desired item.
7272 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007273 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007274 * or null if none was found.
7275 *
7276 * @deprecated
7277 * @hide
7278 */
7279 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007280 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007281 public Object getExtra(String name) {
7282 return getExtra(name, null);
7283 }
7284
7285 /**
7286 * Retrieve extended data from the intent.
7287 *
7288 * @param name The name of the desired item.
7289 * @param defaultValue the value to be returned if no value of the desired
7290 * type is stored with the given name.
7291 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007292 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007293 * or the default value if none was found.
7294 *
7295 * @see #putExtra(String, boolean)
7296 */
7297 public boolean getBooleanExtra(String name, boolean defaultValue) {
7298 return mExtras == null ? defaultValue :
7299 mExtras.getBoolean(name, defaultValue);
7300 }
7301
7302 /**
7303 * Retrieve extended data from the intent.
7304 *
7305 * @param name The name of the desired item.
7306 * @param defaultValue the value to be returned if no value of the desired
7307 * type is stored with the given name.
7308 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007309 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007310 * or the default value if none was found.
7311 *
7312 * @see #putExtra(String, byte)
7313 */
7314 public byte getByteExtra(String name, byte defaultValue) {
7315 return mExtras == null ? defaultValue :
7316 mExtras.getByte(name, defaultValue);
7317 }
7318
7319 /**
7320 * Retrieve extended data from the intent.
7321 *
7322 * @param name The name of the desired item.
7323 * @param defaultValue the value to be returned if no value of the desired
7324 * type is stored with the given name.
7325 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007326 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007327 * or the default value if none was found.
7328 *
7329 * @see #putExtra(String, short)
7330 */
7331 public short getShortExtra(String name, short defaultValue) {
7332 return mExtras == null ? defaultValue :
7333 mExtras.getShort(name, defaultValue);
7334 }
7335
7336 /**
7337 * Retrieve extended data from the intent.
7338 *
7339 * @param name The name of the desired item.
7340 * @param defaultValue the value to be returned if no value of the desired
7341 * type is stored with the given name.
7342 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007343 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007344 * or the default value if none was found.
7345 *
7346 * @see #putExtra(String, char)
7347 */
7348 public char getCharExtra(String name, char defaultValue) {
7349 return mExtras == null ? defaultValue :
7350 mExtras.getChar(name, defaultValue);
7351 }
7352
7353 /**
7354 * Retrieve extended data from the intent.
7355 *
7356 * @param name The name of the desired item.
7357 * @param defaultValue the value to be returned if no value of the desired
7358 * type is stored with the given name.
7359 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007360 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007361 * or the default value if none was found.
7362 *
7363 * @see #putExtra(String, int)
7364 */
7365 public int getIntExtra(String name, int defaultValue) {
7366 return mExtras == null ? defaultValue :
7367 mExtras.getInt(name, defaultValue);
7368 }
7369
7370 /**
7371 * Retrieve extended data from the intent.
7372 *
7373 * @param name The name of the desired item.
7374 * @param defaultValue the value to be returned if no value of the desired
7375 * type is stored with the given name.
7376 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007377 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007378 * or the default value if none was found.
7379 *
7380 * @see #putExtra(String, long)
7381 */
7382 public long getLongExtra(String name, long defaultValue) {
7383 return mExtras == null ? defaultValue :
7384 mExtras.getLong(name, defaultValue);
7385 }
7386
7387 /**
7388 * Retrieve extended data from the intent.
7389 *
7390 * @param name The name of the desired item.
7391 * @param defaultValue the value to be returned if no value of the desired
7392 * type is stored with the given name.
7393 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007394 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007395 * or the default value if no such item is present
7396 *
7397 * @see #putExtra(String, float)
7398 */
7399 public float getFloatExtra(String name, float defaultValue) {
7400 return mExtras == null ? defaultValue :
7401 mExtras.getFloat(name, defaultValue);
7402 }
7403
7404 /**
7405 * Retrieve extended data from the intent.
7406 *
7407 * @param name The name of the desired item.
7408 * @param defaultValue the value to be returned if no value of the desired
7409 * type is stored with the given name.
7410 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007411 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007412 * or the default value if none was found.
7413 *
7414 * @see #putExtra(String, double)
7415 */
7416 public double getDoubleExtra(String name, double defaultValue) {
7417 return mExtras == null ? defaultValue :
7418 mExtras.getDouble(name, defaultValue);
7419 }
7420
7421 /**
7422 * Retrieve extended data from the intent.
7423 *
7424 * @param name The name of the desired item.
7425 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007426 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007427 * or null if no String value was found.
7428 *
7429 * @see #putExtra(String, String)
7430 */
7431 public String getStringExtra(String name) {
7432 return mExtras == null ? null : mExtras.getString(name);
7433 }
7434
7435 /**
7436 * Retrieve extended data from the intent.
7437 *
7438 * @param name The name of the desired item.
7439 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007440 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007441 * or null if no CharSequence value was found.
7442 *
7443 * @see #putExtra(String, CharSequence)
7444 */
7445 public CharSequence getCharSequenceExtra(String name) {
7446 return mExtras == null ? null : mExtras.getCharSequence(name);
7447 }
7448
7449 /**
7450 * Retrieve extended data from the intent.
7451 *
7452 * @param name The name of the desired item.
7453 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007454 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007455 * or null if no Parcelable value was found.
7456 *
7457 * @see #putExtra(String, Parcelable)
7458 */
7459 public <T extends Parcelable> T getParcelableExtra(String name) {
7460 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7461 }
7462
7463 /**
7464 * Retrieve extended data from the intent.
7465 *
7466 * @param name The name of the desired item.
7467 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007468 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007469 * or null if no Parcelable[] value was found.
7470 *
7471 * @see #putExtra(String, Parcelable[])
7472 */
7473 public Parcelable[] getParcelableArrayExtra(String name) {
7474 return mExtras == null ? null : mExtras.getParcelableArray(name);
7475 }
7476
7477 /**
7478 * Retrieve extended data from the intent.
7479 *
7480 * @param name The name of the desired item.
7481 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007482 * @return the value of an item previously added with
7483 * putParcelableArrayListExtra(), or null if no
7484 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007485 *
7486 * @see #putParcelableArrayListExtra(String, ArrayList)
7487 */
7488 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7489 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7490 }
7491
7492 /**
7493 * Retrieve extended data from the intent.
7494 *
7495 * @param name The name of the desired item.
7496 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007497 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007498 * or null if no Serializable value was found.
7499 *
7500 * @see #putExtra(String, Serializable)
7501 */
7502 public Serializable getSerializableExtra(String name) {
7503 return mExtras == null ? null : mExtras.getSerializable(name);
7504 }
7505
7506 /**
7507 * Retrieve extended data from the intent.
7508 *
7509 * @param name The name of the desired item.
7510 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007511 * @return the value of an item previously added with
7512 * putIntegerArrayListExtra(), or null if no
7513 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007514 *
7515 * @see #putIntegerArrayListExtra(String, ArrayList)
7516 */
7517 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7518 return mExtras == null ? null : mExtras.getIntegerArrayList(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 * putStringArrayListExtra(), or null if no
7528 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007529 *
7530 * @see #putStringArrayListExtra(String, ArrayList)
7531 */
7532 public ArrayList<String> getStringArrayListExtra(String name) {
7533 return mExtras == null ? null : mExtras.getStringArrayList(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
7542 * putCharSequenceArrayListExtra, or null if no
7543 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007544 *
7545 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7546 */
7547 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7548 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7549 }
7550
7551 /**
7552 * Retrieve extended data from the intent.
7553 *
7554 * @param name The name of the desired item.
7555 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007556 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007557 * or null if no boolean array value was found.
7558 *
7559 * @see #putExtra(String, boolean[])
7560 */
7561 public boolean[] getBooleanArrayExtra(String name) {
7562 return mExtras == null ? null : mExtras.getBooleanArray(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 putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007571 * or null if no byte array value was found.
7572 *
7573 * @see #putExtra(String, byte[])
7574 */
7575 public byte[] getByteArrayExtra(String name) {
7576 return mExtras == null ? null : mExtras.getByteArray(name);
7577 }
7578
7579 /**
7580 * Retrieve extended data from the intent.
7581 *
7582 * @param name The name of the desired item.
7583 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007584 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007585 * or null if no short array value was found.
7586 *
7587 * @see #putExtra(String, short[])
7588 */
7589 public short[] getShortArrayExtra(String name) {
7590 return mExtras == null ? null : mExtras.getShortArray(name);
7591 }
7592
7593 /**
7594 * Retrieve extended data from the intent.
7595 *
7596 * @param name The name of the desired item.
7597 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007598 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007599 * or null if no char array value was found.
7600 *
7601 * @see #putExtra(String, char[])
7602 */
7603 public char[] getCharArrayExtra(String name) {
7604 return mExtras == null ? null : mExtras.getCharArray(name);
7605 }
7606
7607 /**
7608 * Retrieve extended data from the intent.
7609 *
7610 * @param name The name of the desired item.
7611 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007612 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007613 * or null if no int array value was found.
7614 *
7615 * @see #putExtra(String, int[])
7616 */
7617 public int[] getIntArrayExtra(String name) {
7618 return mExtras == null ? null : mExtras.getIntArray(name);
7619 }
7620
7621 /**
7622 * Retrieve extended data from the intent.
7623 *
7624 * @param name The name of the desired item.
7625 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007626 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007627 * or null if no long array value was found.
7628 *
7629 * @see #putExtra(String, long[])
7630 */
7631 public long[] getLongArrayExtra(String name) {
7632 return mExtras == null ? null : mExtras.getLongArray(name);
7633 }
7634
7635 /**
7636 * Retrieve extended data from the intent.
7637 *
7638 * @param name The name of the desired item.
7639 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007640 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007641 * or null if no float array value was found.
7642 *
7643 * @see #putExtra(String, float[])
7644 */
7645 public float[] getFloatArrayExtra(String name) {
7646 return mExtras == null ? null : mExtras.getFloatArray(name);
7647 }
7648
7649 /**
7650 * Retrieve extended data from the intent.
7651 *
7652 * @param name The name of the desired item.
7653 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007654 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007655 * or null if no double array value was found.
7656 *
7657 * @see #putExtra(String, double[])
7658 */
7659 public double[] getDoubleArrayExtra(String name) {
7660 return mExtras == null ? null : mExtras.getDoubleArray(name);
7661 }
7662
7663 /**
7664 * Retrieve extended data from the intent.
7665 *
7666 * @param name The name of the desired item.
7667 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007668 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007669 * or null if no String array value was found.
7670 *
7671 * @see #putExtra(String, String[])
7672 */
7673 public String[] getStringArrayExtra(String name) {
7674 return mExtras == null ? null : mExtras.getStringArray(name);
7675 }
7676
7677 /**
7678 * Retrieve extended data from the intent.
7679 *
7680 * @param name The name of the desired item.
7681 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007682 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007683 * or null if no CharSequence array value was found.
7684 *
7685 * @see #putExtra(String, CharSequence[])
7686 */
7687 public CharSequence[] getCharSequenceArrayExtra(String name) {
7688 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7689 }
7690
7691 /**
7692 * Retrieve extended data from the intent.
7693 *
7694 * @param name The name of the desired item.
7695 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007696 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007697 * or null if no Bundle value was found.
7698 *
7699 * @see #putExtra(String, Bundle)
7700 */
7701 public Bundle getBundleExtra(String name) {
7702 return mExtras == null ? null : mExtras.getBundle(name);
7703 }
7704
7705 /**
7706 * Retrieve extended data from the intent.
7707 *
7708 * @param name The name of the desired item.
7709 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007710 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007711 * or null if no IBinder value was found.
7712 *
7713 * @see #putExtra(String, IBinder)
7714 *
7715 * @deprecated
7716 * @hide
7717 */
7718 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007719 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007720 public IBinder getIBinderExtra(String name) {
7721 return mExtras == null ? null : mExtras.getIBinder(name);
7722 }
7723
7724 /**
7725 * Retrieve extended data from the intent.
7726 *
7727 * @param name The name of the desired item.
7728 * @param defaultValue The default value to return in case no item is
7729 * associated with the key 'name'
7730 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007731 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007732 * or defaultValue if none was found.
7733 *
7734 * @see #putExtra
7735 *
7736 * @deprecated
7737 * @hide
7738 */
7739 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007740 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007741 public Object getExtra(String name, Object defaultValue) {
7742 Object result = defaultValue;
7743 if (mExtras != null) {
7744 Object result2 = mExtras.get(name);
7745 if (result2 != null) {
7746 result = result2;
7747 }
7748 }
7749
7750 return result;
7751 }
7752
7753 /**
7754 * Retrieves a map of extended data from the intent.
7755 *
7756 * @return the map of all extras previously added with putExtra(),
7757 * or null if none have been added.
7758 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007759 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007760 return (mExtras != null)
7761 ? new Bundle(mExtras)
7762 : null;
7763 }
7764
7765 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007766 * Filter extras to only basic types.
7767 * @hide
7768 */
7769 public void removeUnsafeExtras() {
7770 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007771 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007772 }
7773 }
7774
7775 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007776 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7777 * return itself as-is.
7778 * @hide
7779 */
7780 public boolean canStripForHistory() {
7781 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7782 }
7783
7784 /**
7785 * Call it when the system needs to keep an intent for logging purposes to remove fields
7786 * that are not needed for logging.
7787 * @hide
7788 */
7789 public Intent maybeStripForHistory() {
7790 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7791
7792 if (!canStripForHistory()) {
7793 return this;
7794 }
7795 return new Intent(this, COPY_MODE_HISTORY);
7796 }
7797
7798 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007799 * Retrieve any special flags associated with this intent. You will
7800 * normally just set them with {@link #setFlags} and let the system
7801 * take the appropriate action with them.
7802 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007803 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007805 * @see #addFlags
7806 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007807 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007808 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007809 return mFlags;
7810 }
7811
Dianne Hackborne7f97212011-02-24 14:40:20 -08007812 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007813 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007814 public boolean isExcludingStopped() {
7815 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7816 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7817 }
7818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007820 * Retrieve the application package name this Intent is limited to. When
7821 * resolving an Intent, if non-null this limits the resolution to only
7822 * components in the given application package.
7823 *
7824 * @return The name of the application package for the Intent.
7825 *
7826 * @see #resolveActivity
7827 * @see #setPackage
7828 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007829 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007830 return mPackage;
7831 }
7832
7833 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007834 * Retrieve the concrete component associated with the intent. When receiving
7835 * an intent, this is the component that was found to best handle it (that is,
7836 * yourself) and will always be non-null; in all other cases it will be
7837 * null unless explicitly set.
7838 *
7839 * @return The name of the application component to handle the intent.
7840 *
7841 * @see #resolveActivity
7842 * @see #setComponent
7843 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007844 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007845 return mComponent;
7846 }
7847
7848 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007849 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7850 * used as a hint to the receiver for animations and the like. Null means that there
7851 * is no source bounds.
7852 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007853 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007854 return mSourceBounds;
7855 }
7856
7857 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007858 * Return the Activity component that should be used to handle this intent.
7859 * The appropriate component is determined based on the information in the
7860 * intent, evaluated as follows:
7861 *
7862 * <p>If {@link #getComponent} returns an explicit class, that is returned
7863 * without any further consideration.
7864 *
7865 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7866 * category to be considered.
7867 *
7868 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7869 * action.
7870 *
7871 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7872 * this type.
7873 *
7874 * <p>If {@link #addCategory} has added any categories, the activity must
7875 * handle ALL of the categories specified.
7876 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007877 * <p>If {@link #getPackage} is non-NULL, only activity components in
7878 * that application package will be considered.
7879 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007880 * <p>If there are no activities that satisfy all of these conditions, a
7881 * null string is returned.
7882 *
7883 * <p>If multiple activities are found to satisfy the intent, the one with
7884 * the highest priority will be used. If there are multiple activities
7885 * with the same priority, the system will either pick the best activity
7886 * based on user preference, or resolve to a system class that will allow
7887 * the user to pick an activity and forward from there.
7888 *
7889 * <p>This method is implemented simply by calling
7890 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7891 * true.</p>
7892 * <p> This API is called for you as part of starting an activity from an
7893 * intent. You do not normally need to call it yourself.</p>
7894 *
7895 * @param pm The package manager with which to resolve the Intent.
7896 *
7897 * @return Name of the component implementing an activity that can
7898 * display the intent.
7899 *
7900 * @see #setComponent
7901 * @see #getComponent
7902 * @see #resolveActivityInfo
7903 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007904 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007905 if (mComponent != null) {
7906 return mComponent;
7907 }
7908
7909 ResolveInfo info = pm.resolveActivity(
7910 this, PackageManager.MATCH_DEFAULT_ONLY);
7911 if (info != null) {
7912 return new ComponentName(
7913 info.activityInfo.applicationInfo.packageName,
7914 info.activityInfo.name);
7915 }
7916
7917 return null;
7918 }
7919
7920 /**
7921 * Resolve the Intent into an {@link ActivityInfo}
7922 * describing the activity that should execute the intent. Resolution
7923 * follows the same rules as described for {@link #resolveActivity}, but
7924 * you get back the completely information about the resolved activity
7925 * instead of just its class name.
7926 *
7927 * @param pm The package manager with which to resolve the Intent.
7928 * @param flags Addition information to retrieve as per
7929 * {@link PackageManager#getActivityInfo(ComponentName, int)
7930 * PackageManager.getActivityInfo()}.
7931 *
7932 * @return PackageManager.ActivityInfo
7933 *
7934 * @see #resolveActivity
7935 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007936 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7937 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007938 ActivityInfo ai = null;
7939 if (mComponent != null) {
7940 try {
7941 ai = pm.getActivityInfo(mComponent, flags);
7942 } catch (PackageManager.NameNotFoundException e) {
7943 // ignore
7944 }
7945 } else {
7946 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007947 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007948 if (info != null) {
7949 ai = info.activityInfo;
7950 }
7951 }
7952
7953 return ai;
7954 }
7955
7956 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007957 * Special function for use by the system to resolve service
7958 * intents to system apps. Throws an exception if there are
7959 * multiple potential matches to the Intent. Returns null if
7960 * there are no matches.
7961 * @hide
7962 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007963 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007964 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7965 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007966 if (mComponent != null) {
7967 return mComponent;
7968 }
7969
7970 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7971 if (results == null) {
7972 return null;
7973 }
7974 ComponentName comp = null;
7975 for (int i=0; i<results.size(); i++) {
7976 ResolveInfo ri = results.get(i);
7977 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7978 continue;
7979 }
7980 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7981 ri.serviceInfo.name);
7982 if (comp != null) {
7983 throw new IllegalStateException("Multiple system services handle " + this
7984 + ": " + comp + ", " + foundComp);
7985 }
7986 comp = foundComp;
7987 }
7988 return comp;
7989 }
7990
7991 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007992 * Set the general action to be performed.
7993 *
7994 * @param action An action name, such as ACTION_VIEW. Application-specific
7995 * actions should be prefixed with the vendor's package name.
7996 *
7997 * @return Returns the same Intent object, for chaining multiple calls
7998 * into a single statement.
7999 *
8000 * @see #getAction
8001 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008002 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008003 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008004 return this;
8005 }
8006
8007 /**
8008 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008009 * clears any type that was previously set by {@link #setType} or
8010 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008011 *
Nick Pellyccae4122012-01-09 14:12:58 -08008012 * <p><em>Note: scheme matching in the Android framework is
8013 * case-sensitive, unlike the formal RFC. As a result,
8014 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008015 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008016 * {@link #setDataAndNormalize}
8017 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008018 *
Nick Pellyccae4122012-01-09 14:12:58 -08008019 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008020 *
8021 * @return Returns the same Intent object, for chaining multiple calls
8022 * into a single statement.
8023 *
8024 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008025 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008026 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008027 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008028 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008029 mData = data;
8030 mType = null;
8031 return this;
8032 }
8033
8034 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008035 * Normalize and set the data this intent is operating on.
8036 *
8037 * <p>This method automatically clears any type that was
8038 * previously set (for example, by {@link #setType}).
8039 *
8040 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008041 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008042 * so really this is just a convenience method for
8043 * <pre>
8044 * setData(data.normalize())
8045 * </pre>
8046 *
8047 * @param data The Uri of the data this intent is now targeting.
8048 *
8049 * @return Returns the same Intent object, for chaining multiple calls
8050 * into a single statement.
8051 *
8052 * @see #getData
8053 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008054 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008055 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008056 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008057 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008058 }
8059
8060 /**
8061 * Set an explicit MIME data type.
8062 *
8063 * <p>This is used to create intents that only specify a type and not data,
8064 * for example to indicate the type of data to return.
8065 *
8066 * <p>This method automatically clears any data that was
8067 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008068 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008069 * <p><em>Note: MIME type matching in the Android framework is
8070 * case-sensitive, unlike formal RFC MIME types. As a result,
8071 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008072 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8073 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008074 *
8075 * @param type The MIME type of the data being handled by this intent.
8076 *
8077 * @return Returns the same Intent object, for chaining multiple calls
8078 * into a single statement.
8079 *
8080 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008081 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008082 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008083 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008084 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008085 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008086 mData = null;
8087 mType = type;
8088 return this;
8089 }
8090
8091 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008092 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008093 *
Nick Pellyccae4122012-01-09 14:12:58 -08008094 * <p>This is used to create intents that only specify a type and not data,
8095 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008096 *
Nick Pellyccae4122012-01-09 14:12:58 -08008097 * <p>This method automatically clears any data that was
8098 * previously set (for example by {@link #setData}).
8099 *
8100 * <p>The MIME type is normalized using
8101 * {@link #normalizeMimeType} before it is set,
8102 * so really this is just a convenience method for
8103 * <pre>
8104 * setType(Intent.normalizeMimeType(type))
8105 * </pre>
8106 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008107 * @param type The MIME type of the data being handled by this intent.
8108 *
8109 * @return Returns the same Intent object, for chaining multiple calls
8110 * into a single statement.
8111 *
Nick Pellyccae4122012-01-09 14:12:58 -08008112 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008113 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008114 * @see #normalizeMimeType
8115 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008116 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008117 return setType(normalizeMimeType(type));
8118 }
8119
8120 /**
8121 * (Usually optional) Set the data for the intent along with an explicit
8122 * MIME data type. This method should very rarely be used -- it allows you
8123 * to override the MIME type that would ordinarily be inferred from the
8124 * data with your own type given here.
8125 *
8126 * <p><em>Note: MIME type and Uri scheme matching in the
8127 * Android framework is case-sensitive, unlike the formal RFC definitions.
8128 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008129 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008130 * {@link #setDataAndTypeAndNormalize}
8131 * to ensure that they are converted to lower case.</em>
8132 *
8133 * @param data The Uri of the data this intent is now targeting.
8134 * @param type The MIME type of the data being handled by this intent.
8135 *
8136 * @return Returns the same Intent object, for chaining multiple calls
8137 * into a single statement.
8138 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008139 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008140 * @see #setData
8141 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008142 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008143 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008144 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008145 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008146 mData = data;
8147 mType = type;
8148 return this;
8149 }
8150
8151 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008152 * (Usually optional) Normalize and set both the data Uri and an explicit
8153 * MIME data type. This method should very rarely be used -- it allows you
8154 * to override the MIME type that would ordinarily be inferred from the
8155 * data with your own type given here.
8156 *
8157 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008158 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008159 * before they are set, so really this is just a convenience method for
8160 * <pre>
8161 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8162 * </pre>
8163 *
8164 * @param data The Uri of the data this intent is now targeting.
8165 * @param type The MIME type of the data being handled by this intent.
8166 *
8167 * @return Returns the same Intent object, for chaining multiple calls
8168 * into a single statement.
8169 *
8170 * @see #setType
8171 * @see #setData
8172 * @see #setDataAndType
8173 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008174 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008175 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008176 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008177 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008178 }
8179
8180 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008181 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008182 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 * activities that provide <em>all</em> of the requested categories will be
8184 * used.
8185 *
8186 * @param category The desired category. This can be either one of the
8187 * predefined Intent categories, or a custom category in your own
8188 * namespace.
8189 *
8190 * @return Returns the same Intent object, for chaining multiple calls
8191 * into a single statement.
8192 *
8193 * @see #hasCategory
8194 * @see #removeCategory
8195 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008196 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008197 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008198 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008199 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008200 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008201 return this;
8202 }
8203
8204 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008205 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008206 *
8207 * @param category The category to remove.
8208 *
8209 * @see #addCategory
8210 */
8211 public void removeCategory(String category) {
8212 if (mCategories != null) {
8213 mCategories.remove(category);
8214 if (mCategories.size() == 0) {
8215 mCategories = null;
8216 }
8217 }
8218 }
8219
8220 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008221 * Set a selector for this Intent. This is a modification to the kinds of
8222 * things the Intent will match. If the selector is set, it will be used
8223 * when trying to find entities that can handle the Intent, instead of the
8224 * main contents of the Intent. This allows you build an Intent containing
8225 * a generic protocol while targeting it more specifically.
8226 *
8227 * <p>An example of where this may be used is with things like
8228 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8229 * Intent that will launch the Browser application. However, the correct
8230 * main entry point of an application is actually {@link #ACTION_MAIN}
8231 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8232 * used to specify the actual Activity to launch. If you launch the browser
8233 * with something different, undesired behavior may happen if the user has
8234 * previously or later launches it the normal way, since they do not match.
8235 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8236 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8237 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8238 *
8239 * <p>Setting a selector does not impact the behavior of
8240 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8241 * desired behavior of a selector -- it does not impact the base meaning
8242 * of the Intent, just what kinds of things will be matched against it
8243 * when determining who can handle it.</p>
8244 *
8245 * <p>You can not use both a selector and {@link #setPackage(String)} on
8246 * the same base Intent.</p>
8247 *
8248 * @param selector The desired selector Intent; set to null to not use
8249 * a special selector.
8250 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008251 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008252 if (selector == this) {
8253 throw new IllegalArgumentException(
8254 "Intent being set as a selector of itself");
8255 }
8256 if (selector != null && mPackage != null) {
8257 throw new IllegalArgumentException(
8258 "Can't set selector when package name is already set");
8259 }
8260 mSelector = selector;
8261 }
8262
8263 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008264 * Set a {@link ClipData} associated with this Intent. This replaces any
8265 * previously set ClipData.
8266 *
8267 * <p>The ClipData in an intent is not used for Intent matching or other
8268 * such operations. Semantically it is like extras, used to transmit
8269 * additional data with the Intent. The main feature of using this over
8270 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8271 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8272 * items included in the clip data. This is useful, in particular, if
8273 * you want to transmit an Intent containing multiple <code>content:</code>
8274 * URIs for which the recipient may not have global permission to access the
8275 * content provider.
8276 *
8277 * <p>If the ClipData contains items that are themselves Intents, any
8278 * grant flags in those Intents will be ignored. Only the top-level flags
8279 * of the main Intent are respected, and will be applied to all Uri or
8280 * Intent items in the clip (or sub-items of the clip).
8281 *
8282 * <p>The MIME type, label, and icon in the ClipData object are not
8283 * directly used by Intent. Applications should generally rely on the
8284 * MIME type of the Intent itself, not what it may find in the ClipData.
8285 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008286 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008287 *
8288 * @param clip The new clip to set. May be null to clear the current clip.
8289 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008290 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008291 mClipData = clip;
8292 }
8293
8294 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008295 * This is NOT a secure mechanism to identify the user who sent the intent.
8296 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8297 * who sent the intent.
8298 * @hide
8299 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008300 public void prepareToLeaveUser(int userId) {
8301 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8302 // We want mContentUserHint to refer to the original user, so don't do anything.
8303 if (mContentUserHint == UserHandle.USER_CURRENT) {
8304 mContentUserHint = userId;
8305 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008306 }
8307
8308 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008309 * Add extended data to the intent. The name must include a package
8310 * prefix, for example the app com.android.contacts would use names
8311 * like "com.android.contacts.ShowAll".
8312 *
8313 * @param name The name of the extra data, with package prefix.
8314 * @param value The boolean data value.
8315 *
8316 * @return Returns the same Intent object, for chaining multiple calls
8317 * into a single statement.
8318 *
8319 * @see #putExtras
8320 * @see #removeExtra
8321 * @see #getBooleanExtra(String, boolean)
8322 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008323 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008324 if (mExtras == null) {
8325 mExtras = new Bundle();
8326 }
8327 mExtras.putBoolean(name, value);
8328 return this;
8329 }
8330
8331 /**
8332 * Add extended data to the intent. The name must include a package
8333 * prefix, for example the app com.android.contacts would use names
8334 * like "com.android.contacts.ShowAll".
8335 *
8336 * @param name The name of the extra data, with package prefix.
8337 * @param value The byte data value.
8338 *
8339 * @return Returns the same Intent object, for chaining multiple calls
8340 * into a single statement.
8341 *
8342 * @see #putExtras
8343 * @see #removeExtra
8344 * @see #getByteExtra(String, byte)
8345 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008346 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008347 if (mExtras == null) {
8348 mExtras = new Bundle();
8349 }
8350 mExtras.putByte(name, value);
8351 return this;
8352 }
8353
8354 /**
8355 * Add extended data to the intent. The name must include a package
8356 * prefix, for example the app com.android.contacts would use names
8357 * like "com.android.contacts.ShowAll".
8358 *
8359 * @param name The name of the extra data, with package prefix.
8360 * @param value The char data value.
8361 *
8362 * @return Returns the same Intent object, for chaining multiple calls
8363 * into a single statement.
8364 *
8365 * @see #putExtras
8366 * @see #removeExtra
8367 * @see #getCharExtra(String, char)
8368 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008369 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008370 if (mExtras == null) {
8371 mExtras = new Bundle();
8372 }
8373 mExtras.putChar(name, value);
8374 return this;
8375 }
8376
8377 /**
8378 * Add extended data to the intent. The name must include a package
8379 * prefix, for example the app com.android.contacts would use names
8380 * like "com.android.contacts.ShowAll".
8381 *
8382 * @param name The name of the extra data, with package prefix.
8383 * @param value The short data value.
8384 *
8385 * @return Returns the same Intent object, for chaining multiple calls
8386 * into a single statement.
8387 *
8388 * @see #putExtras
8389 * @see #removeExtra
8390 * @see #getShortExtra(String, short)
8391 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008392 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008393 if (mExtras == null) {
8394 mExtras = new Bundle();
8395 }
8396 mExtras.putShort(name, value);
8397 return this;
8398 }
8399
8400 /**
8401 * Add extended data to the intent. The name must include a package
8402 * prefix, for example the app com.android.contacts would use names
8403 * like "com.android.contacts.ShowAll".
8404 *
8405 * @param name The name of the extra data, with package prefix.
8406 * @param value The integer data value.
8407 *
8408 * @return Returns the same Intent object, for chaining multiple calls
8409 * into a single statement.
8410 *
8411 * @see #putExtras
8412 * @see #removeExtra
8413 * @see #getIntExtra(String, int)
8414 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008415 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008416 if (mExtras == null) {
8417 mExtras = new Bundle();
8418 }
8419 mExtras.putInt(name, value);
8420 return this;
8421 }
8422
8423 /**
8424 * Add extended data to the intent. The name must include a package
8425 * prefix, for example the app com.android.contacts would use names
8426 * like "com.android.contacts.ShowAll".
8427 *
8428 * @param name The name of the extra data, with package prefix.
8429 * @param value The long data value.
8430 *
8431 * @return Returns the same Intent object, for chaining multiple calls
8432 * into a single statement.
8433 *
8434 * @see #putExtras
8435 * @see #removeExtra
8436 * @see #getLongExtra(String, long)
8437 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008438 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008439 if (mExtras == null) {
8440 mExtras = new Bundle();
8441 }
8442 mExtras.putLong(name, value);
8443 return this;
8444 }
8445
8446 /**
8447 * Add extended data to the intent. The name must include a package
8448 * prefix, for example the app com.android.contacts would use names
8449 * like "com.android.contacts.ShowAll".
8450 *
8451 * @param name The name of the extra data, with package prefix.
8452 * @param value The float data value.
8453 *
8454 * @return Returns the same Intent object, for chaining multiple calls
8455 * into a single statement.
8456 *
8457 * @see #putExtras
8458 * @see #removeExtra
8459 * @see #getFloatExtra(String, float)
8460 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008461 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008462 if (mExtras == null) {
8463 mExtras = new Bundle();
8464 }
8465 mExtras.putFloat(name, value);
8466 return this;
8467 }
8468
8469 /**
8470 * Add extended data to the intent. The name must include a package
8471 * prefix, for example the app com.android.contacts would use names
8472 * like "com.android.contacts.ShowAll".
8473 *
8474 * @param name The name of the extra data, with package prefix.
8475 * @param value The double data value.
8476 *
8477 * @return Returns the same Intent object, for chaining multiple calls
8478 * into a single statement.
8479 *
8480 * @see #putExtras
8481 * @see #removeExtra
8482 * @see #getDoubleExtra(String, double)
8483 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008484 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008485 if (mExtras == null) {
8486 mExtras = new Bundle();
8487 }
8488 mExtras.putDouble(name, value);
8489 return this;
8490 }
8491
8492 /**
8493 * Add extended data to the intent. The name must include a package
8494 * prefix, for example the app com.android.contacts would use names
8495 * like "com.android.contacts.ShowAll".
8496 *
8497 * @param name The name of the extra data, with package prefix.
8498 * @param value The String data value.
8499 *
8500 * @return Returns the same Intent object, for chaining multiple calls
8501 * into a single statement.
8502 *
8503 * @see #putExtras
8504 * @see #removeExtra
8505 * @see #getStringExtra(String)
8506 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008507 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008508 if (mExtras == null) {
8509 mExtras = new Bundle();
8510 }
8511 mExtras.putString(name, value);
8512 return this;
8513 }
8514
8515 /**
8516 * Add extended data to the intent. The name must include a package
8517 * prefix, for example the app com.android.contacts would use names
8518 * like "com.android.contacts.ShowAll".
8519 *
8520 * @param name The name of the extra data, with package prefix.
8521 * @param value The CharSequence data value.
8522 *
8523 * @return Returns the same Intent object, for chaining multiple calls
8524 * into a single statement.
8525 *
8526 * @see #putExtras
8527 * @see #removeExtra
8528 * @see #getCharSequenceExtra(String)
8529 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008530 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008531 if (mExtras == null) {
8532 mExtras = new Bundle();
8533 }
8534 mExtras.putCharSequence(name, value);
8535 return this;
8536 }
8537
8538 /**
8539 * Add extended data to the intent. The name must include a package
8540 * prefix, for example the app com.android.contacts would use names
8541 * like "com.android.contacts.ShowAll".
8542 *
8543 * @param name The name of the extra data, with package prefix.
8544 * @param value The Parcelable data value.
8545 *
8546 * @return Returns the same Intent object, for chaining multiple calls
8547 * into a single statement.
8548 *
8549 * @see #putExtras
8550 * @see #removeExtra
8551 * @see #getParcelableExtra(String)
8552 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008553 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008554 if (mExtras == null) {
8555 mExtras = new Bundle();
8556 }
8557 mExtras.putParcelable(name, value);
8558 return this;
8559 }
8560
8561 /**
8562 * Add extended data to the intent. The name must include a package
8563 * prefix, for example the app com.android.contacts would use names
8564 * like "com.android.contacts.ShowAll".
8565 *
8566 * @param name The name of the extra data, with package prefix.
8567 * @param value The Parcelable[] data value.
8568 *
8569 * @return Returns the same Intent object, for chaining multiple calls
8570 * into a single statement.
8571 *
8572 * @see #putExtras
8573 * @see #removeExtra
8574 * @see #getParcelableArrayExtra(String)
8575 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008576 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008577 if (mExtras == null) {
8578 mExtras = new Bundle();
8579 }
8580 mExtras.putParcelableArray(name, value);
8581 return this;
8582 }
8583
8584 /**
8585 * Add extended data to the intent. The name must include a package
8586 * prefix, for example the app com.android.contacts would use names
8587 * like "com.android.contacts.ShowAll".
8588 *
8589 * @param name The name of the extra data, with package prefix.
8590 * @param value The ArrayList<Parcelable> data value.
8591 *
8592 * @return Returns the same Intent object, for chaining multiple calls
8593 * into a single statement.
8594 *
8595 * @see #putExtras
8596 * @see #removeExtra
8597 * @see #getParcelableArrayListExtra(String)
8598 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008599 public @NonNull Intent putParcelableArrayListExtra(String name,
8600 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008601 if (mExtras == null) {
8602 mExtras = new Bundle();
8603 }
8604 mExtras.putParcelableArrayList(name, value);
8605 return this;
8606 }
8607
8608 /**
8609 * Add extended data to the intent. The name must include a package
8610 * prefix, for example the app com.android.contacts would use names
8611 * like "com.android.contacts.ShowAll".
8612 *
8613 * @param name The name of the extra data, with package prefix.
8614 * @param value The ArrayList<Integer> data value.
8615 *
8616 * @return Returns the same Intent object, for chaining multiple calls
8617 * into a single statement.
8618 *
8619 * @see #putExtras
8620 * @see #removeExtra
8621 * @see #getIntegerArrayListExtra(String)
8622 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008623 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008624 if (mExtras == null) {
8625 mExtras = new Bundle();
8626 }
8627 mExtras.putIntegerArrayList(name, value);
8628 return this;
8629 }
8630
8631 /**
8632 * Add extended data to the intent. The name must include a package
8633 * prefix, for example the app com.android.contacts would use names
8634 * like "com.android.contacts.ShowAll".
8635 *
8636 * @param name The name of the extra data, with package prefix.
8637 * @param value The ArrayList<String> data value.
8638 *
8639 * @return Returns the same Intent object, for chaining multiple calls
8640 * into a single statement.
8641 *
8642 * @see #putExtras
8643 * @see #removeExtra
8644 * @see #getStringArrayListExtra(String)
8645 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008646 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008647 if (mExtras == null) {
8648 mExtras = new Bundle();
8649 }
8650 mExtras.putStringArrayList(name, value);
8651 return this;
8652 }
8653
8654 /**
8655 * Add extended data to the intent. The name must include a package
8656 * prefix, for example the app com.android.contacts would use names
8657 * like "com.android.contacts.ShowAll".
8658 *
8659 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008660 * @param value The ArrayList<CharSequence> data value.
8661 *
8662 * @return Returns the same Intent object, for chaining multiple calls
8663 * into a single statement.
8664 *
8665 * @see #putExtras
8666 * @see #removeExtra
8667 * @see #getCharSequenceArrayListExtra(String)
8668 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008669 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8670 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008671 if (mExtras == null) {
8672 mExtras = new Bundle();
8673 }
8674 mExtras.putCharSequenceArrayList(name, value);
8675 return this;
8676 }
8677
8678 /**
8679 * Add extended data to the intent. The name must include a package
8680 * prefix, for example the app com.android.contacts would use names
8681 * like "com.android.contacts.ShowAll".
8682 *
8683 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008684 * @param value The Serializable data value.
8685 *
8686 * @return Returns the same Intent object, for chaining multiple calls
8687 * into a single statement.
8688 *
8689 * @see #putExtras
8690 * @see #removeExtra
8691 * @see #getSerializableExtra(String)
8692 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008693 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008694 if (mExtras == null) {
8695 mExtras = new Bundle();
8696 }
8697 mExtras.putSerializable(name, value);
8698 return this;
8699 }
8700
8701 /**
8702 * Add extended data to the intent. The name must include a package
8703 * prefix, for example the app com.android.contacts would use names
8704 * like "com.android.contacts.ShowAll".
8705 *
8706 * @param name The name of the extra data, with package prefix.
8707 * @param value The boolean array data value.
8708 *
8709 * @return Returns the same Intent object, for chaining multiple calls
8710 * into a single statement.
8711 *
8712 * @see #putExtras
8713 * @see #removeExtra
8714 * @see #getBooleanArrayExtra(String)
8715 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008716 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008717 if (mExtras == null) {
8718 mExtras = new Bundle();
8719 }
8720 mExtras.putBooleanArray(name, value);
8721 return this;
8722 }
8723
8724 /**
8725 * Add extended data to the intent. The name must include a package
8726 * prefix, for example the app com.android.contacts would use names
8727 * like "com.android.contacts.ShowAll".
8728 *
8729 * @param name The name of the extra data, with package prefix.
8730 * @param value The byte array data value.
8731 *
8732 * @return Returns the same Intent object, for chaining multiple calls
8733 * into a single statement.
8734 *
8735 * @see #putExtras
8736 * @see #removeExtra
8737 * @see #getByteArrayExtra(String)
8738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008739 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008740 if (mExtras == null) {
8741 mExtras = new Bundle();
8742 }
8743 mExtras.putByteArray(name, value);
8744 return this;
8745 }
8746
8747 /**
8748 * Add extended data to the intent. The name must include a package
8749 * prefix, for example the app com.android.contacts would use names
8750 * like "com.android.contacts.ShowAll".
8751 *
8752 * @param name The name of the extra data, with package prefix.
8753 * @param value The short array data value.
8754 *
8755 * @return Returns the same Intent object, for chaining multiple calls
8756 * into a single statement.
8757 *
8758 * @see #putExtras
8759 * @see #removeExtra
8760 * @see #getShortArrayExtra(String)
8761 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008762 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008763 if (mExtras == null) {
8764 mExtras = new Bundle();
8765 }
8766 mExtras.putShortArray(name, value);
8767 return this;
8768 }
8769
8770 /**
8771 * Add extended data to the intent. The name must include a package
8772 * prefix, for example the app com.android.contacts would use names
8773 * like "com.android.contacts.ShowAll".
8774 *
8775 * @param name The name of the extra data, with package prefix.
8776 * @param value The char array data value.
8777 *
8778 * @return Returns the same Intent object, for chaining multiple calls
8779 * into a single statement.
8780 *
8781 * @see #putExtras
8782 * @see #removeExtra
8783 * @see #getCharArrayExtra(String)
8784 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008785 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008786 if (mExtras == null) {
8787 mExtras = new Bundle();
8788 }
8789 mExtras.putCharArray(name, value);
8790 return this;
8791 }
8792
8793 /**
8794 * Add extended data to the intent. The name must include a package
8795 * prefix, for example the app com.android.contacts would use names
8796 * like "com.android.contacts.ShowAll".
8797 *
8798 * @param name The name of the extra data, with package prefix.
8799 * @param value The int array data value.
8800 *
8801 * @return Returns the same Intent object, for chaining multiple calls
8802 * into a single statement.
8803 *
8804 * @see #putExtras
8805 * @see #removeExtra
8806 * @see #getIntArrayExtra(String)
8807 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008808 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008809 if (mExtras == null) {
8810 mExtras = new Bundle();
8811 }
8812 mExtras.putIntArray(name, value);
8813 return this;
8814 }
8815
8816 /**
8817 * Add extended data to the intent. The name must include a package
8818 * prefix, for example the app com.android.contacts would use names
8819 * like "com.android.contacts.ShowAll".
8820 *
8821 * @param name The name of the extra data, with package prefix.
8822 * @param value The byte array data value.
8823 *
8824 * @return Returns the same Intent object, for chaining multiple calls
8825 * into a single statement.
8826 *
8827 * @see #putExtras
8828 * @see #removeExtra
8829 * @see #getLongArrayExtra(String)
8830 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008831 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008832 if (mExtras == null) {
8833 mExtras = new Bundle();
8834 }
8835 mExtras.putLongArray(name, value);
8836 return this;
8837 }
8838
8839 /**
8840 * Add extended data to the intent. The name must include a package
8841 * prefix, for example the app com.android.contacts would use names
8842 * like "com.android.contacts.ShowAll".
8843 *
8844 * @param name The name of the extra data, with package prefix.
8845 * @param value The float array data value.
8846 *
8847 * @return Returns the same Intent object, for chaining multiple calls
8848 * into a single statement.
8849 *
8850 * @see #putExtras
8851 * @see #removeExtra
8852 * @see #getFloatArrayExtra(String)
8853 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008854 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008855 if (mExtras == null) {
8856 mExtras = new Bundle();
8857 }
8858 mExtras.putFloatArray(name, value);
8859 return this;
8860 }
8861
8862 /**
8863 * Add extended data to the intent. The name must include a package
8864 * prefix, for example the app com.android.contacts would use names
8865 * like "com.android.contacts.ShowAll".
8866 *
8867 * @param name The name of the extra data, with package prefix.
8868 * @param value The double array data value.
8869 *
8870 * @return Returns the same Intent object, for chaining multiple calls
8871 * into a single statement.
8872 *
8873 * @see #putExtras
8874 * @see #removeExtra
8875 * @see #getDoubleArrayExtra(String)
8876 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008877 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008878 if (mExtras == null) {
8879 mExtras = new Bundle();
8880 }
8881 mExtras.putDoubleArray(name, value);
8882 return this;
8883 }
8884
8885 /**
8886 * Add extended data to the intent. The name must include a package
8887 * prefix, for example the app com.android.contacts would use names
8888 * like "com.android.contacts.ShowAll".
8889 *
8890 * @param name The name of the extra data, with package prefix.
8891 * @param value The String array data value.
8892 *
8893 * @return Returns the same Intent object, for chaining multiple calls
8894 * into a single statement.
8895 *
8896 * @see #putExtras
8897 * @see #removeExtra
8898 * @see #getStringArrayExtra(String)
8899 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008900 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008901 if (mExtras == null) {
8902 mExtras = new Bundle();
8903 }
8904 mExtras.putStringArray(name, value);
8905 return this;
8906 }
8907
8908 /**
8909 * Add extended data to the intent. The name must include a package
8910 * prefix, for example the app com.android.contacts would use names
8911 * like "com.android.contacts.ShowAll".
8912 *
8913 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008914 * @param value The CharSequence array data value.
8915 *
8916 * @return Returns the same Intent object, for chaining multiple calls
8917 * into a single statement.
8918 *
8919 * @see #putExtras
8920 * @see #removeExtra
8921 * @see #getCharSequenceArrayExtra(String)
8922 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008923 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008924 if (mExtras == null) {
8925 mExtras = new Bundle();
8926 }
8927 mExtras.putCharSequenceArray(name, value);
8928 return this;
8929 }
8930
8931 /**
8932 * Add extended data to the intent. The name must include a package
8933 * prefix, for example the app com.android.contacts would use names
8934 * like "com.android.contacts.ShowAll".
8935 *
8936 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008937 * @param value The Bundle data value.
8938 *
8939 * @return Returns the same Intent object, for chaining multiple calls
8940 * into a single statement.
8941 *
8942 * @see #putExtras
8943 * @see #removeExtra
8944 * @see #getBundleExtra(String)
8945 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008946 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008947 if (mExtras == null) {
8948 mExtras = new Bundle();
8949 }
8950 mExtras.putBundle(name, value);
8951 return this;
8952 }
8953
8954 /**
8955 * Add extended data to the intent. The name must include a package
8956 * prefix, for example the app com.android.contacts would use names
8957 * like "com.android.contacts.ShowAll".
8958 *
8959 * @param name The name of the extra data, with package prefix.
8960 * @param value The IBinder data value.
8961 *
8962 * @return Returns the same Intent object, for chaining multiple calls
8963 * into a single statement.
8964 *
8965 * @see #putExtras
8966 * @see #removeExtra
8967 * @see #getIBinderExtra(String)
8968 *
8969 * @deprecated
8970 * @hide
8971 */
8972 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008973 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008974 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008975 if (mExtras == null) {
8976 mExtras = new Bundle();
8977 }
8978 mExtras.putIBinder(name, value);
8979 return this;
8980 }
8981
8982 /**
8983 * Copy all extras in 'src' in to this intent.
8984 *
8985 * @param src Contains the extras to copy.
8986 *
8987 * @see #putExtra
8988 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008989 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008990 if (src.mExtras != null) {
8991 if (mExtras == null) {
8992 mExtras = new Bundle(src.mExtras);
8993 } else {
8994 mExtras.putAll(src.mExtras);
8995 }
8996 }
8997 return this;
8998 }
8999
9000 /**
9001 * Add a set of extended data to the intent. The keys must include a package
9002 * prefix, for example the app com.android.contacts would use names
9003 * like "com.android.contacts.ShowAll".
9004 *
9005 * @param extras The Bundle of extras to add to this intent.
9006 *
9007 * @see #putExtra
9008 * @see #removeExtra
9009 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009010 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009011 if (mExtras == null) {
9012 mExtras = new Bundle();
9013 }
9014 mExtras.putAll(extras);
9015 return this;
9016 }
9017
9018 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009019 * Completely replace the extras in the Intent with the extras in the
9020 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009021 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009022 * @param src The exact extras contained in this Intent are copied
9023 * into the target intent, replacing any that were previously there.
9024 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009025 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009026 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9027 return this;
9028 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009029
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009030 /**
9031 * Completely replace the extras in the Intent with the given Bundle of
9032 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009033 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009034 * @param extras The new set of extras in the Intent, or null to erase
9035 * all extras.
9036 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009037 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009038 mExtras = extras != null ? new Bundle(extras) : null;
9039 return this;
9040 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009041
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009043 * Remove extended data from the intent.
9044 *
9045 * @see #putExtra
9046 */
9047 public void removeExtra(String name) {
9048 if (mExtras != null) {
9049 mExtras.remove(name);
9050 if (mExtras.size() == 0) {
9051 mExtras = null;
9052 }
9053 }
9054 }
9055
9056 /**
9057 * Set special flags controlling how this intent is handled. Most values
9058 * here depend on the type of component being executed by the Intent,
9059 * specifically the FLAG_ACTIVITY_* flags are all for use with
9060 * {@link Context#startActivity Context.startActivity()} and the
9061 * FLAG_RECEIVER_* flags are all for use with
9062 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9063 *
Scott Main7aee61f2011-02-08 11:25:01 -08009064 * <p>See the
9065 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9066 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 * the behavior of your application.
9068 *
9069 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009070 * @return Returns the same Intent object, for chaining multiple calls
9071 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009072 * @see #getFlags
9073 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009074 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009075 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009076 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009077 mFlags = flags;
9078 return this;
9079 }
9080
9081 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009082 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009083 *
9084 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009085 * @return Returns the same Intent object, for chaining multiple calls into
9086 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009087 * @see #setFlags
9088 * @see #getFlags
9089 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009091 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009092 mFlags |= flags;
9093 return this;
9094 }
9095
9096 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009097 * Remove these flags from the intent.
9098 *
9099 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009100 * @see #setFlags
9101 * @see #getFlags
9102 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009103 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009104 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009105 mFlags &= ~flags;
9106 }
9107
9108 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009109 * (Usually optional) Set an explicit application package name that limits
9110 * the components this Intent will resolve to. If left to the default
9111 * value of null, all components in all applications will considered.
9112 * If non-null, the Intent can only match the components in the given
9113 * application package.
9114 *
9115 * @param packageName The name of the application package to handle the
9116 * intent, or null to allow any application package.
9117 *
9118 * @return Returns the same Intent object, for chaining multiple calls
9119 * into a single statement.
9120 *
9121 * @see #getPackage
9122 * @see #resolveActivity
9123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009124 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009125 if (packageName != null && mSelector != null) {
9126 throw new IllegalArgumentException(
9127 "Can't set package name when selector is already set");
9128 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009129 mPackage = packageName;
9130 return this;
9131 }
9132
9133 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009134 * (Usually optional) Explicitly set the component to handle the intent.
9135 * If left with the default value of null, the system will determine the
9136 * appropriate class to use based on the other fields (action, data,
9137 * type, categories) in the Intent. If this class is defined, the
9138 * specified class will always be used regardless of the other fields. You
9139 * should only set this value when you know you absolutely want a specific
9140 * class to be used; otherwise it is better to let the system find the
9141 * appropriate class so that you will respect the installed applications
9142 * and user preferences.
9143 *
9144 * @param component The name of the application component to handle the
9145 * intent, or null to let the system find one for you.
9146 *
9147 * @return Returns the same Intent object, for chaining multiple calls
9148 * into a single statement.
9149 *
9150 * @see #setClass
9151 * @see #setClassName(Context, String)
9152 * @see #setClassName(String, String)
9153 * @see #getComponent
9154 * @see #resolveActivity
9155 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009156 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009157 mComponent = component;
9158 return this;
9159 }
9160
9161 /**
9162 * Convenience for calling {@link #setComponent} with an
9163 * explicit class name.
9164 *
9165 * @param packageContext A Context of the application package implementing
9166 * this class.
9167 * @param className The name of a class inside of the application package
9168 * that will be used as the component for this Intent.
9169 *
9170 * @return Returns the same Intent object, for chaining multiple calls
9171 * into a single statement.
9172 *
9173 * @see #setComponent
9174 * @see #setClass
9175 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009176 public @NonNull Intent setClassName(@NonNull Context packageContext,
9177 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009178 mComponent = new ComponentName(packageContext, className);
9179 return this;
9180 }
9181
9182 /**
9183 * Convenience for calling {@link #setComponent} with an
9184 * explicit application package name and class name.
9185 *
9186 * @param packageName The name of the package implementing the desired
9187 * component.
9188 * @param className The name of a class inside of the application package
9189 * that will be used as the component for this Intent.
9190 *
9191 * @return Returns the same Intent object, for chaining multiple calls
9192 * into a single statement.
9193 *
9194 * @see #setComponent
9195 * @see #setClass
9196 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009197 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009198 mComponent = new ComponentName(packageName, className);
9199 return this;
9200 }
9201
9202 /**
9203 * Convenience for calling {@link #setComponent(ComponentName)} with the
9204 * name returned by a {@link Class} object.
9205 *
9206 * @param packageContext A Context of the application package implementing
9207 * this class.
9208 * @param cls The class name to set, equivalent to
9209 * <code>setClassName(context, cls.getName())</code>.
9210 *
9211 * @return Returns the same Intent object, for chaining multiple calls
9212 * into a single statement.
9213 *
9214 * @see #setComponent
9215 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009216 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009217 mComponent = new ComponentName(packageContext, cls);
9218 return this;
9219 }
9220
9221 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009222 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9223 * used as a hint to the receiver for animations and the like. Null means that there
9224 * is no source bounds.
9225 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009226 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009227 if (r != null) {
9228 mSourceBounds = new Rect(r);
9229 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009230 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009231 }
9232 }
9233
Tor Norbyed9273d62013-05-30 15:59:53 -07009234 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009235 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9236 FILL_IN_ACTION,
9237 FILL_IN_DATA,
9238 FILL_IN_CATEGORIES,
9239 FILL_IN_COMPONENT,
9240 FILL_IN_PACKAGE,
9241 FILL_IN_SOURCE_BOUNDS,
9242 FILL_IN_SELECTOR,
9243 FILL_IN_CLIP_DATA
9244 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009245 @Retention(RetentionPolicy.SOURCE)
9246 public @interface FillInFlags {}
9247
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009248 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009249 * Use with {@link #fillIn} to allow the current action value to be
9250 * overwritten, even if it is already set.
9251 */
9252 public static final int FILL_IN_ACTION = 1<<0;
9253
9254 /**
9255 * Use with {@link #fillIn} to allow the current data or type value
9256 * overwritten, even if it is already set.
9257 */
9258 public static final int FILL_IN_DATA = 1<<1;
9259
9260 /**
9261 * Use with {@link #fillIn} to allow the current categories to be
9262 * overwritten, even if they are already set.
9263 */
9264 public static final int FILL_IN_CATEGORIES = 1<<2;
9265
9266 /**
9267 * Use with {@link #fillIn} to allow the current component value to be
9268 * overwritten, even if it is already set.
9269 */
9270 public static final int FILL_IN_COMPONENT = 1<<3;
9271
9272 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009273 * Use with {@link #fillIn} to allow the current package value to be
9274 * overwritten, even if it is already set.
9275 */
9276 public static final int FILL_IN_PACKAGE = 1<<4;
9277
9278 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009279 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009280 * overwritten, even if it is already set.
9281 */
9282 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9283
9284 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009285 * Use with {@link #fillIn} to allow the current selector to be
9286 * overwritten, even if it is already set.
9287 */
9288 public static final int FILL_IN_SELECTOR = 1<<6;
9289
9290 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009291 * Use with {@link #fillIn} to allow the current ClipData to be
9292 * overwritten, even if it is already set.
9293 */
9294 public static final int FILL_IN_CLIP_DATA = 1<<7;
9295
9296 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009297 * Copy the contents of <var>other</var> in to this object, but only
9298 * where fields are not defined by this object. For purposes of a field
9299 * being defined, the following pieces of data in the Intent are
9300 * considered to be separate fields:
9301 *
9302 * <ul>
9303 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009304 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009305 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9306 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009307 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009308 * <li> component, as set by {@link #setComponent(ComponentName)} or
9309 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009310 * <li> source bounds, as set by {@link #setSourceBounds}.
9311 * <li> selector, as set by {@link #setSelector(Intent)}.
9312 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009313 * <li> each top-level name in the associated extras.
9314 * </ul>
9315 *
9316 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009317 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009318 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9319 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9320 * the restriction where the corresponding field will not be replaced if
9321 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009322 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009323 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9324 * is explicitly specified. The selector will only be copied if
9325 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009326 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009327 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9328 * and Intent B with {action="gotit", data-type="some/thing",
9329 * categories="one","two"}.
9330 *
9331 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9332 * containing: {action="gotit", data-type="some/thing",
9333 * categories="bar"}.
9334 *
9335 * @param other Another Intent whose values are to be used to fill in
9336 * the current one.
9337 * @param flags Options to control which fields can be filled in.
9338 *
9339 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009340 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009341 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009342 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009343 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009344 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009345 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009346 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009347 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009348 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009349 if (other.mAction != null
9350 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009351 mAction = other.mAction;
9352 changes |= FILL_IN_ACTION;
9353 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009354 if ((other.mData != null || other.mType != null)
9355 && ((mData == null && mType == null)
9356 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009357 mData = other.mData;
9358 mType = other.mType;
9359 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009360 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009361 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009362 if (other.mCategories != null
9363 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009364 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009365 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009366 }
9367 changes |= FILL_IN_CATEGORIES;
9368 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009369 if (other.mPackage != null
9370 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009371 // Only do this if mSelector is not set.
9372 if (mSelector == null) {
9373 mPackage = other.mPackage;
9374 changes |= FILL_IN_PACKAGE;
9375 }
9376 }
9377 // Selector is special: it can only be set if explicitly allowed,
9378 // for the same reason as the component name.
9379 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9380 if (mPackage == null) {
9381 mSelector = new Intent(other.mSelector);
9382 mPackage = null;
9383 changes |= FILL_IN_SELECTOR;
9384 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009385 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009386 if (other.mClipData != null
9387 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9388 mClipData = other.mClipData;
9389 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009390 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009391 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009392 // Component is special: it can -only- be set if explicitly allowed,
9393 // since otherwise the sender could force the intent somewhere the
9394 // originator didn't intend.
9395 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009396 mComponent = other.mComponent;
9397 changes |= FILL_IN_COMPONENT;
9398 }
9399 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009400 if (other.mSourceBounds != null
9401 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9402 mSourceBounds = new Rect(other.mSourceBounds);
9403 changes |= FILL_IN_SOURCE_BOUNDS;
9404 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009405 if (mExtras == null) {
9406 if (other.mExtras != null) {
9407 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009408 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009409 }
9410 } else if (other.mExtras != null) {
9411 try {
9412 Bundle newb = new Bundle(other.mExtras);
9413 newb.putAll(mExtras);
9414 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009415 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009416 } catch (RuntimeException e) {
9417 // Modifying the extras can cause us to unparcel the contents
9418 // of the bundle, and if we do this in the system process that
9419 // may fail. We really should handle this (i.e., the Bundle
9420 // impl shouldn't be on top of a plain map), but for now just
9421 // ignore it and keep the original contents. :(
9422 Log.w("Intent", "Failure filling in extras", e);
9423 }
9424 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009425 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9426 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9427 mContentUserHint = other.mContentUserHint;
9428 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009429 return changes;
9430 }
9431
9432 /**
9433 * Wrapper class holding an Intent and implementing comparisons on it for
9434 * the purpose of filtering. The class implements its
9435 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9436 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9437 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9438 * on the wrapped Intent.
9439 */
9440 public static final class FilterComparison {
9441 private final Intent mIntent;
9442 private final int mHashCode;
9443
9444 public FilterComparison(Intent intent) {
9445 mIntent = intent;
9446 mHashCode = intent.filterHashCode();
9447 }
9448
9449 /**
9450 * Return the Intent that this FilterComparison represents.
9451 * @return Returns the Intent held by the FilterComparison. Do
9452 * not modify!
9453 */
9454 public Intent getIntent() {
9455 return mIntent;
9456 }
9457
9458 @Override
9459 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009460 if (obj instanceof FilterComparison) {
9461 Intent other = ((FilterComparison)obj).mIntent;
9462 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009463 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009464 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009465 }
9466
9467 @Override
9468 public int hashCode() {
9469 return mHashCode;
9470 }
9471 }
9472
9473 /**
9474 * Determine if two intents are the same for the purposes of intent
9475 * resolution (filtering). That is, if their action, data, type,
9476 * class, and categories are the same. This does <em>not</em> compare
9477 * any extra data included in the intents.
9478 *
9479 * @param other The other Intent to compare against.
9480 *
9481 * @return Returns true if action, data, type, class, and categories
9482 * are the same.
9483 */
9484 public boolean filterEquals(Intent other) {
9485 if (other == null) {
9486 return false;
9487 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009488 if (!Objects.equals(this.mAction, other.mAction)) return false;
9489 if (!Objects.equals(this.mData, other.mData)) return false;
9490 if (!Objects.equals(this.mType, other.mType)) return false;
9491 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9492 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9493 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009494
9495 return true;
9496 }
9497
9498 /**
9499 * Generate hash code that matches semantics of filterEquals().
9500 *
9501 * @return Returns the hash value of the action, data, type, class, and
9502 * categories.
9503 *
9504 * @see #filterEquals
9505 */
9506 public int filterHashCode() {
9507 int code = 0;
9508 if (mAction != null) {
9509 code += mAction.hashCode();
9510 }
9511 if (mData != null) {
9512 code += mData.hashCode();
9513 }
9514 if (mType != null) {
9515 code += mType.hashCode();
9516 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009517 if (mPackage != null) {
9518 code += mPackage.hashCode();
9519 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009520 if (mComponent != null) {
9521 code += mComponent.hashCode();
9522 }
9523 if (mCategories != null) {
9524 code += mCategories.hashCode();
9525 }
9526 return code;
9527 }
9528
9529 @Override
9530 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009531 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009532
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009533 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009534 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009535 b.append(" }");
9536
9537 return b.toString();
9538 }
9539
9540 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009541 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009542 public String toInsecureString() {
9543 StringBuilder b = new StringBuilder(128);
9544
9545 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009546 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009547 b.append(" }");
9548
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009549 return b.toString();
9550 }
Romain Guy4969af72009-06-17 10:53:19 -07009551
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009552 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009553 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009554 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009555
9556 b.append("Intent { ");
9557 toShortString(b, false, true, true, true);
9558 b.append(" }");
9559
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009560 return b.toString();
9561 }
9562
9563 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009564 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9565 StringBuilder b = new StringBuilder(128);
9566 toShortString(b, secure, comp, extras, clip);
9567 return b.toString();
9568 }
9569
9570 /** @hide */
9571 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9572 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009573 boolean first = true;
9574 if (mAction != null) {
9575 b.append("act=").append(mAction);
9576 first = false;
9577 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009578 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009579 if (!first) {
9580 b.append(' ');
9581 }
9582 first = false;
9583 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009584 for (int i=0; i<mCategories.size(); i++) {
9585 if (i > 0) b.append(',');
9586 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009587 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009588 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009589 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009590 if (mData != null) {
9591 if (!first) {
9592 b.append(' ');
9593 }
9594 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009595 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009596 if (secure) {
9597 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009598 } else {
9599 b.append(mData);
9600 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009601 }
9602 if (mType != null) {
9603 if (!first) {
9604 b.append(' ');
9605 }
9606 first = false;
9607 b.append("typ=").append(mType);
9608 }
9609 if (mFlags != 0) {
9610 if (!first) {
9611 b.append(' ');
9612 }
9613 first = false;
9614 b.append("flg=0x").append(Integer.toHexString(mFlags));
9615 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009616 if (mPackage != null) {
9617 if (!first) {
9618 b.append(' ');
9619 }
9620 first = false;
9621 b.append("pkg=").append(mPackage);
9622 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009623 if (comp && mComponent != null) {
9624 if (!first) {
9625 b.append(' ');
9626 }
9627 first = false;
9628 b.append("cmp=").append(mComponent.flattenToShortString());
9629 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009630 if (mSourceBounds != null) {
9631 if (!first) {
9632 b.append(' ');
9633 }
9634 first = false;
9635 b.append("bnds=").append(mSourceBounds.toShortString());
9636 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009637 if (mClipData != null) {
9638 if (!first) {
9639 b.append(' ');
9640 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009641 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009642 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009643 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009644 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009645 if (mClipData.getDescription() != null) {
9646 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9647 } else {
9648 first = true;
9649 }
9650 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009651 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009652 first = false;
9653 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009654 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009655 if (extras && mExtras != null) {
9656 if (!first) {
9657 b.append(' ');
9658 }
9659 first = false;
9660 b.append("(has extras)");
9661 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009662 if (mContentUserHint != UserHandle.USER_CURRENT) {
9663 if (!first) {
9664 b.append(' ');
9665 }
9666 first = false;
9667 b.append("u=").append(mContentUserHint);
9668 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009669 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009670 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009671 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009672 b.append("}");
9673 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009674 }
9675
Yi Jin129fc6c2017-09-28 15:48:38 -07009676 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009677 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9678 // Same input parameters that toString() gives to toShortString().
9679 writeToProto(proto, fieldId, true, true, true, false);
9680 }
9681
9682 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009683 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9684 boolean extras, boolean clip) {
9685 long token = proto.start(fieldId);
9686 if (mAction != null) {
9687 proto.write(IntentProto.ACTION, mAction);
9688 }
9689 if (mCategories != null) {
9690 for (String category : mCategories) {
9691 proto.write(IntentProto.CATEGORIES, category);
9692 }
9693 }
9694 if (mData != null) {
9695 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9696 }
9697 if (mType != null) {
9698 proto.write(IntentProto.TYPE, mType);
9699 }
9700 if (mFlags != 0) {
9701 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9702 }
9703 if (mPackage != null) {
9704 proto.write(IntentProto.PACKAGE, mPackage);
9705 }
9706 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009707 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009708 }
9709 if (mSourceBounds != null) {
9710 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9711 }
9712 if (mClipData != null) {
9713 StringBuilder b = new StringBuilder();
9714 if (clip) {
9715 mClipData.toShortString(b);
9716 } else {
9717 mClipData.toShortStringShortItems(b, false);
9718 }
9719 proto.write(IntentProto.CLIP_DATA, b.toString());
9720 }
9721 if (extras && mExtras != null) {
9722 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9723 }
9724 if (mContentUserHint != 0) {
9725 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9726 }
9727 if (mSelector != null) {
9728 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9729 }
9730 proto.end(token);
9731 }
9732
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009733 /**
9734 * Call {@link #toUri} with 0 flags.
9735 * @deprecated Use {@link #toUri} instead.
9736 */
9737 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009738 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009739 return toUri(0);
9740 }
9741
9742 /**
9743 * Convert this Intent into a String holding a URI representation of it.
9744 * The returned URI string has been properly URI encoded, so it can be
9745 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9746 * Intent's data as the base URI, with an additional fragment describing
9747 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009748 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009749 * <p>You can convert the returned string back to an Intent with
9750 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009751 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009752 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009753 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009754 * @return Returns a URI encoding URI string describing the entire contents
9755 * of the Intent.
9756 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009757 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009758 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009759 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9760 if (mPackage == null) {
9761 throw new IllegalArgumentException(
9762 "Intent must include an explicit package name to build an android-app: "
9763 + this);
9764 }
9765 uri.append("android-app://");
9766 uri.append(mPackage);
9767 String scheme = null;
9768 if (mData != null) {
9769 scheme = mData.getScheme();
9770 if (scheme != null) {
9771 uri.append('/');
9772 uri.append(scheme);
9773 String authority = mData.getEncodedAuthority();
9774 if (authority != null) {
9775 uri.append('/');
9776 uri.append(authority);
9777 String path = mData.getEncodedPath();
9778 if (path != null) {
9779 uri.append(path);
9780 }
9781 String queryParams = mData.getEncodedQuery();
9782 if (queryParams != null) {
9783 uri.append('?');
9784 uri.append(queryParams);
9785 }
9786 String fragment = mData.getEncodedFragment();
9787 if (fragment != null) {
9788 uri.append('#');
9789 uri.append(fragment);
9790 }
9791 }
9792 }
9793 }
9794 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9795 mPackage, flags);
9796 return uri.toString();
9797 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009798 String scheme = null;
9799 if (mData != null) {
9800 String data = mData.toString();
9801 if ((flags&URI_INTENT_SCHEME) != 0) {
9802 final int N = data.length();
9803 for (int i=0; i<N; i++) {
9804 char c = data.charAt(i);
9805 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009806 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009807 continue;
9808 }
9809 if (c == ':' && i > 0) {
9810 // Valid scheme.
9811 scheme = data.substring(0, i);
9812 uri.append("intent:");
9813 data = data.substring(i+1);
9814 break;
9815 }
Tom Taylord4a47292009-12-21 13:59:18 -08009816
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009817 // No scheme.
9818 break;
9819 }
9820 }
9821 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009822
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009823 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9824 uri.append("intent:");
9825 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009826
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009827 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009828
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009829 return uri.toString();
9830 }
9831
9832 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9833 String defPackage, int flags) {
9834 StringBuilder frag = new StringBuilder(128);
9835
9836 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009837 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009838 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009839 // Note that for now we are not going to try to handle the
9840 // data part; not clear how to represent this as a URI, and
9841 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009842 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9843 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009844 }
9845
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009846 if (frag.length() > 0) {
9847 uri.append("#Intent;");
9848 uri.append(frag);
9849 uri.append("end");
9850 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009851 }
9852
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009853 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9854 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009855 if (scheme != null) {
9856 uri.append("scheme=").append(scheme).append(';');
9857 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009858 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009859 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009860 }
9861 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009862 for (int i=0; i<mCategories.size(); i++) {
9863 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009864 }
9865 }
9866 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009867 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009868 }
9869 if (mFlags != 0) {
9870 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9871 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009872 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009873 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9874 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009875 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009876 uri.append("component=").append(Uri.encode(
9877 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009878 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009879 if (mSourceBounds != null) {
9880 uri.append("sourceBounds=")
9881 .append(Uri.encode(mSourceBounds.flattenToString()))
9882 .append(';');
9883 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009884 if (mExtras != null) {
9885 for (String key : mExtras.keySet()) {
9886 final Object value = mExtras.get(key);
9887 char entryType =
9888 value instanceof String ? 'S' :
9889 value instanceof Boolean ? 'B' :
9890 value instanceof Byte ? 'b' :
9891 value instanceof Character ? 'c' :
9892 value instanceof Double ? 'd' :
9893 value instanceof Float ? 'f' :
9894 value instanceof Integer ? 'i' :
9895 value instanceof Long ? 'l' :
9896 value instanceof Short ? 's' :
9897 '\0';
9898
9899 if (entryType != '\0') {
9900 uri.append(entryType);
9901 uri.append('.');
9902 uri.append(Uri.encode(key));
9903 uri.append('=');
9904 uri.append(Uri.encode(value.toString()));
9905 uri.append(';');
9906 }
9907 }
9908 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009909 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009910
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009911 public int describeContents() {
9912 return (mExtras != null) ? mExtras.describeContents() : 0;
9913 }
9914
9915 public void writeToParcel(Parcel out, int flags) {
9916 out.writeString(mAction);
9917 Uri.writeToParcel(out, mData);
9918 out.writeString(mType);
9919 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009920 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009921 ComponentName.writeToParcel(mComponent, out);
9922
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009923 if (mSourceBounds != null) {
9924 out.writeInt(1);
9925 mSourceBounds.writeToParcel(out, flags);
9926 } else {
9927 out.writeInt(0);
9928 }
9929
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009930 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009931 final int N = mCategories.size();
9932 out.writeInt(N);
9933 for (int i=0; i<N; i++) {
9934 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009935 }
9936 } else {
9937 out.writeInt(0);
9938 }
9939
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009940 if (mSelector != null) {
9941 out.writeInt(1);
9942 mSelector.writeToParcel(out, flags);
9943 } else {
9944 out.writeInt(0);
9945 }
9946
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009947 if (mClipData != null) {
9948 out.writeInt(1);
9949 mClipData.writeToParcel(out, flags);
9950 } else {
9951 out.writeInt(0);
9952 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009953 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009954 out.writeBundle(mExtras);
9955 }
9956
9957 public static final Parcelable.Creator<Intent> CREATOR
9958 = new Parcelable.Creator<Intent>() {
9959 public Intent createFromParcel(Parcel in) {
9960 return new Intent(in);
9961 }
9962 public Intent[] newArray(int size) {
9963 return new Intent[size];
9964 }
9965 };
9966
Dianne Hackborneb034652009-09-07 00:49:58 -07009967 /** @hide */
9968 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009969 readFromParcel(in);
9970 }
9971
9972 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009973 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009974 mData = Uri.CREATOR.createFromParcel(in);
9975 mType = in.readString();
9976 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009977 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009978 mComponent = ComponentName.readFromParcel(in);
9979
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009980 if (in.readInt() != 0) {
9981 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9982 }
9983
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009984 int N = in.readInt();
9985 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009986 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009987 int i;
9988 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009989 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009990 }
9991 } else {
9992 mCategories = null;
9993 }
9994
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009995 if (in.readInt() != 0) {
9996 mSelector = new Intent(in);
9997 }
9998
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009999 if (in.readInt() != 0) {
10000 mClipData = new ClipData(in);
10001 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010002 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010003 mExtras = in.readBundle();
10004 }
10005
10006 /**
10007 * Parses the "intent" element (and its children) from XML and instantiates
10008 * an Intent object. The given XML parser should be located at the tag
10009 * where parsing should start (often named "intent"), from which the
10010 * basic action, data, type, and package and class name will be
10011 * retrieved. The function will then parse in to any child elements,
10012 * looking for <category android:name="xxx"> tags to add categories and
10013 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10014 * to the intent.
10015 *
10016 * @param resources The Resources to use when inflating resources.
10017 * @param parser The XML parser pointing at an "intent" tag.
10018 * @param attrs The AttributeSet interface for retrieving extended
10019 * attribute data at the current <var>parser</var> location.
10020 * @return An Intent object matching the XML data.
10021 * @throws XmlPullParserException If there was an XML parsing error.
10022 * @throws IOException If there was an I/O error.
10023 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010024 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10025 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010026 throws XmlPullParserException, IOException {
10027 Intent intent = new Intent();
10028
10029 TypedArray sa = resources.obtainAttributes(attrs,
10030 com.android.internal.R.styleable.Intent);
10031
10032 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10033
10034 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10035 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10036 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10037
10038 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10039 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10040 if (packageName != null && className != null) {
10041 intent.setComponent(new ComponentName(packageName, className));
10042 }
10043
10044 sa.recycle();
10045
10046 int outerDepth = parser.getDepth();
10047 int type;
10048 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10049 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10050 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10051 continue;
10052 }
10053
10054 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010055 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010056 sa = resources.obtainAttributes(attrs,
10057 com.android.internal.R.styleable.IntentCategory);
10058 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10059 sa.recycle();
10060
10061 if (cat != null) {
10062 intent.addCategory(cat);
10063 }
10064 XmlUtils.skipCurrentTag(parser);
10065
Craig Mautner21d24a22014-04-23 11:45:37 -070010066 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010067 if (intent.mExtras == null) {
10068 intent.mExtras = new Bundle();
10069 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010070 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010071 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010072
10073 } else {
10074 XmlUtils.skipCurrentTag(parser);
10075 }
10076 }
10077
10078 return intent;
10079 }
Nick Pellyccae4122012-01-09 14:12:58 -080010080
Craig Mautner21d24a22014-04-23 11:45:37 -070010081 /** @hide */
10082 public void saveToXml(XmlSerializer out) throws IOException {
10083 if (mAction != null) {
10084 out.attribute(null, ATTR_ACTION, mAction);
10085 }
10086 if (mData != null) {
10087 out.attribute(null, ATTR_DATA, mData.toString());
10088 }
10089 if (mType != null) {
10090 out.attribute(null, ATTR_TYPE, mType);
10091 }
10092 if (mComponent != null) {
10093 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10094 }
10095 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10096
10097 if (mCategories != null) {
10098 out.startTag(null, TAG_CATEGORIES);
10099 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10100 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10101 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010102 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010103 }
10104 }
10105
10106 /** @hide */
10107 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10108 XmlPullParserException {
10109 Intent intent = new Intent();
10110 final int outerDepth = in.getDepth();
10111
10112 int attrCount = in.getAttributeCount();
10113 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10114 final String attrName = in.getAttributeName(attrNdx);
10115 final String attrValue = in.getAttributeValue(attrNdx);
10116 if (ATTR_ACTION.equals(attrName)) {
10117 intent.setAction(attrValue);
10118 } else if (ATTR_DATA.equals(attrName)) {
10119 intent.setData(Uri.parse(attrValue));
10120 } else if (ATTR_TYPE.equals(attrName)) {
10121 intent.setType(attrValue);
10122 } else if (ATTR_COMPONENT.equals(attrName)) {
10123 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10124 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010125 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010126 } else {
10127 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10128 }
10129 }
10130
10131 int event;
10132 String name;
10133 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10134 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10135 if (event == XmlPullParser.START_TAG) {
10136 name = in.getName();
10137 if (TAG_CATEGORIES.equals(name)) {
10138 attrCount = in.getAttributeCount();
10139 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10140 intent.addCategory(in.getAttributeValue(attrNdx));
10141 }
10142 } else {
10143 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10144 XmlUtils.skipCurrentTag(in);
10145 }
10146 }
10147 }
10148
10149 return intent;
10150 }
10151
Nick Pellyccae4122012-01-09 14:12:58 -080010152 /**
10153 * Normalize a MIME data type.
10154 *
10155 * <p>A normalized MIME type has white-space trimmed,
10156 * content-type parameters removed, and is lower-case.
10157 * This aligns the type with Android best practices for
10158 * intent filtering.
10159 *
10160 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10161 * "text/x-vCard" becomes "text/x-vcard".
10162 *
10163 * <p>All MIME types received from outside Android (such as user input,
10164 * or external sources like Bluetooth, NFC, or the Internet) should
10165 * be normalized before they are used to create an Intent.
10166 *
10167 * @param type MIME data type to normalize
10168 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010169 * @see #setType
10170 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010171 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010172 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010173 if (type == null) {
10174 return null;
10175 }
10176
Elliott Hughescb64d432013-08-02 10:00:44 -070010177 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010178
10179 final int semicolonIndex = type.indexOf(';');
10180 if (semicolonIndex != -1) {
10181 type = type.substring(0, semicolonIndex);
10182 }
10183 return type;
10184 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010185
10186 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010187 * Prepare this {@link Intent} to leave an app process.
10188 *
10189 * @hide
10190 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010191 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010192 public void prepareToLeaveProcess(Context context) {
10193 final boolean leavingPackage = (mComponent == null)
10194 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10195 prepareToLeaveProcess(leavingPackage);
10196 }
10197
10198 /**
10199 * Prepare this {@link Intent} to leave an app process.
10200 *
10201 * @hide
10202 */
10203 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010204 setAllowFds(false);
10205
10206 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010207 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010208 }
10209 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010210 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010211 }
10212
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010213 if (mExtras != null && !mExtras.isParcelled()) {
10214 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10215 if (intent instanceof Intent) {
10216 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10217 }
10218 }
10219
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010220 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10221 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010222 switch (mAction) {
10223 case ACTION_MEDIA_REMOVED:
10224 case ACTION_MEDIA_UNMOUNTED:
10225 case ACTION_MEDIA_CHECKING:
10226 case ACTION_MEDIA_NOFS:
10227 case ACTION_MEDIA_MOUNTED:
10228 case ACTION_MEDIA_SHARED:
10229 case ACTION_MEDIA_UNSHARED:
10230 case ACTION_MEDIA_BAD_REMOVAL:
10231 case ACTION_MEDIA_UNMOUNTABLE:
10232 case ACTION_MEDIA_EJECT:
10233 case ACTION_MEDIA_SCANNER_STARTED:
10234 case ACTION_MEDIA_SCANNER_FINISHED:
10235 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010236 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10237 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010238 // Ignore legacy actions
10239 break;
10240 default:
10241 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010242 }
10243 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010244
10245 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10246 && leavingPackage) {
10247 switch (mAction) {
10248 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010249 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010250 // Ignore actions that don't need to grant
10251 break;
10252 default:
10253 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10254 }
10255 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010256 }
10257
10258 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010259 * @hide
10260 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010261 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010262 // We just entered destination process, so we should be able to read all
10263 // parcelables inside.
10264 setDefusable(true);
10265
10266 if (mSelector != null) {
10267 mSelector.prepareToEnterProcess();
10268 }
10269 if (mClipData != null) {
10270 mClipData.prepareToEnterProcess();
10271 }
10272
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010273 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010274 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10275 fixUris(mContentUserHint);
10276 mContentUserHint = UserHandle.USER_CURRENT;
10277 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010278 }
10279 }
10280
Patrick Baumann577d4022018-01-31 16:55:10 +000010281 /** @hide */
10282 public boolean hasWebURI() {
10283 if (getData() == null) {
10284 return false;
10285 }
10286 final String scheme = getScheme();
10287 if (TextUtils.isEmpty(scheme)) {
10288 return false;
10289 }
10290 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10291 }
10292
10293 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010294 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010295 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010296 && hasWebURI();
10297 }
10298
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010299 /**
10300 * @hide
10301 */
10302 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010303 Uri data = getData();
10304 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010305 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010306 }
10307 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010308 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010309 }
10310 String action = getAction();
10311 if (ACTION_SEND.equals(action)) {
10312 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10313 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010314 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010315 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010316 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010317 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10318 if (streams != null) {
10319 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10320 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010321 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010322 }
10323 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10324 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010325 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10326 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10327 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10328 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10329 if (output != null) {
10330 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10331 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010332 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010333 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010334
10335 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010336 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010337 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10338 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010339 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010340 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010341 * @hide
10342 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010343 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010344 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010345 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010346
10347 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010348 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010349
10350 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010351 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010352 // Inspect contained intents to see if we need to migrate extras. We
10353 // don't promote ClipData to the parent, since ChooserActivity will
10354 // already start the picked item as the caller, and we can't combine
10355 // the flags in a safe way.
10356
10357 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010358 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010359 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10360 if (intent != null) {
10361 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010362 }
10363 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010364 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010365 try {
10366 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10367 if (intents != null) {
10368 for (int i = 0; i < intents.length; i++) {
10369 final Intent intent = (Intent) intents[i];
10370 if (intent != null) {
10371 migrated |= intent.migrateExtraStreamToClipData();
10372 }
10373 }
10374 }
10375 } catch (ClassCastException e) {
10376 }
10377 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010378
10379 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010380 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010381 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10382 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10383 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10384 if (stream != null || text != null || htmlText != null) {
10385 final ClipData clipData = new ClipData(
10386 null, new String[] { getType() },
10387 new ClipData.Item(text, htmlText, null, stream));
10388 setClipData(clipData);
10389 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010390 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010391 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010392 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010393 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010394
10395 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010396 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010397 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10398 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10399 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10400 int num = -1;
10401 if (streams != null) {
10402 num = streams.size();
10403 }
10404 if (texts != null) {
10405 if (num >= 0 && num != texts.size()) {
10406 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010407 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010408 }
10409 num = texts.size();
10410 }
10411 if (htmlTexts != null) {
10412 if (num >= 0 && num != htmlTexts.size()) {
10413 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010414 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010415 }
10416 num = htmlTexts.size();
10417 }
10418 if (num > 0) {
10419 final ClipData clipData = new ClipData(
10420 null, new String[] { getType() },
10421 makeClipItem(streams, texts, htmlTexts, 0));
10422
10423 for (int i = 1; i < num; i++) {
10424 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10425 }
10426
10427 setClipData(clipData);
10428 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010429 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010430 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010431 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010432 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010433 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10434 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10435 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10436 final Uri output;
10437 try {
10438 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10439 } catch (ClassCastException e) {
10440 return false;
10441 }
10442 if (output != null) {
10443 setClipData(ClipData.newRawUri("", output));
10444 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10445 return true;
10446 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010447 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010448
10449 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010450 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010451
Michael Wright19859762017-09-18 20:57:58 +010010452 /**
10453 * Convert the dock state to a human readable format.
10454 * @hide
10455 */
10456 public static String dockStateToString(int dock) {
10457 switch (dock) {
10458 case EXTRA_DOCK_STATE_HE_DESK:
10459 return "EXTRA_DOCK_STATE_HE_DESK";
10460 case EXTRA_DOCK_STATE_LE_DESK:
10461 return "EXTRA_DOCK_STATE_LE_DESK";
10462 case EXTRA_DOCK_STATE_CAR:
10463 return "EXTRA_DOCK_STATE_CAR";
10464 case EXTRA_DOCK_STATE_DESK:
10465 return "EXTRA_DOCK_STATE_DESK";
10466 case EXTRA_DOCK_STATE_UNDOCKED:
10467 return "EXTRA_DOCK_STATE_UNDOCKED";
10468 default:
10469 return Integer.toString(dock);
10470 }
10471 }
10472
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010473 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10474 ArrayList<String> htmlTexts, int which) {
10475 Uri uri = streams != null ? streams.get(which) : null;
10476 CharSequence text = texts != null ? texts.get(which) : null;
10477 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10478 return new ClipData.Item(text, htmlText, null, uri);
10479 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010480
10481 /** @hide */
10482 public boolean isDocument() {
10483 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10484 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010485}