blob: 9543ad22ce2beff2b014f62122a2f49a05a6c856 [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 /**
Varun Shahb9fd6be2018-10-22 19:16:33 -07001729 * A string that associates with a metadata entry, indicating the last run version of the
1730 * platform that was setup.
1731 *
1732 * @see #ACTION_UPGRADE_SETUP
1733 *
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001734 * @hide
1735 */
Varun Shahb9fd6be2018-10-22 19:16:33 -07001736 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001737 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1738
Svet Ganov3695b8a2015-03-24 16:30:25 -07001739 /**
1740 * Activity action: Launch UI to manage the permissions of an app.
1741 * <p>
1742 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1743 * will be managed by the launched UI.
1744 * </p>
1745 * <p>
1746 * Output: Nothing.
1747 * </p>
1748 *
1749 * @see #EXTRA_PACKAGE_NAME
1750 *
1751 * @hide
1752 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001753 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001754 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1755 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1756 "android.intent.action.MANAGE_APP_PERMISSIONS";
1757
1758 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001759 * Activity action: Launch UI to manage permissions.
1760 * <p>
1761 * Input: Nothing.
1762 * </p>
1763 * <p>
1764 * Output: Nothing.
1765 * </p>
1766 *
1767 * @hide
1768 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001769 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001770 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1771 public static final String ACTION_MANAGE_PERMISSIONS =
1772 "android.intent.action.MANAGE_PERMISSIONS";
1773
1774 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001775 * Activity action: Launch UI to review permissions for an app.
1776 * The system uses this intent if permission review for apps not
1777 * supporting the new runtime permissions model is enabled. In
1778 * this mode a permission review is required before any of the
1779 * app components can run.
1780 * <p>
1781 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1782 * permissions will be reviewed (mandatory).
1783 * </p>
1784 * <p>
1785 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1786 * be fired after the permission review (optional).
1787 * </p>
1788 * <p>
1789 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1790 * be invoked after the permission review (optional).
1791 * </p>
1792 * <p>
1793 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1794 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1795 * </p>
1796 * <p>
1797 * Output: Nothing.
1798 * </p>
1799 *
1800 * @see #EXTRA_PACKAGE_NAME
1801 * @see #EXTRA_INTENT
1802 * @see #EXTRA_REMOTE_CALLBACK
1803 * @see #EXTRA_RESULT_NEEDED
1804 *
1805 * @hide
1806 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001807 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001808 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1809 public static final String ACTION_REVIEW_PERMISSIONS =
1810 "android.intent.action.REVIEW_PERMISSIONS";
1811
1812 /**
1813 * Intent extra: A callback for reporting remote result as a bundle.
1814 * <p>
1815 * Type: IRemoteCallback
1816 * </p>
1817 *
1818 * @hide
1819 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001820 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001821 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1822
1823 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001824 * Intent extra: An app package name.
1825 * <p>
1826 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001827 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001828 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001829 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001830 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1831
1832 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001833 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1834 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1835 *
1836 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1837 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1838 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001839 *
1840 * @see #ACTION_MY_PACKAGE_SUSPENDED
1841 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1842 * @see PackageManager#isPackageSuspended()
1843 * @see PackageManager#getSuspendedPackageAppExtras()
1844 */
1845 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1846
1847 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001848 * Intent extra: An app split name.
1849 * <p>
1850 * Type: String
1851 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001852 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001853 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1854
1855 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001856 * Intent extra: A {@link ComponentName} value.
1857 * <p>
1858 * Type: String
1859 * </p>
1860 */
1861 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1862
1863 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001864 * Intent extra: An extra for specifying whether a result is needed.
1865 * <p>
1866 * Type: boolean
1867 * </p>
1868 *
1869 * @hide
1870 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001871 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001872 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1873
1874 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001875 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1876 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1877 *
1878 * @see PackageManager#isPackageSuspended()
1879 * @see #ACTION_PACKAGES_SUSPENDED
1880 *
1881 * @hide
1882 */
1883 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1884
1885 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001886 * Activity action: Launch UI to manage which apps have a given permission.
1887 * <p>
1888 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1889 * to which will be managed by the launched UI.
1890 * </p>
1891 * <p>
1892 * Output: Nothing.
1893 * </p>
1894 *
1895 * @see #EXTRA_PERMISSION_NAME
1896 *
1897 * @hide
1898 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001899 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001900 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1901 public static final String ACTION_MANAGE_PERMISSION_APPS =
1902 "android.intent.action.MANAGE_PERMISSION_APPS";
1903
1904 /**
1905 * Intent extra: The name of a permission.
1906 * <p>
1907 * Type: String
1908 * </p>
1909 *
1910 * @hide
1911 */
1912 @SystemApi
1913 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1914
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001915 // ---------------------------------------------------------------------
1916 // ---------------------------------------------------------------------
1917 // Standard intent broadcast actions (see action variable).
1918
1919 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001920 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1921 * <p>
1922 * For historical reasons, the name of this broadcast action refers to the power
1923 * state of the screen but it is actually sent in response to changes in the
1924 * overall interactive state of the device.
1925 * </p><p>
1926 * This broadcast is sent when the device becomes non-interactive which may have
1927 * nothing to do with the screen turning off. To determine the
1928 * actual state of the screen, use {@link android.view.Display#getState}.
1929 * </p><p>
1930 * See {@link android.os.PowerManager#isInteractive} for details.
1931 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001932 * You <em>cannot</em> receive this through components declared in
1933 * manifests, only by explicitly registering for it with
1934 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1935 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001936 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001937 * <p class="note">This is a protected intent that can only be sent
1938 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001939 */
1940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1941 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001942
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001943 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001944 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1945 * <p>
1946 * For historical reasons, the name of this broadcast action refers to the power
1947 * state of the screen but it is actually sent in response to changes in the
1948 * overall interactive state of the device.
1949 * </p><p>
1950 * This broadcast is sent when the device becomes interactive which may have
1951 * nothing to do with the screen turning on. To determine the
1952 * actual state of the screen, use {@link android.view.Display#getState}.
1953 * </p><p>
1954 * See {@link android.os.PowerManager#isInteractive} for details.
1955 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001956 * You <em>cannot</em> receive this through components declared in
1957 * manifests, only by explicitly registering for it with
1958 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1959 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001960 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001961 * <p class="note">This is a protected intent that can only be sent
1962 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001963 */
1964 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1965 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001966
1967 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001968 * Broadcast Action: Sent after the system stops dreaming.
1969 *
1970 * <p class="note">This is a protected intent that can only be sent by the system.
1971 * It is only sent to registered receivers.</p>
1972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1975
1976 /**
1977 * Broadcast Action: Sent after the system starts dreaming.
1978 *
1979 * <p class="note">This is a protected intent that can only be sent by the system.
1980 * It is only sent to registered receivers.</p>
1981 */
1982 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1983 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1984
1985 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001986 * 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 -07001987 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001989 * <p class="note">This is a protected intent that can only be sent
1990 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001993 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001994
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 /**
1996 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001997 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001998 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001999 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2000 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002001 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002002 * <p class="note">This is a protected intent that can only be sent
2003 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002004 */
2005 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2006 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2007 /**
2008 * Broadcast Action: The time was set.
2009 */
2010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2011 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2012 /**
2013 * Broadcast Action: The date has changed.
2014 */
2015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2016 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2017 /**
2018 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2019 * <ul>
2020 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2021 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002022 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002023 * <p class="note">This is a protected intent that can only be sent
2024 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002025 */
2026 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2027 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2028 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002029 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2030 * DNS entries should be tossed.
2031 * @hide
2032 */
2033 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2034 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2035 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002036 * Alarm Changed Action: This is broadcast when the AlarmClock
2037 * application's alarm is set or unset. It is used by the
2038 * AlarmClock application and the StatusBar service.
2039 * @hide
2040 */
2041 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002042 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002043 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002044
2045 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002046 * Broadcast Action: This is broadcast once, after the user has finished
2047 * booting, but while still in the "locked" state. It can be used to perform
2048 * application-specific initialization, such as installing alarms. You must
2049 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2050 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002051 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002052 * This broadcast is sent immediately at boot by all devices (regardless of
2053 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2054 * higher. Upon receipt of this broadcast, the user is still locked and only
2055 * device-protected storage can be accessed safely. If you want to access
2056 * credential-protected storage, you need to wait for the user to be
2057 * unlocked (typically by entering their lock pattern or PIN for the first
2058 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2059 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2060 * <p>
2061 * To receive this broadcast, your receiver component must be marked as
2062 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002063 * <p class="note">
2064 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002065 *
2066 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002067 */
2068 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2069 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2070
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002071 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002072 * Broadcast Action: This is broadcast once, after the user has finished
2073 * booting. It can be used to perform application-specific initialization,
2074 * such as installing alarms. You must hold the
2075 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2076 * order to receive this broadcast.
2077 * <p>
2078 * This broadcast is sent at boot by all devices (both with and without
2079 * direct boot support). Upon receipt of this broadcast, the user is
2080 * unlocked and both device-protected and credential-protected storage can
2081 * accessed safely.
2082 * <p>
2083 * If you need to run while the user is still locked (before they've entered
2084 * their lock pattern or PIN for the first time), you can listen for the
2085 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2086 * <p class="note">
2087 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002088 */
2089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002090 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002091 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002092
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002093 /**
2094 * Broadcast Action: This is broadcast when a user action should request a
2095 * temporary system dialog to dismiss. Some examples of temporary system
2096 * dialogs are the notification window-shade and the recent tasks dialog.
2097 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002099 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2100 /**
2101 * Broadcast Action: Trigger the download and eventual installation
2102 * of a package.
2103 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002104 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002105 * <p class="note">This is a protected intent that can only be sent
2106 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002107 *
2108 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002109 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002110 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002111 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2112 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2113 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002114 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002115 * device. The data contains the name of the package. Note that the
2116 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002117 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002118 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002119 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2120 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002121 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2122 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002123 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2129 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002130 * Broadcast Action: A new version of an application package has been
2131 * installed, replacing an existing version that was previously installed.
2132 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002133 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002134 * <ul>
2135 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2136 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002137 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002138 * <p class="note">This is a protected intent that can only be sent
2139 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002140 */
2141 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2142 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2143 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002144 * Broadcast Action: A new version of your application has been installed
2145 * over an existing one. This is only sent to the application that was
2146 * replaced. It does not contain any additional data; to receive it, just
2147 * use an intent filter for this action.
2148 *
2149 * <p class="note">This is a protected intent that can only be sent
2150 * by the system.
2151 */
2152 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2153 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2154 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 * Broadcast Action: An existing application package has been removed from
2156 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002157 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002158 * <ul>
2159 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2160 * to the package.
2161 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2162 * application -- data and code -- is being removed.
2163 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2164 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2165 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002166 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002167 * <p class="note">This is a protected intent that can only be sent
2168 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2172 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002173 * Broadcast Action: An existing application package has been completely
2174 * removed from the device. The data contains the name of the package.
2175 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2176 * {@link #EXTRA_DATA_REMOVED} is true and
2177 * {@link #EXTRA_REPLACING} is false of that broadcast.
2178 *
2179 * <ul>
2180 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2181 * to the package.
2182 * </ul>
2183 *
2184 * <p class="note">This is a protected intent that can only be sent
2185 * by the system.
2186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_PACKAGE_FULLY_REMOVED
2189 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2190 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002191 * Broadcast Action: An existing application package has been changed (for
2192 * example, a component has been enabled or disabled). The data contains
2193 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002194 * <ul>
2195 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002196 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002197 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002198 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2199 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002200 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002201 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002202 * <p class="note">This is a protected intent that can only be sent
2203 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2207 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002208 * @hide
2209 * Broadcast Action: Ask system services if there is any reason to
2210 * restart the given package. The data contains the name of the
2211 * package.
2212 * <ul>
2213 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2214 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2215 * </ul>
2216 *
2217 * <p class="note">This is a protected intent that can only be sent
2218 * by the system.
2219 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002220 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2223 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002224 * Broadcast Action: The user has restarted a package, and all of its
2225 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002226 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002227 * be removed. Note that the restarted package does <em>not</em>
2228 * receive this broadcast.
2229 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002230 * <ul>
2231 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2232 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002233 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002234 * <p class="note">This is a protected intent that can only be sent
2235 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002236 */
2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2238 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2239 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002240 * Broadcast Action: The user has cleared the data of a package. This should
2241 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002242 * its persistent data is erased and this broadcast sent.
2243 * Note that the cleared package does <em>not</em>
2244 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002245 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002246 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2247 * package whose data was cleared is an uninstalled instant app, then the UID
2248 * will be -1. The platform keeps some meta-data associated with instant apps
2249 * after they are uninstalled.
2250 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2251 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002252 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002253 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002254 * <p class="note">This is a protected intent that can only be sent
2255 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2259 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002260 * Broadcast Action: Packages have been suspended.
2261 * <p>Includes the following extras:
2262 * <ul>
2263 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002264 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002265 * </ul>
2266 *
2267 * <p class="note">This is a protected intent that can only be sent
2268 * by the system. It is only sent to registered receivers.
2269 */
2270 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2271 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2272 /**
2273 * Broadcast Action: Packages have been unsuspended.
2274 * <p>Includes the following extras:
2275 * <ul>
2276 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002277 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002278 * </ul>
2279 *
2280 * <p class="note">This is a protected intent that can only be sent
2281 * by the system. It is only sent to registered receivers.
2282 */
2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2284 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002285
2286 /**
2287 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002288 * whenever a package is put into a suspended state or any of its app extras change while in the
2289 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002290 * <p> Optionally includes the following extras:
2291 * <ul>
2292 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2293 * useful information for the app being suspended.
2294 * </ul>
2295 * <p class="note">This is a protected intent that can only be sent
2296 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2297 * the manifest.</em>
2298 *
2299 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2300 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2301 * @see PackageManager#isPackageSuspended()
2302 * @see PackageManager#getSuspendedPackageAppExtras()
2303 */
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2306
2307 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002308 * Activity Action: Started to show more details about why an application was suspended.
2309 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002310 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2311 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002312 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002313 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2314 * handling this intent and protect it with
2315 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2316 *
2317 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2318 *
2319 * <p class="note">This is a protected intent that can only be sent
2320 * by the system.
2321 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002322 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2323 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002324 * @see PackageManager#isPackageSuspended()
2325 * @see #ACTION_PACKAGES_SUSPENDED
2326 *
2327 * @hide
2328 */
2329 @SystemApi
2330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2331 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2332 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2333
2334 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002335 * Broadcast Action: Sent to a package that has been unsuspended.
2336 *
2337 * <p class="note">This is a protected intent that can only be sent
2338 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2339 * the manifest.</em>
2340 *
2341 * @see #ACTION_MY_PACKAGE_SUSPENDED
2342 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2343 * @see PackageManager#isPackageSuspended()
2344 * @see PackageManager#getSuspendedPackageAppExtras()
2345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2347 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2348
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002349 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002350 * Broadcast Action: A user ID has been removed from the system. The user
2351 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002352 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002353 * <p class="note">This is a protected intent that can only be sent
2354 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002355 */
2356 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2357 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002358
2359 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002360 * Broadcast Action: Sent to the installer package of an application when
2361 * that application is first launched (that is the first time it is moved
2362 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002363 *
2364 * <p class="note">This is a protected intent that can only be sent
2365 * by the system.
2366 */
2367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2368 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2369
2370 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002371 * Broadcast Action: Sent to the system package verifier when a package
2372 * needs to be verified. The data contains the package URI.
2373 * <p class="note">
2374 * This is a protected intent that can only be sent by the system.
2375 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002376 */
2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2378 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2379
2380 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002381 * Broadcast Action: Sent to the system package verifier when a package is
2382 * verified. The data contains the package URI.
2383 * <p class="note">
2384 * This is a protected intent that can only be sent by the system.
2385 */
2386 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2387 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2388
2389 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002390 * Broadcast Action: Sent to the system intent filter verifier when an
2391 * intent filter needs to be verified. The data contains the filter data
2392 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002393 * <p class="note">
2394 * This is a protected intent that can only be sent by the system.
2395 * </p>
2396 *
2397 * @hide
2398 */
2399 @SystemApi
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2402
2403 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002404 * Broadcast Action: Resources for a set of packages (which were
2405 * previously unavailable) are currently
2406 * available since the media on which they exist is available.
2407 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2408 * list of packages whose availability changed.
2409 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2410 * list of uids of packages whose availability changed.
2411 * Note that the
2412 * packages in this list do <em>not</em> receive this broadcast.
2413 * The specified set of packages are now available on the system.
2414 * <p>Includes the following extras:
2415 * <ul>
2416 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2417 * whose resources(were previously unavailable) are currently available.
2418 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2419 * packages whose resources(were previously unavailable)
2420 * are currently available.
2421 * </ul>
2422 *
2423 * <p class="note">This is a protected intent that can only be sent
2424 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002425 */
2426 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002427 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2428 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002429
2430 /**
2431 * Broadcast Action: Resources for a set of packages are currently
2432 * unavailable since the media on which they exist is unavailable.
2433 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2434 * list of packages whose availability changed.
2435 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2436 * list of uids of packages whose availability changed.
2437 * The specified set of packages can no longer be
2438 * launched and are practically unavailable on the system.
2439 * <p>Inclues the following extras:
2440 * <ul>
2441 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2442 * whose resources are no longer available.
2443 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2444 * whose resources are no longer available.
2445 * </ul>
2446 *
2447 * <p class="note">This is a protected intent that can only be sent
2448 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002451 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002452 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002453
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002454 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002455 * Broadcast Action: preferred activities have changed *explicitly*.
2456 *
2457 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2458 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2459 * be sent.
2460 *
2461 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2462 *
2463 * @hide
2464 */
2465 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2466 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2467 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2468
2469
2470 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002471 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002472 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002473 * This should <em>only</em> be used to determine when the wallpaper
2474 * has changed to show the new wallpaper to the user. You should certainly
2475 * never, in response to this, change the wallpaper or other attributes of
2476 * it such as the suggested size. That would be crazy, right? You'd cause
2477 * all kinds of loops, especially if other apps are doing similar things,
2478 * right? Of course. So please don't do this.
2479 *
2480 * @deprecated Modern applications should use
2481 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2482 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2483 * shown behind their UI, rather than watching for this broadcast and
2484 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002485 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002486 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002487 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2488 /**
2489 * Broadcast Action: The current device {@link android.content.res.Configuration}
2490 * (orientation, locale, etc) has changed. When such a change happens, the
2491 * UIs (view hierarchy) will need to be rebuilt based on this new
2492 * information; for the most part, applications don't need to worry about
2493 * this, because the system will take care of stopping and restarting the
2494 * application to make sure it sees the new changes. Some system code that
2495 * can not be restarted will need to watch for this action and handle it
2496 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002497 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002498 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002499 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002500 * in manifests, only by explicitly registering for it with
2501 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2502 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002503 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002504 * <p class="note">This is a protected intent that can only be sent
2505 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002506 *
2507 * @see android.content.res.Configuration
2508 */
2509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2510 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002511
2512 /**
2513 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2514 * such that the device may be eligible for the installation of additional configuration splits.
2515 * Configuration properties that can trigger this broadcast include locale and display density.
2516 *
2517 * <p class="note">
2518 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2519 * components declared in manifests. However, the receiver <em>must</em> hold the
2520 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2521 *
2522 * <p class="note">
2523 * This is a protected intent that can only be sent by the system.
2524 *
2525 * @hide
2526 */
2527 @SystemApi
2528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2529 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2530 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002531 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002532 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002533 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002534 * <p class="note">This is a protected intent that can only be sent
2535 * by the system.
2536 */
2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2538 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2539 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002540 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2541 * charging state, level, and other information about the battery.
2542 * See {@link android.os.BatteryManager} for documentation on the
2543 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002544 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002546 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002547 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002548 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002549 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2550 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2551 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2552 * broadcasts that are sent and can be received through manifest
2553 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002554 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002555 * <p class="note">This is a protected intent that can only be sent
2556 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002557 */
2558 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2559 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002560
2561
2562 /**
2563 * Broadcast Action: Sent when the current battery level changes.
2564 *
2565 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2566 * instances representing individual battery level changes with associated
2567 * extras from {@link #ACTION_BATTERY_CHANGED}.
2568 *
2569 * <p class="note">
2570 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2571 *
2572 * @hide
2573 */
2574 @SystemApi
2575 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2576 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002577 /**
2578 * Broadcast Action: Indicates low battery condition on the device.
2579 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002580 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002581 * <p class="note">This is a protected intent that can only be sent
2582 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002583 */
2584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2585 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2586 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002587 * Broadcast Action: Indicates the battery is now okay after being low.
2588 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2589 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002590 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002591 * <p class="note">This is a protected intent that can only be sent
2592 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002593 */
2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2595 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2596 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002597 * Broadcast Action: External power has been connected to the device.
2598 * This is intended for applications that wish to register specifically to this notification.
2599 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2600 * stay active to receive this notification. This action can be used to implement actions
2601 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002602 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002603 * <p class="note">This is a protected intent that can only be sent
2604 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002607 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002608 /**
2609 * Broadcast Action: External power has been removed from the device.
2610 * This is intended for applications that wish to register specifically to this notification.
2611 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2612 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002613 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002614 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002615 * <p class="note">This is a protected intent that can only be sent
2616 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002619 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002620 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002621 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002622 * Broadcast Action: Device is shutting down.
2623 * This is broadcast when the device is being shut down (completely turned
2624 * off, not sleeping). Once the broadcast is complete, the final shutdown
2625 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002626 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002627 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2628 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2629 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002630 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002631 * <p class="note">This is a protected intent that can only be sent
2632 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002633 * <p>May include the following extras:
2634 * <ul>
2635 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2636 * shutdown is only for userspace processes. If not set, assumed to be false.
2637 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002638 */
2639 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002640 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002641 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002642 * Activity Action: Start this activity to request system shutdown.
2643 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002644 * to request confirmation from the user before shutting down. The optional boolean
2645 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2646 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002647 *
2648 * <p class="note">This is a protected intent that can only be sent
2649 * by the system.
2650 *
2651 * {@hide}
2652 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002653 public static final String ACTION_REQUEST_SHUTDOWN
2654 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002655 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002656 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002657 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002658 * <p class="note">
2659 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002660 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002661 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2662 * or above, this broadcast will no longer be delivered to any
2663 * {@link BroadcastReceiver} defined in your manifest. Instead,
2664 * apps are strongly encouraged to use the improved
2665 * {@link Context#getCacheDir()} behavior so the system can
2666 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002667 */
2668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002669 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002670 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2671 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002672 * Broadcast Action: Indicates low storage space condition on the device no
2673 * longer exists
2674 * <p class="note">
2675 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002676 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002677 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2678 * or above, this broadcast will no longer be delivered to any
2679 * {@link BroadcastReceiver} defined in your manifest. Instead,
2680 * apps are strongly encouraged to use the improved
2681 * {@link Context#getCacheDir()} behavior so the system can
2682 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002683 */
2684 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002685 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002686 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2687 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002688 * Broadcast Action: A sticky broadcast that indicates a storage space full
2689 * condition on the device. This is intended for activities that want to be
2690 * able to fill the data partition completely, leaving only enough free
2691 * space to prevent system-wide SQLite failures.
2692 * <p class="note">
2693 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002694 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002695 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2696 * or above, this broadcast will no longer be delivered to any
2697 * {@link BroadcastReceiver} defined in your manifest. Instead,
2698 * apps are strongly encouraged to use the improved
2699 * {@link Context#getCacheDir()} behavior so the system can
2700 * automatically free up storage when needed.
2701 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002702 */
2703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002704 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002705 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2706 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002707 * Broadcast Action: Indicates storage space full condition on the device no
2708 * longer exists.
2709 * <p class="note">
2710 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002711 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002712 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2713 * or above, this broadcast will no longer be delivered to any
2714 * {@link BroadcastReceiver} defined in your manifest. Instead,
2715 * apps are strongly encouraged to use the improved
2716 * {@link Context#getCacheDir()} behavior so the system can
2717 * automatically free up storage when needed.
2718 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002721 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002722 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2723 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002724 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2725 * and package management should be started.
2726 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2727 * notification.
2728 */
2729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2730 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2731 /**
2732 * Broadcast Action: The device has entered USB Mass Storage mode.
2733 * This is used mainly for the USB Settings panel.
2734 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2735 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002736 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002737 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002738 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002740 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2741
2742 /**
2743 * Broadcast Action: The device has exited USB Mass Storage mode.
2744 * This is used mainly for the USB Settings panel.
2745 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2746 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002747 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002748 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002749 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002751 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2752
2753 /**
2754 * Broadcast Action: External media has been removed.
2755 * The path to the mount point for the removed media is contained in the Intent.mData field.
2756 */
2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2759
2760 /**
2761 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002762 * 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 -07002763 */
2764 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2765 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2766
2767 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002768 * Broadcast Action: External media is present, and being disk-checked
2769 * 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 -08002770 */
2771 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2772 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2773
2774 /**
2775 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2776 * 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 -08002777 */
2778 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2779 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2780
2781 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002782 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002783 * 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 -07002784 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2785 * media was mounted read only.
2786 */
2787 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2788 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2789
2790 /**
2791 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002792 * 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 -07002793 */
2794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2795 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2796
2797 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002798 * Broadcast Action: External media is no longer being shared via USB mass storage.
2799 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2800 *
2801 * @hide
2802 */
2803 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2804
2805 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002806 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2807 * The path to the mount point for the removed media is contained in the Intent.mData field.
2808 */
2809 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2810 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2811
2812 /**
2813 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002814 * 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 -07002815 */
2816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2817 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2818
2819 /**
2820 * Broadcast Action: User has expressed the desire to remove the external storage media.
2821 * Applications should close all files they have open within the mount point when they receive this intent.
2822 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2823 */
2824 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2825 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2826
2827 /**
2828 * Broadcast Action: The media scanner has started scanning a directory.
2829 * The path to the directory being scanned is contained in the Intent.mData field.
2830 */
2831 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2833
2834 /**
2835 * Broadcast Action: The media scanner has finished scanning a directory.
2836 * The path to the scanned directory is contained in the Intent.mData field.
2837 */
2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2840
2841 /**
2842 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2843 * The path to the file is contained in the Intent.mData field.
2844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2847
2848 /**
2849 * Broadcast Action: The "Media Button" was pressed. Includes a single
2850 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2851 * caused the broadcast.
2852 */
2853 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2854 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2855
2856 /**
2857 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2858 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2859 * caused the broadcast.
2860 */
2861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2862 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2863
2864 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2865 // location; they are not general-purpose actions.
2866
2867 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002868 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002869 */
2870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2871 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2872 "android.intent.action.GTALK_CONNECTED";
2873
2874 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002875 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002876 */
2877 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2878 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2879 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002880
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002881 /**
2882 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002883 */
2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2885 public static final String ACTION_INPUT_METHOD_CHANGED =
2886 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002887
2888 /**
2889 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2890 * more radios have been turned off or on. The intent will have the following extra value:</p>
2891 * <ul>
2892 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2893 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2894 * turned off</li>
2895 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002896 *
Peng Xua35b5532016-01-20 00:05:45 -08002897 * <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 -07002898 */
2899 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2900 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2901
2902 /**
2903 * Broadcast Action: Some content providers have parts of their namespace
2904 * where they publish new events or items that the user may be especially
2905 * interested in. For these things, they may broadcast this action when the
2906 * set of interesting items change.
2907 *
2908 * For example, GmailProvider sends this notification when the set of unread
2909 * mail in the inbox changes.
2910 *
2911 * <p>The data of the intent identifies which part of which provider
2912 * changed. When queried through the content resolver, the data URI will
2913 * return the data set in question.
2914 *
2915 * <p>The intent will have the following extra values:
2916 * <ul>
2917 * <li><em>count</em> - The number of items in the data set. This is the
2918 * same as the number of items in the cursor returned by querying the
2919 * data URI. </li>
2920 * </ul>
2921 *
2922 * This intent will be sent at boot (if the count is non-zero) and when the
2923 * data set changes. It is possible for the data set to change without the
2924 * count changing (for example, if a new unread message arrives in the same
2925 * sync operation in which a message is archived). The phone should still
2926 * ring/vibrate/etc as normal in this case.
2927 */
2928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2929 public static final String ACTION_PROVIDER_CHANGED =
2930 "android.intent.action.PROVIDER_CHANGED";
2931
2932 /**
2933 * Broadcast Action: Wired Headset plugged in or unplugged.
2934 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002935 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2936 * and documentation.
2937 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002938 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002939 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002940 */
2941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002942 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002943
2944 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002945 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2946 * <ul>
2947 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2948 * </ul>
2949 *
2950 * <p class="note">This is a protected intent that can only be sent
2951 * by the system.
2952 *
2953 * @hide
2954 */
2955 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2956 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2957 = "android.intent.action.ADVANCED_SETTINGS";
2958
2959 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002960 * Broadcast Action: Sent after application restrictions are changed.
2961 *
2962 * <p class="note">This is a protected intent that can only be sent
2963 * by the system.</p>
2964 */
2965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2966 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2967 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2968
2969 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002970 * Broadcast Action: An outgoing call is about to be placed.
2971 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002972 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002973 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002974 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002975 * the phone number originally intended to be dialed.</li>
2976 * </ul>
2977 * <p>Once the broadcast is finished, the resultData is used as the actual
2978 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002979 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002980 * outgoing call in turn: for example, a parental control application
2981 * might verify that the user is authorized to place the call at that
2982 * time, then a number-rewriting application might add an area code if
2983 * one was not specified.</p>
2984 * <p>For consistency, any receiver whose purpose is to prohibit phone
2985 * calls should have a priority of 0, to ensure it will see the final
2986 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002987 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002988 * should have a positive priority.
2989 * Negative priorities are reserved for the system for this broadcast;
2990 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002991 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2992 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002993 * <p>Emergency calls cannot be intercepted using this mechanism, and
2994 * other calls cannot be modified to call emergency numbers using this
2995 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002996 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2997 * call to use their own service instead. Those apps should first prevent
2998 * the call from being placed by setting resultData to <code>null</code>
2999 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003000 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003001 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3002 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003003 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003004 * <p class="note">This is a protected intent that can only be sent
3005 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003006 */
3007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3008 public static final String ACTION_NEW_OUTGOING_CALL =
3009 "android.intent.action.NEW_OUTGOING_CALL";
3010
3011 /**
3012 * Broadcast Action: Have the device reboot. This is only for use by
3013 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003014 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003015 * <p class="note">This is a protected intent that can only be sent
3016 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003017 */
3018 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3019 public static final String ACTION_REBOOT =
3020 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003021
Wei Huang97ecc9c2009-05-11 17:44:20 -07003022 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003023 * Broadcast Action: A sticky broadcast for changes in the physical
3024 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003025 *
3026 * <p>The intent will have the following extra values:
3027 * <ul>
3028 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003029 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003030 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003031 * <p>This is intended for monitoring the current physical dock state.
3032 * See {@link android.app.UiModeManager} for the normal API dealing with
3033 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003034 */
3035 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3036 public static final String ACTION_DOCK_EVENT =
3037 "android.intent.action.DOCK_EVENT";
3038
3039 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003040 * Broadcast Action: A broadcast when idle maintenance can be started.
3041 * This means that the user is not interacting with the device and is
3042 * not expected to do so soon. Typical use of the idle maintenance is
3043 * to perform somehow expensive tasks that can be postponed at a moment
3044 * when they will not degrade user experience.
3045 * <p>
3046 * <p class="note">In order to keep the device responsive in case of an
3047 * unexpected user interaction, implementations of a maintenance task
3048 * should be interruptible. In such a scenario a broadcast with action
3049 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3050 * should not do the maintenance work in
3051 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3052 * maintenance service by {@link Context#startService(Intent)}. Also
3053 * you should hold a wake lock while your maintenance service is running
3054 * to prevent the device going to sleep.
3055 * </p>
3056 * <p>
3057 * <p class="note">This is a protected intent that can only be sent by
3058 * the system.
3059 * </p>
3060 *
3061 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003062 *
3063 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003064 */
3065 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3066 public static final String ACTION_IDLE_MAINTENANCE_START =
3067 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3068
3069 /**
3070 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3071 * This means that the user was not interacting with the device as a result
3072 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3073 * was sent and now the user started interacting with the device. Typical
3074 * use of the idle maintenance is to perform somehow expensive tasks that
3075 * can be postponed at a moment when they will not degrade user experience.
3076 * <p>
3077 * <p class="note">In order to keep the device responsive in case of an
3078 * unexpected user interaction, implementations of a maintenance task
3079 * should be interruptible. Hence, on receiving a broadcast with this
3080 * action, the maintenance task should be interrupted as soon as possible.
3081 * In other words, you should not do the maintenance work in
3082 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3083 * maintenance service that was started on receiving of
3084 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3085 * lock you acquired when your maintenance service started.
3086 * </p>
3087 * <p class="note">This is a protected intent that can only be sent
3088 * by the system.
3089 *
3090 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003091 *
3092 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003093 */
3094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3095 public static final String ACTION_IDLE_MAINTENANCE_END =
3096 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3097
3098 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003099 * Broadcast Action: a remote intent is to be broadcasted.
3100 *
3101 * A remote intent is used for remote RPC between devices. The remote intent
3102 * is serialized and sent from one device to another device. The receiving
3103 * device parses the remote intent and broadcasts it. Note that anyone can
3104 * broadcast a remote intent. However, if the intent receiver of the remote intent
3105 * does not trust intent broadcasts from arbitrary intent senders, it should require
3106 * the sender to hold certain permissions so only trusted sender's broadcast will be
3107 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003108 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003109 */
3110 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003111 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003112
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003113 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003114 * Broadcast Action: This is broadcast once when the user is booting after a
3115 * system update. It can be used to perform cleanup or upgrades after a
3116 * system update.
3117 * <p>
3118 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3119 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3120 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3121 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003122 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003123 * @hide
3124 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003125 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003126 public static final String ACTION_PRE_BOOT_COMPLETED =
3127 "android.intent.action.PRE_BOOT_COMPLETED";
3128
Amith Yamasani13593602012-03-22 16:16:17 -07003129 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003130 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003131 * on restricted users. The broadcast intent contains an extra
3132 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3133 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3134 * String[] depending on the restriction type.<p/>
3135 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003136 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3137 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3138 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003139 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3140 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003141 * @see RestrictionEntry
3142 */
3143 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3144 "android.intent.action.GET_RESTRICTION_ENTRIES";
3145
3146 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003147 * Sent the first time a user is starting, to allow system apps to
3148 * perform one time initialization. (This will not be seen by third
3149 * party applications because a newly initialized user does not have any
3150 * third party applications installed for it.) This is sent early in
3151 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003152 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3153 * broadcast, since it is part of a visible user interaction; be as quick
3154 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003155 */
3156 public static final String ACTION_USER_INITIALIZE =
3157 "android.intent.action.USER_INITIALIZE";
3158
3159 /**
3160 * Sent when a user switch is happening, causing the process's user to be
3161 * brought to the foreground. This is only sent to receivers registered
3162 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3163 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003164 * foreground. This is sent as a foreground
3165 * broadcast, since it is part of a visible user interaction; be as quick
3166 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003167 */
3168 public static final String ACTION_USER_FOREGROUND =
3169 "android.intent.action.USER_FOREGROUND";
3170
3171 /**
3172 * Sent when a user switch is happening, causing the process's user to be
3173 * sent to the background. This is only sent to receivers registered
3174 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3175 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003176 * background. This is sent as a foreground
3177 * broadcast, since it is part of a visible user interaction; be as quick
3178 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003179 */
3180 public static final String ACTION_USER_BACKGROUND =
3181 "android.intent.action.USER_BACKGROUND";
3182
3183 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003184 * Broadcast sent to the system when a user is added. Carries an extra
3185 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3186 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003187 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003188 * @hide
3189 */
3190 public static final String ACTION_USER_ADDED =
3191 "android.intent.action.USER_ADDED";
3192
3193 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003194 * Broadcast sent by the system when a user is started. Carries an extra
3195 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003196 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003197 * that has been started. This is sent as a foreground
3198 * broadcast, since it is part of a visible user interaction; be as quick
3199 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003200 * @hide
3201 */
3202 public static final String ACTION_USER_STARTED =
3203 "android.intent.action.USER_STARTED";
3204
3205 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003206 * Broadcast sent when a user is in the process of starting. Carries an extra
3207 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3208 * sent to registered receivers, not manifest receivers. It is sent to all
3209 * users (including the one that is being started). You must hold
3210 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3211 * this broadcast. This is sent as a background broadcast, since
3212 * its result is not part of the primary UX flow; to safely keep track of
3213 * started/stopped state of a user you can use this in conjunction with
3214 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3215 * other user state broadcasts since those are foreground broadcasts so can
3216 * execute in a different order.
3217 * @hide
3218 */
3219 public static final String ACTION_USER_STARTING =
3220 "android.intent.action.USER_STARTING";
3221
3222 /**
3223 * Broadcast sent when a user is going to be stopped. Carries an extra
3224 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3225 * sent to registered receivers, not manifest receivers. It is sent to all
3226 * users (including the one that is being stopped). You must hold
3227 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3228 * this broadcast. The user will not stop until all receivers have
3229 * handled the broadcast. This is sent as a background broadcast, since
3230 * its result is not part of the primary UX flow; to safely keep track of
3231 * started/stopped state of a user you can use this in conjunction with
3232 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3233 * other user state broadcasts since those are foreground broadcasts so can
3234 * execute in a different order.
3235 * @hide
3236 */
3237 public static final String ACTION_USER_STOPPING =
3238 "android.intent.action.USER_STOPPING";
3239
3240 /**
3241 * Broadcast sent to the system when a user is stopped. Carries an extra
3242 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3243 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3244 * specific package. This is only sent to registered receivers, not manifest
3245 * receivers. It is sent to all running users <em>except</em> the one that
3246 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003247 * @hide
3248 */
3249 public static final String ACTION_USER_STOPPED =
3250 "android.intent.action.USER_STOPPED";
3251
3252 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003253 * 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 -07003254 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003255 * one that has been removed. The user will not be completely removed until all receivers have
3256 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003257 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003258 * @hide
3259 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003260 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003261 public static final String ACTION_USER_REMOVED =
3262 "android.intent.action.USER_REMOVED";
3263
3264 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003265 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003266 * the userHandle of the user to become the current one. This is only sent to
3267 * registered receivers, not manifest receivers. It is sent to all running users.
3268 * You must hold
3269 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003270 * @hide
3271 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003272 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003273 public static final String ACTION_USER_SWITCHED =
3274 "android.intent.action.USER_SWITCHED";
3275
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003276 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003277 * Broadcast Action: Sent when the credential-encrypted private storage has
3278 * become unlocked for the target user. This is only sent to registered
3279 * receivers, not manifest receivers.
3280 */
3281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3282 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3283
3284 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003285 * Broadcast sent to the system when a user's information changes. Carries an extra
3286 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003287 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003288 * @hide
3289 */
3290 public static final String ACTION_USER_INFO_CHANGED =
3291 "android.intent.action.USER_INFO_CHANGED";
3292
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003293 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003294 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3295 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003296 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3297 * that need to display merged content across both primary and managed profiles need to
3298 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003299 * not manifest receivers.
3300 */
3301 public static final String ACTION_MANAGED_PROFILE_ADDED =
3302 "android.intent.action.MANAGED_PROFILE_ADDED";
3303
3304 /**
3305 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003306 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3307 * Only applications (for example Launchers) that need to display merged content across both
3308 * primary and managed profiles need to worry about this broadcast. This is only sent to
3309 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003310 */
3311 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3312 "android.intent.action.MANAGED_PROFILE_REMOVED";
3313
3314 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003315 * Broadcast sent to the primary user when the credential-encrypted private storage for
3316 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3317 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3318 * Launchers) that need to display merged content across both primary and managed profiles
3319 * need to worry about this broadcast. This is only sent to registered receivers,
3320 * not manifest receivers.
3321 */
3322 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3323 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3324
3325 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003326 * Broadcast sent to the primary user when an associated managed profile has become available.
3327 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003328 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3329 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3330 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003331 */
Rubin Xue95057a2016-04-01 16:49:25 +01003332 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3333 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3334
3335 /**
3336 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3337 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3338 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3339 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3340 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3341 */
3342 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3343 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003344
3345 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003346 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3347 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3348 * the device was locked or unlocked.
3349 *
3350 * This is only sent to registered receivers.
3351 *
3352 * @hide
3353 */
3354 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3355 "android.intent.action.DEVICE_LOCKED_CHANGED";
3356
3357 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003358 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3359 */
3360 public static final String ACTION_QUICK_CLOCK =
3361 "android.intent.action.QUICK_CLOCK";
3362
Michael Wright0087a142013-02-05 16:29:39 -08003363 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003364 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003365 * @hide
3366 */
3367 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003368 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003369
Justin Kohd378ad72013-04-01 12:18:26 -07003370 /**
3371 * Broadcast Action: A global button was pressed. Includes a single
3372 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3373 * caused the broadcast.
3374 * @hide
3375 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003376 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003377 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3378
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003379 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003380 * Broadcast Action: Sent when media resource is granted.
3381 * <p>
3382 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3383 * granted.
3384 * </p>
3385 * <p class="note">
3386 * This is a protected intent that can only be sent by the system.
3387 * </p>
3388 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003389 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003390 * </p>
3391 *
3392 * @hide
3393 */
3394 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3395 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3396
3397 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003398 * Broadcast Action: An overlay package has changed. The data contains the
3399 * name of the overlay package which has changed. This is broadcast on all
3400 * changes to the OverlayInfo returned by {@link
3401 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3402 * most common change is a state change that will change whether the
3403 * overlay is enabled or not.
3404 * @hide
3405 */
3406 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3407
3408 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003409 * Activity Action: Allow the user to select and return one or more existing
3410 * documents. When invoked, the system will display the various
3411 * {@link DocumentsProvider} instances installed on the device, letting the
3412 * user interactively navigate through them. These documents include local
3413 * media, such as photos and video, and documents provided by installed
3414 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003415 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003416 * Each document is represented as a {@code content://} URI backed by a
3417 * {@link DocumentsProvider}, which can be opened as a stream with
3418 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3419 * {@link android.provider.DocumentsContract.Document} metadata.
3420 * <p>
3421 * All selected documents are returned to the calling application with
3422 * persistable read and write permission grants. If you want to maintain
3423 * access to the documents across device reboots, you need to explicitly
3424 * take the persistable permissions using
3425 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3426 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003427 * Callers must indicate the acceptable document MIME types through
3428 * {@link #setType(String)}. For example, to select photos, use
3429 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3430 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3431 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003432 * <p>
3433 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003434 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3435 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003436 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003437 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3438 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003439 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003440 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003441 * Callers can set a document URI through
3442 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3443 * location of documents navigator. System will do its best to launch the
3444 * navigator in the specified document if it's a folder, or the folder that
3445 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003446 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003447 * Output: The URI of the item that was picked, returned in
3448 * {@link #getData()}. This must be a {@code content://} URI so that any
3449 * receiver can access it. If multiple documents were selected, they are
3450 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003451 *
3452 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003453 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003454 * @see #ACTION_CREATE_DOCUMENT
3455 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003456 */
3457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3458 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3459
3460 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003461 * Activity Action: Allow the user to create a new document. When invoked,
3462 * the system will display the various {@link DocumentsProvider} instances
3463 * installed on the device, letting the user navigate through them. The
3464 * returned document may be a newly created document with no content, or it
3465 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003466 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003467 * Each document is represented as a {@code content://} URI backed by a
3468 * {@link DocumentsProvider}, which can be opened as a stream with
3469 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3470 * {@link android.provider.DocumentsContract.Document} metadata.
3471 * <p>
3472 * Callers must indicate the concrete MIME type of the document being
3473 * created by setting {@link #setType(String)}. This MIME type cannot be
3474 * changed after the document is created.
3475 * <p>
3476 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3477 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003478 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003479 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3480 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003481 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003482 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003483 * Callers can set a document URI through
3484 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3485 * location of documents navigator. System will do its best to launch the
3486 * navigator in the specified document if it's a folder, or the folder that
3487 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003488 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003489 * Output: The URI of the item that was created. This must be a
3490 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003491 *
3492 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003493 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003494 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003495 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003496 */
3497 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3498 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3499
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003500 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003501 * Activity Action: Allow the user to pick a directory subtree. When
3502 * invoked, the system will display the various {@link DocumentsProvider}
3503 * instances installed on the device, letting the user navigate through
3504 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003505 * <p>
3506 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003507 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3508 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3509 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003510 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003511 * Callers can set a document URI through
3512 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3513 * location of documents navigator. System will do its best to launch the
3514 * navigator in the specified document if it's a folder, or the folder that
3515 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003516 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003517 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003518 *
3519 * @see DocumentsContract
3520 */
3521 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003522 public static final String
3523 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003524
Felipe Lemec7b1f892016-01-15 15:02:31 -08003525 /**
Peng Xua35b5532016-01-20 00:05:45 -08003526 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3527 * exisiting sensor being disconnected.
3528 *
3529 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3530 *
3531 * {@hide}
3532 */
3533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3534 public static final String
3535 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3536
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003537 /**
Sam Line707f832017-04-13 17:00:55 -07003538 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003539 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003540 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003541 */
3542 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003543 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003544 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3545
Christopher Tate6597e342015-02-17 12:15:25 -08003546 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003547 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3548 * is about to be performed.
3549 * @hide
3550 */
3551 @SystemApi
3552 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3553 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3554 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3555
3556 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003557 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3558 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3559 *
3560 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3561 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003562 * @hide
3563 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003564 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003565 public static final String EXTRA_FORCE_MASTER_CLEAR =
3566 "android.intent.extra.FORCE_MASTER_CLEAR";
3567
3568 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003569 * A broadcast action to trigger a factory reset.
3570 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003571 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3572 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003573 *
3574 * <p>Not for use by third-party applications.
3575 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003576 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003577 *
3578 * {@hide}
3579 */
3580 @SystemApi
3581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3582 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3583
3584 /**
3585 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3586 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3587 *
3588 * <p>Not for use by third-party applications.
3589 *
3590 * @hide
3591 */
3592 @SystemApi
3593 public static final String EXTRA_FORCE_FACTORY_RESET =
3594 "android.intent.extra.FORCE_FACTORY_RESET";
3595
3596 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003597 * Broadcast action: report that a settings element is being restored from backup. The intent
3598 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3599 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3600 * is the value of that settings entry prior to the restore operation, and
3601 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3602 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3603 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003604 *
3605 * <p>This broadcast is sent only for settings provider entries known to require special handling
3606 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3607 * the provider's backup agent implementation.
3608 *
3609 * @see #EXTRA_SETTING_NAME
3610 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3611 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003612 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003613 * {@hide}
3614 */
3615 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3616
3617 /** {@hide} */
3618 public static final String EXTRA_SETTING_NAME = "setting_name";
3619 /** {@hide} */
3620 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3621 /** {@hide} */
3622 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003623 /** {@hide} */
3624 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003625
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003626 /**
3627 * Activity Action: Process a piece of text.
3628 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3629 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3630 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3631 */
3632 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3633 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003634
3635 /**
3636 * Broadcast Action: The sim card state has changed.
3637 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3638 * because TelephonyIntents is an internal class.
3639 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003640 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3641 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003642 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003643 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003644 @SystemApi
3645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3646 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3647
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003648 /**
fionaxu90fee272017-03-31 12:45:12 -07003649 * Broadcast Action: indicate that the phone service state has changed.
3650 * The intent will have the following extra values:</p>
3651 * <p>
3652 * @see #EXTRA_VOICE_REG_STATE
3653 * @see #EXTRA_DATA_REG_STATE
3654 * @see #EXTRA_VOICE_ROAMING_TYPE
3655 * @see #EXTRA_DATA_ROAMING_TYPE
3656 * @see #EXTRA_OPERATOR_ALPHA_LONG
3657 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3658 * @see #EXTRA_OPERATOR_NUMERIC
3659 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3660 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3661 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3662 * @see #EXTRA_MANUAL
3663 * @see #EXTRA_VOICE_RADIO_TECH
3664 * @see #EXTRA_DATA_RADIO_TECH
3665 * @see #EXTRA_CSS_INDICATOR
3666 * @see #EXTRA_NETWORK_ID
3667 * @see #EXTRA_SYSTEM_ID
3668 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3669 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3670 * @see #EXTRA_EMERGENCY_ONLY
3671 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3672 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3673 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3674 *
3675 * <p class="note">
3676 * Requires the READ_PHONE_STATE permission.
3677 *
3678 * <p class="note">This is a protected intent that can only be sent by the system.
3679 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003680 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003681 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3682 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3683 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3684 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003685 */
3686 @Deprecated
3687 @SystemApi
3688 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3689 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3690
3691 /**
3692 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3693 * state.
3694 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3695 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3696 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3697 * @see android.telephony.ServiceState#STATE_POWER_OFF
3698 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003699 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003700 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003701 */
3702 @Deprecated
3703 @SystemApi
3704 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3705
3706 /**
3707 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3708 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3709 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3710 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3711 * @see android.telephony.ServiceState#STATE_POWER_OFF
3712 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003713 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003714 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003715 */
3716 @Deprecated
3717 @SystemApi
3718 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3719
3720 /**
3721 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3722 * type.
3723 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003724 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003725 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003726 */
3727 @Deprecated
3728 @SystemApi
3729 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3730
3731 /**
3732 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3733 * type.
3734 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003735 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003736 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003737 */
3738 @Deprecated
3739 @SystemApi
3740 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3741
3742 /**
3743 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3744 * registered voice operator name in long alphanumeric format.
3745 * {@code null} if the operator name is not known or unregistered.
3746 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003747 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003748 * @deprecated Use
3749 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003750 */
3751 @Deprecated
3752 @SystemApi
3753 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3754
3755 /**
3756 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3757 * registered voice operator name in short alphanumeric format.
3758 * {@code null} if the operator name is not known or unregistered.
3759 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003760 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003761 * @deprecated Use
3762 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003763 */
3764 @Deprecated
3765 @SystemApi
3766 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3767
3768 /**
3769 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3770 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3771 * network.
3772 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003773 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003774 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003775 */
3776 @Deprecated
3777 @SystemApi
3778 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3779
3780 /**
3781 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3782 * registered data operator name in long alphanumeric format.
3783 * {@code null} if the operator name is not known or unregistered.
3784 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003785 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003786 * @deprecated Use
3787 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003788 */
3789 @Deprecated
3790 @SystemApi
3791 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3792
3793 /**
3794 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3795 * registered data operator name in short alphanumeric format.
3796 * {@code null} if the operator name is not known or unregistered.
3797 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003798 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003799 * @deprecated Use
3800 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003801 */
3802 @Deprecated
3803 @SystemApi
3804 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3805
3806 /**
3807 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3808 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3809 * data operator.
3810 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003811 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003812 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003813 */
3814 @Deprecated
3815 @SystemApi
3816 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3817
3818 /**
3819 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3820 * network selection mode is manual.
3821 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3822 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003823 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003824 * @deprecated Use
3825 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003826 */
3827 @Deprecated
3828 @SystemApi
3829 public static final String EXTRA_MANUAL = "manual";
3830
3831 /**
3832 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3833 * radio technology.
3834 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003835 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003836 * @deprecated Use
3837 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003838 */
3839 @Deprecated
3840 @SystemApi
3841 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3842
3843 /**
3844 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3845 * radio technology.
3846 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003847 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003848 * @deprecated Use
3849 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003850 */
3851 @Deprecated
3852 @SystemApi
3853 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3854
3855 /**
3856 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3857 * support on CDMA network.
3858 * Will be {@code true} if support, {@code false} otherwise.
3859 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003860 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003861 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003862 */
3863 @Deprecated
3864 @SystemApi
3865 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3866
3867 /**
3868 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3869 * id. {@code Integer.MAX_VALUE} if unknown.
3870 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003871 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003872 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003873 */
3874 @Deprecated
3875 @SystemApi
3876 public static final String EXTRA_NETWORK_ID = "networkId";
3877
3878 /**
3879 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3880 * {@code Integer.MAX_VALUE} if unknown.
3881 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003882 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003883 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003884 */
3885 @Deprecated
3886 @SystemApi
3887 public static final String EXTRA_SYSTEM_ID = "systemId";
3888
3889 /**
3890 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3891 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3892 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003893 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003894 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003895 */
3896 @Deprecated
3897 @SystemApi
3898 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3899
3900 /**
3901 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3902 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3903 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003904 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003905 * @deprecated Use
3906 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003907 */
3908 @Deprecated
3909 @SystemApi
3910 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3911
3912 /**
3913 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3914 * only mode.
3915 * {@code true} if in emergency only mode, {@code false} otherwise.
3916 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003917 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003918 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003919 */
3920 @Deprecated
3921 @SystemApi
3922 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3923
3924 /**
3925 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3926 * registration state is roaming.
3927 * {@code true} if registration indicates roaming, {@code false} otherwise
3928 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003929 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003930 * @deprecated Use
3931 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003932 */
3933 @Deprecated
3934 @SystemApi
3935 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3936 "isDataRoamingFromRegistration";
3937
3938 /**
3939 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3940 * aggregation is in use.
3941 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3942 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003943 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003944 * @deprecated Use
3945 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003946 */
3947 @Deprecated
3948 @SystemApi
3949 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3950
3951 /**
3952 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3953 * is reduced from the rsrp threshold while calculating signal strength level.
3954 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003955 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003956 */
3957 @Deprecated
3958 @SystemApi
3959 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3960
3961 /**
chen xu02811692018-10-03 19:07:09 -07003962 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
3963 * @hide
3964 */
3965 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
3966
3967 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003968 * The name of the extra used to define the text to be processed, as a
3969 * CharSequence. Note that this may be a styled CharSequence, so you must use
3970 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003971 */
3972 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3973 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003974 * 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 +00003975 */
3976 public static final String EXTRA_PROCESS_TEXT_READONLY =
3977 "android.intent.extra.PROCESS_TEXT_READONLY";
3978
Bryce Leebc58f592015-09-25 16:43:01 -07003979 /**
3980 * Broadcast action: reports when a new thermal event has been reached. When the device
3981 * is reaching its maximum temperatue, the thermal level reported
3982 * {@hide}
3983 */
3984 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3985 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3986
3987 /** {@hide} */
3988 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3989
3990 /**
3991 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003992 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003993 * {@hide}
3994 */
3995 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3996
3997 /**
3998 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003999 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004000 * {@hide}
4001 */
4002 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4003
4004 /**
4005 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004006 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004007 * {@hide}
4008 */
4009 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4010
lpeter318abc92018-05-04 16:13:14 +08004011 /**
4012 * Broadcast Action: Indicates the dock in idle 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_IDLE = "android.intent.action.DOCK_IDLE";
4020
4021 /**
4022 * Broadcast Action: Indicates the dock in active state while device is docked.
4023 *
4024 * <p class="note">This is a protected intent that can only be sent
4025 * by the system.
4026 *
4027 * @hide
4028 */
4029 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4030
Bryce Leebc58f592015-09-25 16:43:01 -07004031
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004032 // ---------------------------------------------------------------------
4033 // ---------------------------------------------------------------------
4034 // Standard intent categories (see addCategory()).
4035
4036 /**
4037 * Set if the activity should be an option for the default action
4038 * (center press) to perform on a piece of data. Setting this will
4039 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004040 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004041 * Intent when initiating an action -- it is for use in intent filters
4042 * specified in packages.
4043 */
4044 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4045 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4046 /**
4047 * Activities that can be safely invoked from a browser must support this
4048 * category. For example, if the user is viewing a web page or an e-mail
4049 * and clicks on a link in the text, the Intent generated execute that
4050 * link will require the BROWSABLE category, so that only activities
4051 * supporting this category will be considered as possible actions. By
4052 * supporting this category, you are promising that there is nothing
4053 * damaging (without user intervention) that can happen by invoking any
4054 * matching Intent.
4055 */
4056 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4057 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4058 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004059 * Categories for activities that can participate in voice interaction.
4060 * An activity that supports this category must be prepared to run with
4061 * no UI shown at all (though in some case it may have a UI shown), and
4062 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4063 */
4064 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4065 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4066 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004067 * Set if the activity should be considered as an alternative action to
4068 * the data the user is currently viewing. See also
4069 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4070 * applies to the selection in a list of items.
4071 *
4072 * <p>Supporting this category means that you would like your activity to be
4073 * displayed in the set of alternative things the user can do, usually as
4074 * part of the current activity's options menu. You will usually want to
4075 * include a specific label in the &lt;intent-filter&gt; of this action
4076 * describing to the user what it does.
4077 *
4078 * <p>The action of IntentFilter with this category is important in that it
4079 * describes the specific action the target will perform. This generally
4080 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4081 * a specific name such as "com.android.camera.action.CROP. Only one
4082 * alternative of any particular action will be shown to the user, so using
4083 * a specific action like this makes sure that your alternative will be
4084 * displayed while also allowing other applications to provide their own
4085 * overrides of that particular action.
4086 */
4087 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4088 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4089 /**
4090 * Set if the activity should be considered as an alternative selection
4091 * action to the data the user has currently selected. This is like
4092 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4093 * of items from which the user can select, giving them alternatives to the
4094 * default action that will be performed on it.
4095 */
4096 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4097 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4098 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004099 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004100 */
4101 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4102 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4103 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004104 * Should be displayed in the top-level launcher.
4105 */
4106 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4107 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4108 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004109 * Indicates an activity optimized for Leanback mode, and that should
4110 * be displayed in the Leanback launcher.
4111 */
4112 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4113 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4114 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004115 * Indicates the preferred entry-point activity when an application is launched from a Car
4116 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4117 * fallback, or exclude the application entirely.
4118 * @hide
4119 */
4120 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4121 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4122 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004123 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4124 * @hide
4125 */
4126 @SystemApi
4127 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4128 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004129 * Provides information about the package it is in; typically used if
4130 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4131 * a front-door to the user without having to be shown in the all apps list.
4132 */
4133 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4134 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4135 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004136 * This is the home activity, that is the first activity that is displayed
4137 * when the device boots.
4138 */
4139 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4140 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4141 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004142 * This is the home activity that is displayed when the device is finished setting up and ready
4143 * for use.
4144 * @hide
4145 */
4146 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4147 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4148 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004149 * This is the setup wizard activity, that is the first activity that is displayed
4150 * when the user sets up the device for the first time.
4151 * @hide
4152 */
4153 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4154 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4155 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004156 * This is the home activity, that is the activity that serves as the launcher app
4157 * from there the user can start other apps. Often components with lower/higher
4158 * priority intent filters handle the home intent, for example SetupWizard, to
4159 * setup the device and we need to be able to distinguish the home app from these
4160 * setup helpers.
4161 * @hide
4162 */
4163 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4164 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4165 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004166 * This activity is a preference panel.
4167 */
4168 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4169 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4170 /**
4171 * This activity is a development preference panel.
4172 */
4173 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4174 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4175 /**
4176 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004177 */
4178 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4179 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4180 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004181 * This activity allows the user to browse and download new applications.
4182 */
4183 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4184 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4185 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004186 * This activity may be exercised by the monkey or other automated test tools.
4187 */
4188 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4189 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4190 /**
4191 * To be used as a test (not part of the normal user experience).
4192 */
4193 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4194 /**
4195 * To be used as a unit test (run through the Test Harness).
4196 */
4197 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4198 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004199 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004200 * experience).
4201 */
4202 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004204 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004205 * Used to indicate that an intent only wants URIs that can be opened with
4206 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4207 * must support at least the columns defined in {@link OpenableColumns} when
4208 * queried.
4209 *
4210 * @see #ACTION_GET_CONTENT
4211 * @see #ACTION_OPEN_DOCUMENT
4212 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004213 */
4214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4215 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4216
4217 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004218 * Used to indicate that an intent filter can accept files which are not necessarily
4219 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4220 * at least streamable via
4221 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4222 * using one of the stream types exposed via
4223 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4224 *
4225 * @see #ACTION_SEND
4226 * @see #ACTION_SEND_MULTIPLE
4227 */
4228 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4229 public static final String CATEGORY_TYPED_OPENABLE =
4230 "android.intent.category.TYPED_OPENABLE";
4231
4232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004233 * To be used as code under test for framework instrumentation tests.
4234 */
4235 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4236 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004237 /**
4238 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004239 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4240 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004241 */
4242 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4243 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4244 /**
4245 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004246 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4247 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004248 */
4249 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4250 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004251 /**
4252 * An activity to run when device is inserted into a analog (low end) dock.
4253 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4254 * information, see {@link android.app.UiModeManager}.
4255 */
4256 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4257 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4258
4259 /**
4260 * An activity to run when device is inserted into a digital (high end) dock.
4261 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4262 * information, see {@link android.app.UiModeManager}.
4263 */
4264 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4265 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004266
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004267 /**
4268 * Used to indicate that the activity can be used in a car environment.
4269 */
4270 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4271 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4272
Zak Cohendb6ca492017-01-26 14:09:00 -08004273 /**
4274 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4275 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4276 * information, see {@link android.app.UiModeManager}.
4277 */
4278 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4279 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004280 // ---------------------------------------------------------------------
4281 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004282 // Application launch intent categories (see addCategory()).
4283
4284 /**
4285 * Used with {@link #ACTION_MAIN} to launch the browser application.
4286 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004287 * <p>NOTE: This should not be used as the primary key of an Intent,
4288 * since it will not result in the app launching with the correct
4289 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004290 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004291 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004292 */
4293 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4294 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4295
4296 /**
4297 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4298 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004299 * <p>NOTE: This should not be used as the primary key of an Intent,
4300 * since it will not result in the app launching with the correct
4301 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004302 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004303 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004304 */
4305 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4306 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4307
4308 /**
4309 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4310 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004311 * <p>NOTE: This should not be used as the primary key of an Intent,
4312 * since it will not result in the app launching with the correct
4313 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004314 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004315 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004316 */
4317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4318 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4319
4320 /**
4321 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4322 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004323 * <p>NOTE: This should not be used as the primary key of an Intent,
4324 * since it will not result in the app launching with the correct
4325 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004326 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004327 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004328 */
4329 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4330 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4331
4332 /**
4333 * Used with {@link #ACTION_MAIN} to launch the email application.
4334 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004335 * <p>NOTE: This should not be used as the primary key of an Intent,
4336 * since it will not result in the app launching with the correct
4337 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004338 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004339 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004340 */
4341 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4342 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4343
4344 /**
4345 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4346 * The activity should be able to view and manipulate image and video files
4347 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004348 * <p>NOTE: This should not be used as the primary key of an Intent,
4349 * since it will not result in the app launching with the correct
4350 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004351 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004352 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004353 */
4354 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4355 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4356
4357 /**
4358 * Used with {@link #ACTION_MAIN} to launch the maps application.
4359 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004360 * <p>NOTE: This should not be used as the primary key of an Intent,
4361 * since it will not result in the app launching with the correct
4362 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004363 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004364 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004365 */
4366 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4367 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4368
4369 /**
4370 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4371 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004372 * <p>NOTE: This should not be used as the primary key of an Intent,
4373 * since it will not result in the app launching with the correct
4374 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004375 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004376 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004377 */
4378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4379 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4380
4381 /**
4382 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004383 * The activity should be able to play, browse, or manipulate music files
4384 * stored on the device.
4385 * <p>NOTE: This should not be used as the primary key of an Intent,
4386 * since it will not result in the app launching with the correct
4387 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004388 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004389 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004390 */
4391 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4392 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4393
4394 // ---------------------------------------------------------------------
4395 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004396 // Standard extra data keys.
4397
4398 /**
4399 * The initial data to place in a newly created record. Use with
4400 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4401 * fields as would be given to the underlying ContentProvider.insert()
4402 * call.
4403 */
4404 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4405
4406 /**
4407 * A constant CharSequence that is associated with the Intent, used with
4408 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4409 * this may be a styled CharSequence, so you must use
4410 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4411 * retrieve it.
4412 */
4413 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4414
4415 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004416 * A constant String that is associated with the Intent, used with
4417 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4418 * as HTML formatted text. Note that you <em>must</em> also supply
4419 * {@link #EXTRA_TEXT}.
4420 */
4421 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4422
4423 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004424 * A content: URI holding a stream of data associated with the Intent,
4425 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004426 */
4427 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4428
4429 /**
4430 * A String[] holding e-mail addresses that should be delivered to.
4431 */
4432 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4433
4434 /**
4435 * A String[] holding e-mail addresses that should be carbon copied.
4436 */
4437 public static final String EXTRA_CC = "android.intent.extra.CC";
4438
4439 /**
4440 * A String[] holding e-mail addresses that should be blind carbon copied.
4441 */
4442 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4443
4444 /**
4445 * A constant string holding the desired subject line of a message.
4446 */
4447 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4448
4449 /**
4450 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004451 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004452 */
4453 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4454
4455 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004456 * An int representing the user id to be used.
4457 *
4458 * @hide
4459 */
4460 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4461
4462 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004463 * An int representing the task id to be retrieved. This is used when a launch from recents is
4464 * intercepted by another action such as credentials confirmation to remember which task should
4465 * be resumed when complete.
4466 *
4467 * @hide
4468 */
4469 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4470
4471 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004472 * An Intent[] describing additional, alternate choices you would like shown with
4473 * {@link #ACTION_CHOOSER}.
4474 *
4475 * <p>An app may be capable of providing several different payload types to complete a
4476 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4477 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4478 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4479 * photo data or a hosted link where the photos can be viewed.</p>
4480 *
4481 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4482 * first/primary/preferred intent in the set. Additional intents specified in
4483 * this extra are ordered; by default intents that appear earlier in the array will be
4484 * preferred over intents that appear later in the array as matches for the same
4485 * target component. To alter this preference, a calling app may also supply
4486 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4487 */
4488 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4489
4490 /**
Adam Powell52c39212016-04-07 15:14:18 -07004491 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4492 * and omitted from a list of components presented to the user.
4493 *
4494 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4495 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4496 * from your own package or other apps from your organization if the idea of sending to those
4497 * targets would be redundant with other app functionality. Filtered components will not
4498 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4499 */
4500 public static final String EXTRA_EXCLUDE_COMPONENTS
4501 = "android.intent.extra.EXCLUDE_COMPONENTS";
4502
4503 /**
4504 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4505 * describing additional high-priority deep-link targets for the chooser to present to the user.
4506 *
4507 * <p>Targets provided in this way will be presented inline with all other targets provided
4508 * by services from other apps. They will be prioritized before other service targets, but
4509 * after those targets provided by sources that the user has manually pinned to the front.</p>
4510 *
4511 * @see #ACTION_CHOOSER
4512 */
4513 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4514
4515 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004516 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4517 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4518 *
4519 * <p>An app preparing an action for another app to complete may wish to allow the user to
4520 * disambiguate between several options for completing the action based on the chosen target
4521 * or otherwise refine the action before it is invoked.
4522 * </p>
4523 *
4524 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4525 * <ul>
4526 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4527 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4528 * chosen target beyond the first</li>
4529 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4530 * should fill in and send once the disambiguation is complete</li>
4531 * </ul>
4532 */
4533 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4534 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4535
4536 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004537 * An {@code ArrayList} of {@code String} annotations describing content for
4538 * {@link #ACTION_CHOOSER}.
4539 *
4540 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4541 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4542 *
4543 * <p>Annotations should describe the major components or topics of the content. It is up to
4544 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4545 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004546 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4547 * character. Performance on customized annotations can suffer, if they are rarely used for
4548 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4549 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004550 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004551 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004552 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004553 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004554 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004555 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004556 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004557 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004558 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004559 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4560 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4561 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4562 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4563 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004564 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004565 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4566 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004567 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004568 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004569 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004570 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004571 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004572 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004573 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004574 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004575 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004576 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004577 * Christmas and Thanksgiving.</li>
4578 * </ul>
4579 */
4580 public static final String EXTRA_CONTENT_ANNOTATIONS
4581 = "android.intent.extra.CONTENT_ANNOTATIONS";
4582
4583 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004584 * A {@link ResultReceiver} used to return data back to the sender.
4585 *
4586 * <p>Used to complete an app-specific
4587 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4588 *
4589 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4590 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4591 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4592 * when the user selects a target component from the chooser. It is up to the recipient
4593 * to send a result to this ResultReceiver to signal that disambiguation is complete
4594 * and that the chooser should invoke the user's choice.</p>
4595 *
4596 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4597 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4598 * to match and fill in the final Intent or ChooserTarget before starting it.
4599 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4600 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4601 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4602 *
4603 * <p>The result code passed to the ResultReceiver should be
4604 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4605 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4606 * the chooser should finish without starting a target.</p>
4607 */
4608 public static final String EXTRA_RESULT_RECEIVER
4609 = "android.intent.extra.RESULT_RECEIVER";
4610
4611 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004612 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004613 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004614 */
4615 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4616
4617 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004618 * A Parcelable[] of {@link Intent} or
4619 * {@link android.content.pm.LabeledIntent} objects as set with
4620 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4621 * a the front of the list of choices, when shown to the user with a
4622 * {@link #ACTION_CHOOSER}.
4623 */
4624 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4625
4626 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004627 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004628 * @hide
4629 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004630 @SystemApi
4631 public static final String EXTRA_INSTANT_APP_SUCCESS =
4632 "android.intent.extra.INSTANT_APP_SUCCESS";
4633
4634 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004635 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004636 * @hide
4637 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004638 @SystemApi
4639 public static final String EXTRA_INSTANT_APP_FAILURE =
4640 "android.intent.extra.INSTANT_APP_FAILURE";
4641
4642 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004643 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004644 * @hide
4645 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004646 @SystemApi
4647 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4648 "android.intent.extra.INSTANT_APP_HOSTNAME";
4649
4650 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004651 * An opaque token to track instant app resolution.
4652 * @hide
4653 */
4654 @SystemApi
4655 public static final String EXTRA_INSTANT_APP_TOKEN =
4656 "android.intent.extra.INSTANT_APP_TOKEN";
4657
4658 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004659 * The action that triggered an instant application resolution.
4660 * @hide
4661 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004662 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004663 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4664
4665 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004666 * An array of {@link Bundle}s containing details about resolved instant apps..
4667 * @hide
4668 */
4669 @SystemApi
4670 public static final String EXTRA_INSTANT_APP_BUNDLES =
4671 "android.intent.extra.INSTANT_APP_BUNDLES";
4672
4673 /**
4674 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004675 * installed. This data is populated from the response to
4676 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4677 * instant application resolver.
4678 * @hide
4679 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004680 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004681 public static final String EXTRA_INSTANT_APP_EXTRAS =
4682 "android.intent.extra.INSTANT_APP_EXTRAS";
4683
4684 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004685 * A boolean value indicating that the instant app resolver was unable to state with certainty
4686 * that it did or did not have an app for the sanitized {@link Intent} defined at
4687 * {@link #EXTRA_INTENT}.
4688 * @hide
4689 */
4690 @SystemApi
4691 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4692 "android.intent.extra.UNKNOWN_INSTANT_APP";
4693
4694 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004695 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004696 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004697 * @hide
4698 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004699 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004700 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4701
4702 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004703 * The version code of the app to install components from.
4704 * @hide
4705 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004706 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004707 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4708
4709 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004710 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004711 * @hide
4712 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004713 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004714 public static final String EXTRA_CALLING_PACKAGE
4715 = "android.intent.extra.CALLING_PACKAGE";
4716
4717 /**
4718 * Optional calling app provided bundle containing additional launch information the
4719 * installer may use.
4720 * @hide
4721 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004722 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004723 public static final String EXTRA_VERIFICATION_BUNDLE
4724 = "android.intent.extra.VERIFICATION_BUNDLE";
4725
4726 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004727 * A Bundle forming a mapping of potential target package names to different extras Bundles
4728 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4729 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4730 * be currently installed on the device.
4731 *
4732 * <p>An application may choose to provide alternate extras for the case where a user
4733 * selects an activity from a predetermined set of target packages. If the activity
4734 * the user selects from the chooser belongs to a package with its package name as
4735 * a key in this bundle, the corresponding extras for that package will be merged with
4736 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4737 * extra has the same key as an extra already present in the intent it will overwrite
4738 * the extra from the intent.</p>
4739 *
4740 * <p><em>Examples:</em>
4741 * <ul>
4742 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4743 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4744 * parameters for that target.</li>
4745 * <li>An application may offer additional metadata for known targets of a given intent
4746 * to pass along information only relevant to that target such as account or content
4747 * identifiers already known to that application.</li>
4748 * </ul></p>
4749 */
4750 public static final String EXTRA_REPLACEMENT_EXTRAS =
4751 "android.intent.extra.REPLACEMENT_EXTRAS";
4752
4753 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004754 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4755 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4756 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4757 * {@link ComponentName} of the chosen component.
4758 *
4759 * <p>In some situations this callback may never come, for example if the user abandons
4760 * the chooser, switches to another task or any number of other reasons. Apps should not
4761 * be written assuming that this callback will always occur.</p>
4762 */
4763 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4764 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4765
4766 /**
4767 * The {@link ComponentName} chosen by the user to complete an action.
4768 *
4769 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4770 */
4771 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4772
4773 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004774 * A {@link android.view.KeyEvent} object containing the event that
4775 * triggered the creation of the Intent it is in.
4776 */
4777 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4778
4779 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004780 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4781 * before shutting down.
4782 *
4783 * {@hide}
4784 */
4785 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4786
4787 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004788 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4789 * requested by the user.
4790 *
4791 * {@hide}
4792 */
4793 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4794 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4795
4796 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004797 * 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 -07004798 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4799 * of restarting the application.
4800 */
4801 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4802
4803 /**
4804 * A String holding the phone number originally entered in
4805 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4806 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4807 */
4808 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004809
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004810 /**
4811 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4812 * intents to supply the uid the package had been assigned. Also an optional
4813 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4814 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4815 * purpose.
4816 */
4817 public static final String EXTRA_UID = "android.intent.extra.UID";
4818
4819 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004820 * @hide String array of package names.
4821 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004822 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004823 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4824
4825 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004826 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4827 * intents to indicate whether this represents a full uninstall (removing
4828 * both the code and its data) or a partial uninstall (leaving its data,
4829 * implying that this is an update).
4830 */
4831 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004832
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004833 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004834 * @hide
4835 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4836 * intents to indicate that at this point the package has been removed for
4837 * all users on the device.
4838 */
4839 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4840 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4841
4842 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004843 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4844 * intents to indicate that this is a replacement of the package, so this
4845 * broadcast will immediately be followed by an add broadcast for a
4846 * different version of the same package.
4847 */
4848 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004849
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004851 * Used as an int extra field in {@link android.app.AlarmManager} intents
4852 * to tell the application being invoked how many pending alarms are being
4853 * delievered with the intent. For one-shot alarms this will always be 1.
4854 * For recurring alarms, this might be greater than 1 if the device was
4855 * asleep or powered off at the time an earlier alarm would have been
4856 * delivered.
4857 */
4858 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004859
Jacek Surazski86b6c532009-05-13 14:38:28 +02004860 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004861 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4862 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004863 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4864 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004865 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4866 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4867 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004868 */
4869 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4870
4871 /**
4872 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4873 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004874 */
4875 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4876
4877 /**
4878 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4879 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004880 */
4881 public static final int EXTRA_DOCK_STATE_DESK = 1;
4882
4883 /**
4884 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4885 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004886 */
4887 public static final int EXTRA_DOCK_STATE_CAR = 2;
4888
4889 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004890 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4891 * to represent that the phone is in a analog (low end) dock.
4892 */
4893 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4894
4895 /**
4896 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4897 * to represent that the phone is in a digital (high end) dock.
4898 */
4899 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4900
4901 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004902 * Boolean that can be supplied as meta-data with a dock activity, to
4903 * indicate that the dock should take over the home key when it is active.
4904 */
4905 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004906
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004907 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004908 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4909 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004910 */
4911 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4912
4913 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004914 * Used in the extra field in the remote intent. It's astring token passed with the
4915 * remote intent.
4916 */
4917 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4918 "android.intent.extra.remote_intent_token";
4919
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004920 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004921 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004922 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004923 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004924 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004925 "android.intent.extra.changed_component_name";
4926
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004927 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004928 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004929 * and contains a string array of all of the components that have changed. If
4930 * the state of the overall package has changed, then it will contain an entry
4931 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004932 */
4933 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4934 "android.intent.extra.changed_component_name_list";
4935
4936 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004937 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004938 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004939 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4940 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4941 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004942 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004943 */
4944 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4945 "android.intent.extra.changed_package_list";
4946
4947 /**
4948 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004949 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4950 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004951 * and contains an integer array of uids of all of the components
4952 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004953 */
4954 public static final String EXTRA_CHANGED_UID_LIST =
4955 "android.intent.extra.changed_uid_list";
4956
4957 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004958 * @hide
4959 * Magic extra system code can use when binding, to give a label for
4960 * who it is that has bound to a service. This is an integer giving
4961 * a framework string resource that can be displayed to the user.
4962 */
4963 public static final String EXTRA_CLIENT_LABEL =
4964 "android.intent.extra.client_label";
4965
4966 /**
4967 * @hide
4968 * Magic extra system code can use when binding, to give a PendingIntent object
4969 * that can be launched for the user to disable the system's use of this
4970 * service.
4971 */
4972 public static final String EXTRA_CLIENT_INTENT =
4973 "android.intent.extra.client_intent";
4974
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004975 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004976 * Extra used to indicate that an intent should only return data that is on
4977 * the local device. This is a boolean extra; the default is false. If true,
4978 * an implementation should only allow the user to select data that is
4979 * already on the device, not requiring it be downloaded from a remote
4980 * service when opened.
4981 *
4982 * @see #ACTION_GET_CONTENT
4983 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004984 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004985 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004986 */
4987 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004988 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004989
Amith Yamasani13593602012-03-22 16:16:17 -07004990 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004991 * Extra used to indicate that an intent can allow the user to select and
4992 * return multiple items. This is a boolean extra; the default is false. If
4993 * true, an implementation is allowed to present the user with a UI where
4994 * they can pick multiple items that are all returned to the caller. When
4995 * this happens, they should be returned as the {@link #getClipData()} part
4996 * of the result Intent.
4997 *
4998 * @see #ACTION_GET_CONTENT
4999 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005000 */
5001 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005002 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005003
5004 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005005 * The integer userHandle carried with broadcast intents related to addition, removal and
5006 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5007 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5008 *
Amith Yamasani13593602012-03-22 16:16:17 -07005009 * @hide
5010 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005011 public static final String EXTRA_USER_HANDLE =
5012 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005013
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005014 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005015 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005016 */
5017 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005018 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005019
5020 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005021 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005022 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5023 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005024 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005025 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5026
5027 /**
5028 * Extra sent in the intent to the BroadcastReceiver that handles
5029 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5030 * the restrictions as key/value pairs.
5031 */
5032 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5033 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005034
Amith Yamasani86118ba2013-03-28 14:33:16 -07005035 /**
5036 * Extra used in the response from a BroadcastReceiver that handles
5037 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5038 */
5039 public static final String EXTRA_RESTRICTIONS_INTENT =
5040 "android.intent.extra.restrictions_intent";
5041
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005042 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005043 * Extra used to communicate a set of acceptable MIME types. The type of the
5044 * extra is {@code String[]}. Values may be a combination of concrete MIME
5045 * types (such as "image/png") and/or partial MIME types (such as
5046 * "audio/*").
5047 *
5048 * @see #ACTION_GET_CONTENT
5049 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005050 */
5051 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5052
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005053 /**
5054 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5055 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005056 * When this is true, hardware devices can use this information to determine that
5057 * they shouldn't do a complete shutdown of their device since this is not a
5058 * complete shutdown down to the kernel, but only user space restarting.
5059 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005060 */
5061 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5062 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5063
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005064 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005065 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5066 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5067 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5068 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005069 *
5070 * @hide for internal use only.
5071 */
5072 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5073 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005074 /** @hide */
5075 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5076 /** @hide */
5077 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5078 /** @hide */
5079 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005080
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005081 /**
5082 * Intent extra: the reason that the operation associated with this intent is being performed.
5083 *
5084 * <p>Type: String
5085 * @hide
5086 */
5087 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005088 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5089
qingxi240c2bb2017-04-12 17:31:18 -07005090 /**
5091 * {@hide}
5092 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5093 */
Rubin Xue8490f12015-06-25 12:17:48 +01005094 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5095
Santos Cordon15a13782015-03-31 18:32:31 -07005096 /**
qingxi240c2bb2017-04-12 17:31:18 -07005097 * {@hide}
5098 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5099 * reset for the device with eSIM. This extra will be sent together with
5100 * {@link #ACTION_FACTORY_RESET}
5101 */
5102 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5103
5104 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005105 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5106 * activation request.
5107 * TODO: Add information about the structure and response data used with the pending intent.
5108 * @hide
5109 */
5110 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5111 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5112
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005113 /**
5114 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005115 *
5116 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005117 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005118 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005119 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5120
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005121 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005122 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5123 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5124 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005125 *
5126 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005127 * @see #ACTION_QUICK_VIEW
5128 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005129 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005130 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005131 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5132 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005133
5134 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005135 * An optional extra of {@code String[]} indicating which quick view features should be made
5136 * available to the user in the quick view UI while handing a
5137 * {@link Intent#ACTION_QUICK_VIEW} intent.
5138 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5139 * Quick viewer can implement features not listed below.
5140 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005141 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5142 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5143 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005144 * <p>
5145 * Requirements:
5146 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5147 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5148 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5149 * internal policies.
5150 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5151 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5152 * disable or hide features.
5153 *
5154 * @see #ACTION_QUICK_VIEW
5155 */
5156 public static final String EXTRA_QUICK_VIEW_FEATURES =
5157 "android.intent.extra.QUICK_VIEW_FEATURES";
5158
5159 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005160 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005161 * When a profile goes into quiet mode, all apps in the profile are killed and the
5162 * profile user is stopped. Widgets originating from the profile are masked, and app
5163 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005164 */
5165 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005166
5167 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005168 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005169 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005170 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5171 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005172 *
5173 * @hide
5174 */
5175 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5176 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5177
5178 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005179 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5180 * whether to show the chooser or not when there is only one application available
5181 * to choose from.
5182 *
5183 * @hide
5184 */
5185 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5186 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
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 video codec is allowed to use.
5191 *
5192 * @hide
5193 */
5194 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5195
5196 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005197 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005198 * to represent that a audio codec is allowed to use.
5199 *
5200 * @hide
5201 */
5202 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005204 // ---------------------------------------------------------------------
5205 // ---------------------------------------------------------------------
5206 // Intent flags (see mFlags variable).
5207
Tor Norbyed9273d62013-05-30 15:59:53 -07005208 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005209 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005210 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5211 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005212 @Retention(RetentionPolicy.SOURCE)
5213 public @interface GrantUriMode {}
5214
Jeff Sharkey846318a2014-04-04 12:12:41 -07005215 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005216 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005217 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5218 @Retention(RetentionPolicy.SOURCE)
5219 public @interface AccessUriMode {}
5220
5221 /**
5222 * Test if given mode flags specify an access mode, which must be at least
5223 * read and/or write.
5224 *
5225 * @hide
5226 */
5227 public static boolean isAccessUriMode(int modeFlags) {
5228 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5229 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5230 }
5231
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005232 /** @hide */
5233 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5234 FLAG_GRANT_READ_URI_PERMISSION,
5235 FLAG_GRANT_WRITE_URI_PERMISSION,
5236 FLAG_FROM_BACKGROUND,
5237 FLAG_DEBUG_LOG_RESOLUTION,
5238 FLAG_EXCLUDE_STOPPED_PACKAGES,
5239 FLAG_INCLUDE_STOPPED_PACKAGES,
5240 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5241 FLAG_GRANT_PREFIX_URI_PERMISSION,
5242 FLAG_DEBUG_TRIAGED_MISSING,
5243 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005244 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005245 FLAG_ACTIVITY_NO_HISTORY,
5246 FLAG_ACTIVITY_SINGLE_TOP,
5247 FLAG_ACTIVITY_NEW_TASK,
5248 FLAG_ACTIVITY_MULTIPLE_TASK,
5249 FLAG_ACTIVITY_CLEAR_TOP,
5250 FLAG_ACTIVITY_FORWARD_RESULT,
5251 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5252 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5253 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5254 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5255 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5256 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5257 FLAG_ACTIVITY_NEW_DOCUMENT,
5258 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5259 FLAG_ACTIVITY_NO_USER_ACTION,
5260 FLAG_ACTIVITY_REORDER_TO_FRONT,
5261 FLAG_ACTIVITY_NO_ANIMATION,
5262 FLAG_ACTIVITY_CLEAR_TASK,
5263 FLAG_ACTIVITY_TASK_ON_HOME,
5264 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5265 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5266 FLAG_RECEIVER_REGISTERED_ONLY,
5267 FLAG_RECEIVER_REPLACE_PENDING,
5268 FLAG_RECEIVER_FOREGROUND,
5269 FLAG_RECEIVER_NO_ABORT,
5270 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5271 FLAG_RECEIVER_BOOT_UPGRADE,
5272 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5273 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5274 FLAG_RECEIVER_FROM_SHELL,
5275 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5276 })
5277 @Retention(RetentionPolicy.SOURCE)
5278 public @interface Flags {}
5279
5280 /** @hide */
5281 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5282 FLAG_FROM_BACKGROUND,
5283 FLAG_DEBUG_LOG_RESOLUTION,
5284 FLAG_EXCLUDE_STOPPED_PACKAGES,
5285 FLAG_INCLUDE_STOPPED_PACKAGES,
5286 FLAG_DEBUG_TRIAGED_MISSING,
5287 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005288 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005289 FLAG_ACTIVITY_NO_HISTORY,
5290 FLAG_ACTIVITY_SINGLE_TOP,
5291 FLAG_ACTIVITY_NEW_TASK,
5292 FLAG_ACTIVITY_MULTIPLE_TASK,
5293 FLAG_ACTIVITY_CLEAR_TOP,
5294 FLAG_ACTIVITY_FORWARD_RESULT,
5295 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5296 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5297 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5298 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5299 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5300 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5301 FLAG_ACTIVITY_NEW_DOCUMENT,
5302 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5303 FLAG_ACTIVITY_NO_USER_ACTION,
5304 FLAG_ACTIVITY_REORDER_TO_FRONT,
5305 FLAG_ACTIVITY_NO_ANIMATION,
5306 FLAG_ACTIVITY_CLEAR_TASK,
5307 FLAG_ACTIVITY_TASK_ON_HOME,
5308 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5309 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5310 FLAG_RECEIVER_REGISTERED_ONLY,
5311 FLAG_RECEIVER_REPLACE_PENDING,
5312 FLAG_RECEIVER_FOREGROUND,
5313 FLAG_RECEIVER_NO_ABORT,
5314 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5315 FLAG_RECEIVER_BOOT_UPGRADE,
5316 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5317 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5318 FLAG_RECEIVER_FROM_SHELL,
5319 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5320 })
5321 @Retention(RetentionPolicy.SOURCE)
5322 public @interface MutableFlags {}
5323
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005324 /**
5325 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005326 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005327 * specified in its ClipData. When applying to an Intent's ClipData,
5328 * all URIs as well as recursive traversals through data or other ClipData
5329 * in Intent items will be granted; only the grant flags of the top-level
5330 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005331 */
5332 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5333 /**
5334 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005335 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005336 * specified in its ClipData. When applying to an Intent's ClipData,
5337 * all URIs as well as recursive traversals through data or other ClipData
5338 * in Intent items will be granted; only the grant flags of the top-level
5339 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005340 */
5341 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5342 /**
5343 * Can be set by the caller to indicate that this Intent is coming from
5344 * a background operation, not from direct user interaction.
5345 */
5346 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5347 /**
5348 * A flag you can enable for debugging: when set, log messages will be
5349 * printed during the resolution of this intent to show you what has
5350 * been found to create the final resolved list.
5351 */
5352 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005353 /**
5354 * If set, this intent will not match any components in packages that
5355 * are currently stopped. If this is not set, then the default behavior
5356 * is to include such applications in the result.
5357 */
5358 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5359 /**
5360 * If set, this intent will always match any components in packages that
5361 * are currently stopped. This is the default behavior when
5362 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5363 * flags are set, this one wins (it allows overriding of exclude for
5364 * places where the framework may automatically set the exclude flag).
5365 */
5366 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367
5368 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005369 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005370 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005371 * persisted across device reboots until explicitly revoked with
5372 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5373 * grant for possible persisting; the receiving application must call
5374 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5375 * actually persist.
5376 *
5377 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5378 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5379 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005380 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005381 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005382 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005383
5384 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005385 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5386 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5387 * applies to any URI that is a prefix match against the original granted
5388 * URI. (Without this flag, the URI must match exactly for access to be
5389 * granted.) Another URI is considered a prefix match only when scheme,
5390 * authority, and all path segments defined by the prefix are an exact
5391 * match.
5392 */
5393 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5394
5395 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005396 * Flag used to automatically match intents based on their Direct Boot
5397 * awareness and the current user state.
5398 * <p>
5399 * Since the default behavior is to automatically apply the current user
5400 * state, this is effectively a sentinel value that doesn't change the
5401 * output of any queries based on its presence or absence.
5402 * <p>
5403 * Instead, this value can be useful in conjunction with
5404 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5405 * to detect when a caller is relying on implicit automatic matching,
5406 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005407 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005408 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5409
5410 /** {@hide} */
5411 @Deprecated
5412 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005413
5414 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005415 * Internal flag used to indicate ephemeral applications should not be
5416 * considered when resolving the intent.
5417 *
5418 * @hide
5419 */
5420 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5421
5422 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005423 * If set, the new activity is not kept in the history stack. As soon as
5424 * the user navigates away from it, the activity is finished. This may also
5425 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5426 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005427 *
5428 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5429 * is never invoked when the current activity starts a new activity which
5430 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005431 */
5432 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5433 /**
5434 * If set, the activity will not be launched if it is already running
5435 * at the top of the history stack.
5436 */
5437 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5438 /**
5439 * If set, this activity will become the start of a new task on this
5440 * history stack. A task (from the activity that started it to the
5441 * next task activity) defines an atomic group of activities that the
5442 * user can move to. Tasks can be moved to the foreground and background;
5443 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005444 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005445 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5446 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005447 *
5448 * <p>This flag is generally used by activities that want
5449 * to present a "launcher" style behavior: they give the user a list of
5450 * separate things that can be done, which otherwise run completely
5451 * independently of the activity launching them.
5452 *
5453 * <p>When using this flag, if a task is already running for the activity
5454 * you are now starting, then a new activity will not be started; instead,
5455 * the current task will simply be brought to the front of the screen with
5456 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5457 * to disable this behavior.
5458 *
5459 * <p>This flag can not be used when the caller is requesting a result from
5460 * the activity being launched.
5461 */
5462 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5463 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005464 * This flag is used to create a new task and launch an activity into it.
5465 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5466 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5467 * search through existing tasks for ones matching this Intent. Only if no such
5468 * task is found would a new task be created. When paired with
5469 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5470 * the search for a matching task and unconditionally start a new task.
5471 *
5472 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5473 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005474 * top-level application launcher.</strong> Used in conjunction with
5475 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5476 * behavior of bringing an existing task to the foreground. When set,
5477 * a new task is <em>always</em> started to host the Activity for the
5478 * Intent, regardless of whether there is already an existing task running
5479 * the same thing.
5480 *
5481 * <p><strong>Because the default system does not include graphical task management,
5482 * you should not use this flag unless you provide some way for a user to
5483 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005484 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005485 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5486 * creating new document tasks.
5487 *
5488 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005489 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005490 *
Scott Main7aee61f2011-02-08 11:25:01 -08005491 * <p>See
5492 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5493 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005494 *
5495 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5496 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005497 */
5498 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5499 /**
5500 * If set, and the activity being launched is already running in the
5501 * current task, then instead of launching a new instance of that activity,
5502 * all of the other activities on top of it will be closed and this Intent
5503 * will be delivered to the (now on top) old activity as a new Intent.
5504 *
5505 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5506 * If D calls startActivity() with an Intent that resolves to the component
5507 * of activity B, then C and D will be finished and B receive the given
5508 * Intent, resulting in the stack now being: A, B.
5509 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005510 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005511 * either receive the new intent you are starting here in its
5512 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005513 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005514 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5515 * the same intent, then it will be finished and re-created; for all other
5516 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5517 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005518 *
5519 * <p>This launch mode can also be used to good effect in conjunction with
5520 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5521 * of a task, it will bring any currently running instance of that task
5522 * to the foreground, and then clear it to its root state. This is
5523 * especially useful, for example, when launching an activity from the
5524 * notification manager.
5525 *
Scott Main7aee61f2011-02-08 11:25:01 -08005526 * <p>See
5527 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5528 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005529 */
5530 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5531 /**
5532 * If set and this intent is being used to launch a new activity from an
5533 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005534 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005535 * {@link android.app.Activity#setResult} and have that result sent back to
5536 * the reply target of the original activity.
5537 */
5538 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5539 /**
5540 * If set and this intent is being used to launch a new activity from an
5541 * existing one, the current activity will not be counted as the top
5542 * activity for deciding whether the new intent should be delivered to
5543 * the top instead of starting a new one. The previous activity will
5544 * be used as the top, with the assumption being that the current activity
5545 * will finish itself immediately.
5546 */
5547 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5548 /**
5549 * If set, the new activity is not kept in the list of recently launched
5550 * activities.
5551 */
5552 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5553 /**
5554 * This flag is not normally set by application code, but set for you by
5555 * the system as described in the
5556 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5557 * launchMode} documentation for the singleTask mode.
5558 */
5559 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5560 /**
5561 * If set, and this activity is either being started in a new task or
5562 * bringing to the top an existing task, then it will be launched as
5563 * the front door of the task. This will result in the application of
5564 * any affinities needed to have that task in the proper state (either
5565 * moving activities to or from it), or simply resetting that task to
5566 * its initial state if needed.
5567 */
5568 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5569 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005570 * This flag is not normally set by application code, but set for you by
5571 * the system if this activity is being launched from history
5572 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005573 */
5574 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005575 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005576 * @deprecated As of API 21 this performs identically to
5577 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005578 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005579 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005580 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005581 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005582 * This flag is used to open a document into a new task rooted at the activity launched
5583 * by this Intent. Through the use of this flag, or its equivalent attribute,
5584 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005585 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005586 *
Craig Mautner026596b2014-05-21 15:35:44 -07005587 * <p>The use of the activity attribute form of this,
5588 * {@link android.R.attr#documentLaunchMode}, is
5589 * preferred over the Intent flag described here. The attribute form allows the
5590 * Activity to specify multiple document behavior for all launchers of the Activity
5591 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005592 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005593 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5594 * it is kept after the activity is finished is different than the use of
5595 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5596 * this flag is being used to create a new recents entry, then by default that entry
5597 * will be removed once the activity is finished. You can modify this behavior with
5598 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5599 *
Craig Mautner026596b2014-05-21 15:35:44 -07005600 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5601 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5602 * equivalent of the Activity manifest specifying {@link
5603 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5604 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5605 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005606 *
Craig Mautner026596b2014-05-21 15:35:44 -07005607 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005608 *
Craig Mautner026596b2014-05-21 15:35:44 -07005609 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005610 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5611 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005612 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005613 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005614 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005615 * callback from occurring on the current frontmost activity before it is
5616 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005617 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005618 * <p>Typically, an activity can rely on that callback to indicate that an
5619 * explicit user action has caused their activity to be moved out of the
5620 * foreground. The callback marks an appropriate point in the activity's
5621 * lifecycle for it to dismiss any notifications that it intends to display
5622 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005623 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005624 * <p>If an activity is ever started via any non-user-driven events such as
5625 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5626 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005627 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005628 */
5629 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005630 /**
5631 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5632 * this flag will cause the launched activity to be brought to the front of its
5633 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005634 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005635 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5636 * If D calls startActivity() with an Intent that resolves to the component
5637 * of activity B, then B will be brought to the front of the history stack,
5638 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005639 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005640 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005641 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005642 */
5643 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005644 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005645 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5646 * this flag will prevent the system from applying an activity transition
5647 * animation to go to the next activity state. This doesn't mean an
5648 * animation will never run -- if another activity change happens that doesn't
5649 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005650 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005651 * when you are going to do a series of activity operations but the
5652 * animation seen by the user shouldn't be driven by the first activity
5653 * change but rather a later one.
5654 */
5655 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5656 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005657 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5658 * this flag will cause any existing task that would be associated with the
5659 * activity to be cleared before the activity is started. That is, the activity
5660 * becomes the new root of an otherwise empty task, and any old activities
5661 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5662 */
5663 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5664 /**
5665 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5666 * this flag will cause a newly launching task to be placed on top of the current
5667 * home activity task (if there is one). That is, pressing back from the task
5668 * will always return the user to home even if that was not the last activity they
5669 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5670 */
5671 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5672 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005673 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5674 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005675 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005676 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005677 * this flag. When set and the task's activity is finished, the recents
5678 * entry will remain in the interface for the user to re-launch it, like a
5679 * recents entry for a top-level application.
5680 * <p>
5681 * The receiving activity can override this request with
5682 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5683 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005684 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005685 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005686 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005687
5688 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005689 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5690 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005691 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5692 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005693 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005694 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005695
Patrick Baumann577d4022018-01-31 16:55:10 +00005696
5697 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005698 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5699 * this flag will attempt to launch an instant app if no full app on the device can already
5700 * handle the intent.
5701 * <p>
5702 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5703 * are supported:
5704 * <ul>
5705 * <li>{@link Intent#setAction(String)}</li>
5706 * <li>{@link Intent#addCategory(String)}</li>
5707 * <li>{@link Intent#setData(Uri)}</li>
5708 * <li>{@link Intent#setType(String)}</li>
5709 * <li>{@link Intent#setPackage(String)}</li>
5710 * <li>{@link Intent#addFlags(int)}</li>
5711 * </ul>
5712 * <p>
5713 * In the case that no instant app can be found, the installer will be launched to notify the
5714 * user that the intent could not be resolved. On devices that do not support instant apps,
5715 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005716 */
5717 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5718
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005719 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005720 * If set, when sending a broadcast only registered receivers will be
5721 * called -- no BroadcastReceiver components will be launched.
5722 */
5723 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005724 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005725 * If set, when sending a broadcast the new broadcast will replace
5726 * any existing pending broadcast that matches it. Matching is defined
5727 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5728 * true for the intents of the two broadcasts. When a match is found,
5729 * the new broadcast (and receivers associated with it) will replace the
5730 * existing one in the pending broadcast list, remaining at the same
5731 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005732 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005733 * <p>This flag is most typically used with sticky broadcasts, which
5734 * only care about delivering the most recent values of the broadcast
5735 * to their receivers.
5736 */
5737 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5738 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005739 * If set, when sending a broadcast the recipient is allowed to run at
5740 * foreground priority, with a shorter timeout interval. During normal
5741 * broadcasts the receivers are not automatically hoisted out of the
5742 * background priority class.
5743 */
5744 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5745 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005746 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5747 * They can still propagate results through to later receivers, but they can not prevent
5748 * later receivers from seeing the broadcast.
5749 */
5750 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5751 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005752 * If set, when sending a broadcast <i>before boot has completed</i> only
5753 * registered receivers will be called -- no BroadcastReceiver components
5754 * will be launched. Sticky intent state will be recorded properly even
5755 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5756 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005757 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005758 * <p>This flag is only for use by system sevices as a convenience to
5759 * avoid having to implement a more complex mechanism around detection
5760 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005761 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005762 * @hide
5763 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005764 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005765 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005766 /**
5767 * Set when this broadcast is for a boot upgrade, a special mode that
5768 * allows the broadcast to be sent before the system is ready and launches
5769 * the app process with no providers running in it.
5770 * @hide
5771 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005772 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005773 /**
5774 * If set, the broadcast will always go to manifest receivers in background (cached
5775 * or not running) apps, regardless of whether that would be done by default. By
5776 * default they will only receive broadcasts if the broadcast has specified an
5777 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005778 *
5779 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5780 * the broadcast code there must also be changed to match.
5781 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005782 * @hide
5783 */
5784 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5785 /**
5786 * If set, the broadcast will never go to manifest receivers in background (cached
5787 * or not running) apps, regardless of whether that would be done by default. By
5788 * default they will receive broadcasts if the broadcast has specified an
5789 * explicit component or package name.
5790 * @hide
5791 */
5792 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005793 /**
5794 * If set, this broadcast is being sent from the shell.
5795 * @hide
5796 */
5797 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005798
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005799 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005800 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5801 * will not receive broadcasts.
5802 *
5803 * <em>This flag has no effect when used by an Instant App.</em>
5804 */
5805 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5806
5807 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005808 * @hide Flags that can't be changed with PendingIntent.
5809 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005810 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5811 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5812 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005813
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005814 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005815 // ---------------------------------------------------------------------
5816 // toUri() and parseUri() options.
5817
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005818 /** @hide */
5819 @IntDef(flag = true, prefix = { "URI_" }, value = {
5820 URI_ALLOW_UNSAFE,
5821 URI_ANDROID_APP_SCHEME,
5822 URI_INTENT_SCHEME,
5823 })
5824 @Retention(RetentionPolicy.SOURCE)
5825 public @interface UriFlags {}
5826
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005827 /**
5828 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5829 * always has the "intent:" scheme. This syntax can be used when you want
5830 * to later disambiguate between URIs that are intended to describe an
5831 * Intent vs. all others that should be treated as raw URIs. When used
5832 * with {@link #parseUri}, any other scheme will result in a generic
5833 * VIEW action for that raw URI.
5834 */
5835 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005836
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005837 /**
5838 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5839 * always has the "android-app:" scheme. This is a variation of
5840 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5841 * http/https URI being delivered to a specific package name. The format
5842 * is:
5843 *
5844 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005845 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005846 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005847 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5848 * you must also include a scheme; including a path also requires both a host and a scheme.
5849 * The final #Intent; fragment can be used without a scheme, host, or path.
5850 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005851 * used with intents that have a {@link #setSelector}, since the base intent
5852 * will always have an explicit package name.</p>
5853 *
5854 * <p>Some examples of how this scheme maps to Intent objects:</p>
5855 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5856 * <colgroup align="left" />
5857 * <colgroup align="left" />
5858 * <thead>
5859 * <tr><th>URI</th> <th>Intent</th></tr>
5860 * </thead>
5861 *
5862 * <tbody>
5863 * <tr><td><code>android-app://com.example.app</code></td>
5864 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5865 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5866 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5867 * </table></td>
5868 * </tr>
5869 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5870 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5871 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5872 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5873 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5874 * </table></td>
5875 * </tr>
5876 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5877 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5878 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5879 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5880 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5881 * </table></td>
5882 * </tr>
5883 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5884 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5885 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5886 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5887 * </table></td>
5888 * </tr>
5889 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5890 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5891 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5892 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5893 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5894 * </table></td>
5895 * </tr>
5896 * <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>
5897 * <td><table border="" style="margin:0" >
5898 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5899 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5900 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5901 * </table></td>
5902 * </tr>
5903 * </tbody>
5904 * </table>
5905 */
5906 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5907
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005908 /**
5909 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5910 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5911 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5912 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5913 * generated Intent can not cause unexpected data access to happen.
5914 *
5915 * <p>If you do not trust the source of the URI being parsed, you should still do further
5916 * processing to protect yourself from it. In particular, when using it to start an
5917 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5918 * that can handle it.</p>
5919 */
5920 public static final int URI_ALLOW_UNSAFE = 1<<2;
5921
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005922 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005923
5924 private String mAction;
5925 private Uri mData;
5926 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005927 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005928 private ComponentName mComponent;
5929 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005930 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005931 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005932 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005933 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005934 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005935 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005936 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005937 /** Token to track instant app launches. Local only; do not copy cross-process. */
5938 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005939
5940 // ---------------------------------------------------------------------
5941
Makoto Onuki97f82f22017-05-31 16:20:21 -07005942 private static final int COPY_MODE_ALL = 0;
5943 private static final int COPY_MODE_FILTER = 1;
5944 private static final int COPY_MODE_HISTORY = 2;
5945
5946 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005947 @IntDef(prefix = { "COPY_MODE_" }, value = {
5948 COPY_MODE_ALL,
5949 COPY_MODE_FILTER,
5950 COPY_MODE_HISTORY
5951 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005952 @Retention(RetentionPolicy.SOURCE)
5953 public @interface CopyMode {}
5954
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005955 /**
5956 * Create an empty intent.
5957 */
5958 public Intent() {
5959 }
5960
5961 /**
5962 * Copy constructor.
5963 */
5964 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005965 this(o, COPY_MODE_ALL);
5966 }
5967
5968 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005969 this.mAction = o.mAction;
5970 this.mData = o.mData;
5971 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005972 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005973 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005975 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005976 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005978
5979 if (copyMode != COPY_MODE_FILTER) {
5980 this.mFlags = o.mFlags;
5981 this.mContentUserHint = o.mContentUserHint;
5982 this.mLaunchToken = o.mLaunchToken;
5983 if (o.mSourceBounds != null) {
5984 this.mSourceBounds = new Rect(o.mSourceBounds);
5985 }
5986 if (o.mSelector != null) {
5987 this.mSelector = new Intent(o.mSelector);
5988 }
5989
5990 if (copyMode != COPY_MODE_HISTORY) {
5991 if (o.mExtras != null) {
5992 this.mExtras = new Bundle(o.mExtras);
5993 }
5994 if (o.mClipData != null) {
5995 this.mClipData = new ClipData(o.mClipData);
5996 }
5997 } else {
5998 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5999 this.mExtras = Bundle.STRIPPED;
6000 }
6001
6002 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6003 // history.
6004 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006005 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006006 }
6007
6008 @Override
6009 public Object clone() {
6010 return new Intent(this);
6011 }
6012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006013 /**
6014 * Make a clone of only the parts of the Intent that are relevant for
6015 * filter matching: the action, data, type, component, and categories.
6016 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006017 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006018 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006019 }
6020
6021 /**
6022 * Create an intent with a given action. All other fields (data, type,
6023 * class) are null. Note that the action <em>must</em> be in a
6024 * namespace because Intents are used globally in the system -- for
6025 * example the system VIEW action is android.intent.action.VIEW; an
6026 * application's custom action would be something like
6027 * com.google.app.myapp.CUSTOM_ACTION.
6028 *
6029 * @param action The Intent action, such as ACTION_VIEW.
6030 */
6031 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006032 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006033 }
6034
6035 /**
6036 * Create an intent with a given action and for a given data url. Note
6037 * that the action <em>must</em> be in a namespace because Intents are
6038 * used globally in the system -- for example the system VIEW action is
6039 * android.intent.action.VIEW; an application's custom action would be
6040 * something like com.google.app.myapp.CUSTOM_ACTION.
6041 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006042 * <p><em>Note: scheme and host name matching in the Android framework is
6043 * case-sensitive, unlike the formal RFC. As a result,
6044 * you should always ensure that you write your Uri with these elements
6045 * using lower case letters, and normalize any Uris you receive from
6046 * outside of Android to ensure the scheme and host is lower case.</em></p>
6047 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006048 * @param action The Intent action, such as ACTION_VIEW.
6049 * @param uri The Intent data URI.
6050 */
6051 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006052 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006053 mData = uri;
6054 }
6055
6056 /**
6057 * Create an intent for a specific component. All other fields (action, data,
6058 * type, class) are null, though they can be modified later with explicit
6059 * calls. This provides a convenient way to create an intent that is
6060 * intended to execute a hard-coded class name, rather than relying on the
6061 * system to find an appropriate class for you; see {@link #setComponent}
6062 * for more information on the repercussions of this.
6063 *
6064 * @param packageContext A Context of the application package implementing
6065 * this class.
6066 * @param cls The component class that is to be used for the intent.
6067 *
6068 * @see #setClass
6069 * @see #setComponent
6070 * @see #Intent(String, android.net.Uri , Context, Class)
6071 */
6072 public Intent(Context packageContext, Class<?> cls) {
6073 mComponent = new ComponentName(packageContext, cls);
6074 }
6075
6076 /**
6077 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006078 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006079 * construct the Intent and then calling {@link #setClass} to set its
6080 * class.
6081 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006082 * <p><em>Note: scheme and host name matching in the Android framework is
6083 * case-sensitive, unlike the formal RFC. As a result,
6084 * you should always ensure that you write your Uri with these elements
6085 * using lower case letters, and normalize any Uris you receive from
6086 * outside of Android to ensure the scheme and host is lower case.</em></p>
6087 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006088 * @param action The Intent action, such as ACTION_VIEW.
6089 * @param uri The Intent data URI.
6090 * @param packageContext A Context of the application package implementing
6091 * this class.
6092 * @param cls The component class that is to be used for the intent.
6093 *
6094 * @see #Intent(String, android.net.Uri)
6095 * @see #Intent(Context, Class)
6096 * @see #setClass
6097 * @see #setComponent
6098 */
6099 public Intent(String action, Uri uri,
6100 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006101 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006102 mData = uri;
6103 mComponent = new ComponentName(packageContext, cls);
6104 }
6105
6106 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006107 * Create an intent to launch the main (root) activity of a task. This
6108 * is the Intent that is started when the application's is launched from
6109 * Home. For anything else that wants to launch an application in the
6110 * same way, it is important that they use an Intent structured the same
6111 * way, and can use this function to ensure this is the case.
6112 *
6113 * <p>The returned Intent has the given Activity component as its explicit
6114 * component, {@link #ACTION_MAIN} as its action, and includes the
6115 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6116 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6117 * to do that through {@link #addFlags(int)} on the returned Intent.
6118 *
6119 * @param mainActivity The main activity component that this Intent will
6120 * launch.
6121 * @return Returns a newly created Intent that can be used to launch the
6122 * activity as a main application entry.
6123 *
6124 * @see #setClass
6125 * @see #setComponent
6126 */
6127 public static Intent makeMainActivity(ComponentName mainActivity) {
6128 Intent intent = new Intent(ACTION_MAIN);
6129 intent.setComponent(mainActivity);
6130 intent.addCategory(CATEGORY_LAUNCHER);
6131 return intent;
6132 }
6133
6134 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006135 * Make an Intent for the main activity of an application, without
6136 * specifying a specific activity to run but giving a selector to find
6137 * the activity. This results in a final Intent that is structured
6138 * the same as when the application is launched from
6139 * Home. For anything else that wants to launch an application in the
6140 * same way, it is important that they use an Intent structured the same
6141 * way, and can use this function to ensure this is the case.
6142 *
6143 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6144 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6145 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6146 * to do that through {@link #addFlags(int)} on the returned Intent.
6147 *
6148 * @param selectorAction The action name of the Intent's selector.
6149 * @param selectorCategory The name of a category to add to the Intent's
6150 * selector.
6151 * @return Returns a newly created Intent that can be used to launch the
6152 * activity as a main application entry.
6153 *
6154 * @see #setSelector(Intent)
6155 */
6156 public static Intent makeMainSelectorActivity(String selectorAction,
6157 String selectorCategory) {
6158 Intent intent = new Intent(ACTION_MAIN);
6159 intent.addCategory(CATEGORY_LAUNCHER);
6160 Intent selector = new Intent();
6161 selector.setAction(selectorAction);
6162 selector.addCategory(selectorCategory);
6163 intent.setSelector(selector);
6164 return intent;
6165 }
6166
6167 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006168 * Make an Intent that can be used to re-launch an application's task
6169 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6170 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6171 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6172 *
6173 * @param mainActivity The activity component that is the root of the
6174 * task; this is the activity that has been published in the application's
6175 * manifest as the main launcher icon.
6176 *
6177 * @return Returns a newly created Intent that can be used to relaunch the
6178 * activity's task in its root state.
6179 */
6180 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6181 Intent intent = makeMainActivity(mainActivity);
6182 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6183 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6184 return intent;
6185 }
6186
6187 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006188 * Call {@link #parseUri} with 0 flags.
6189 * @deprecated Use {@link #parseUri} instead.
6190 */
6191 @Deprecated
6192 public static Intent getIntent(String uri) throws URISyntaxException {
6193 return parseUri(uri, 0);
6194 }
Tom Taylord4a47292009-12-21 13:59:18 -08006195
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006196 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006197 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006198 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006199 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006200 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006201 *
6202 * <p>The URI given here must not be relative -- that is, it must include
6203 * the scheme and full path.
6204 *
6205 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006206 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006207 *
6208 * @return Intent The newly created Intent object.
6209 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006210 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6211 * it bad (as parsed by the Uri class) or the Intent data within the
6212 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006213 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006214 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006215 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006216 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006217 int i = 0;
6218 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006219 final boolean androidApp = uri.startsWith("android-app:");
6220
6221 // Validate intent scheme if requested.
6222 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6223 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006224 Intent intent = new Intent(ACTION_VIEW);
6225 try {
6226 intent.setData(Uri.parse(uri));
6227 } catch (IllegalArgumentException e) {
6228 throw new URISyntaxException(uri, e.getMessage());
6229 }
6230 return intent;
6231 }
6232 }
Tom Taylord4a47292009-12-21 13:59:18 -08006233
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006234 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006235 // simple case
6236 if (i == -1) {
6237 if (!androidApp) {
6238 return new Intent(ACTION_VIEW, Uri.parse(uri));
6239 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006240
6241 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006242 } else if (!uri.startsWith("#Intent;", i)) {
6243 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006244 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006245 } else {
6246 i = -1;
6247 }
6248 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006249
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006250 // new format
6251 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006252 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006253 boolean explicitAction = false;
6254 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006255
6256 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006257 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006258 String data;
6259 if (i >= 0) {
6260 data = uri.substring(0, i);
6261 i += 8; // length of "#Intent;"
6262 } else {
6263 data = uri;
6264 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006265
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006266 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006267 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006268 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006269 if (eq < 0) eq = i-1;
6270 int semi = uri.indexOf(';', i);
6271 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006272
6273 // action
6274 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006275 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006276 if (!inSelector) {
6277 explicitAction = true;
6278 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006279 }
6280
6281 // categories
6282 else if (uri.startsWith("category=", i)) {
6283 intent.addCategory(value);
6284 }
6285
6286 // type
6287 else if (uri.startsWith("type=", i)) {
6288 intent.mType = value;
6289 }
6290
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006291 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006292 else if (uri.startsWith("launchFlags=", i)) {
6293 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006294 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6295 intent.mFlags &= ~IMMUTABLE_FLAGS;
6296 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006297 }
6298
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006299 // package
6300 else if (uri.startsWith("package=", i)) {
6301 intent.mPackage = value;
6302 }
6303
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006304 // component
6305 else if (uri.startsWith("component=", i)) {
6306 intent.mComponent = ComponentName.unflattenFromString(value);
6307 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006308
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006309 // scheme
6310 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006311 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006312 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006313 } else {
6314 scheme = value;
6315 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006316 }
6317
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006318 // source bounds
6319 else if (uri.startsWith("sourceBounds=", i)) {
6320 intent.mSourceBounds = Rect.unflattenFromString(value);
6321 }
6322
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006323 // selector
6324 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6325 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006326 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006327 }
6328
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006329 // extra
6330 else {
6331 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006332 // create Bundle if it doesn't already exist
6333 if (intent.mExtras == null) intent.mExtras = new Bundle();
6334 Bundle b = intent.mExtras;
6335 // add EXTRA
6336 if (uri.startsWith("S.", i)) b.putString(key, value);
6337 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6338 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6339 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6340 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6341 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6342 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6343 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6344 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6345 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6346 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006347
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006348 // move to the next item
6349 i = semi + 1;
6350 }
6351
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006352 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006353 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006354 if (baseIntent.mPackage == null) {
6355 baseIntent.setSelector(intent);
6356 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006357 intent = baseIntent;
6358 }
6359
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006360 if (data != null) {
6361 if (data.startsWith("intent:")) {
6362 data = data.substring(7);
6363 if (scheme != null) {
6364 data = scheme + ':' + data;
6365 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006366 } else if (data.startsWith("android-app:")) {
6367 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6368 // Correctly formed android-app, first part is package name.
6369 int end = data.indexOf('/', 14);
6370 if (end < 0) {
6371 // All we have is a package name.
6372 intent.mPackage = data.substring(14);
6373 if (!explicitAction) {
6374 intent.setAction(ACTION_MAIN);
6375 }
6376 data = "";
6377 } else {
6378 // Target the Intent at the given package name always.
6379 String authority = null;
6380 intent.mPackage = data.substring(14, end);
6381 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006382 if ((end+1) < data.length()) {
6383 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6384 // Found a scheme, remember it.
6385 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006386 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006387 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6388 // Found a authority, remember it.
6389 authority = data.substring(end+1, newEnd);
6390 end = newEnd;
6391 }
6392 } else {
6393 // All we have is a scheme.
6394 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006395 }
6396 }
6397 if (scheme == null) {
6398 // If there was no scheme, then this just targets the package.
6399 if (!explicitAction) {
6400 intent.setAction(ACTION_MAIN);
6401 }
6402 data = "";
6403 } else if (authority == null) {
6404 data = scheme + ":";
6405 } else {
6406 data = scheme + "://" + authority + data.substring(end);
6407 }
6408 }
6409 } else {
6410 data = "";
6411 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006412 }
Tom Taylord4a47292009-12-21 13:59:18 -08006413
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006414 if (data.length() > 0) {
6415 try {
6416 intent.mData = Uri.parse(data);
6417 } catch (IllegalArgumentException e) {
6418 throw new URISyntaxException(uri, e.getMessage());
6419 }
6420 }
6421 }
Tom Taylord4a47292009-12-21 13:59:18 -08006422
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006423 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006424
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006425 } catch (IndexOutOfBoundsException e) {
6426 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6427 }
6428 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006429
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006430 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006431 return getIntentOld(uri, 0);
6432 }
6433
6434 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006435 Intent intent;
6436
6437 int i = uri.lastIndexOf('#');
6438 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006439 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006440 final int intentFragmentStart = i;
6441 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006442
6443 i++;
6444
6445 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006446 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006447 i += 7;
6448 int j = uri.indexOf(')', i);
6449 action = uri.substring(i, j);
6450 i = j + 1;
6451 }
6452
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006453 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006454
6455 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006456 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006457 i += 11;
6458 int j = uri.indexOf(')', i);
6459 while (i < j) {
6460 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006461 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006462 if (i < sep) {
6463 intent.addCategory(uri.substring(i, sep));
6464 }
6465 i = sep + 1;
6466 }
6467 i = j + 1;
6468 }
6469
6470 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006471 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006472 i += 5;
6473 int j = uri.indexOf(')', i);
6474 intent.mType = uri.substring(i, j);
6475 i = j + 1;
6476 }
6477
6478 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006479 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006480 i += 12;
6481 int j = uri.indexOf(')', i);
6482 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006483 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6484 intent.mFlags &= ~IMMUTABLE_FLAGS;
6485 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006486 i = j + 1;
6487 }
6488
6489 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006490 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006491 i += 10;
6492 int j = uri.indexOf(')', i);
6493 int sep = uri.indexOf('!', i);
6494 if (sep >= 0 && sep < j) {
6495 String pkg = uri.substring(i, sep);
6496 String cls = uri.substring(sep + 1, j);
6497 intent.mComponent = new ComponentName(pkg, cls);
6498 }
6499 i = j + 1;
6500 }
6501
6502 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006503 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006504 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006505
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006506 final int closeParen = uri.indexOf(')', i);
6507 if (closeParen == -1) throw new URISyntaxException(uri,
6508 "EXTRA missing trailing ')'", i);
6509
6510 while (i < closeParen) {
6511 // fetch the key value
6512 int j = uri.indexOf('=', i);
6513 if (j <= i + 1 || i >= closeParen) {
6514 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6515 }
6516 char type = uri.charAt(i);
6517 i++;
6518 String key = uri.substring(i, j);
6519 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006520
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006521 // get type-value
6522 j = uri.indexOf('!', i);
6523 if (j == -1 || j >= closeParen) j = closeParen;
6524 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6525 String value = uri.substring(i, j);
6526 i = j;
6527
6528 // create Bundle if it doesn't already exist
6529 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006530
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006531 // add item to bundle
6532 try {
6533 switch (type) {
6534 case 'S':
6535 intent.mExtras.putString(key, Uri.decode(value));
6536 break;
6537 case 'B':
6538 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6539 break;
6540 case 'b':
6541 intent.mExtras.putByte(key, Byte.parseByte(value));
6542 break;
6543 case 'c':
6544 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6545 break;
6546 case 'd':
6547 intent.mExtras.putDouble(key, Double.parseDouble(value));
6548 break;
6549 case 'f':
6550 intent.mExtras.putFloat(key, Float.parseFloat(value));
6551 break;
6552 case 'i':
6553 intent.mExtras.putInt(key, Integer.parseInt(value));
6554 break;
6555 case 'l':
6556 intent.mExtras.putLong(key, Long.parseLong(value));
6557 break;
6558 case 's':
6559 intent.mExtras.putShort(key, Short.parseShort(value));
6560 break;
6561 default:
6562 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6563 }
6564 } catch (NumberFormatException e) {
6565 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6566 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006567
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006568 char ch = uri.charAt(i);
6569 if (ch == ')') break;
6570 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6571 i++;
6572 }
6573 }
6574
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006575 if (isIntentFragment) {
6576 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6577 } else {
6578 intent.mData = Uri.parse(uri);
6579 }
Tom Taylord4a47292009-12-21 13:59:18 -08006580
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006581 if (intent.mAction == null) {
6582 // By default, if no action is specified, then use VIEW.
6583 intent.mAction = ACTION_VIEW;
6584 }
6585
6586 } else {
6587 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6588 }
6589
6590 return intent;
6591 }
6592
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006593 /** @hide */
6594 public interface CommandOptionHandler {
6595 boolean handleOption(String opt, ShellCommand cmd);
6596 }
6597
6598 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006599 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006600 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6601 throws URISyntaxException {
6602 Intent intent = new Intent();
6603 Intent baseIntent = intent;
6604 boolean hasIntentInfo = false;
6605
6606 Uri data = null;
6607 String type = null;
6608
6609 String opt;
6610 while ((opt=cmd.getNextOption()) != null) {
6611 switch (opt) {
6612 case "-a":
6613 intent.setAction(cmd.getNextArgRequired());
6614 if (intent == baseIntent) {
6615 hasIntentInfo = true;
6616 }
6617 break;
6618 case "-d":
6619 data = Uri.parse(cmd.getNextArgRequired());
6620 if (intent == baseIntent) {
6621 hasIntentInfo = true;
6622 }
6623 break;
6624 case "-t":
6625 type = cmd.getNextArgRequired();
6626 if (intent == baseIntent) {
6627 hasIntentInfo = true;
6628 }
6629 break;
6630 case "-c":
6631 intent.addCategory(cmd.getNextArgRequired());
6632 if (intent == baseIntent) {
6633 hasIntentInfo = true;
6634 }
6635 break;
6636 case "-e":
6637 case "--es": {
6638 String key = cmd.getNextArgRequired();
6639 String value = cmd.getNextArgRequired();
6640 intent.putExtra(key, value);
6641 }
6642 break;
6643 case "--esn": {
6644 String key = cmd.getNextArgRequired();
6645 intent.putExtra(key, (String) null);
6646 }
6647 break;
6648 case "--ei": {
6649 String key = cmd.getNextArgRequired();
6650 String value = cmd.getNextArgRequired();
6651 intent.putExtra(key, Integer.decode(value));
6652 }
6653 break;
6654 case "--eu": {
6655 String key = cmd.getNextArgRequired();
6656 String value = cmd.getNextArgRequired();
6657 intent.putExtra(key, Uri.parse(value));
6658 }
6659 break;
6660 case "--ecn": {
6661 String key = cmd.getNextArgRequired();
6662 String value = cmd.getNextArgRequired();
6663 ComponentName cn = ComponentName.unflattenFromString(value);
6664 if (cn == null)
6665 throw new IllegalArgumentException("Bad component name: " + value);
6666 intent.putExtra(key, cn);
6667 }
6668 break;
6669 case "--eia": {
6670 String key = cmd.getNextArgRequired();
6671 String value = cmd.getNextArgRequired();
6672 String[] strings = value.split(",");
6673 int[] list = new int[strings.length];
6674 for (int i = 0; i < strings.length; i++) {
6675 list[i] = Integer.decode(strings[i]);
6676 }
6677 intent.putExtra(key, list);
6678 }
6679 break;
6680 case "--eial": {
6681 String key = cmd.getNextArgRequired();
6682 String value = cmd.getNextArgRequired();
6683 String[] strings = value.split(",");
6684 ArrayList<Integer> list = new ArrayList<>(strings.length);
6685 for (int i = 0; i < strings.length; i++) {
6686 list.add(Integer.decode(strings[i]));
6687 }
6688 intent.putExtra(key, list);
6689 }
6690 break;
6691 case "--el": {
6692 String key = cmd.getNextArgRequired();
6693 String value = cmd.getNextArgRequired();
6694 intent.putExtra(key, Long.valueOf(value));
6695 }
6696 break;
6697 case "--ela": {
6698 String key = cmd.getNextArgRequired();
6699 String value = cmd.getNextArgRequired();
6700 String[] strings = value.split(",");
6701 long[] list = new long[strings.length];
6702 for (int i = 0; i < strings.length; i++) {
6703 list[i] = Long.valueOf(strings[i]);
6704 }
6705 intent.putExtra(key, list);
6706 hasIntentInfo = true;
6707 }
6708 break;
6709 case "--elal": {
6710 String key = cmd.getNextArgRequired();
6711 String value = cmd.getNextArgRequired();
6712 String[] strings = value.split(",");
6713 ArrayList<Long> list = new ArrayList<>(strings.length);
6714 for (int i = 0; i < strings.length; i++) {
6715 list.add(Long.valueOf(strings[i]));
6716 }
6717 intent.putExtra(key, list);
6718 hasIntentInfo = true;
6719 }
6720 break;
6721 case "--ef": {
6722 String key = cmd.getNextArgRequired();
6723 String value = cmd.getNextArgRequired();
6724 intent.putExtra(key, Float.valueOf(value));
6725 hasIntentInfo = true;
6726 }
6727 break;
6728 case "--efa": {
6729 String key = cmd.getNextArgRequired();
6730 String value = cmd.getNextArgRequired();
6731 String[] strings = value.split(",");
6732 float[] list = new float[strings.length];
6733 for (int i = 0; i < strings.length; i++) {
6734 list[i] = Float.valueOf(strings[i]);
6735 }
6736 intent.putExtra(key, list);
6737 hasIntentInfo = true;
6738 }
6739 break;
6740 case "--efal": {
6741 String key = cmd.getNextArgRequired();
6742 String value = cmd.getNextArgRequired();
6743 String[] strings = value.split(",");
6744 ArrayList<Float> list = new ArrayList<>(strings.length);
6745 for (int i = 0; i < strings.length; i++) {
6746 list.add(Float.valueOf(strings[i]));
6747 }
6748 intent.putExtra(key, list);
6749 hasIntentInfo = true;
6750 }
6751 break;
6752 case "--esa": {
6753 String key = cmd.getNextArgRequired();
6754 String value = cmd.getNextArgRequired();
6755 // Split on commas unless they are preceeded by an escape.
6756 // The escape character must be escaped for the string and
6757 // again for the regex, thus four escape characters become one.
6758 String[] strings = value.split("(?<!\\\\),");
6759 intent.putExtra(key, strings);
6760 hasIntentInfo = true;
6761 }
6762 break;
6763 case "--esal": {
6764 String key = cmd.getNextArgRequired();
6765 String value = cmd.getNextArgRequired();
6766 // Split on commas unless they are preceeded by an escape.
6767 // The escape character must be escaped for the string and
6768 // again for the regex, thus four escape characters become one.
6769 String[] strings = value.split("(?<!\\\\),");
6770 ArrayList<String> list = new ArrayList<>(strings.length);
6771 for (int i = 0; i < strings.length; i++) {
6772 list.add(strings[i]);
6773 }
6774 intent.putExtra(key, list);
6775 hasIntentInfo = true;
6776 }
6777 break;
6778 case "--ez": {
6779 String key = cmd.getNextArgRequired();
6780 String value = cmd.getNextArgRequired().toLowerCase();
6781 // Boolean.valueOf() results in false for anything that is not "true", which is
6782 // error-prone in shell commands
6783 boolean arg;
6784 if ("true".equals(value) || "t".equals(value)) {
6785 arg = true;
6786 } else if ("false".equals(value) || "f".equals(value)) {
6787 arg = false;
6788 } else {
6789 try {
6790 arg = Integer.decode(value) != 0;
6791 } catch (NumberFormatException ex) {
6792 throw new IllegalArgumentException("Invalid boolean value: " + value);
6793 }
6794 }
6795
6796 intent.putExtra(key, arg);
6797 }
6798 break;
6799 case "-n": {
6800 String str = cmd.getNextArgRequired();
6801 ComponentName cn = ComponentName.unflattenFromString(str);
6802 if (cn == null)
6803 throw new IllegalArgumentException("Bad component name: " + str);
6804 intent.setComponent(cn);
6805 if (intent == baseIntent) {
6806 hasIntentInfo = true;
6807 }
6808 }
6809 break;
6810 case "-p": {
6811 String str = cmd.getNextArgRequired();
6812 intent.setPackage(str);
6813 if (intent == baseIntent) {
6814 hasIntentInfo = true;
6815 }
6816 }
6817 break;
6818 case "-f":
6819 String str = cmd.getNextArgRequired();
6820 intent.setFlags(Integer.decode(str).intValue());
6821 break;
6822 case "--grant-read-uri-permission":
6823 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6824 break;
6825 case "--grant-write-uri-permission":
6826 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6827 break;
6828 case "--grant-persistable-uri-permission":
6829 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6830 break;
6831 case "--grant-prefix-uri-permission":
6832 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6833 break;
6834 case "--exclude-stopped-packages":
6835 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6836 break;
6837 case "--include-stopped-packages":
6838 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6839 break;
6840 case "--debug-log-resolution":
6841 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6842 break;
6843 case "--activity-brought-to-front":
6844 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6845 break;
6846 case "--activity-clear-top":
6847 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6848 break;
6849 case "--activity-clear-when-task-reset":
6850 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6851 break;
6852 case "--activity-exclude-from-recents":
6853 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6854 break;
6855 case "--activity-launched-from-history":
6856 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6857 break;
6858 case "--activity-multiple-task":
6859 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6860 break;
6861 case "--activity-no-animation":
6862 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6863 break;
6864 case "--activity-no-history":
6865 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6866 break;
6867 case "--activity-no-user-action":
6868 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6869 break;
6870 case "--activity-previous-is-top":
6871 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6872 break;
6873 case "--activity-reorder-to-front":
6874 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6875 break;
6876 case "--activity-reset-task-if-needed":
6877 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6878 break;
6879 case "--activity-single-top":
6880 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6881 break;
6882 case "--activity-clear-task":
6883 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6884 break;
6885 case "--activity-task-on-home":
6886 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6887 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006888 case "--activity-match-external":
6889 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6890 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006891 case "--receiver-registered-only":
6892 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6893 break;
6894 case "--receiver-replace-pending":
6895 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6896 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006897 case "--receiver-foreground":
6898 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6899 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006900 case "--receiver-no-abort":
6901 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6902 break;
6903 case "--receiver-include-background":
6904 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6905 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006906 case "--selector":
6907 intent.setDataAndType(data, type);
6908 intent = new Intent();
6909 break;
6910 default:
6911 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6912 // Okay, caller handled this option.
6913 } else {
6914 throw new IllegalArgumentException("Unknown option: " + opt);
6915 }
6916 break;
6917 }
6918 }
6919 intent.setDataAndType(data, type);
6920
6921 final boolean hasSelector = intent != baseIntent;
6922 if (hasSelector) {
6923 // A selector was specified; fix up.
6924 baseIntent.setSelector(intent);
6925 intent = baseIntent;
6926 }
6927
6928 String arg = cmd.getNextArg();
6929 baseIntent = null;
6930 if (arg == null) {
6931 if (hasSelector) {
6932 // If a selector has been specified, and no arguments
6933 // have been supplied for the main Intent, then we can
6934 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6935 // need to have a component name specified yet, the
6936 // selector will take care of that.
6937 baseIntent = new Intent(Intent.ACTION_MAIN);
6938 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6939 }
6940 } else if (arg.indexOf(':') >= 0) {
6941 // The argument is a URI. Fully parse it, and use that result
6942 // to fill in any data not specified so far.
6943 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6944 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6945 } else if (arg.indexOf('/') >= 0) {
6946 // The argument is a component name. Build an Intent to launch
6947 // it.
6948 baseIntent = new Intent(Intent.ACTION_MAIN);
6949 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6950 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6951 } else {
6952 // Assume the argument is a package name.
6953 baseIntent = new Intent(Intent.ACTION_MAIN);
6954 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6955 baseIntent.setPackage(arg);
6956 }
6957 if (baseIntent != null) {
6958 Bundle extras = intent.getExtras();
6959 intent.replaceExtras((Bundle)null);
6960 Bundle uriExtras = baseIntent.getExtras();
6961 baseIntent.replaceExtras((Bundle)null);
6962 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6963 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6964 for (String c : cats) {
6965 baseIntent.removeCategory(c);
6966 }
6967 }
6968 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6969 if (extras == null) {
6970 extras = uriExtras;
6971 } else if (uriExtras != null) {
6972 uriExtras.putAll(extras);
6973 extras = uriExtras;
6974 }
6975 intent.replaceExtras(extras);
6976 hasIntentInfo = true;
6977 }
6978
6979 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6980 return intent;
6981 }
6982
6983 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006984 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006985 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6986 final String[] lines = new String[] {
6987 "<INTENT> specifications include these flags and arguments:",
6988 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6989 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07006990 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006991 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6992 " [--esn <EXTRA_KEY> ...]",
6993 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6994 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6995 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6996 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6997 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6998 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6999 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7000 " (mutiple extras passed as Integer[])",
7001 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7002 " (mutiple extras passed as List<Integer>)",
7003 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7004 " (mutiple extras passed as Long[])",
7005 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7006 " (mutiple extras passed as List<Long>)",
7007 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7008 " (mutiple extras passed as Float[])",
7009 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7010 " (mutiple extras passed as List<Float>)",
7011 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7012 " (mutiple extras passed as String[]; to embed a comma into a string,",
7013 " escape it using \"\\,\")",
7014 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7015 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7016 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007017 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007018 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7019 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7020 " [--debug-log-resolution] [--exclude-stopped-packages]",
7021 " [--include-stopped-packages]",
7022 " [--activity-brought-to-front] [--activity-clear-top]",
7023 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7024 " [--activity-launched-from-history] [--activity-multiple-task]",
7025 " [--activity-no-animation] [--activity-no-history]",
7026 " [--activity-no-user-action] [--activity-previous-is-top]",
7027 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7028 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007029 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007030 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007031 " [--receiver-foreground] [--receiver-no-abort]",
7032 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007033 " [--selector]",
7034 " [<URI> | <PACKAGE> | <COMPONENT>]"
7035 };
7036 for (String line : lines) {
7037 pw.print(prefix);
7038 pw.println(line);
7039 }
7040 }
7041
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007042 /**
7043 * Retrieve the general action to be performed, such as
7044 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7045 * the information in the intent should be interpreted -- most importantly,
7046 * what to do with the data returned by {@link #getData}.
7047 *
7048 * @return The action of this intent or null if none is specified.
7049 *
7050 * @see #setAction
7051 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007052 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007053 return mAction;
7054 }
7055
7056 /**
7057 * Retrieve data this intent is operating on. This URI specifies the name
7058 * of the data; often it uses the content: scheme, specifying data in a
7059 * content provider. Other schemes may be handled by specific activities,
7060 * such as http: by the web browser.
7061 *
7062 * @return The URI of the data this intent is targeting or null.
7063 *
7064 * @see #getScheme
7065 * @see #setData
7066 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007067 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007068 return mData;
7069 }
7070
7071 /**
7072 * The same as {@link #getData()}, but returns the URI as an encoded
7073 * String.
7074 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007075 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007076 return mData != null ? mData.toString() : null;
7077 }
7078
7079 /**
7080 * Return the scheme portion of the intent's data. If the data is null or
7081 * does not include a scheme, null is returned. Otherwise, the scheme
7082 * prefix without the final ':' is returned, i.e. "http".
7083 *
7084 * <p>This is the same as calling getData().getScheme() (and checking for
7085 * null data).
7086 *
7087 * @return The scheme of this intent.
7088 *
7089 * @see #getData
7090 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007091 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007092 return mData != null ? mData.getScheme() : null;
7093 }
7094
7095 /**
7096 * Retrieve any explicit MIME type included in the intent. This is usually
7097 * null, as the type is determined by the intent data.
7098 *
7099 * @return If a type was manually set, it is returned; else null is
7100 * returned.
7101 *
7102 * @see #resolveType(ContentResolver)
7103 * @see #setType
7104 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007105 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007106 return mType;
7107 }
7108
7109 /**
7110 * Return the MIME data type of this intent. If the type field is
7111 * explicitly set, that is simply returned. Otherwise, if the data is set,
7112 * the type of that data is returned. If neither fields are set, a null is
7113 * returned.
7114 *
7115 * @return The MIME type of this intent.
7116 *
7117 * @see #getType
7118 * @see #resolveType(ContentResolver)
7119 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007120 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007121 return resolveType(context.getContentResolver());
7122 }
7123
7124 /**
7125 * Return the MIME data type of this intent. If the type field is
7126 * explicitly set, that is simply returned. Otherwise, if the data is set,
7127 * the type of that data is returned. If neither fields are set, a null is
7128 * returned.
7129 *
7130 * @param resolver A ContentResolver that can be used to determine the MIME
7131 * type of the intent's data.
7132 *
7133 * @return The MIME type of this intent.
7134 *
7135 * @see #getType
7136 * @see #resolveType(Context)
7137 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007138 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007139 if (mType != null) {
7140 return mType;
7141 }
7142 if (mData != null) {
7143 if ("content".equals(mData.getScheme())) {
7144 return resolver.getType(mData);
7145 }
7146 }
7147 return null;
7148 }
7149
7150 /**
7151 * Return the MIME data type of this intent, only if it will be needed for
7152 * intent resolution. This is not generally useful for application code;
7153 * it is used by the frameworks for communicating with back-end system
7154 * services.
7155 *
7156 * @param resolver A ContentResolver that can be used to determine the MIME
7157 * type of the intent's data.
7158 *
7159 * @return The MIME type of this intent, or null if it is unknown or not
7160 * needed.
7161 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007162 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007163 if (mComponent != null) {
7164 return mType;
7165 }
7166 return resolveType(resolver);
7167 }
7168
7169 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007170 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007171 *
7172 * @param category The category to check.
7173 *
7174 * @return boolean True if the intent contains the category, else false.
7175 *
7176 * @see #getCategories
7177 * @see #addCategory
7178 */
7179 public boolean hasCategory(String category) {
7180 return mCategories != null && mCategories.contains(category);
7181 }
7182
7183 /**
7184 * Return the set of all categories in the intent. If there are no categories,
7185 * returns NULL.
7186 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007187 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007188 *
7189 * @see #hasCategory
7190 * @see #addCategory
7191 */
7192 public Set<String> getCategories() {
7193 return mCategories;
7194 }
7195
7196 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007197 * Return the specific selector associated with this Intent. If there is
7198 * none, returns null. See {@link #setSelector} for more information.
7199 *
7200 * @see #setSelector
7201 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007202 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007203 return mSelector;
7204 }
7205
7206 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007207 * Return the {@link ClipData} associated with this Intent. If there is
7208 * none, returns null. See {@link #setClipData} for more information.
7209 *
John Spurlock125d1332013-11-25 11:58:37 -05007210 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007211 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007212 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007213 return mClipData;
7214 }
7215
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007216 /** @hide */
7217 public int getContentUserHint() {
7218 return mContentUserHint;
7219 }
7220
Todd Kennedyb3b431302017-03-20 16:05:48 -07007221 /** @hide */
7222 public String getLaunchToken() {
7223 return mLaunchToken;
7224 }
7225
7226 /** @hide */
7227 public void setLaunchToken(String launchToken) {
7228 mLaunchToken = launchToken;
7229 }
7230
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007231 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007232 * Sets the ClassLoader that will be used when unmarshalling
7233 * any Parcelable values from the extras of this Intent.
7234 *
7235 * @param loader a ClassLoader, or null to use the default loader
7236 * at the time of unmarshalling.
7237 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007238 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007239 if (mExtras != null) {
7240 mExtras.setClassLoader(loader);
7241 }
7242 }
7243
7244 /**
7245 * Returns true if an extra value is associated with the given name.
7246 * @param name the extra's name
7247 * @return true if the given extra is present.
7248 */
7249 public boolean hasExtra(String name) {
7250 return mExtras != null && mExtras.containsKey(name);
7251 }
7252
7253 /**
7254 * Returns true if the Intent's extras contain a parcelled file descriptor.
7255 * @return true if the Intent contains a parcelled file descriptor.
7256 */
7257 public boolean hasFileDescriptors() {
7258 return mExtras != null && mExtras.hasFileDescriptors();
7259 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007260
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007261 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007262 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007263 public void setAllowFds(boolean allowFds) {
7264 if (mExtras != null) {
7265 mExtras.setAllowFds(allowFds);
7266 }
7267 }
7268
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007269 /** {@hide} */
7270 public void setDefusable(boolean defusable) {
7271 if (mExtras != null) {
7272 mExtras.setDefusable(defusable);
7273 }
7274 }
7275
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007276 /**
7277 * Retrieve extended data from the intent.
7278 *
7279 * @param name The name of the desired item.
7280 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007281 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007282 * or null if none was found.
7283 *
7284 * @deprecated
7285 * @hide
7286 */
7287 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007288 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007289 public Object getExtra(String name) {
7290 return getExtra(name, null);
7291 }
7292
7293 /**
7294 * Retrieve extended data from the intent.
7295 *
7296 * @param name The name of the desired item.
7297 * @param defaultValue the value to be returned if no value of the desired
7298 * type is stored with the given name.
7299 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007300 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 * or the default value if none was found.
7302 *
7303 * @see #putExtra(String, boolean)
7304 */
7305 public boolean getBooleanExtra(String name, boolean defaultValue) {
7306 return mExtras == null ? defaultValue :
7307 mExtras.getBoolean(name, defaultValue);
7308 }
7309
7310 /**
7311 * Retrieve extended data from the intent.
7312 *
7313 * @param name The name of the desired item.
7314 * @param defaultValue the value to be returned if no value of the desired
7315 * type is stored with the given name.
7316 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007317 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 * or the default value if none was found.
7319 *
7320 * @see #putExtra(String, byte)
7321 */
7322 public byte getByteExtra(String name, byte defaultValue) {
7323 return mExtras == null ? defaultValue :
7324 mExtras.getByte(name, defaultValue);
7325 }
7326
7327 /**
7328 * Retrieve extended data from the intent.
7329 *
7330 * @param name The name of the desired item.
7331 * @param defaultValue the value to be returned if no value of the desired
7332 * type is stored with the given name.
7333 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007334 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007335 * or the default value if none was found.
7336 *
7337 * @see #putExtra(String, short)
7338 */
7339 public short getShortExtra(String name, short defaultValue) {
7340 return mExtras == null ? defaultValue :
7341 mExtras.getShort(name, defaultValue);
7342 }
7343
7344 /**
7345 * Retrieve extended data from the intent.
7346 *
7347 * @param name The name of the desired item.
7348 * @param defaultValue the value to be returned if no value of the desired
7349 * type is stored with the given name.
7350 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007351 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007352 * or the default value if none was found.
7353 *
7354 * @see #putExtra(String, char)
7355 */
7356 public char getCharExtra(String name, char defaultValue) {
7357 return mExtras == null ? defaultValue :
7358 mExtras.getChar(name, defaultValue);
7359 }
7360
7361 /**
7362 * Retrieve extended data from the intent.
7363 *
7364 * @param name The name of the desired item.
7365 * @param defaultValue the value to be returned if no value of the desired
7366 * type is stored with the given name.
7367 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007368 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007369 * or the default value if none was found.
7370 *
7371 * @see #putExtra(String, int)
7372 */
7373 public int getIntExtra(String name, int defaultValue) {
7374 return mExtras == null ? defaultValue :
7375 mExtras.getInt(name, defaultValue);
7376 }
7377
7378 /**
7379 * Retrieve extended data from the intent.
7380 *
7381 * @param name The name of the desired item.
7382 * @param defaultValue the value to be returned if no value of the desired
7383 * type is stored with the given name.
7384 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007385 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007386 * or the default value if none was found.
7387 *
7388 * @see #putExtra(String, long)
7389 */
7390 public long getLongExtra(String name, long defaultValue) {
7391 return mExtras == null ? defaultValue :
7392 mExtras.getLong(name, defaultValue);
7393 }
7394
7395 /**
7396 * Retrieve extended data from the intent.
7397 *
7398 * @param name The name of the desired item.
7399 * @param defaultValue the value to be returned if no value of the desired
7400 * type is stored with the given name.
7401 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007402 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007403 * or the default value if no such item is present
7404 *
7405 * @see #putExtra(String, float)
7406 */
7407 public float getFloatExtra(String name, float defaultValue) {
7408 return mExtras == null ? defaultValue :
7409 mExtras.getFloat(name, defaultValue);
7410 }
7411
7412 /**
7413 * Retrieve extended data from the intent.
7414 *
7415 * @param name The name of the desired item.
7416 * @param defaultValue the value to be returned if no value of the desired
7417 * type is stored with the given name.
7418 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007419 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007420 * or the default value if none was found.
7421 *
7422 * @see #putExtra(String, double)
7423 */
7424 public double getDoubleExtra(String name, double defaultValue) {
7425 return mExtras == null ? defaultValue :
7426 mExtras.getDouble(name, defaultValue);
7427 }
7428
7429 /**
7430 * Retrieve extended data from the intent.
7431 *
7432 * @param name The name of the desired item.
7433 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007434 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007435 * or null if no String value was found.
7436 *
7437 * @see #putExtra(String, String)
7438 */
7439 public String getStringExtra(String name) {
7440 return mExtras == null ? null : mExtras.getString(name);
7441 }
7442
7443 /**
7444 * Retrieve extended data from the intent.
7445 *
7446 * @param name The name of the desired item.
7447 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007448 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007449 * or null if no CharSequence value was found.
7450 *
7451 * @see #putExtra(String, CharSequence)
7452 */
7453 public CharSequence getCharSequenceExtra(String name) {
7454 return mExtras == null ? null : mExtras.getCharSequence(name);
7455 }
7456
7457 /**
7458 * Retrieve extended data from the intent.
7459 *
7460 * @param name The name of the desired item.
7461 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007462 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007463 * or null if no Parcelable value was found.
7464 *
7465 * @see #putExtra(String, Parcelable)
7466 */
7467 public <T extends Parcelable> T getParcelableExtra(String name) {
7468 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7469 }
7470
7471 /**
7472 * Retrieve extended data from the intent.
7473 *
7474 * @param name The name of the desired item.
7475 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007476 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007477 * or null if no Parcelable[] value was found.
7478 *
7479 * @see #putExtra(String, Parcelable[])
7480 */
7481 public Parcelable[] getParcelableArrayExtra(String name) {
7482 return mExtras == null ? null : mExtras.getParcelableArray(name);
7483 }
7484
7485 /**
7486 * Retrieve extended data from the intent.
7487 *
7488 * @param name The name of the desired item.
7489 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007490 * @return the value of an item previously added with
7491 * putParcelableArrayListExtra(), or null if no
7492 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007493 *
7494 * @see #putParcelableArrayListExtra(String, ArrayList)
7495 */
7496 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7497 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7498 }
7499
7500 /**
7501 * Retrieve extended data from the intent.
7502 *
7503 * @param name The name of the desired item.
7504 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007505 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007506 * or null if no Serializable value was found.
7507 *
7508 * @see #putExtra(String, Serializable)
7509 */
7510 public Serializable getSerializableExtra(String name) {
7511 return mExtras == null ? null : mExtras.getSerializable(name);
7512 }
7513
7514 /**
7515 * Retrieve extended data from the intent.
7516 *
7517 * @param name The name of the desired item.
7518 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007519 * @return the value of an item previously added with
7520 * putIntegerArrayListExtra(), or null if no
7521 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007522 *
7523 * @see #putIntegerArrayListExtra(String, ArrayList)
7524 */
7525 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7526 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7527 }
7528
7529 /**
7530 * Retrieve extended data from the intent.
7531 *
7532 * @param name The name of the desired item.
7533 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007534 * @return the value of an item previously added with
7535 * putStringArrayListExtra(), or null if no
7536 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007537 *
7538 * @see #putStringArrayListExtra(String, ArrayList)
7539 */
7540 public ArrayList<String> getStringArrayListExtra(String name) {
7541 return mExtras == null ? null : mExtras.getStringArrayList(name);
7542 }
7543
7544 /**
7545 * Retrieve extended data from the intent.
7546 *
7547 * @param name The name of the desired item.
7548 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007549 * @return the value of an item previously added with
7550 * putCharSequenceArrayListExtra, or null if no
7551 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007552 *
7553 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7554 */
7555 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7556 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7557 }
7558
7559 /**
7560 * Retrieve extended data from the intent.
7561 *
7562 * @param name The name of the desired item.
7563 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007564 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007565 * or null if no boolean array value was found.
7566 *
7567 * @see #putExtra(String, boolean[])
7568 */
7569 public boolean[] getBooleanArrayExtra(String name) {
7570 return mExtras == null ? null : mExtras.getBooleanArray(name);
7571 }
7572
7573 /**
7574 * Retrieve extended data from the intent.
7575 *
7576 * @param name The name of the desired item.
7577 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007578 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007579 * or null if no byte array value was found.
7580 *
7581 * @see #putExtra(String, byte[])
7582 */
7583 public byte[] getByteArrayExtra(String name) {
7584 return mExtras == null ? null : mExtras.getByteArray(name);
7585 }
7586
7587 /**
7588 * Retrieve extended data from the intent.
7589 *
7590 * @param name The name of the desired item.
7591 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007592 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007593 * or null if no short array value was found.
7594 *
7595 * @see #putExtra(String, short[])
7596 */
7597 public short[] getShortArrayExtra(String name) {
7598 return mExtras == null ? null : mExtras.getShortArray(name);
7599 }
7600
7601 /**
7602 * Retrieve extended data from the intent.
7603 *
7604 * @param name The name of the desired item.
7605 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007606 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007607 * or null if no char array value was found.
7608 *
7609 * @see #putExtra(String, char[])
7610 */
7611 public char[] getCharArrayExtra(String name) {
7612 return mExtras == null ? null : mExtras.getCharArray(name);
7613 }
7614
7615 /**
7616 * Retrieve extended data from the intent.
7617 *
7618 * @param name The name of the desired item.
7619 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007620 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007621 * or null if no int array value was found.
7622 *
7623 * @see #putExtra(String, int[])
7624 */
7625 public int[] getIntArrayExtra(String name) {
7626 return mExtras == null ? null : mExtras.getIntArray(name);
7627 }
7628
7629 /**
7630 * Retrieve extended data from the intent.
7631 *
7632 * @param name The name of the desired item.
7633 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007634 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007635 * or null if no long array value was found.
7636 *
7637 * @see #putExtra(String, long[])
7638 */
7639 public long[] getLongArrayExtra(String name) {
7640 return mExtras == null ? null : mExtras.getLongArray(name);
7641 }
7642
7643 /**
7644 * Retrieve extended data from the intent.
7645 *
7646 * @param name The name of the desired item.
7647 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007648 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007649 * or null if no float array value was found.
7650 *
7651 * @see #putExtra(String, float[])
7652 */
7653 public float[] getFloatArrayExtra(String name) {
7654 return mExtras == null ? null : mExtras.getFloatArray(name);
7655 }
7656
7657 /**
7658 * Retrieve extended data from the intent.
7659 *
7660 * @param name The name of the desired item.
7661 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007662 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007663 * or null if no double array value was found.
7664 *
7665 * @see #putExtra(String, double[])
7666 */
7667 public double[] getDoubleArrayExtra(String name) {
7668 return mExtras == null ? null : mExtras.getDoubleArray(name);
7669 }
7670
7671 /**
7672 * Retrieve extended data from the intent.
7673 *
7674 * @param name The name of the desired item.
7675 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007676 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007677 * or null if no String array value was found.
7678 *
7679 * @see #putExtra(String, String[])
7680 */
7681 public String[] getStringArrayExtra(String name) {
7682 return mExtras == null ? null : mExtras.getStringArray(name);
7683 }
7684
7685 /**
7686 * Retrieve extended data from the intent.
7687 *
7688 * @param name The name of the desired item.
7689 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007690 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007691 * or null if no CharSequence array value was found.
7692 *
7693 * @see #putExtra(String, CharSequence[])
7694 */
7695 public CharSequence[] getCharSequenceArrayExtra(String name) {
7696 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7697 }
7698
7699 /**
7700 * Retrieve extended data from the intent.
7701 *
7702 * @param name The name of the desired item.
7703 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007704 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007705 * or null if no Bundle value was found.
7706 *
7707 * @see #putExtra(String, Bundle)
7708 */
7709 public Bundle getBundleExtra(String name) {
7710 return mExtras == null ? null : mExtras.getBundle(name);
7711 }
7712
7713 /**
7714 * Retrieve extended data from the intent.
7715 *
7716 * @param name The name of the desired item.
7717 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007718 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007719 * or null if no IBinder value was found.
7720 *
7721 * @see #putExtra(String, IBinder)
7722 *
7723 * @deprecated
7724 * @hide
7725 */
7726 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007727 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007728 public IBinder getIBinderExtra(String name) {
7729 return mExtras == null ? null : mExtras.getIBinder(name);
7730 }
7731
7732 /**
7733 * Retrieve extended data from the intent.
7734 *
7735 * @param name The name of the desired item.
7736 * @param defaultValue The default value to return in case no item is
7737 * associated with the key 'name'
7738 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007739 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007740 * or defaultValue if none was found.
7741 *
7742 * @see #putExtra
7743 *
7744 * @deprecated
7745 * @hide
7746 */
7747 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007748 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007749 public Object getExtra(String name, Object defaultValue) {
7750 Object result = defaultValue;
7751 if (mExtras != null) {
7752 Object result2 = mExtras.get(name);
7753 if (result2 != null) {
7754 result = result2;
7755 }
7756 }
7757
7758 return result;
7759 }
7760
7761 /**
7762 * Retrieves a map of extended data from the intent.
7763 *
7764 * @return the map of all extras previously added with putExtra(),
7765 * or null if none have been added.
7766 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007767 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007768 return (mExtras != null)
7769 ? new Bundle(mExtras)
7770 : null;
7771 }
7772
7773 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007774 * Filter extras to only basic types.
7775 * @hide
7776 */
7777 public void removeUnsafeExtras() {
7778 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007779 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007780 }
7781 }
7782
7783 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007784 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7785 * return itself as-is.
7786 * @hide
7787 */
7788 public boolean canStripForHistory() {
7789 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7790 }
7791
7792 /**
7793 * Call it when the system needs to keep an intent for logging purposes to remove fields
7794 * that are not needed for logging.
7795 * @hide
7796 */
7797 public Intent maybeStripForHistory() {
7798 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7799
7800 if (!canStripForHistory()) {
7801 return this;
7802 }
7803 return new Intent(this, COPY_MODE_HISTORY);
7804 }
7805
7806 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007807 * Retrieve any special flags associated with this intent. You will
7808 * normally just set them with {@link #setFlags} and let the system
7809 * take the appropriate action with them.
7810 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007811 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007812 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007813 * @see #addFlags
7814 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007815 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007816 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007817 return mFlags;
7818 }
7819
Dianne Hackborne7f97212011-02-24 14:40:20 -08007820 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007821 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007822 public boolean isExcludingStopped() {
7823 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7824 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7825 }
7826
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007827 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007828 * Retrieve the application package name this Intent is limited to. When
7829 * resolving an Intent, if non-null this limits the resolution to only
7830 * components in the given application package.
7831 *
7832 * @return The name of the application package for the Intent.
7833 *
7834 * @see #resolveActivity
7835 * @see #setPackage
7836 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007837 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007838 return mPackage;
7839 }
7840
7841 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007842 * Retrieve the concrete component associated with the intent. When receiving
7843 * an intent, this is the component that was found to best handle it (that is,
7844 * yourself) and will always be non-null; in all other cases it will be
7845 * null unless explicitly set.
7846 *
7847 * @return The name of the application component to handle the intent.
7848 *
7849 * @see #resolveActivity
7850 * @see #setComponent
7851 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007852 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007853 return mComponent;
7854 }
7855
7856 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007857 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7858 * used as a hint to the receiver for animations and the like. Null means that there
7859 * is no source bounds.
7860 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007861 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007862 return mSourceBounds;
7863 }
7864
7865 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007866 * Return the Activity component that should be used to handle this intent.
7867 * The appropriate component is determined based on the information in the
7868 * intent, evaluated as follows:
7869 *
7870 * <p>If {@link #getComponent} returns an explicit class, that is returned
7871 * without any further consideration.
7872 *
7873 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7874 * category to be considered.
7875 *
7876 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7877 * action.
7878 *
7879 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7880 * this type.
7881 *
7882 * <p>If {@link #addCategory} has added any categories, the activity must
7883 * handle ALL of the categories specified.
7884 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007885 * <p>If {@link #getPackage} is non-NULL, only activity components in
7886 * that application package will be considered.
7887 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007888 * <p>If there are no activities that satisfy all of these conditions, a
7889 * null string is returned.
7890 *
7891 * <p>If multiple activities are found to satisfy the intent, the one with
7892 * the highest priority will be used. If there are multiple activities
7893 * with the same priority, the system will either pick the best activity
7894 * based on user preference, or resolve to a system class that will allow
7895 * the user to pick an activity and forward from there.
7896 *
7897 * <p>This method is implemented simply by calling
7898 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7899 * true.</p>
7900 * <p> This API is called for you as part of starting an activity from an
7901 * intent. You do not normally need to call it yourself.</p>
7902 *
7903 * @param pm The package manager with which to resolve the Intent.
7904 *
7905 * @return Name of the component implementing an activity that can
7906 * display the intent.
7907 *
7908 * @see #setComponent
7909 * @see #getComponent
7910 * @see #resolveActivityInfo
7911 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007912 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007913 if (mComponent != null) {
7914 return mComponent;
7915 }
7916
7917 ResolveInfo info = pm.resolveActivity(
7918 this, PackageManager.MATCH_DEFAULT_ONLY);
7919 if (info != null) {
7920 return new ComponentName(
7921 info.activityInfo.applicationInfo.packageName,
7922 info.activityInfo.name);
7923 }
7924
7925 return null;
7926 }
7927
7928 /**
7929 * Resolve the Intent into an {@link ActivityInfo}
7930 * describing the activity that should execute the intent. Resolution
7931 * follows the same rules as described for {@link #resolveActivity}, but
7932 * you get back the completely information about the resolved activity
7933 * instead of just its class name.
7934 *
7935 * @param pm The package manager with which to resolve the Intent.
7936 * @param flags Addition information to retrieve as per
7937 * {@link PackageManager#getActivityInfo(ComponentName, int)
7938 * PackageManager.getActivityInfo()}.
7939 *
7940 * @return PackageManager.ActivityInfo
7941 *
7942 * @see #resolveActivity
7943 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007944 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7945 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007946 ActivityInfo ai = null;
7947 if (mComponent != null) {
7948 try {
7949 ai = pm.getActivityInfo(mComponent, flags);
7950 } catch (PackageManager.NameNotFoundException e) {
7951 // ignore
7952 }
7953 } else {
7954 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007955 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007956 if (info != null) {
7957 ai = info.activityInfo;
7958 }
7959 }
7960
7961 return ai;
7962 }
7963
7964 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007965 * Special function for use by the system to resolve service
7966 * intents to system apps. Throws an exception if there are
7967 * multiple potential matches to the Intent. Returns null if
7968 * there are no matches.
7969 * @hide
7970 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007971 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007972 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7973 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007974 if (mComponent != null) {
7975 return mComponent;
7976 }
7977
7978 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7979 if (results == null) {
7980 return null;
7981 }
7982 ComponentName comp = null;
7983 for (int i=0; i<results.size(); i++) {
7984 ResolveInfo ri = results.get(i);
7985 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7986 continue;
7987 }
7988 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7989 ri.serviceInfo.name);
7990 if (comp != null) {
7991 throw new IllegalStateException("Multiple system services handle " + this
7992 + ": " + comp + ", " + foundComp);
7993 }
7994 comp = foundComp;
7995 }
7996 return comp;
7997 }
7998
7999 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008000 * Set the general action to be performed.
8001 *
8002 * @param action An action name, such as ACTION_VIEW. Application-specific
8003 * actions should be prefixed with the vendor's package name.
8004 *
8005 * @return Returns the same Intent object, for chaining multiple calls
8006 * into a single statement.
8007 *
8008 * @see #getAction
8009 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008010 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008011 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008012 return this;
8013 }
8014
8015 /**
8016 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008017 * clears any type that was previously set by {@link #setType} or
8018 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008019 *
Nick Pellyccae4122012-01-09 14:12:58 -08008020 * <p><em>Note: scheme matching in the Android framework is
8021 * case-sensitive, unlike the formal RFC. As a result,
8022 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008023 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008024 * {@link #setDataAndNormalize}
8025 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008026 *
Nick Pellyccae4122012-01-09 14:12:58 -08008027 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008028 *
8029 * @return Returns the same Intent object, for chaining multiple calls
8030 * into a single statement.
8031 *
8032 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008033 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008034 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008035 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008036 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008037 mData = data;
8038 mType = null;
8039 return this;
8040 }
8041
8042 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008043 * Normalize and set the data this intent is operating on.
8044 *
8045 * <p>This method automatically clears any type that was
8046 * previously set (for example, by {@link #setType}).
8047 *
8048 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008049 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008050 * so really this is just a convenience method for
8051 * <pre>
8052 * setData(data.normalize())
8053 * </pre>
8054 *
8055 * @param data The Uri of the data this intent is now targeting.
8056 *
8057 * @return Returns the same Intent object, for chaining multiple calls
8058 * into a single statement.
8059 *
8060 * @see #getData
8061 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008062 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008063 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008064 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008065 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008066 }
8067
8068 /**
8069 * Set an explicit MIME data type.
8070 *
8071 * <p>This is used to create intents that only specify a type and not data,
8072 * for example to indicate the type of data to return.
8073 *
8074 * <p>This method automatically clears any data that was
8075 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008076 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008077 * <p><em>Note: MIME type matching in the Android framework is
8078 * case-sensitive, unlike formal RFC MIME types. As a result,
8079 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008080 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8081 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008082 *
8083 * @param type The MIME type of the data being handled by this intent.
8084 *
8085 * @return Returns the same Intent object, for chaining multiple calls
8086 * into a single statement.
8087 *
8088 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008089 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008090 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008091 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008092 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008093 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008094 mData = null;
8095 mType = type;
8096 return this;
8097 }
8098
8099 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008100 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008101 *
Nick Pellyccae4122012-01-09 14:12:58 -08008102 * <p>This is used to create intents that only specify a type and not data,
8103 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008104 *
Nick Pellyccae4122012-01-09 14:12:58 -08008105 * <p>This method automatically clears any data that was
8106 * previously set (for example by {@link #setData}).
8107 *
8108 * <p>The MIME type is normalized using
8109 * {@link #normalizeMimeType} before it is set,
8110 * so really this is just a convenience method for
8111 * <pre>
8112 * setType(Intent.normalizeMimeType(type))
8113 * </pre>
8114 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008115 * @param type The MIME type of the data being handled by this intent.
8116 *
8117 * @return Returns the same Intent object, for chaining multiple calls
8118 * into a single statement.
8119 *
Nick Pellyccae4122012-01-09 14:12:58 -08008120 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008121 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008122 * @see #normalizeMimeType
8123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008124 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008125 return setType(normalizeMimeType(type));
8126 }
8127
8128 /**
8129 * (Usually optional) Set the data for the intent along with an explicit
8130 * MIME data type. This method should very rarely be used -- it allows you
8131 * to override the MIME type that would ordinarily be inferred from the
8132 * data with your own type given here.
8133 *
8134 * <p><em>Note: MIME type and Uri scheme matching in the
8135 * Android framework is case-sensitive, unlike the formal RFC definitions.
8136 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008137 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008138 * {@link #setDataAndTypeAndNormalize}
8139 * to ensure that they are converted to lower case.</em>
8140 *
8141 * @param data The Uri of the data this intent is now targeting.
8142 * @param type The MIME type of the data being handled by this intent.
8143 *
8144 * @return Returns the same Intent object, for chaining multiple calls
8145 * into a single statement.
8146 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008147 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008148 * @see #setData
8149 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008150 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008151 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008152 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008153 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008154 mData = data;
8155 mType = type;
8156 return this;
8157 }
8158
8159 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008160 * (Usually optional) Normalize and set both the data Uri and an explicit
8161 * MIME data type. This method should very rarely be used -- it allows you
8162 * to override the MIME type that would ordinarily be inferred from the
8163 * data with your own type given here.
8164 *
8165 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008166 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008167 * before they are set, so really this is just a convenience method for
8168 * <pre>
8169 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8170 * </pre>
8171 *
8172 * @param data The Uri of the data this intent is now targeting.
8173 * @param type The MIME type of the data being handled by this intent.
8174 *
8175 * @return Returns the same Intent object, for chaining multiple calls
8176 * into a single statement.
8177 *
8178 * @see #setType
8179 * @see #setData
8180 * @see #setDataAndType
8181 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008182 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008184 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008185 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008186 }
8187
8188 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008189 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008190 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008191 * activities that provide <em>all</em> of the requested categories will be
8192 * used.
8193 *
8194 * @param category The desired category. This can be either one of the
8195 * predefined Intent categories, or a custom category in your own
8196 * namespace.
8197 *
8198 * @return Returns the same Intent object, for chaining multiple calls
8199 * into a single statement.
8200 *
8201 * @see #hasCategory
8202 * @see #removeCategory
8203 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008204 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008205 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008206 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008207 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008208 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008209 return this;
8210 }
8211
8212 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008213 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008214 *
8215 * @param category The category to remove.
8216 *
8217 * @see #addCategory
8218 */
8219 public void removeCategory(String category) {
8220 if (mCategories != null) {
8221 mCategories.remove(category);
8222 if (mCategories.size() == 0) {
8223 mCategories = null;
8224 }
8225 }
8226 }
8227
8228 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008229 * Set a selector for this Intent. This is a modification to the kinds of
8230 * things the Intent will match. If the selector is set, it will be used
8231 * when trying to find entities that can handle the Intent, instead of the
8232 * main contents of the Intent. This allows you build an Intent containing
8233 * a generic protocol while targeting it more specifically.
8234 *
8235 * <p>An example of where this may be used is with things like
8236 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8237 * Intent that will launch the Browser application. However, the correct
8238 * main entry point of an application is actually {@link #ACTION_MAIN}
8239 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8240 * used to specify the actual Activity to launch. If you launch the browser
8241 * with something different, undesired behavior may happen if the user has
8242 * previously or later launches it the normal way, since they do not match.
8243 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8244 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8245 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8246 *
8247 * <p>Setting a selector does not impact the behavior of
8248 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8249 * desired behavior of a selector -- it does not impact the base meaning
8250 * of the Intent, just what kinds of things will be matched against it
8251 * when determining who can handle it.</p>
8252 *
8253 * <p>You can not use both a selector and {@link #setPackage(String)} on
8254 * the same base Intent.</p>
8255 *
8256 * @param selector The desired selector Intent; set to null to not use
8257 * a special selector.
8258 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008259 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008260 if (selector == this) {
8261 throw new IllegalArgumentException(
8262 "Intent being set as a selector of itself");
8263 }
8264 if (selector != null && mPackage != null) {
8265 throw new IllegalArgumentException(
8266 "Can't set selector when package name is already set");
8267 }
8268 mSelector = selector;
8269 }
8270
8271 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008272 * Set a {@link ClipData} associated with this Intent. This replaces any
8273 * previously set ClipData.
8274 *
8275 * <p>The ClipData in an intent is not used for Intent matching or other
8276 * such operations. Semantically it is like extras, used to transmit
8277 * additional data with the Intent. The main feature of using this over
8278 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8279 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8280 * items included in the clip data. This is useful, in particular, if
8281 * you want to transmit an Intent containing multiple <code>content:</code>
8282 * URIs for which the recipient may not have global permission to access the
8283 * content provider.
8284 *
8285 * <p>If the ClipData contains items that are themselves Intents, any
8286 * grant flags in those Intents will be ignored. Only the top-level flags
8287 * of the main Intent are respected, and will be applied to all Uri or
8288 * Intent items in the clip (or sub-items of the clip).
8289 *
8290 * <p>The MIME type, label, and icon in the ClipData object are not
8291 * directly used by Intent. Applications should generally rely on the
8292 * MIME type of the Intent itself, not what it may find in the ClipData.
8293 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008294 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008295 *
8296 * @param clip The new clip to set. May be null to clear the current clip.
8297 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008298 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008299 mClipData = clip;
8300 }
8301
8302 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008303 * This is NOT a secure mechanism to identify the user who sent the intent.
8304 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8305 * who sent the intent.
8306 * @hide
8307 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008308 public void prepareToLeaveUser(int userId) {
8309 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8310 // We want mContentUserHint to refer to the original user, so don't do anything.
8311 if (mContentUserHint == UserHandle.USER_CURRENT) {
8312 mContentUserHint = userId;
8313 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008314 }
8315
8316 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008317 * Add extended data to the intent. The name must include a package
8318 * prefix, for example the app com.android.contacts would use names
8319 * like "com.android.contacts.ShowAll".
8320 *
8321 * @param name The name of the extra data, with package prefix.
8322 * @param value The boolean data value.
8323 *
8324 * @return Returns the same Intent object, for chaining multiple calls
8325 * into a single statement.
8326 *
8327 * @see #putExtras
8328 * @see #removeExtra
8329 * @see #getBooleanExtra(String, boolean)
8330 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008331 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008332 if (mExtras == null) {
8333 mExtras = new Bundle();
8334 }
8335 mExtras.putBoolean(name, value);
8336 return this;
8337 }
8338
8339 /**
8340 * Add extended data to the intent. The name must include a package
8341 * prefix, for example the app com.android.contacts would use names
8342 * like "com.android.contacts.ShowAll".
8343 *
8344 * @param name The name of the extra data, with package prefix.
8345 * @param value The byte data value.
8346 *
8347 * @return Returns the same Intent object, for chaining multiple calls
8348 * into a single statement.
8349 *
8350 * @see #putExtras
8351 * @see #removeExtra
8352 * @see #getByteExtra(String, byte)
8353 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008354 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008355 if (mExtras == null) {
8356 mExtras = new Bundle();
8357 }
8358 mExtras.putByte(name, value);
8359 return this;
8360 }
8361
8362 /**
8363 * Add extended data to the intent. The name must include a package
8364 * prefix, for example the app com.android.contacts would use names
8365 * like "com.android.contacts.ShowAll".
8366 *
8367 * @param name The name of the extra data, with package prefix.
8368 * @param value The char data value.
8369 *
8370 * @return Returns the same Intent object, for chaining multiple calls
8371 * into a single statement.
8372 *
8373 * @see #putExtras
8374 * @see #removeExtra
8375 * @see #getCharExtra(String, char)
8376 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008377 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008378 if (mExtras == null) {
8379 mExtras = new Bundle();
8380 }
8381 mExtras.putChar(name, value);
8382 return this;
8383 }
8384
8385 /**
8386 * Add extended data to the intent. The name must include a package
8387 * prefix, for example the app com.android.contacts would use names
8388 * like "com.android.contacts.ShowAll".
8389 *
8390 * @param name The name of the extra data, with package prefix.
8391 * @param value The short data value.
8392 *
8393 * @return Returns the same Intent object, for chaining multiple calls
8394 * into a single statement.
8395 *
8396 * @see #putExtras
8397 * @see #removeExtra
8398 * @see #getShortExtra(String, short)
8399 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008400 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008401 if (mExtras == null) {
8402 mExtras = new Bundle();
8403 }
8404 mExtras.putShort(name, value);
8405 return this;
8406 }
8407
8408 /**
8409 * Add extended data to the intent. The name must include a package
8410 * prefix, for example the app com.android.contacts would use names
8411 * like "com.android.contacts.ShowAll".
8412 *
8413 * @param name The name of the extra data, with package prefix.
8414 * @param value The integer data value.
8415 *
8416 * @return Returns the same Intent object, for chaining multiple calls
8417 * into a single statement.
8418 *
8419 * @see #putExtras
8420 * @see #removeExtra
8421 * @see #getIntExtra(String, int)
8422 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008423 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008424 if (mExtras == null) {
8425 mExtras = new Bundle();
8426 }
8427 mExtras.putInt(name, value);
8428 return this;
8429 }
8430
8431 /**
8432 * Add extended data to the intent. The name must include a package
8433 * prefix, for example the app com.android.contacts would use names
8434 * like "com.android.contacts.ShowAll".
8435 *
8436 * @param name The name of the extra data, with package prefix.
8437 * @param value The long data value.
8438 *
8439 * @return Returns the same Intent object, for chaining multiple calls
8440 * into a single statement.
8441 *
8442 * @see #putExtras
8443 * @see #removeExtra
8444 * @see #getLongExtra(String, long)
8445 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008446 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008447 if (mExtras == null) {
8448 mExtras = new Bundle();
8449 }
8450 mExtras.putLong(name, value);
8451 return this;
8452 }
8453
8454 /**
8455 * Add extended data to the intent. The name must include a package
8456 * prefix, for example the app com.android.contacts would use names
8457 * like "com.android.contacts.ShowAll".
8458 *
8459 * @param name The name of the extra data, with package prefix.
8460 * @param value The float data value.
8461 *
8462 * @return Returns the same Intent object, for chaining multiple calls
8463 * into a single statement.
8464 *
8465 * @see #putExtras
8466 * @see #removeExtra
8467 * @see #getFloatExtra(String, float)
8468 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008469 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008470 if (mExtras == null) {
8471 mExtras = new Bundle();
8472 }
8473 mExtras.putFloat(name, value);
8474 return this;
8475 }
8476
8477 /**
8478 * Add extended data to the intent. The name must include a package
8479 * prefix, for example the app com.android.contacts would use names
8480 * like "com.android.contacts.ShowAll".
8481 *
8482 * @param name The name of the extra data, with package prefix.
8483 * @param value The double data value.
8484 *
8485 * @return Returns the same Intent object, for chaining multiple calls
8486 * into a single statement.
8487 *
8488 * @see #putExtras
8489 * @see #removeExtra
8490 * @see #getDoubleExtra(String, double)
8491 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008492 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008493 if (mExtras == null) {
8494 mExtras = new Bundle();
8495 }
8496 mExtras.putDouble(name, value);
8497 return this;
8498 }
8499
8500 /**
8501 * Add extended data to the intent. The name must include a package
8502 * prefix, for example the app com.android.contacts would use names
8503 * like "com.android.contacts.ShowAll".
8504 *
8505 * @param name The name of the extra data, with package prefix.
8506 * @param value The String data value.
8507 *
8508 * @return Returns the same Intent object, for chaining multiple calls
8509 * into a single statement.
8510 *
8511 * @see #putExtras
8512 * @see #removeExtra
8513 * @see #getStringExtra(String)
8514 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008515 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008516 if (mExtras == null) {
8517 mExtras = new Bundle();
8518 }
8519 mExtras.putString(name, value);
8520 return this;
8521 }
8522
8523 /**
8524 * Add extended data to the intent. The name must include a package
8525 * prefix, for example the app com.android.contacts would use names
8526 * like "com.android.contacts.ShowAll".
8527 *
8528 * @param name The name of the extra data, with package prefix.
8529 * @param value The CharSequence data value.
8530 *
8531 * @return Returns the same Intent object, for chaining multiple calls
8532 * into a single statement.
8533 *
8534 * @see #putExtras
8535 * @see #removeExtra
8536 * @see #getCharSequenceExtra(String)
8537 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008538 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008539 if (mExtras == null) {
8540 mExtras = new Bundle();
8541 }
8542 mExtras.putCharSequence(name, value);
8543 return this;
8544 }
8545
8546 /**
8547 * Add extended data to the intent. The name must include a package
8548 * prefix, for example the app com.android.contacts would use names
8549 * like "com.android.contacts.ShowAll".
8550 *
8551 * @param name The name of the extra data, with package prefix.
8552 * @param value The Parcelable data value.
8553 *
8554 * @return Returns the same Intent object, for chaining multiple calls
8555 * into a single statement.
8556 *
8557 * @see #putExtras
8558 * @see #removeExtra
8559 * @see #getParcelableExtra(String)
8560 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008561 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008562 if (mExtras == null) {
8563 mExtras = new Bundle();
8564 }
8565 mExtras.putParcelable(name, value);
8566 return this;
8567 }
8568
8569 /**
8570 * Add extended data to the intent. The name must include a package
8571 * prefix, for example the app com.android.contacts would use names
8572 * like "com.android.contacts.ShowAll".
8573 *
8574 * @param name The name of the extra data, with package prefix.
8575 * @param value The Parcelable[] data value.
8576 *
8577 * @return Returns the same Intent object, for chaining multiple calls
8578 * into a single statement.
8579 *
8580 * @see #putExtras
8581 * @see #removeExtra
8582 * @see #getParcelableArrayExtra(String)
8583 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008584 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008585 if (mExtras == null) {
8586 mExtras = new Bundle();
8587 }
8588 mExtras.putParcelableArray(name, value);
8589 return this;
8590 }
8591
8592 /**
8593 * Add extended data to the intent. The name must include a package
8594 * prefix, for example the app com.android.contacts would use names
8595 * like "com.android.contacts.ShowAll".
8596 *
8597 * @param name The name of the extra data, with package prefix.
8598 * @param value The ArrayList<Parcelable> data value.
8599 *
8600 * @return Returns the same Intent object, for chaining multiple calls
8601 * into a single statement.
8602 *
8603 * @see #putExtras
8604 * @see #removeExtra
8605 * @see #getParcelableArrayListExtra(String)
8606 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008607 public @NonNull Intent putParcelableArrayListExtra(String name,
8608 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008609 if (mExtras == null) {
8610 mExtras = new Bundle();
8611 }
8612 mExtras.putParcelableArrayList(name, value);
8613 return this;
8614 }
8615
8616 /**
8617 * Add extended data to the intent. The name must include a package
8618 * prefix, for example the app com.android.contacts would use names
8619 * like "com.android.contacts.ShowAll".
8620 *
8621 * @param name The name of the extra data, with package prefix.
8622 * @param value The ArrayList<Integer> data value.
8623 *
8624 * @return Returns the same Intent object, for chaining multiple calls
8625 * into a single statement.
8626 *
8627 * @see #putExtras
8628 * @see #removeExtra
8629 * @see #getIntegerArrayListExtra(String)
8630 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008631 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008632 if (mExtras == null) {
8633 mExtras = new Bundle();
8634 }
8635 mExtras.putIntegerArrayList(name, value);
8636 return this;
8637 }
8638
8639 /**
8640 * Add extended data to the intent. The name must include a package
8641 * prefix, for example the app com.android.contacts would use names
8642 * like "com.android.contacts.ShowAll".
8643 *
8644 * @param name The name of the extra data, with package prefix.
8645 * @param value The ArrayList<String> data value.
8646 *
8647 * @return Returns the same Intent object, for chaining multiple calls
8648 * into a single statement.
8649 *
8650 * @see #putExtras
8651 * @see #removeExtra
8652 * @see #getStringArrayListExtra(String)
8653 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008654 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008655 if (mExtras == null) {
8656 mExtras = new Bundle();
8657 }
8658 mExtras.putStringArrayList(name, value);
8659 return this;
8660 }
8661
8662 /**
8663 * Add extended data to the intent. The name must include a package
8664 * prefix, for example the app com.android.contacts would use names
8665 * like "com.android.contacts.ShowAll".
8666 *
8667 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008668 * @param value The ArrayList<CharSequence> data value.
8669 *
8670 * @return Returns the same Intent object, for chaining multiple calls
8671 * into a single statement.
8672 *
8673 * @see #putExtras
8674 * @see #removeExtra
8675 * @see #getCharSequenceArrayListExtra(String)
8676 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008677 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8678 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008679 if (mExtras == null) {
8680 mExtras = new Bundle();
8681 }
8682 mExtras.putCharSequenceArrayList(name, value);
8683 return this;
8684 }
8685
8686 /**
8687 * Add extended data to the intent. The name must include a package
8688 * prefix, for example the app com.android.contacts would use names
8689 * like "com.android.contacts.ShowAll".
8690 *
8691 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008692 * @param value The Serializable data value.
8693 *
8694 * @return Returns the same Intent object, for chaining multiple calls
8695 * into a single statement.
8696 *
8697 * @see #putExtras
8698 * @see #removeExtra
8699 * @see #getSerializableExtra(String)
8700 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008701 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008702 if (mExtras == null) {
8703 mExtras = new Bundle();
8704 }
8705 mExtras.putSerializable(name, value);
8706 return this;
8707 }
8708
8709 /**
8710 * Add extended data to the intent. The name must include a package
8711 * prefix, for example the app com.android.contacts would use names
8712 * like "com.android.contacts.ShowAll".
8713 *
8714 * @param name The name of the extra data, with package prefix.
8715 * @param value The boolean array data value.
8716 *
8717 * @return Returns the same Intent object, for chaining multiple calls
8718 * into a single statement.
8719 *
8720 * @see #putExtras
8721 * @see #removeExtra
8722 * @see #getBooleanArrayExtra(String)
8723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008724 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008725 if (mExtras == null) {
8726 mExtras = new Bundle();
8727 }
8728 mExtras.putBooleanArray(name, value);
8729 return this;
8730 }
8731
8732 /**
8733 * Add extended data to the intent. The name must include a package
8734 * prefix, for example the app com.android.contacts would use names
8735 * like "com.android.contacts.ShowAll".
8736 *
8737 * @param name The name of the extra data, with package prefix.
8738 * @param value The byte array data value.
8739 *
8740 * @return Returns the same Intent object, for chaining multiple calls
8741 * into a single statement.
8742 *
8743 * @see #putExtras
8744 * @see #removeExtra
8745 * @see #getByteArrayExtra(String)
8746 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008747 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008748 if (mExtras == null) {
8749 mExtras = new Bundle();
8750 }
8751 mExtras.putByteArray(name, value);
8752 return this;
8753 }
8754
8755 /**
8756 * Add extended data to the intent. The name must include a package
8757 * prefix, for example the app com.android.contacts would use names
8758 * like "com.android.contacts.ShowAll".
8759 *
8760 * @param name The name of the extra data, with package prefix.
8761 * @param value The short array data value.
8762 *
8763 * @return Returns the same Intent object, for chaining multiple calls
8764 * into a single statement.
8765 *
8766 * @see #putExtras
8767 * @see #removeExtra
8768 * @see #getShortArrayExtra(String)
8769 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008770 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008771 if (mExtras == null) {
8772 mExtras = new Bundle();
8773 }
8774 mExtras.putShortArray(name, value);
8775 return this;
8776 }
8777
8778 /**
8779 * Add extended data to the intent. The name must include a package
8780 * prefix, for example the app com.android.contacts would use names
8781 * like "com.android.contacts.ShowAll".
8782 *
8783 * @param name The name of the extra data, with package prefix.
8784 * @param value The char array data value.
8785 *
8786 * @return Returns the same Intent object, for chaining multiple calls
8787 * into a single statement.
8788 *
8789 * @see #putExtras
8790 * @see #removeExtra
8791 * @see #getCharArrayExtra(String)
8792 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008793 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008794 if (mExtras == null) {
8795 mExtras = new Bundle();
8796 }
8797 mExtras.putCharArray(name, value);
8798 return this;
8799 }
8800
8801 /**
8802 * Add extended data to the intent. The name must include a package
8803 * prefix, for example the app com.android.contacts would use names
8804 * like "com.android.contacts.ShowAll".
8805 *
8806 * @param name The name of the extra data, with package prefix.
8807 * @param value The int array data value.
8808 *
8809 * @return Returns the same Intent object, for chaining multiple calls
8810 * into a single statement.
8811 *
8812 * @see #putExtras
8813 * @see #removeExtra
8814 * @see #getIntArrayExtra(String)
8815 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008816 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008817 if (mExtras == null) {
8818 mExtras = new Bundle();
8819 }
8820 mExtras.putIntArray(name, value);
8821 return this;
8822 }
8823
8824 /**
8825 * Add extended data to the intent. The name must include a package
8826 * prefix, for example the app com.android.contacts would use names
8827 * like "com.android.contacts.ShowAll".
8828 *
8829 * @param name The name of the extra data, with package prefix.
8830 * @param value The byte array data value.
8831 *
8832 * @return Returns the same Intent object, for chaining multiple calls
8833 * into a single statement.
8834 *
8835 * @see #putExtras
8836 * @see #removeExtra
8837 * @see #getLongArrayExtra(String)
8838 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008839 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008840 if (mExtras == null) {
8841 mExtras = new Bundle();
8842 }
8843 mExtras.putLongArray(name, value);
8844 return this;
8845 }
8846
8847 /**
8848 * Add extended data to the intent. The name must include a package
8849 * prefix, for example the app com.android.contacts would use names
8850 * like "com.android.contacts.ShowAll".
8851 *
8852 * @param name The name of the extra data, with package prefix.
8853 * @param value The float array data value.
8854 *
8855 * @return Returns the same Intent object, for chaining multiple calls
8856 * into a single statement.
8857 *
8858 * @see #putExtras
8859 * @see #removeExtra
8860 * @see #getFloatArrayExtra(String)
8861 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008862 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008863 if (mExtras == null) {
8864 mExtras = new Bundle();
8865 }
8866 mExtras.putFloatArray(name, value);
8867 return this;
8868 }
8869
8870 /**
8871 * Add extended data to the intent. The name must include a package
8872 * prefix, for example the app com.android.contacts would use names
8873 * like "com.android.contacts.ShowAll".
8874 *
8875 * @param name The name of the extra data, with package prefix.
8876 * @param value The double array data value.
8877 *
8878 * @return Returns the same Intent object, for chaining multiple calls
8879 * into a single statement.
8880 *
8881 * @see #putExtras
8882 * @see #removeExtra
8883 * @see #getDoubleArrayExtra(String)
8884 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008885 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008886 if (mExtras == null) {
8887 mExtras = new Bundle();
8888 }
8889 mExtras.putDoubleArray(name, value);
8890 return this;
8891 }
8892
8893 /**
8894 * Add extended data to the intent. The name must include a package
8895 * prefix, for example the app com.android.contacts would use names
8896 * like "com.android.contacts.ShowAll".
8897 *
8898 * @param name The name of the extra data, with package prefix.
8899 * @param value The String array data value.
8900 *
8901 * @return Returns the same Intent object, for chaining multiple calls
8902 * into a single statement.
8903 *
8904 * @see #putExtras
8905 * @see #removeExtra
8906 * @see #getStringArrayExtra(String)
8907 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008908 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008909 if (mExtras == null) {
8910 mExtras = new Bundle();
8911 }
8912 mExtras.putStringArray(name, value);
8913 return this;
8914 }
8915
8916 /**
8917 * Add extended data to the intent. The name must include a package
8918 * prefix, for example the app com.android.contacts would use names
8919 * like "com.android.contacts.ShowAll".
8920 *
8921 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008922 * @param value The CharSequence array data value.
8923 *
8924 * @return Returns the same Intent object, for chaining multiple calls
8925 * into a single statement.
8926 *
8927 * @see #putExtras
8928 * @see #removeExtra
8929 * @see #getCharSequenceArrayExtra(String)
8930 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008931 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008932 if (mExtras == null) {
8933 mExtras = new Bundle();
8934 }
8935 mExtras.putCharSequenceArray(name, value);
8936 return this;
8937 }
8938
8939 /**
8940 * Add extended data to the intent. The name must include a package
8941 * prefix, for example the app com.android.contacts would use names
8942 * like "com.android.contacts.ShowAll".
8943 *
8944 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 * @param value The Bundle data value.
8946 *
8947 * @return Returns the same Intent object, for chaining multiple calls
8948 * into a single statement.
8949 *
8950 * @see #putExtras
8951 * @see #removeExtra
8952 * @see #getBundleExtra(String)
8953 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008954 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008955 if (mExtras == null) {
8956 mExtras = new Bundle();
8957 }
8958 mExtras.putBundle(name, value);
8959 return this;
8960 }
8961
8962 /**
8963 * Add extended data to the intent. The name must include a package
8964 * prefix, for example the app com.android.contacts would use names
8965 * like "com.android.contacts.ShowAll".
8966 *
8967 * @param name The name of the extra data, with package prefix.
8968 * @param value The IBinder data value.
8969 *
8970 * @return Returns the same Intent object, for chaining multiple calls
8971 * into a single statement.
8972 *
8973 * @see #putExtras
8974 * @see #removeExtra
8975 * @see #getIBinderExtra(String)
8976 *
8977 * @deprecated
8978 * @hide
8979 */
8980 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008981 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008982 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008983 if (mExtras == null) {
8984 mExtras = new Bundle();
8985 }
8986 mExtras.putIBinder(name, value);
8987 return this;
8988 }
8989
8990 /**
8991 * Copy all extras in 'src' in to this intent.
8992 *
8993 * @param src Contains the extras to copy.
8994 *
8995 * @see #putExtra
8996 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008997 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008998 if (src.mExtras != null) {
8999 if (mExtras == null) {
9000 mExtras = new Bundle(src.mExtras);
9001 } else {
9002 mExtras.putAll(src.mExtras);
9003 }
9004 }
9005 return this;
9006 }
9007
9008 /**
9009 * Add a set of extended data to the intent. The keys must include a package
9010 * prefix, for example the app com.android.contacts would use names
9011 * like "com.android.contacts.ShowAll".
9012 *
9013 * @param extras The Bundle of extras to add to this intent.
9014 *
9015 * @see #putExtra
9016 * @see #removeExtra
9017 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009018 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009019 if (mExtras == null) {
9020 mExtras = new Bundle();
9021 }
9022 mExtras.putAll(extras);
9023 return this;
9024 }
9025
9026 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009027 * Completely replace the extras in the Intent with the extras in the
9028 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009029 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009030 * @param src The exact extras contained in this Intent are copied
9031 * into the target intent, replacing any that were previously there.
9032 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009033 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009034 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9035 return this;
9036 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009037
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009038 /**
9039 * Completely replace the extras in the Intent with the given Bundle of
9040 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009041 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009042 * @param extras The new set of extras in the Intent, or null to erase
9043 * all extras.
9044 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009045 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009046 mExtras = extras != null ? new Bundle(extras) : null;
9047 return this;
9048 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009049
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009050 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009051 * Remove extended data from the intent.
9052 *
9053 * @see #putExtra
9054 */
9055 public void removeExtra(String name) {
9056 if (mExtras != null) {
9057 mExtras.remove(name);
9058 if (mExtras.size() == 0) {
9059 mExtras = null;
9060 }
9061 }
9062 }
9063
9064 /**
9065 * Set special flags controlling how this intent is handled. Most values
9066 * here depend on the type of component being executed by the Intent,
9067 * specifically the FLAG_ACTIVITY_* flags are all for use with
9068 * {@link Context#startActivity Context.startActivity()} and the
9069 * FLAG_RECEIVER_* flags are all for use with
9070 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9071 *
Scott Main7aee61f2011-02-08 11:25:01 -08009072 * <p>See the
9073 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9074 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009075 * the behavior of your application.
9076 *
9077 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009078 * @return Returns the same Intent object, for chaining multiple calls
9079 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009080 * @see #getFlags
9081 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009082 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009083 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009084 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009085 mFlags = flags;
9086 return this;
9087 }
9088
9089 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009090 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009091 *
9092 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009093 * @return Returns the same Intent object, for chaining multiple calls into
9094 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009095 * @see #setFlags
9096 * @see #getFlags
9097 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009098 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009099 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009100 mFlags |= flags;
9101 return this;
9102 }
9103
9104 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009105 * Remove these flags from the intent.
9106 *
9107 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009108 * @see #setFlags
9109 * @see #getFlags
9110 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009111 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009112 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009113 mFlags &= ~flags;
9114 }
9115
9116 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009117 * (Usually optional) Set an explicit application package name that limits
9118 * the components this Intent will resolve to. If left to the default
9119 * value of null, all components in all applications will considered.
9120 * If non-null, the Intent can only match the components in the given
9121 * application package.
9122 *
9123 * @param packageName The name of the application package to handle the
9124 * intent, or null to allow any application package.
9125 *
9126 * @return Returns the same Intent object, for chaining multiple calls
9127 * into a single statement.
9128 *
9129 * @see #getPackage
9130 * @see #resolveActivity
9131 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009132 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009133 if (packageName != null && mSelector != null) {
9134 throw new IllegalArgumentException(
9135 "Can't set package name when selector is already set");
9136 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009137 mPackage = packageName;
9138 return this;
9139 }
9140
9141 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009142 * (Usually optional) Explicitly set the component to handle the intent.
9143 * If left with the default value of null, the system will determine the
9144 * appropriate class to use based on the other fields (action, data,
9145 * type, categories) in the Intent. If this class is defined, the
9146 * specified class will always be used regardless of the other fields. You
9147 * should only set this value when you know you absolutely want a specific
9148 * class to be used; otherwise it is better to let the system find the
9149 * appropriate class so that you will respect the installed applications
9150 * and user preferences.
9151 *
9152 * @param component The name of the application component to handle the
9153 * intent, or null to let the system find one for you.
9154 *
9155 * @return Returns the same Intent object, for chaining multiple calls
9156 * into a single statement.
9157 *
9158 * @see #setClass
9159 * @see #setClassName(Context, String)
9160 * @see #setClassName(String, String)
9161 * @see #getComponent
9162 * @see #resolveActivity
9163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009164 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009165 mComponent = component;
9166 return this;
9167 }
9168
9169 /**
9170 * Convenience for calling {@link #setComponent} with an
9171 * explicit class name.
9172 *
9173 * @param packageContext A Context of the application package implementing
9174 * this class.
9175 * @param className The name of a class inside of the application package
9176 * that will be used as the component for this Intent.
9177 *
9178 * @return Returns the same Intent object, for chaining multiple calls
9179 * into a single statement.
9180 *
9181 * @see #setComponent
9182 * @see #setClass
9183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009184 public @NonNull Intent setClassName(@NonNull Context packageContext,
9185 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009186 mComponent = new ComponentName(packageContext, className);
9187 return this;
9188 }
9189
9190 /**
9191 * Convenience for calling {@link #setComponent} with an
9192 * explicit application package name and class name.
9193 *
9194 * @param packageName The name of the package implementing the desired
9195 * component.
9196 * @param className The name of a class inside of the application package
9197 * that will be used as the component for this Intent.
9198 *
9199 * @return Returns the same Intent object, for chaining multiple calls
9200 * into a single statement.
9201 *
9202 * @see #setComponent
9203 * @see #setClass
9204 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009205 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009206 mComponent = new ComponentName(packageName, className);
9207 return this;
9208 }
9209
9210 /**
9211 * Convenience for calling {@link #setComponent(ComponentName)} with the
9212 * name returned by a {@link Class} object.
9213 *
9214 * @param packageContext A Context of the application package implementing
9215 * this class.
9216 * @param cls The class name to set, equivalent to
9217 * <code>setClassName(context, cls.getName())</code>.
9218 *
9219 * @return Returns the same Intent object, for chaining multiple calls
9220 * into a single statement.
9221 *
9222 * @see #setComponent
9223 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009224 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009225 mComponent = new ComponentName(packageContext, cls);
9226 return this;
9227 }
9228
9229 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009230 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9231 * used as a hint to the receiver for animations and the like. Null means that there
9232 * is no source bounds.
9233 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009234 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009235 if (r != null) {
9236 mSourceBounds = new Rect(r);
9237 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009238 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009239 }
9240 }
9241
Tor Norbyed9273d62013-05-30 15:59:53 -07009242 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009243 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9244 FILL_IN_ACTION,
9245 FILL_IN_DATA,
9246 FILL_IN_CATEGORIES,
9247 FILL_IN_COMPONENT,
9248 FILL_IN_PACKAGE,
9249 FILL_IN_SOURCE_BOUNDS,
9250 FILL_IN_SELECTOR,
9251 FILL_IN_CLIP_DATA
9252 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009253 @Retention(RetentionPolicy.SOURCE)
9254 public @interface FillInFlags {}
9255
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009257 * Use with {@link #fillIn} to allow the current action value to be
9258 * overwritten, even if it is already set.
9259 */
9260 public static final int FILL_IN_ACTION = 1<<0;
9261
9262 /**
9263 * Use with {@link #fillIn} to allow the current data or type value
9264 * overwritten, even if it is already set.
9265 */
9266 public static final int FILL_IN_DATA = 1<<1;
9267
9268 /**
9269 * Use with {@link #fillIn} to allow the current categories to be
9270 * overwritten, even if they are already set.
9271 */
9272 public static final int FILL_IN_CATEGORIES = 1<<2;
9273
9274 /**
9275 * Use with {@link #fillIn} to allow the current component value to be
9276 * overwritten, even if it is already set.
9277 */
9278 public static final int FILL_IN_COMPONENT = 1<<3;
9279
9280 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009281 * Use with {@link #fillIn} to allow the current package value to be
9282 * overwritten, even if it is already set.
9283 */
9284 public static final int FILL_IN_PACKAGE = 1<<4;
9285
9286 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009287 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009288 * overwritten, even if it is already set.
9289 */
9290 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9291
9292 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009293 * Use with {@link #fillIn} to allow the current selector to be
9294 * overwritten, even if it is already set.
9295 */
9296 public static final int FILL_IN_SELECTOR = 1<<6;
9297
9298 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009299 * Use with {@link #fillIn} to allow the current ClipData to be
9300 * overwritten, even if it is already set.
9301 */
9302 public static final int FILL_IN_CLIP_DATA = 1<<7;
9303
9304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009305 * Copy the contents of <var>other</var> in to this object, but only
9306 * where fields are not defined by this object. For purposes of a field
9307 * being defined, the following pieces of data in the Intent are
9308 * considered to be separate fields:
9309 *
9310 * <ul>
9311 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009312 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009313 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9314 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009315 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009316 * <li> component, as set by {@link #setComponent(ComponentName)} or
9317 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009318 * <li> source bounds, as set by {@link #setSourceBounds}.
9319 * <li> selector, as set by {@link #setSelector(Intent)}.
9320 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009321 * <li> each top-level name in the associated extras.
9322 * </ul>
9323 *
9324 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009325 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009326 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9327 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9328 * the restriction where the corresponding field will not be replaced if
9329 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009330 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009331 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9332 * is explicitly specified. The selector will only be copied if
9333 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009334 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009335 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9336 * and Intent B with {action="gotit", data-type="some/thing",
9337 * categories="one","two"}.
9338 *
9339 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9340 * containing: {action="gotit", data-type="some/thing",
9341 * categories="bar"}.
9342 *
9343 * @param other Another Intent whose values are to be used to fill in
9344 * the current one.
9345 * @param flags Options to control which fields can be filled in.
9346 *
9347 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009348 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009349 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009350 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009351 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009352 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009353 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009354 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009355 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009356 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009357 if (other.mAction != null
9358 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009359 mAction = other.mAction;
9360 changes |= FILL_IN_ACTION;
9361 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009362 if ((other.mData != null || other.mType != null)
9363 && ((mData == null && mType == null)
9364 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009365 mData = other.mData;
9366 mType = other.mType;
9367 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009368 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009369 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009370 if (other.mCategories != null
9371 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009372 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009373 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009374 }
9375 changes |= FILL_IN_CATEGORIES;
9376 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009377 if (other.mPackage != null
9378 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009379 // Only do this if mSelector is not set.
9380 if (mSelector == null) {
9381 mPackage = other.mPackage;
9382 changes |= FILL_IN_PACKAGE;
9383 }
9384 }
9385 // Selector is special: it can only be set if explicitly allowed,
9386 // for the same reason as the component name.
9387 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9388 if (mPackage == null) {
9389 mSelector = new Intent(other.mSelector);
9390 mPackage = null;
9391 changes |= FILL_IN_SELECTOR;
9392 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009393 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009394 if (other.mClipData != null
9395 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9396 mClipData = other.mClipData;
9397 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009398 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009399 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009400 // Component is special: it can -only- be set if explicitly allowed,
9401 // since otherwise the sender could force the intent somewhere the
9402 // originator didn't intend.
9403 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009404 mComponent = other.mComponent;
9405 changes |= FILL_IN_COMPONENT;
9406 }
9407 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009408 if (other.mSourceBounds != null
9409 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9410 mSourceBounds = new Rect(other.mSourceBounds);
9411 changes |= FILL_IN_SOURCE_BOUNDS;
9412 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009413 if (mExtras == null) {
9414 if (other.mExtras != null) {
9415 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009416 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009417 }
9418 } else if (other.mExtras != null) {
9419 try {
9420 Bundle newb = new Bundle(other.mExtras);
9421 newb.putAll(mExtras);
9422 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009423 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009424 } catch (RuntimeException e) {
9425 // Modifying the extras can cause us to unparcel the contents
9426 // of the bundle, and if we do this in the system process that
9427 // may fail. We really should handle this (i.e., the Bundle
9428 // impl shouldn't be on top of a plain map), but for now just
9429 // ignore it and keep the original contents. :(
9430 Log.w("Intent", "Failure filling in extras", e);
9431 }
9432 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009433 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9434 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9435 mContentUserHint = other.mContentUserHint;
9436 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009437 return changes;
9438 }
9439
9440 /**
9441 * Wrapper class holding an Intent and implementing comparisons on it for
9442 * the purpose of filtering. The class implements its
9443 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9444 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9445 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9446 * on the wrapped Intent.
9447 */
9448 public static final class FilterComparison {
9449 private final Intent mIntent;
9450 private final int mHashCode;
9451
9452 public FilterComparison(Intent intent) {
9453 mIntent = intent;
9454 mHashCode = intent.filterHashCode();
9455 }
9456
9457 /**
9458 * Return the Intent that this FilterComparison represents.
9459 * @return Returns the Intent held by the FilterComparison. Do
9460 * not modify!
9461 */
9462 public Intent getIntent() {
9463 return mIntent;
9464 }
9465
9466 @Override
9467 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009468 if (obj instanceof FilterComparison) {
9469 Intent other = ((FilterComparison)obj).mIntent;
9470 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009471 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009472 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009473 }
9474
9475 @Override
9476 public int hashCode() {
9477 return mHashCode;
9478 }
9479 }
9480
9481 /**
9482 * Determine if two intents are the same for the purposes of intent
9483 * resolution (filtering). That is, if their action, data, type,
9484 * class, and categories are the same. This does <em>not</em> compare
9485 * any extra data included in the intents.
9486 *
9487 * @param other The other Intent to compare against.
9488 *
9489 * @return Returns true if action, data, type, class, and categories
9490 * are the same.
9491 */
9492 public boolean filterEquals(Intent other) {
9493 if (other == null) {
9494 return false;
9495 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009496 if (!Objects.equals(this.mAction, other.mAction)) return false;
9497 if (!Objects.equals(this.mData, other.mData)) return false;
9498 if (!Objects.equals(this.mType, other.mType)) return false;
9499 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9500 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9501 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009502
9503 return true;
9504 }
9505
9506 /**
9507 * Generate hash code that matches semantics of filterEquals().
9508 *
9509 * @return Returns the hash value of the action, data, type, class, and
9510 * categories.
9511 *
9512 * @see #filterEquals
9513 */
9514 public int filterHashCode() {
9515 int code = 0;
9516 if (mAction != null) {
9517 code += mAction.hashCode();
9518 }
9519 if (mData != null) {
9520 code += mData.hashCode();
9521 }
9522 if (mType != null) {
9523 code += mType.hashCode();
9524 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009525 if (mPackage != null) {
9526 code += mPackage.hashCode();
9527 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009528 if (mComponent != null) {
9529 code += mComponent.hashCode();
9530 }
9531 if (mCategories != null) {
9532 code += mCategories.hashCode();
9533 }
9534 return code;
9535 }
9536
9537 @Override
9538 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009539 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009540
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009541 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009542 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009543 b.append(" }");
9544
9545 return b.toString();
9546 }
9547
9548 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009549 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009550 public String toInsecureString() {
9551 StringBuilder b = new StringBuilder(128);
9552
9553 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009554 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009555 b.append(" }");
9556
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009557 return b.toString();
9558 }
Romain Guy4969af72009-06-17 10:53:19 -07009559
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009560 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009561 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009562 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009563
9564 b.append("Intent { ");
9565 toShortString(b, false, true, true, true);
9566 b.append(" }");
9567
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009568 return b.toString();
9569 }
9570
9571 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009572 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9573 StringBuilder b = new StringBuilder(128);
9574 toShortString(b, secure, comp, extras, clip);
9575 return b.toString();
9576 }
9577
9578 /** @hide */
9579 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9580 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009581 boolean first = true;
9582 if (mAction != null) {
9583 b.append("act=").append(mAction);
9584 first = false;
9585 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009586 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009587 if (!first) {
9588 b.append(' ');
9589 }
9590 first = false;
9591 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009592 for (int i=0; i<mCategories.size(); i++) {
9593 if (i > 0) b.append(',');
9594 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009595 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009596 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009597 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009598 if (mData != null) {
9599 if (!first) {
9600 b.append(' ');
9601 }
9602 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009603 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009604 if (secure) {
9605 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009606 } else {
9607 b.append(mData);
9608 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009609 }
9610 if (mType != null) {
9611 if (!first) {
9612 b.append(' ');
9613 }
9614 first = false;
9615 b.append("typ=").append(mType);
9616 }
9617 if (mFlags != 0) {
9618 if (!first) {
9619 b.append(' ');
9620 }
9621 first = false;
9622 b.append("flg=0x").append(Integer.toHexString(mFlags));
9623 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009624 if (mPackage != null) {
9625 if (!first) {
9626 b.append(' ');
9627 }
9628 first = false;
9629 b.append("pkg=").append(mPackage);
9630 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009631 if (comp && mComponent != null) {
9632 if (!first) {
9633 b.append(' ');
9634 }
9635 first = false;
9636 b.append("cmp=").append(mComponent.flattenToShortString());
9637 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009638 if (mSourceBounds != null) {
9639 if (!first) {
9640 b.append(' ');
9641 }
9642 first = false;
9643 b.append("bnds=").append(mSourceBounds.toShortString());
9644 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009645 if (mClipData != null) {
9646 if (!first) {
9647 b.append(' ');
9648 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009649 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009650 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009651 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009652 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009653 if (mClipData.getDescription() != null) {
9654 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9655 } else {
9656 first = true;
9657 }
9658 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009659 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009660 first = false;
9661 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009662 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009663 if (extras && mExtras != null) {
9664 if (!first) {
9665 b.append(' ');
9666 }
9667 first = false;
9668 b.append("(has extras)");
9669 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009670 if (mContentUserHint != UserHandle.USER_CURRENT) {
9671 if (!first) {
9672 b.append(' ');
9673 }
9674 first = false;
9675 b.append("u=").append(mContentUserHint);
9676 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009677 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009678 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009679 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009680 b.append("}");
9681 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009682 }
9683
Yi Jin129fc6c2017-09-28 15:48:38 -07009684 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009685 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9686 // Same input parameters that toString() gives to toShortString().
9687 writeToProto(proto, fieldId, true, true, true, false);
9688 }
9689
9690 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009691 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9692 boolean extras, boolean clip) {
9693 long token = proto.start(fieldId);
9694 if (mAction != null) {
9695 proto.write(IntentProto.ACTION, mAction);
9696 }
9697 if (mCategories != null) {
9698 for (String category : mCategories) {
9699 proto.write(IntentProto.CATEGORIES, category);
9700 }
9701 }
9702 if (mData != null) {
9703 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9704 }
9705 if (mType != null) {
9706 proto.write(IntentProto.TYPE, mType);
9707 }
9708 if (mFlags != 0) {
9709 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9710 }
9711 if (mPackage != null) {
9712 proto.write(IntentProto.PACKAGE, mPackage);
9713 }
9714 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009715 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009716 }
9717 if (mSourceBounds != null) {
9718 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9719 }
9720 if (mClipData != null) {
9721 StringBuilder b = new StringBuilder();
9722 if (clip) {
9723 mClipData.toShortString(b);
9724 } else {
9725 mClipData.toShortStringShortItems(b, false);
9726 }
9727 proto.write(IntentProto.CLIP_DATA, b.toString());
9728 }
9729 if (extras && mExtras != null) {
9730 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9731 }
9732 if (mContentUserHint != 0) {
9733 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9734 }
9735 if (mSelector != null) {
9736 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9737 }
9738 proto.end(token);
9739 }
9740
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009741 /**
9742 * Call {@link #toUri} with 0 flags.
9743 * @deprecated Use {@link #toUri} instead.
9744 */
9745 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009746 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009747 return toUri(0);
9748 }
9749
9750 /**
9751 * Convert this Intent into a String holding a URI representation of it.
9752 * The returned URI string has been properly URI encoded, so it can be
9753 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9754 * Intent's data as the base URI, with an additional fragment describing
9755 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009756 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009757 * <p>You can convert the returned string back to an Intent with
9758 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009759 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009760 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009761 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009762 * @return Returns a URI encoding URI string describing the entire contents
9763 * of the Intent.
9764 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009765 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009766 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009767 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9768 if (mPackage == null) {
9769 throw new IllegalArgumentException(
9770 "Intent must include an explicit package name to build an android-app: "
9771 + this);
9772 }
9773 uri.append("android-app://");
9774 uri.append(mPackage);
9775 String scheme = null;
9776 if (mData != null) {
9777 scheme = mData.getScheme();
9778 if (scheme != null) {
9779 uri.append('/');
9780 uri.append(scheme);
9781 String authority = mData.getEncodedAuthority();
9782 if (authority != null) {
9783 uri.append('/');
9784 uri.append(authority);
9785 String path = mData.getEncodedPath();
9786 if (path != null) {
9787 uri.append(path);
9788 }
9789 String queryParams = mData.getEncodedQuery();
9790 if (queryParams != null) {
9791 uri.append('?');
9792 uri.append(queryParams);
9793 }
9794 String fragment = mData.getEncodedFragment();
9795 if (fragment != null) {
9796 uri.append('#');
9797 uri.append(fragment);
9798 }
9799 }
9800 }
9801 }
9802 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9803 mPackage, flags);
9804 return uri.toString();
9805 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009806 String scheme = null;
9807 if (mData != null) {
9808 String data = mData.toString();
9809 if ((flags&URI_INTENT_SCHEME) != 0) {
9810 final int N = data.length();
9811 for (int i=0; i<N; i++) {
9812 char c = data.charAt(i);
9813 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009814 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009815 continue;
9816 }
9817 if (c == ':' && i > 0) {
9818 // Valid scheme.
9819 scheme = data.substring(0, i);
9820 uri.append("intent:");
9821 data = data.substring(i+1);
9822 break;
9823 }
Tom Taylord4a47292009-12-21 13:59:18 -08009824
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009825 // No scheme.
9826 break;
9827 }
9828 }
9829 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009830
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009831 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9832 uri.append("intent:");
9833 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009834
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009835 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009836
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009837 return uri.toString();
9838 }
9839
9840 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9841 String defPackage, int flags) {
9842 StringBuilder frag = new StringBuilder(128);
9843
9844 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009845 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009846 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009847 // Note that for now we are not going to try to handle the
9848 // data part; not clear how to represent this as a URI, and
9849 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009850 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9851 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009852 }
9853
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009854 if (frag.length() > 0) {
9855 uri.append("#Intent;");
9856 uri.append(frag);
9857 uri.append("end");
9858 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009859 }
9860
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009861 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9862 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009863 if (scheme != null) {
9864 uri.append("scheme=").append(scheme).append(';');
9865 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009866 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009867 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009868 }
9869 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009870 for (int i=0; i<mCategories.size(); i++) {
9871 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009872 }
9873 }
9874 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009875 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009876 }
9877 if (mFlags != 0) {
9878 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9879 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009880 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009881 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9882 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009883 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009884 uri.append("component=").append(Uri.encode(
9885 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009886 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009887 if (mSourceBounds != null) {
9888 uri.append("sourceBounds=")
9889 .append(Uri.encode(mSourceBounds.flattenToString()))
9890 .append(';');
9891 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009892 if (mExtras != null) {
9893 for (String key : mExtras.keySet()) {
9894 final Object value = mExtras.get(key);
9895 char entryType =
9896 value instanceof String ? 'S' :
9897 value instanceof Boolean ? 'B' :
9898 value instanceof Byte ? 'b' :
9899 value instanceof Character ? 'c' :
9900 value instanceof Double ? 'd' :
9901 value instanceof Float ? 'f' :
9902 value instanceof Integer ? 'i' :
9903 value instanceof Long ? 'l' :
9904 value instanceof Short ? 's' :
9905 '\0';
9906
9907 if (entryType != '\0') {
9908 uri.append(entryType);
9909 uri.append('.');
9910 uri.append(Uri.encode(key));
9911 uri.append('=');
9912 uri.append(Uri.encode(value.toString()));
9913 uri.append(';');
9914 }
9915 }
9916 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009917 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009918
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009919 public int describeContents() {
9920 return (mExtras != null) ? mExtras.describeContents() : 0;
9921 }
9922
9923 public void writeToParcel(Parcel out, int flags) {
9924 out.writeString(mAction);
9925 Uri.writeToParcel(out, mData);
9926 out.writeString(mType);
9927 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009928 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009929 ComponentName.writeToParcel(mComponent, out);
9930
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009931 if (mSourceBounds != null) {
9932 out.writeInt(1);
9933 mSourceBounds.writeToParcel(out, flags);
9934 } else {
9935 out.writeInt(0);
9936 }
9937
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009938 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009939 final int N = mCategories.size();
9940 out.writeInt(N);
9941 for (int i=0; i<N; i++) {
9942 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009943 }
9944 } else {
9945 out.writeInt(0);
9946 }
9947
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009948 if (mSelector != null) {
9949 out.writeInt(1);
9950 mSelector.writeToParcel(out, flags);
9951 } else {
9952 out.writeInt(0);
9953 }
9954
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009955 if (mClipData != null) {
9956 out.writeInt(1);
9957 mClipData.writeToParcel(out, flags);
9958 } else {
9959 out.writeInt(0);
9960 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009961 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009962 out.writeBundle(mExtras);
9963 }
9964
9965 public static final Parcelable.Creator<Intent> CREATOR
9966 = new Parcelable.Creator<Intent>() {
9967 public Intent createFromParcel(Parcel in) {
9968 return new Intent(in);
9969 }
9970 public Intent[] newArray(int size) {
9971 return new Intent[size];
9972 }
9973 };
9974
Dianne Hackborneb034652009-09-07 00:49:58 -07009975 /** @hide */
9976 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009977 readFromParcel(in);
9978 }
9979
9980 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009981 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009982 mData = Uri.CREATOR.createFromParcel(in);
9983 mType = in.readString();
9984 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009985 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009986 mComponent = ComponentName.readFromParcel(in);
9987
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009988 if (in.readInt() != 0) {
9989 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9990 }
9991
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009992 int N = in.readInt();
9993 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009994 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009995 int i;
9996 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009997 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009998 }
9999 } else {
10000 mCategories = null;
10001 }
10002
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010003 if (in.readInt() != 0) {
10004 mSelector = new Intent(in);
10005 }
10006
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010007 if (in.readInt() != 0) {
10008 mClipData = new ClipData(in);
10009 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010010 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010011 mExtras = in.readBundle();
10012 }
10013
10014 /**
10015 * Parses the "intent" element (and its children) from XML and instantiates
10016 * an Intent object. The given XML parser should be located at the tag
10017 * where parsing should start (often named "intent"), from which the
10018 * basic action, data, type, and package and class name will be
10019 * retrieved. The function will then parse in to any child elements,
10020 * looking for <category android:name="xxx"> tags to add categories and
10021 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10022 * to the intent.
10023 *
10024 * @param resources The Resources to use when inflating resources.
10025 * @param parser The XML parser pointing at an "intent" tag.
10026 * @param attrs The AttributeSet interface for retrieving extended
10027 * attribute data at the current <var>parser</var> location.
10028 * @return An Intent object matching the XML data.
10029 * @throws XmlPullParserException If there was an XML parsing error.
10030 * @throws IOException If there was an I/O error.
10031 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010032 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10033 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010034 throws XmlPullParserException, IOException {
10035 Intent intent = new Intent();
10036
10037 TypedArray sa = resources.obtainAttributes(attrs,
10038 com.android.internal.R.styleable.Intent);
10039
10040 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10041
10042 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10043 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10044 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10045
10046 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10047 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10048 if (packageName != null && className != null) {
10049 intent.setComponent(new ComponentName(packageName, className));
10050 }
10051
10052 sa.recycle();
10053
10054 int outerDepth = parser.getDepth();
10055 int type;
10056 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10057 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10058 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10059 continue;
10060 }
10061
10062 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010063 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010064 sa = resources.obtainAttributes(attrs,
10065 com.android.internal.R.styleable.IntentCategory);
10066 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10067 sa.recycle();
10068
10069 if (cat != null) {
10070 intent.addCategory(cat);
10071 }
10072 XmlUtils.skipCurrentTag(parser);
10073
Craig Mautner21d24a22014-04-23 11:45:37 -070010074 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010075 if (intent.mExtras == null) {
10076 intent.mExtras = new Bundle();
10077 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010078 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010079 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010080
10081 } else {
10082 XmlUtils.skipCurrentTag(parser);
10083 }
10084 }
10085
10086 return intent;
10087 }
Nick Pellyccae4122012-01-09 14:12:58 -080010088
Craig Mautner21d24a22014-04-23 11:45:37 -070010089 /** @hide */
10090 public void saveToXml(XmlSerializer out) throws IOException {
10091 if (mAction != null) {
10092 out.attribute(null, ATTR_ACTION, mAction);
10093 }
10094 if (mData != null) {
10095 out.attribute(null, ATTR_DATA, mData.toString());
10096 }
10097 if (mType != null) {
10098 out.attribute(null, ATTR_TYPE, mType);
10099 }
10100 if (mComponent != null) {
10101 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10102 }
10103 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10104
10105 if (mCategories != null) {
10106 out.startTag(null, TAG_CATEGORIES);
10107 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10108 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10109 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010110 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010111 }
10112 }
10113
10114 /** @hide */
10115 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10116 XmlPullParserException {
10117 Intent intent = new Intent();
10118 final int outerDepth = in.getDepth();
10119
10120 int attrCount = in.getAttributeCount();
10121 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10122 final String attrName = in.getAttributeName(attrNdx);
10123 final String attrValue = in.getAttributeValue(attrNdx);
10124 if (ATTR_ACTION.equals(attrName)) {
10125 intent.setAction(attrValue);
10126 } else if (ATTR_DATA.equals(attrName)) {
10127 intent.setData(Uri.parse(attrValue));
10128 } else if (ATTR_TYPE.equals(attrName)) {
10129 intent.setType(attrValue);
10130 } else if (ATTR_COMPONENT.equals(attrName)) {
10131 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10132 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010133 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010134 } else {
10135 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10136 }
10137 }
10138
10139 int event;
10140 String name;
10141 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10142 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10143 if (event == XmlPullParser.START_TAG) {
10144 name = in.getName();
10145 if (TAG_CATEGORIES.equals(name)) {
10146 attrCount = in.getAttributeCount();
10147 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10148 intent.addCategory(in.getAttributeValue(attrNdx));
10149 }
10150 } else {
10151 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10152 XmlUtils.skipCurrentTag(in);
10153 }
10154 }
10155 }
10156
10157 return intent;
10158 }
10159
Nick Pellyccae4122012-01-09 14:12:58 -080010160 /**
10161 * Normalize a MIME data type.
10162 *
10163 * <p>A normalized MIME type has white-space trimmed,
10164 * content-type parameters removed, and is lower-case.
10165 * This aligns the type with Android best practices for
10166 * intent filtering.
10167 *
10168 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10169 * "text/x-vCard" becomes "text/x-vcard".
10170 *
10171 * <p>All MIME types received from outside Android (such as user input,
10172 * or external sources like Bluetooth, NFC, or the Internet) should
10173 * be normalized before they are used to create an Intent.
10174 *
10175 * @param type MIME data type to normalize
10176 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010177 * @see #setType
10178 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010179 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010180 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010181 if (type == null) {
10182 return null;
10183 }
10184
Elliott Hughescb64d432013-08-02 10:00:44 -070010185 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010186
10187 final int semicolonIndex = type.indexOf(';');
10188 if (semicolonIndex != -1) {
10189 type = type.substring(0, semicolonIndex);
10190 }
10191 return type;
10192 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010193
10194 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010195 * Prepare this {@link Intent} to leave an app process.
10196 *
10197 * @hide
10198 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010199 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010200 public void prepareToLeaveProcess(Context context) {
10201 final boolean leavingPackage = (mComponent == null)
10202 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10203 prepareToLeaveProcess(leavingPackage);
10204 }
10205
10206 /**
10207 * Prepare this {@link Intent} to leave an app process.
10208 *
10209 * @hide
10210 */
10211 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010212 setAllowFds(false);
10213
10214 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010215 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010216 }
10217 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010218 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010219 }
10220
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010221 if (mExtras != null && !mExtras.isParcelled()) {
10222 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10223 if (intent instanceof Intent) {
10224 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10225 }
10226 }
10227
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010228 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10229 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010230 switch (mAction) {
10231 case ACTION_MEDIA_REMOVED:
10232 case ACTION_MEDIA_UNMOUNTED:
10233 case ACTION_MEDIA_CHECKING:
10234 case ACTION_MEDIA_NOFS:
10235 case ACTION_MEDIA_MOUNTED:
10236 case ACTION_MEDIA_SHARED:
10237 case ACTION_MEDIA_UNSHARED:
10238 case ACTION_MEDIA_BAD_REMOVAL:
10239 case ACTION_MEDIA_UNMOUNTABLE:
10240 case ACTION_MEDIA_EJECT:
10241 case ACTION_MEDIA_SCANNER_STARTED:
10242 case ACTION_MEDIA_SCANNER_FINISHED:
10243 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010244 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10245 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010246 // Ignore legacy actions
10247 break;
10248 default:
10249 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010250 }
10251 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010252
10253 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10254 && leavingPackage) {
10255 switch (mAction) {
10256 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010257 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010258 // Ignore actions that don't need to grant
10259 break;
10260 default:
10261 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10262 }
10263 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010264 }
10265
10266 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010267 * @hide
10268 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010269 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010270 // We just entered destination process, so we should be able to read all
10271 // parcelables inside.
10272 setDefusable(true);
10273
10274 if (mSelector != null) {
10275 mSelector.prepareToEnterProcess();
10276 }
10277 if (mClipData != null) {
10278 mClipData.prepareToEnterProcess();
10279 }
10280
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010281 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010282 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10283 fixUris(mContentUserHint);
10284 mContentUserHint = UserHandle.USER_CURRENT;
10285 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010286 }
10287 }
10288
Patrick Baumann577d4022018-01-31 16:55:10 +000010289 /** @hide */
10290 public boolean hasWebURI() {
10291 if (getData() == null) {
10292 return false;
10293 }
10294 final String scheme = getScheme();
10295 if (TextUtils.isEmpty(scheme)) {
10296 return false;
10297 }
10298 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10299 }
10300
10301 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010302 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010303 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010304 && hasWebURI();
10305 }
10306
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010307 /**
10308 * @hide
10309 */
10310 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010311 Uri data = getData();
10312 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010313 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010314 }
10315 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010316 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010317 }
10318 String action = getAction();
10319 if (ACTION_SEND.equals(action)) {
10320 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10321 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010322 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010323 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010324 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010325 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10326 if (streams != null) {
10327 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10328 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010329 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010330 }
10331 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10332 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010333 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10334 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10335 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10336 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10337 if (output != null) {
10338 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10339 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010340 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010341 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010342
10343 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010344 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010345 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10346 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010347 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010348 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010349 * @hide
10350 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010351 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010352 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010353 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010354
10355 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010356 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010357
10358 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010359 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010360 // Inspect contained intents to see if we need to migrate extras. We
10361 // don't promote ClipData to the parent, since ChooserActivity will
10362 // already start the picked item as the caller, and we can't combine
10363 // the flags in a safe way.
10364
10365 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010366 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010367 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10368 if (intent != null) {
10369 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010370 }
10371 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010372 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010373 try {
10374 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10375 if (intents != null) {
10376 for (int i = 0; i < intents.length; i++) {
10377 final Intent intent = (Intent) intents[i];
10378 if (intent != null) {
10379 migrated |= intent.migrateExtraStreamToClipData();
10380 }
10381 }
10382 }
10383 } catch (ClassCastException e) {
10384 }
10385 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010386
10387 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010388 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010389 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10390 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10391 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10392 if (stream != null || text != null || htmlText != null) {
10393 final ClipData clipData = new ClipData(
10394 null, new String[] { getType() },
10395 new ClipData.Item(text, htmlText, null, stream));
10396 setClipData(clipData);
10397 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010398 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010399 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010400 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010401 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010402
10403 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010404 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010405 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10406 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10407 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10408 int num = -1;
10409 if (streams != null) {
10410 num = streams.size();
10411 }
10412 if (texts != null) {
10413 if (num >= 0 && num != texts.size()) {
10414 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010415 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010416 }
10417 num = texts.size();
10418 }
10419 if (htmlTexts != null) {
10420 if (num >= 0 && num != htmlTexts.size()) {
10421 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010422 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010423 }
10424 num = htmlTexts.size();
10425 }
10426 if (num > 0) {
10427 final ClipData clipData = new ClipData(
10428 null, new String[] { getType() },
10429 makeClipItem(streams, texts, htmlTexts, 0));
10430
10431 for (int i = 1; i < num; i++) {
10432 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10433 }
10434
10435 setClipData(clipData);
10436 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010437 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010438 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010439 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010440 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010441 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10442 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10443 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10444 final Uri output;
10445 try {
10446 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10447 } catch (ClassCastException e) {
10448 return false;
10449 }
10450 if (output != null) {
10451 setClipData(ClipData.newRawUri("", output));
10452 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10453 return true;
10454 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010455 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010456
10457 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010458 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010459
Michael Wright19859762017-09-18 20:57:58 +010010460 /**
10461 * Convert the dock state to a human readable format.
10462 * @hide
10463 */
10464 public static String dockStateToString(int dock) {
10465 switch (dock) {
10466 case EXTRA_DOCK_STATE_HE_DESK:
10467 return "EXTRA_DOCK_STATE_HE_DESK";
10468 case EXTRA_DOCK_STATE_LE_DESK:
10469 return "EXTRA_DOCK_STATE_LE_DESK";
10470 case EXTRA_DOCK_STATE_CAR:
10471 return "EXTRA_DOCK_STATE_CAR";
10472 case EXTRA_DOCK_STATE_DESK:
10473 return "EXTRA_DOCK_STATE_DESK";
10474 case EXTRA_DOCK_STATE_UNDOCKED:
10475 return "EXTRA_DOCK_STATE_UNDOCKED";
10476 default:
10477 return Integer.toString(dock);
10478 }
10479 }
10480
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010481 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10482 ArrayList<String> htmlTexts, int which) {
10483 Uri uri = streams != null ? streams.get(which) : null;
10484 CharSequence text = texts != null ? texts.get(which) : null;
10485 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10486 return new ClipData.Item(text, htmlText, null, uri);
10487 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010488
10489 /** @hide */
10490 public boolean isDocument() {
10491 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10492 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010493}