blob: 2963947c03c62b7d660d3b6b2471110d2de9973d [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 Inwood1c77a112018-08-14 14:06:26 +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
1541 */
1542 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1543 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1544
1545 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001546 * Activity Action: Activity to handle split installation failures.
1547 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1548 * but the split that contains the application isn't installed. When a split is
1549 * installed in this manner, the containing package usually doesn't know this is
1550 * happening. However, if an error occurs during installation, the containing
1551 * package can define a single activity handling this action to deal with such
1552 * failures.
1553 * <p>The activity handling this action must be in the base package.
1554 * <p>
1555 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1556 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1557 */
1558 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1559 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1560
1561 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001562 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001563 * <p class="note">
1564 * This is a protected intent that can only be sent by the system.
1565 * </p>
1566 *
1567 * @hide
1568 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001569 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001570 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001571 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1572 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573
1574 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576 * <p>
1577 * The system will have a persistent connection to this service.
1578 * This is a protected intent that can only be sent by the system.
1579 * </p>
1580 *
1581 * @hide
1582 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001583 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001584 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001585 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1586 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001587
1588 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001589 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001590 *
1591 * <p class="note">
1592 * This is a protected intent that can only be sent by the system.
1593 * </p>
1594 *
1595 * @hide
1596 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001598 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1600 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001601
1602 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001603 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1604 * package. Specifies the installer package name; this package will receive the
1605 * {@link #ACTION_APP_ERROR} intent.
1606 */
1607 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1608 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1609
1610 /**
1611 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1612 * package. Specifies that the application being installed should not be
1613 * treated as coming from an unknown source, but as coming from the app
1614 * invoking the Intent. For this to work you must start the installer with
1615 * startActivityForResult().
1616 */
1617 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1618 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1619
1620 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001621 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1622 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001623 * data field originated from.
1624 */
rich cannings706e8ba2012-08-20 13:20:14 -07001625 public static final String EXTRA_ORIGINATING_URI
1626 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001627
1628 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001629 * This extra can be used with any Intent used to launch an activity, supplying information
1630 * about who is launching that activity. This field contains a {@link android.net.Uri}
1631 * object, typically an http: or https: URI of the web site that the referral came from;
1632 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1633 * a native application that it came from.
1634 *
1635 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1636 * instead of directly retrieving the extra. It is also valid for applications to
1637 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1638 * a string, not a Uri; the field here, if supplied, will always take precedence,
1639 * however.</p>
1640 *
1641 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001642 */
1643 public static final String EXTRA_REFERRER
1644 = "android.intent.extra.REFERRER";
1645
1646 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001647 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1648 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1649 * not be created, in particular when Intent extras are supplied through the
1650 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1651 * schemes.
1652 *
1653 * @see #EXTRA_REFERRER
1654 */
1655 public static final String EXTRA_REFERRER_NAME
1656 = "android.intent.extra.REFERRER_NAME";
1657
1658 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001659 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001660 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001661 * Currently only a system app that hosts the provider authority "downloads" or holds the
1662 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001663 * @hide
1664 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001665 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001666 public static final String EXTRA_ORIGINATING_UID
1667 = "android.intent.extra.ORIGINATING_UID";
1668
1669 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001670 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1671 * package. Tells the installer UI to skip the confirmation with the user
1672 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001673 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1674 * will no longer show an interstitial message about updating existing
1675 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001676 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001677 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001678 public static final String EXTRA_ALLOW_REPLACE
1679 = "android.intent.extra.ALLOW_REPLACE";
1680
1681 /**
1682 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1683 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1684 * return to the application the result code of the install/uninstall. The returned result
1685 * code will be {@link android.app.Activity#RESULT_OK} on success or
1686 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1687 */
1688 public static final String EXTRA_RETURN_RESULT
1689 = "android.intent.extra.RETURN_RESULT";
1690
1691 /**
1692 * Package manager install result code. @hide because result codes are not
1693 * yet ready to be exposed.
1694 */
1695 public static final String EXTRA_INSTALL_RESULT
1696 = "android.intent.extra.INSTALL_RESULT";
1697
1698 /**
1699 * Activity Action: Launch application uninstaller.
1700 * <p>
1701 * Input: The data must be a package: URI whose scheme specific part is
1702 * the package name of the current installed package to be uninstalled.
1703 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1704 * <p>
1705 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1706 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001707 * <p>
1708 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1709 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001710 */
1711 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1712 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1713
1714 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001715 * Specify whether the package should be uninstalled for all users.
1716 * @hide because these should not be part of normal application flow.
1717 */
1718 public static final String EXTRA_UNINSTALL_ALL_USERS
1719 = "android.intent.extra.UNINSTALL_ALL_USERS";
1720
1721 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001722 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1723 * describing the last run version of the platform that was setup.
1724 * @hide
1725 */
1726 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1727
Svet Ganov3695b8a2015-03-24 16:30:25 -07001728 /**
1729 * Activity action: Launch UI to manage the permissions of an app.
1730 * <p>
1731 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1732 * will be managed by the launched UI.
1733 * </p>
1734 * <p>
1735 * Output: Nothing.
1736 * </p>
1737 *
1738 * @see #EXTRA_PACKAGE_NAME
1739 *
1740 * @hide
1741 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001742 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001743 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1744 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1745 "android.intent.action.MANAGE_APP_PERMISSIONS";
1746
1747 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001748 * Activity action: Launch UI to manage permissions.
1749 * <p>
1750 * Input: Nothing.
1751 * </p>
1752 * <p>
1753 * Output: Nothing.
1754 * </p>
1755 *
1756 * @hide
1757 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001758 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001759 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1760 public static final String ACTION_MANAGE_PERMISSIONS =
1761 "android.intent.action.MANAGE_PERMISSIONS";
1762
1763 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001764 * Activity action: Launch UI to review permissions for an app.
1765 * The system uses this intent if permission review for apps not
1766 * supporting the new runtime permissions model is enabled. In
1767 * this mode a permission review is required before any of the
1768 * app components can run.
1769 * <p>
1770 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1771 * permissions will be reviewed (mandatory).
1772 * </p>
1773 * <p>
1774 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1775 * be fired after the permission review (optional).
1776 * </p>
1777 * <p>
1778 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1779 * be invoked after the permission review (optional).
1780 * </p>
1781 * <p>
1782 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1783 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1784 * </p>
1785 * <p>
1786 * Output: Nothing.
1787 * </p>
1788 *
1789 * @see #EXTRA_PACKAGE_NAME
1790 * @see #EXTRA_INTENT
1791 * @see #EXTRA_REMOTE_CALLBACK
1792 * @see #EXTRA_RESULT_NEEDED
1793 *
1794 * @hide
1795 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001796 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001797 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1798 public static final String ACTION_REVIEW_PERMISSIONS =
1799 "android.intent.action.REVIEW_PERMISSIONS";
1800
1801 /**
1802 * Intent extra: A callback for reporting remote result as a bundle.
1803 * <p>
1804 * Type: IRemoteCallback
1805 * </p>
1806 *
1807 * @hide
1808 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001809 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001810 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1811
1812 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001813 * Intent extra: An app package name.
1814 * <p>
1815 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001816 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001817 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001818 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001819 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1820
1821 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001822 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1823 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1824 *
1825 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1826 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1827 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001828 *
1829 * @see #ACTION_MY_PACKAGE_SUSPENDED
1830 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1831 * @see PackageManager#isPackageSuspended()
1832 * @see PackageManager#getSuspendedPackageAppExtras()
1833 */
1834 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1835
1836 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001837 * Intent extra: An app split name.
1838 * <p>
1839 * Type: String
1840 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001841 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001842 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1843
1844 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001845 * Intent extra: A {@link ComponentName} value.
1846 * <p>
1847 * Type: String
1848 * </p>
1849 */
1850 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1851
1852 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001853 * Intent extra: An extra for specifying whether a result is needed.
1854 * <p>
1855 * Type: boolean
1856 * </p>
1857 *
1858 * @hide
1859 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001860 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001861 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1862
1863 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001864 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1865 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1866 *
1867 * @see PackageManager#isPackageSuspended()
1868 * @see #ACTION_PACKAGES_SUSPENDED
1869 *
1870 * @hide
1871 */
1872 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1873
1874 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001875 * Activity action: Launch UI to manage which apps have a given permission.
1876 * <p>
1877 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1878 * to which will be managed by the launched UI.
1879 * </p>
1880 * <p>
1881 * Output: Nothing.
1882 * </p>
1883 *
1884 * @see #EXTRA_PERMISSION_NAME
1885 *
1886 * @hide
1887 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001888 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001889 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1890 public static final String ACTION_MANAGE_PERMISSION_APPS =
1891 "android.intent.action.MANAGE_PERMISSION_APPS";
1892
1893 /**
1894 * Intent extra: The name of a permission.
1895 * <p>
1896 * Type: String
1897 * </p>
1898 *
1899 * @hide
1900 */
1901 @SystemApi
1902 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1903
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001904 // ---------------------------------------------------------------------
1905 // ---------------------------------------------------------------------
1906 // Standard intent broadcast actions (see action variable).
1907
1908 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001909 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1910 * <p>
1911 * For historical reasons, the name of this broadcast action refers to the power
1912 * state of the screen but it is actually sent in response to changes in the
1913 * overall interactive state of the device.
1914 * </p><p>
1915 * This broadcast is sent when the device becomes non-interactive which may have
1916 * nothing to do with the screen turning off. To determine the
1917 * actual state of the screen, use {@link android.view.Display#getState}.
1918 * </p><p>
1919 * See {@link android.os.PowerManager#isInteractive} for details.
1920 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001921 * You <em>cannot</em> receive this through components declared in
1922 * manifests, only by explicitly registering for it with
1923 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1924 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001925 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001926 * <p class="note">This is a protected intent that can only be sent
1927 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001928 */
1929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1930 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001931
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001932 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001933 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1934 * <p>
1935 * For historical reasons, the name of this broadcast action refers to the power
1936 * state of the screen but it is actually sent in response to changes in the
1937 * overall interactive state of the device.
1938 * </p><p>
1939 * This broadcast is sent when the device becomes interactive which may have
1940 * nothing to do with the screen turning on. To determine the
1941 * actual state of the screen, use {@link android.view.Display#getState}.
1942 * </p><p>
1943 * See {@link android.os.PowerManager#isInteractive} for details.
1944 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001945 * You <em>cannot</em> receive this through components declared in
1946 * manifests, only by explicitly registering for it with
1947 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1948 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001949 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001950 * <p class="note">This is a protected intent that can only be sent
1951 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001952 */
1953 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1954 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001955
1956 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001957 * Broadcast Action: Sent after the system stops dreaming.
1958 *
1959 * <p class="note">This is a protected intent that can only be sent by the system.
1960 * It is only sent to registered receivers.</p>
1961 */
1962 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1963 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1964
1965 /**
1966 * Broadcast Action: Sent after the system starts dreaming.
1967 *
1968 * <p class="note">This is a protected intent that can only be sent by the system.
1969 * It is only sent to registered receivers.</p>
1970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1973
1974 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001975 * 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 -07001976 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001977 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001978 * <p class="note">This is a protected intent that can only be sent
1979 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001980 */
1981 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001982 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001983
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001984 /**
1985 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001986 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001987 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001988 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1989 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001990 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001991 * <p class="note">This is a protected intent that can only be sent
1992 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1996 /**
1997 * Broadcast Action: The time was set.
1998 */
1999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2000 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2001 /**
2002 * Broadcast Action: The date has changed.
2003 */
2004 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2005 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2006 /**
2007 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2008 * <ul>
2009 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2010 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002011 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002012 * <p class="note">This is a protected intent that can only be sent
2013 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002014 */
2015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2016 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2017 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002018 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2019 * DNS entries should be tossed.
2020 * @hide
2021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002025 * Alarm Changed Action: This is broadcast when the AlarmClock
2026 * application's alarm is set or unset. It is used by the
2027 * AlarmClock application and the StatusBar service.
2028 * @hide
2029 */
2030 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood1c77a112018-08-14 14:06:26 +01002031 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002032 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002033
2034 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002035 * Broadcast Action: This is broadcast once, after the user has finished
2036 * booting, but while still in the "locked" state. It can be used to perform
2037 * application-specific initialization, such as installing alarms. You must
2038 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2039 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002040 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002041 * This broadcast is sent immediately at boot by all devices (regardless of
2042 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2043 * higher. Upon receipt of this broadcast, the user is still locked and only
2044 * device-protected storage can be accessed safely. If you want to access
2045 * credential-protected storage, you need to wait for the user to be
2046 * unlocked (typically by entering their lock pattern or PIN for the first
2047 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2048 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2049 * <p>
2050 * To receive this broadcast, your receiver component must be marked as
2051 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002052 * <p class="note">
2053 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002054 *
2055 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002056 */
2057 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2058 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2059
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002060 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002061 * Broadcast Action: This is broadcast once, after the user has finished
2062 * booting. It can be used to perform application-specific initialization,
2063 * such as installing alarms. You must hold the
2064 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2065 * order to receive this broadcast.
2066 * <p>
2067 * This broadcast is sent at boot by all devices (both with and without
2068 * direct boot support). Upon receipt of this broadcast, the user is
2069 * unlocked and both device-protected and credential-protected storage can
2070 * accessed safely.
2071 * <p>
2072 * If you need to run while the user is still locked (before they've entered
2073 * their lock pattern or PIN for the first time), you can listen for the
2074 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2075 * <p class="note">
2076 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 */
2078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002079 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002080 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002081
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002082 /**
2083 * Broadcast Action: This is broadcast when a user action should request a
2084 * temporary system dialog to dismiss. Some examples of temporary system
2085 * dialogs are the notification window-shade and the recent tasks dialog.
2086 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002088 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2089 /**
2090 * Broadcast Action: Trigger the download and eventual installation
2091 * of a package.
2092 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002093 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002094 * <p class="note">This is a protected intent that can only be sent
2095 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002096 *
2097 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002098 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002099 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002100 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2101 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2102 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002103 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002104 * device. The data contains the name of the package. Note that the
2105 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002106 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002107 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002108 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2109 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002110 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2111 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002112 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002113 * <p class="note">This is a protected intent that can only be sent
2114 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002115 */
2116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2117 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2118 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002119 * Broadcast Action: A new version of an application package has been
2120 * installed, replacing an existing version that was previously installed.
2121 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002122 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002123 * <ul>
2124 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2125 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002126 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002127 * <p class="note">This is a protected intent that can only be sent
2128 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002129 */
2130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2131 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2132 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002133 * Broadcast Action: A new version of your application has been installed
2134 * over an existing one. This is only sent to the application that was
2135 * replaced. It does not contain any additional data; to receive it, just
2136 * use an intent filter for this action.
2137 *
2138 * <p class="note">This is a protected intent that can only be sent
2139 * by the system.
2140 */
2141 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2142 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2143 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002144 * Broadcast Action: An existing application package has been removed from
2145 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002146 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002147 * <ul>
2148 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2149 * to the package.
2150 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2151 * application -- data and code -- is being removed.
2152 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2153 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2154 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002155 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002156 * <p class="note">This is a protected intent that can only be sent
2157 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002158 */
2159 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2160 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2161 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002162 * Broadcast Action: An existing application package has been completely
2163 * removed from the device. The data contains the name of the package.
2164 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2165 * {@link #EXTRA_DATA_REMOVED} is true and
2166 * {@link #EXTRA_REPLACING} is false of that broadcast.
2167 *
2168 * <ul>
2169 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2170 * to the package.
2171 * </ul>
2172 *
2173 * <p class="note">This is a protected intent that can only be sent
2174 * by the system.
2175 */
2176 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2177 public static final String ACTION_PACKAGE_FULLY_REMOVED
2178 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2179 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002180 * Broadcast Action: An existing application package has been changed (for
2181 * example, a component has been enabled or disabled). The data contains
2182 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002183 * <ul>
2184 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002185 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002186 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002187 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2188 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002189 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002190 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002191 * <p class="note">This is a protected intent that can only be sent
2192 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002193 */
2194 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2195 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2196 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002197 * @hide
2198 * Broadcast Action: Ask system services if there is any reason to
2199 * restart the given package. The data contains the name of the
2200 * package.
2201 * <ul>
2202 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2203 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2204 * </ul>
2205 *
2206 * <p class="note">This is a protected intent that can only be sent
2207 * by the system.
2208 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002209 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002210 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2211 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2212 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002213 * Broadcast Action: The user has restarted a package, and all of its
2214 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002215 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002216 * be removed. Note that the restarted package does <em>not</em>
2217 * receive this broadcast.
2218 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002219 * <ul>
2220 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2221 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002222 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002223 * <p class="note">This is a protected intent that can only be sent
2224 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002225 */
2226 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2227 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2228 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002229 * Broadcast Action: The user has cleared the data of a package. This should
2230 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002231 * its persistent data is erased and this broadcast sent.
2232 * Note that the cleared package does <em>not</em>
2233 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002234 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002235 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2236 * package whose data was cleared is an uninstalled instant app, then the UID
2237 * will be -1. The platform keeps some meta-data associated with instant apps
2238 * after they are uninstalled.
2239 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2240 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002241 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002242 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002243 * <p class="note">This is a protected intent that can only be sent
2244 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002245 */
2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2247 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2248 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002249 * Broadcast Action: Packages have been suspended.
2250 * <p>Includes the following extras:
2251 * <ul>
2252 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2253 * </ul>
2254 *
2255 * <p class="note">This is a protected intent that can only be sent
2256 * by the system. It is only sent to registered receivers.
2257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2259 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2260 /**
2261 * Broadcast Action: Packages have been unsuspended.
2262 * <p>Includes the following extras:
2263 * <ul>
2264 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2265 * </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_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002272
2273 /**
2274 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002275 * whenever a package is put into a suspended state or any of its app extras change while in the
2276 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002277 * <p> Optionally includes the following extras:
2278 * <ul>
2279 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2280 * useful information for the app being suspended.
2281 * </ul>
2282 * <p class="note">This is a protected intent that can only be sent
2283 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2284 * the manifest.</em>
2285 *
2286 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2287 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2288 * @see PackageManager#isPackageSuspended()
2289 * @see PackageManager#getSuspendedPackageAppExtras()
2290 */
2291 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2292 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2293
2294 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002295 * Activity Action: Started to show more details about why an application was suspended.
2296 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002297 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2298 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002299 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002300 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2301 * handling this intent and protect it with
2302 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2303 *
2304 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2305 *
2306 * <p class="note">This is a protected intent that can only be sent
2307 * by the system.
2308 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002309 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2310 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002311 * @see PackageManager#isPackageSuspended()
2312 * @see #ACTION_PACKAGES_SUSPENDED
2313 *
2314 * @hide
2315 */
2316 @SystemApi
2317 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2318 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2319 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2320
2321 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002322 * Broadcast Action: Sent to a package that has been unsuspended.
2323 *
2324 * <p class="note">This is a protected intent that can only be sent
2325 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2326 * the manifest.</em>
2327 *
2328 * @see #ACTION_MY_PACKAGE_SUSPENDED
2329 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2330 * @see PackageManager#isPackageSuspended()
2331 * @see PackageManager#getSuspendedPackageAppExtras()
2332 */
2333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2334 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2335
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002336 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002337 * Broadcast Action: A user ID has been removed from the system. The user
2338 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002339 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002340 * <p class="note">This is a protected intent that can only be sent
2341 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002342 */
2343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2344 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002345
2346 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002347 * Broadcast Action: Sent to the installer package of an application when
2348 * that application is first launched (that is the first time it is moved
2349 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002350 *
2351 * <p class="note">This is a protected intent that can only be sent
2352 * by the system.
2353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2355 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2356
2357 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002358 * Broadcast Action: Sent to the system package verifier when a package
2359 * needs to be verified. The data contains the package URI.
2360 * <p class="note">
2361 * This is a protected intent that can only be sent by the system.
2362 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002363 */
2364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2365 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2366
2367 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002368 * Broadcast Action: Sent to the system package verifier when a package is
2369 * verified. The data contains the package URI.
2370 * <p class="note">
2371 * This is a protected intent that can only be sent by the system.
2372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2374 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2375
2376 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002377 * Broadcast Action: Sent to the system intent filter verifier when an
2378 * intent filter needs to be verified. The data contains the filter data
2379 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002380 * <p class="note">
2381 * This is a protected intent that can only be sent by the system.
2382 * </p>
2383 *
2384 * @hide
2385 */
2386 @SystemApi
2387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2388 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2389
2390 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002391 * Broadcast Action: Resources for a set of packages (which were
2392 * previously unavailable) are currently
2393 * available since the media on which they exist is available.
2394 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2395 * list of packages whose availability changed.
2396 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2397 * list of uids of packages whose availability changed.
2398 * Note that the
2399 * packages in this list do <em>not</em> receive this broadcast.
2400 * The specified set of packages are now available on the system.
2401 * <p>Includes the following extras:
2402 * <ul>
2403 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2404 * whose resources(were previously unavailable) are currently available.
2405 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2406 * packages whose resources(were previously unavailable)
2407 * are currently available.
2408 * </ul>
2409 *
2410 * <p class="note">This is a protected intent that can only be sent
2411 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002414 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2415 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002416
2417 /**
2418 * Broadcast Action: Resources for a set of packages are currently
2419 * unavailable since the media on which they exist is unavailable.
2420 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2421 * list of packages whose availability changed.
2422 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2423 * list of uids of packages whose availability changed.
2424 * The specified set of packages can no longer be
2425 * launched and are practically unavailable on the system.
2426 * <p>Inclues the following extras:
2427 * <ul>
2428 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2429 * whose resources are no longer available.
2430 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2431 * whose resources are no longer available.
2432 * </ul>
2433 *
2434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002438 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002439 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002440
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002441 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002442 * Broadcast Action: preferred activities have changed *explicitly*.
2443 *
2444 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2445 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2446 * be sent.
2447 *
2448 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2449 *
2450 * @hide
2451 */
2452 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2453 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2454 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2455
2456
2457 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002458 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002459 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002460 * This should <em>only</em> be used to determine when the wallpaper
2461 * has changed to show the new wallpaper to the user. You should certainly
2462 * never, in response to this, change the wallpaper or other attributes of
2463 * it such as the suggested size. That would be crazy, right? You'd cause
2464 * all kinds of loops, especially if other apps are doing similar things,
2465 * right? Of course. So please don't do this.
2466 *
2467 * @deprecated Modern applications should use
2468 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2469 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2470 * shown behind their UI, rather than watching for this broadcast and
2471 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002472 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002473 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002474 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2475 /**
2476 * Broadcast Action: The current device {@link android.content.res.Configuration}
2477 * (orientation, locale, etc) has changed. When such a change happens, the
2478 * UIs (view hierarchy) will need to be rebuilt based on this new
2479 * information; for the most part, applications don't need to worry about
2480 * this, because the system will take care of stopping and restarting the
2481 * application to make sure it sees the new changes. Some system code that
2482 * can not be restarted will need to watch for this action and handle it
2483 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002484 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002485 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002486 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002487 * in manifests, only by explicitly registering for it with
2488 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2489 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002490 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002491 * <p class="note">This is a protected intent that can only be sent
2492 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002493 *
2494 * @see android.content.res.Configuration
2495 */
2496 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2497 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002498
2499 /**
2500 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2501 * such that the device may be eligible for the installation of additional configuration splits.
2502 * Configuration properties that can trigger this broadcast include locale and display density.
2503 *
2504 * <p class="note">
2505 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2506 * components declared in manifests. However, the receiver <em>must</em> hold the
2507 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2508 *
2509 * <p class="note">
2510 * This is a protected intent that can only be sent by the system.
2511 *
2512 * @hide
2513 */
2514 @SystemApi
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2516 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2517 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002518 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002519 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002520 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002521 * <p class="note">This is a protected intent that can only be sent
2522 * by the system.
2523 */
2524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2525 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2526 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002527 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2528 * charging state, level, and other information about the battery.
2529 * See {@link android.os.BatteryManager} for documentation on the
2530 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002531 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002532 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002533 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002534 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002535 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002536 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2537 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2538 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2539 * broadcasts that are sent and can be received through manifest
2540 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002541 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002542 * <p class="note">This is a protected intent that can only be sent
2543 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002547
2548
2549 /**
2550 * Broadcast Action: Sent when the current battery level changes.
2551 *
2552 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2553 * instances representing individual battery level changes with associated
2554 * extras from {@link #ACTION_BATTERY_CHANGED}.
2555 *
2556 * <p class="note">
2557 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2558 *
2559 * @hide
2560 */
2561 @SystemApi
2562 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2563 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002564 /**
2565 * Broadcast Action: Indicates low battery condition on the device.
2566 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002567 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002568 * <p class="note">This is a protected intent that can only be sent
2569 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002570 */
2571 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2572 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2573 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002574 * Broadcast Action: Indicates the battery is now okay after being low.
2575 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2576 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002577 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002578 * <p class="note">This is a protected intent that can only be sent
2579 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002580 */
2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2582 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2583 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002584 * Broadcast Action: External power has been connected to the device.
2585 * This is intended for applications that wish to register specifically to this notification.
2586 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2587 * stay active to receive this notification. This action can be used to implement actions
2588 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002589 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002590 * <p class="note">This is a protected intent that can only be sent
2591 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002592 */
2593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002594 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002595 /**
2596 * Broadcast Action: External power has been removed from the device.
2597 * This is intended for applications that wish to register specifically to this notification.
2598 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2599 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002600 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002601 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002602 * <p class="note">This is a protected intent that can only be sent
2603 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002606 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002607 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002608 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002609 * Broadcast Action: Device is shutting down.
2610 * This is broadcast when the device is being shut down (completely turned
2611 * off, not sleeping). Once the broadcast is complete, the final shutdown
2612 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002613 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002614 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2615 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2616 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002617 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002618 * <p class="note">This is a protected intent that can only be sent
2619 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002620 * <p>May include the following extras:
2621 * <ul>
2622 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2623 * shutdown is only for userspace processes. If not set, assumed to be false.
2624 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002625 */
2626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002627 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002628 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002629 * Activity Action: Start this activity to request system shutdown.
2630 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002631 * to request confirmation from the user before shutting down. The optional boolean
2632 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2633 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002634 *
2635 * <p class="note">This is a protected intent that can only be sent
2636 * by the system.
2637 *
2638 * {@hide}
2639 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002640 public static final String ACTION_REQUEST_SHUTDOWN
2641 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002642 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002643 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002644 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002645 * <p class="note">
2646 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002647 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002648 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2649 * or above, this broadcast will no longer be delivered to any
2650 * {@link BroadcastReceiver} defined in your manifest. Instead,
2651 * apps are strongly encouraged to use the improved
2652 * {@link Context#getCacheDir()} behavior so the system can
2653 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002654 */
2655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002656 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002657 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2658 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002659 * Broadcast Action: Indicates low storage space condition on the device no
2660 * longer exists
2661 * <p class="note">
2662 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002663 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002664 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2665 * or above, this broadcast will no longer be delivered to any
2666 * {@link BroadcastReceiver} defined in your manifest. Instead,
2667 * apps are strongly encouraged to use the improved
2668 * {@link Context#getCacheDir()} behavior so the system can
2669 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002670 */
2671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002672 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2674 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002675 * Broadcast Action: A sticky broadcast that indicates a storage space full
2676 * condition on the device. This is intended for activities that want to be
2677 * able to fill the data partition completely, leaving only enough free
2678 * space to prevent system-wide SQLite failures.
2679 * <p class="note">
2680 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002681 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002682 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2683 * or above, this broadcast will no longer be delivered to any
2684 * {@link BroadcastReceiver} defined in your manifest. Instead,
2685 * apps are strongly encouraged to use the improved
2686 * {@link Context#getCacheDir()} behavior so the system can
2687 * automatically free up storage when needed.
2688 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002689 */
2690 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002691 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002692 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2693 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002694 * Broadcast Action: Indicates storage space full condition on the device no
2695 * longer exists.
2696 * <p class="note">
2697 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002698 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002699 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2700 * or above, this broadcast will no longer be delivered to any
2701 * {@link BroadcastReceiver} defined in your manifest. Instead,
2702 * apps are strongly encouraged to use the improved
2703 * {@link Context#getCacheDir()} behavior so the system can
2704 * automatically free up storage when needed.
2705 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002706 */
2707 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002708 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002709 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2710 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002711 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2712 * and package management should be started.
2713 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2714 * notification.
2715 */
2716 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2717 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2718 /**
2719 * Broadcast Action: The device has entered USB Mass Storage mode.
2720 * This is used mainly for the USB Settings panel.
2721 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2722 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002723 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002724 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002725 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2728
2729 /**
2730 * Broadcast Action: The device has exited USB Mass Storage mode.
2731 * This is used mainly for the USB Settings panel.
2732 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2733 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002734 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002735 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002736 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2739
2740 /**
2741 * Broadcast Action: External media has been removed.
2742 * The path to the mount point for the removed media is contained in the Intent.mData field.
2743 */
2744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2746
2747 /**
2748 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002749 * 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 -07002750 */
2751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2752 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2753
2754 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002755 * Broadcast Action: External media is present, and being disk-checked
2756 * 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 -08002757 */
2758 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2759 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2760
2761 /**
2762 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2763 * 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 -08002764 */
2765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2766 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2767
2768 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002770 * 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 -07002771 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2772 * media was mounted read only.
2773 */
2774 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2775 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2776
2777 /**
2778 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002779 * 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 -07002780 */
2781 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2782 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2783
2784 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002785 * Broadcast Action: External media is no longer being shared via USB mass storage.
2786 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2787 *
2788 * @hide
2789 */
2790 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2791
2792 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002793 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2794 * The path to the mount point for the removed media is contained in the Intent.mData field.
2795 */
2796 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2797 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2798
2799 /**
2800 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002801 * 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 -07002802 */
2803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2804 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2805
2806 /**
2807 * Broadcast Action: User has expressed the desire to remove the external storage media.
2808 * Applications should close all files they have open within the mount point when they receive this intent.
2809 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2810 */
2811 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2812 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2813
2814 /**
2815 * Broadcast Action: The media scanner has started scanning a directory.
2816 * The path to the directory being scanned is contained in the Intent.mData field.
2817 */
2818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2819 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2820
2821 /**
2822 * Broadcast Action: The media scanner has finished scanning a directory.
2823 * The path to the scanned directory is contained in the Intent.mData field.
2824 */
2825 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2826 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2827
2828 /**
2829 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2830 * The path to the file is contained in the Intent.mData field.
2831 */
2832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2833 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2834
2835 /**
2836 * Broadcast Action: The "Media Button" was pressed. Includes a single
2837 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2838 * caused the broadcast.
2839 */
2840 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2841 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2842
2843 /**
2844 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2845 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2846 * caused the broadcast.
2847 */
2848 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2849 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2850
2851 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2852 // location; they are not general-purpose actions.
2853
2854 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002855 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2859 "android.intent.action.GTALK_CONNECTED";
2860
2861 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002862 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002863 */
2864 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2865 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2866 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002867
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002868 /**
2869 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002870 */
2871 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2872 public static final String ACTION_INPUT_METHOD_CHANGED =
2873 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002874
2875 /**
2876 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2877 * more radios have been turned off or on. The intent will have the following extra value:</p>
2878 * <ul>
2879 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2880 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2881 * turned off</li>
2882 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002883 *
Peng Xua35b5532016-01-20 00:05:45 -08002884 * <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 -07002885 */
2886 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2887 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2888
2889 /**
2890 * Broadcast Action: Some content providers have parts of their namespace
2891 * where they publish new events or items that the user may be especially
2892 * interested in. For these things, they may broadcast this action when the
2893 * set of interesting items change.
2894 *
2895 * For example, GmailProvider sends this notification when the set of unread
2896 * mail in the inbox changes.
2897 *
2898 * <p>The data of the intent identifies which part of which provider
2899 * changed. When queried through the content resolver, the data URI will
2900 * return the data set in question.
2901 *
2902 * <p>The intent will have the following extra values:
2903 * <ul>
2904 * <li><em>count</em> - The number of items in the data set. This is the
2905 * same as the number of items in the cursor returned by querying the
2906 * data URI. </li>
2907 * </ul>
2908 *
2909 * This intent will be sent at boot (if the count is non-zero) and when the
2910 * data set changes. It is possible for the data set to change without the
2911 * count changing (for example, if a new unread message arrives in the same
2912 * sync operation in which a message is archived). The phone should still
2913 * ring/vibrate/etc as normal in this case.
2914 */
2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2916 public static final String ACTION_PROVIDER_CHANGED =
2917 "android.intent.action.PROVIDER_CHANGED";
2918
2919 /**
2920 * Broadcast Action: Wired Headset plugged in or unplugged.
2921 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002922 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2923 * and documentation.
2924 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002925 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002926 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002927 */
2928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002929 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002930
2931 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002932 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2933 * <ul>
2934 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2935 * </ul>
2936 *
2937 * <p class="note">This is a protected intent that can only be sent
2938 * by the system.
2939 *
2940 * @hide
2941 */
2942 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2943 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2944 = "android.intent.action.ADVANCED_SETTINGS";
2945
2946 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002947 * Broadcast Action: Sent after application restrictions are changed.
2948 *
2949 * <p class="note">This is a protected intent that can only be sent
2950 * by the system.</p>
2951 */
2952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2953 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2954 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2955
2956 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002957 * Broadcast Action: An outgoing call is about to be placed.
2958 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002959 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002960 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002961 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002962 * the phone number originally intended to be dialed.</li>
2963 * </ul>
2964 * <p>Once the broadcast is finished, the resultData is used as the actual
2965 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002966 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002967 * outgoing call in turn: for example, a parental control application
2968 * might verify that the user is authorized to place the call at that
2969 * time, then a number-rewriting application might add an area code if
2970 * one was not specified.</p>
2971 * <p>For consistency, any receiver whose purpose is to prohibit phone
2972 * calls should have a priority of 0, to ensure it will see the final
2973 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002974 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002975 * should have a positive priority.
2976 * Negative priorities are reserved for the system for this broadcast;
2977 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002978 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2979 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002980 * <p>Emergency calls cannot be intercepted using this mechanism, and
2981 * other calls cannot be modified to call emergency numbers using this
2982 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002983 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2984 * call to use their own service instead. Those apps should first prevent
2985 * the call from being placed by setting resultData to <code>null</code>
2986 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002987 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002988 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2989 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002990 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002991 * <p class="note">This is a protected intent that can only be sent
2992 * by the system.
Tyler Gunnd8f76c852019-01-15 08:57:57 -08002993 *
2994 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
2995 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
2996 * This means that attempts to re-write the outgoing call by other apps using this intent will
2997 * be ignored.
2998 * </p>
2999 *
3000 * @deprecated Apps that redirect outgoing calls should use the
3001 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3002 * should use the {@link android.telecom.CallScreeningService} API.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003003 */
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003004 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003005 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3006 public static final String ACTION_NEW_OUTGOING_CALL =
3007 "android.intent.action.NEW_OUTGOING_CALL";
3008
3009 /**
3010 * Broadcast Action: Have the device reboot. This is only for use by
3011 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003012 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003013 * <p class="note">This is a protected intent that can only be sent
3014 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003015 */
3016 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3017 public static final String ACTION_REBOOT =
3018 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003019
Wei Huang97ecc9c2009-05-11 17:44:20 -07003020 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003021 * Broadcast Action: A sticky broadcast for changes in the physical
3022 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003023 *
3024 * <p>The intent will have the following extra values:
3025 * <ul>
3026 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003027 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003028 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003029 * <p>This is intended for monitoring the current physical dock state.
3030 * See {@link android.app.UiModeManager} for the normal API dealing with
3031 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003032 */
3033 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3034 public static final String ACTION_DOCK_EVENT =
3035 "android.intent.action.DOCK_EVENT";
3036
3037 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003038 * Broadcast Action: A broadcast when idle maintenance can be started.
3039 * This means that the user is not interacting with the device and is
3040 * not expected to do so soon. Typical use of the idle maintenance is
3041 * to perform somehow expensive tasks that can be postponed at a moment
3042 * when they will not degrade user experience.
3043 * <p>
3044 * <p class="note">In order to keep the device responsive in case of an
3045 * unexpected user interaction, implementations of a maintenance task
3046 * should be interruptible. In such a scenario a broadcast with action
3047 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3048 * should not do the maintenance work in
3049 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3050 * maintenance service by {@link Context#startService(Intent)}. Also
3051 * you should hold a wake lock while your maintenance service is running
3052 * to prevent the device going to sleep.
3053 * </p>
3054 * <p>
3055 * <p class="note">This is a protected intent that can only be sent by
3056 * the system.
3057 * </p>
3058 *
3059 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003060 *
3061 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003062 */
3063 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3064 public static final String ACTION_IDLE_MAINTENANCE_START =
3065 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3066
3067 /**
3068 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3069 * This means that the user was not interacting with the device as a result
3070 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3071 * was sent and now the user started interacting with the device. Typical
3072 * use of the idle maintenance is to perform somehow expensive tasks that
3073 * can be postponed at a moment when they will not degrade user experience.
3074 * <p>
3075 * <p class="note">In order to keep the device responsive in case of an
3076 * unexpected user interaction, implementations of a maintenance task
3077 * should be interruptible. Hence, on receiving a broadcast with this
3078 * action, the maintenance task should be interrupted as soon as possible.
3079 * In other words, you should not do the maintenance work in
3080 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3081 * maintenance service that was started on receiving of
3082 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3083 * lock you acquired when your maintenance service started.
3084 * </p>
3085 * <p class="note">This is a protected intent that can only be sent
3086 * by the system.
3087 *
3088 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003089 *
3090 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003091 */
3092 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3093 public static final String ACTION_IDLE_MAINTENANCE_END =
3094 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3095
3096 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003097 * Broadcast Action: a remote intent is to be broadcasted.
3098 *
3099 * A remote intent is used for remote RPC between devices. The remote intent
3100 * is serialized and sent from one device to another device. The receiving
3101 * device parses the remote intent and broadcasts it. Note that anyone can
3102 * broadcast a remote intent. However, if the intent receiver of the remote intent
3103 * does not trust intent broadcasts from arbitrary intent senders, it should require
3104 * the sender to hold certain permissions so only trusted sender's broadcast will be
3105 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003106 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003107 */
3108 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003109 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003110
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003111 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003112 * Broadcast Action: This is broadcast once when the user is booting after a
3113 * system update. It can be used to perform cleanup or upgrades after a
3114 * system update.
3115 * <p>
3116 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3117 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3118 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3119 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003120 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003121 * @hide
3122 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003123 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003124 public static final String ACTION_PRE_BOOT_COMPLETED =
3125 "android.intent.action.PRE_BOOT_COMPLETED";
3126
Amith Yamasani13593602012-03-22 16:16:17 -07003127 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003128 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003129 * on restricted users. The broadcast intent contains an extra
3130 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3131 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3132 * String[] depending on the restriction type.<p/>
3133 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003134 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3135 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3136 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003137 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3138 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003139 * @see RestrictionEntry
3140 */
3141 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3142 "android.intent.action.GET_RESTRICTION_ENTRIES";
3143
3144 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003145 * Sent the first time a user is starting, to allow system apps to
3146 * perform one time initialization. (This will not be seen by third
3147 * party applications because a newly initialized user does not have any
3148 * third party applications installed for it.) This is sent early in
3149 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003150 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3151 * broadcast, since it is part of a visible user interaction; be as quick
3152 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003153 */
3154 public static final String ACTION_USER_INITIALIZE =
3155 "android.intent.action.USER_INITIALIZE";
3156
3157 /**
3158 * Sent when a user switch is happening, causing the process's user to be
3159 * brought to the foreground. This is only sent to receivers registered
3160 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3161 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003162 * foreground. This is sent as a foreground
3163 * broadcast, since it is part of a visible user interaction; be as quick
3164 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003165 */
3166 public static final String ACTION_USER_FOREGROUND =
3167 "android.intent.action.USER_FOREGROUND";
3168
3169 /**
3170 * Sent when a user switch is happening, causing the process's user to be
3171 * sent to the background. This is only sent to receivers registered
3172 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3173 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003174 * background. This is sent as a foreground
3175 * broadcast, since it is part of a visible user interaction; be as quick
3176 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003177 */
3178 public static final String ACTION_USER_BACKGROUND =
3179 "android.intent.action.USER_BACKGROUND";
3180
3181 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003182 * Broadcast sent to the system when a user is added. Carries an extra
3183 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3184 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003185 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003186 * @hide
3187 */
3188 public static final String ACTION_USER_ADDED =
3189 "android.intent.action.USER_ADDED";
3190
3191 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003192 * Broadcast sent by the system when a user is started. Carries an extra
3193 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003194 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003195 * that has been started. This is sent as a foreground
3196 * broadcast, since it is part of a visible user interaction; be as quick
3197 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003198 * @hide
3199 */
3200 public static final String ACTION_USER_STARTED =
3201 "android.intent.action.USER_STARTED";
3202
3203 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003204 * Broadcast sent when a user is in the process of starting. Carries an extra
3205 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3206 * sent to registered receivers, not manifest receivers. It is sent to all
3207 * users (including the one that is being started). You must hold
3208 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3209 * this broadcast. This is sent as a background broadcast, since
3210 * its result is not part of the primary UX flow; to safely keep track of
3211 * started/stopped state of a user you can use this in conjunction with
3212 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3213 * other user state broadcasts since those are foreground broadcasts so can
3214 * execute in a different order.
3215 * @hide
3216 */
3217 public static final String ACTION_USER_STARTING =
3218 "android.intent.action.USER_STARTING";
3219
3220 /**
3221 * Broadcast sent when a user is going to be stopped. Carries an extra
3222 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3223 * sent to registered receivers, not manifest receivers. It is sent to all
3224 * users (including the one that is being stopped). You must hold
3225 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3226 * this broadcast. The user will not stop until all receivers have
3227 * handled the broadcast. This is sent as a background broadcast, since
3228 * its result is not part of the primary UX flow; to safely keep track of
3229 * started/stopped state of a user you can use this in conjunction with
3230 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3231 * other user state broadcasts since those are foreground broadcasts so can
3232 * execute in a different order.
3233 * @hide
3234 */
3235 public static final String ACTION_USER_STOPPING =
3236 "android.intent.action.USER_STOPPING";
3237
3238 /**
3239 * Broadcast sent to the system when a user is stopped. Carries an extra
3240 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3241 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3242 * specific package. This is only sent to registered receivers, not manifest
3243 * receivers. It is sent to all running users <em>except</em> the one that
3244 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003245 * @hide
3246 */
3247 public static final String ACTION_USER_STOPPED =
3248 "android.intent.action.USER_STOPPED";
3249
3250 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003251 * 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 -07003252 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003253 * one that has been removed. The user will not be completely removed until all receivers have
3254 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003255 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003256 * @hide
3257 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003258 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003259 public static final String ACTION_USER_REMOVED =
3260 "android.intent.action.USER_REMOVED";
3261
3262 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003263 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003264 * the userHandle of the user to become the current one. This is only sent to
3265 * registered receivers, not manifest receivers. It is sent to all running users.
3266 * You must hold
3267 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003268 * @hide
3269 */
Mathew Inwood1c77a112018-08-14 14:06:26 +01003270 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003271 public static final String ACTION_USER_SWITCHED =
3272 "android.intent.action.USER_SWITCHED";
3273
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003274 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003275 * Broadcast Action: Sent when the credential-encrypted private storage has
3276 * become unlocked for the target user. This is only sent to registered
3277 * receivers, not manifest receivers.
3278 */
3279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3280 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3281
3282 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003283 * Broadcast sent to the system when a user's information changes. Carries an extra
3284 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003285 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003286 * @hide
3287 */
3288 public static final String ACTION_USER_INFO_CHANGED =
3289 "android.intent.action.USER_INFO_CHANGED";
3290
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003291 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003292 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3293 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003294 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3295 * that need to display merged content across both primary and managed profiles need to
3296 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003297 * not manifest receivers.
3298 */
3299 public static final String ACTION_MANAGED_PROFILE_ADDED =
3300 "android.intent.action.MANAGED_PROFILE_ADDED";
3301
3302 /**
3303 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003304 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3305 * Only applications (for example Launchers) that need to display merged content across both
3306 * primary and managed profiles need to worry about this broadcast. This is only sent to
3307 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003308 */
3309 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3310 "android.intent.action.MANAGED_PROFILE_REMOVED";
3311
3312 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003313 * Broadcast sent to the primary user when the credential-encrypted private storage for
3314 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3315 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3316 * Launchers) that need to display merged content across both primary and managed profiles
3317 * need to worry about this broadcast. This is only sent to registered receivers,
3318 * not manifest receivers.
3319 */
3320 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3321 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3322
3323 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003324 * Broadcast sent to the primary user when an associated managed profile has become available.
3325 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003326 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3327 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3328 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003329 */
Rubin Xue95057a2016-04-01 16:49:25 +01003330 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3331 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3332
3333 /**
3334 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3335 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3336 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3337 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3338 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3339 */
3340 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3341 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003342
3343 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003344 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3345 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3346 * the device was locked or unlocked.
3347 *
3348 * This is only sent to registered receivers.
3349 *
3350 * @hide
3351 */
3352 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3353 "android.intent.action.DEVICE_LOCKED_CHANGED";
3354
3355 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003356 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3357 */
3358 public static final String ACTION_QUICK_CLOCK =
3359 "android.intent.action.QUICK_CLOCK";
3360
Michael Wright0087a142013-02-05 16:29:39 -08003361 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003362 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003363 * @hide
3364 */
3365 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003366 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003367
Justin Kohd378ad72013-04-01 12:18:26 -07003368 /**
3369 * Broadcast Action: A global button was pressed. Includes a single
3370 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3371 * caused the broadcast.
3372 * @hide
3373 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003374 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003375 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3376
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003377 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003378 * Broadcast Action: Sent when media resource is granted.
3379 * <p>
3380 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3381 * granted.
3382 * </p>
3383 * <p class="note">
3384 * This is a protected intent that can only be sent by the system.
3385 * </p>
3386 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003387 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003388 * </p>
3389 *
3390 * @hide
3391 */
3392 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3393 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3394
3395 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003396 * Broadcast Action: An overlay package has changed. The data contains the
3397 * name of the overlay package which has changed. This is broadcast on all
3398 * changes to the OverlayInfo returned by {@link
3399 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3400 * most common change is a state change that will change whether the
3401 * overlay is enabled or not.
3402 * @hide
3403 */
3404 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3405
3406 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003407 * Activity Action: Allow the user to select and return one or more existing
3408 * documents. When invoked, the system will display the various
3409 * {@link DocumentsProvider} instances installed on the device, letting the
3410 * user interactively navigate through them. These documents include local
3411 * media, such as photos and video, and documents provided by installed
3412 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003413 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003414 * Each document is represented as a {@code content://} URI backed by a
3415 * {@link DocumentsProvider}, which can be opened as a stream with
3416 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3417 * {@link android.provider.DocumentsContract.Document} metadata.
3418 * <p>
3419 * All selected documents are returned to the calling application with
3420 * persistable read and write permission grants. If you want to maintain
3421 * access to the documents across device reboots, you need to explicitly
3422 * take the persistable permissions using
3423 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3424 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003425 * Callers must indicate the acceptable document MIME types through
3426 * {@link #setType(String)}. For example, to select photos, use
3427 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3428 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3429 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003430 * <p>
3431 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003432 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3433 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003434 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003435 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3436 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003437 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003438 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003439 * Callers can set a document URI through
3440 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3441 * location of documents navigator. System will do its best to launch the
3442 * navigator in the specified document if it's a folder, or the folder that
3443 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003444 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003445 * Output: The URI of the item that was picked, returned in
3446 * {@link #getData()}. This must be a {@code content://} URI so that any
3447 * receiver can access it. If multiple documents were selected, they are
3448 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003449 *
3450 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003451 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003452 * @see #ACTION_CREATE_DOCUMENT
3453 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003454 */
3455 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3456 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3457
3458 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003459 * Activity Action: Allow the user to create a new document. When invoked,
3460 * the system will display the various {@link DocumentsProvider} instances
3461 * installed on the device, letting the user navigate through them. The
3462 * returned document may be a newly created document with no content, or it
3463 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003464 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003465 * Each document is represented as a {@code content://} URI backed by a
3466 * {@link DocumentsProvider}, which can be opened as a stream with
3467 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3468 * {@link android.provider.DocumentsContract.Document} metadata.
3469 * <p>
3470 * Callers must indicate the concrete MIME type of the document being
3471 * created by setting {@link #setType(String)}. This MIME type cannot be
3472 * changed after the document is created.
3473 * <p>
3474 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3475 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003476 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003477 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3478 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003479 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003480 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003481 * Callers can set a document URI through
3482 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3483 * location of documents navigator. System will do its best to launch the
3484 * navigator in the specified document if it's a folder, or the folder that
3485 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003486 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003487 * Output: The URI of the item that was created. This must be a
3488 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003489 *
3490 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003491 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003492 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003493 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003494 */
3495 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3496 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3497
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003498 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003499 * Activity Action: Allow the user to pick a directory subtree. When
3500 * invoked, the system will display the various {@link DocumentsProvider}
3501 * instances installed on the device, letting the user navigate through
3502 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003503 * <p>
3504 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003505 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3506 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3507 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003508 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003509 * Callers can set a document URI through
3510 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3511 * location of documents navigator. System will do its best to launch the
3512 * navigator in the specified document if it's a folder, or the folder that
3513 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003514 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003515 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003516 *
3517 * @see DocumentsContract
3518 */
3519 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003520 public static final String
3521 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003522
Felipe Lemec7b1f892016-01-15 15:02:31 -08003523 /**
Peng Xua35b5532016-01-20 00:05:45 -08003524 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3525 * exisiting sensor being disconnected.
3526 *
3527 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3528 *
3529 * {@hide}
3530 */
3531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3532 public static final String
3533 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3534
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003535 /**
Sam Line707f832017-04-13 17:00:55 -07003536 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003537 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003538 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003539 */
3540 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003541 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003542 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3543
Christopher Tate6597e342015-02-17 12:15:25 -08003544 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003545 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3546 * is about to be performed.
3547 * @hide
3548 */
3549 @SystemApi
3550 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3551 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3552 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3553
3554 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003555 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3556 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3557 *
3558 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3559 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003560 * @hide
3561 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003562 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003563 public static final String EXTRA_FORCE_MASTER_CLEAR =
3564 "android.intent.extra.FORCE_MASTER_CLEAR";
3565
3566 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003567 * A broadcast action to trigger a factory reset.
3568 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003569 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3570 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003571 *
3572 * <p>Not for use by third-party applications.
3573 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003574 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003575 *
3576 * {@hide}
3577 */
3578 @SystemApi
3579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3580 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3581
3582 /**
3583 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3584 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3585 *
3586 * <p>Not for use by third-party applications.
3587 *
3588 * @hide
3589 */
3590 @SystemApi
3591 public static final String EXTRA_FORCE_FACTORY_RESET =
3592 "android.intent.extra.FORCE_FACTORY_RESET";
3593
3594 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003595 * Broadcast action: report that a settings element is being restored from backup. The intent
3596 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3597 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3598 * is the value of that settings entry prior to the restore operation, and
3599 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3600 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3601 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003602 *
3603 * <p>This broadcast is sent only for settings provider entries known to require special handling
3604 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3605 * the provider's backup agent implementation.
3606 *
3607 * @see #EXTRA_SETTING_NAME
3608 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3609 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003610 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003611 * {@hide}
3612 */
3613 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3614
3615 /** {@hide} */
3616 public static final String EXTRA_SETTING_NAME = "setting_name";
3617 /** {@hide} */
3618 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3619 /** {@hide} */
3620 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003621 /** {@hide} */
3622 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003623
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003624 /**
3625 * Activity Action: Process a piece of text.
3626 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3627 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3628 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3629 */
3630 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3631 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003632
3633 /**
3634 * Broadcast Action: The sim card state has changed.
3635 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3636 * because TelephonyIntents is an internal class.
3637 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003638 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3639 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003640 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003641 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003642 @SystemApi
3643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3644 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3645
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003646 /**
fionaxu90fee272017-03-31 12:45:12 -07003647 * Broadcast Action: indicate that the phone service state has changed.
3648 * The intent will have the following extra values:</p>
3649 * <p>
3650 * @see #EXTRA_VOICE_REG_STATE
3651 * @see #EXTRA_DATA_REG_STATE
3652 * @see #EXTRA_VOICE_ROAMING_TYPE
3653 * @see #EXTRA_DATA_ROAMING_TYPE
3654 * @see #EXTRA_OPERATOR_ALPHA_LONG
3655 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3656 * @see #EXTRA_OPERATOR_NUMERIC
3657 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3658 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3659 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3660 * @see #EXTRA_MANUAL
3661 * @see #EXTRA_VOICE_RADIO_TECH
3662 * @see #EXTRA_DATA_RADIO_TECH
3663 * @see #EXTRA_CSS_INDICATOR
3664 * @see #EXTRA_NETWORK_ID
3665 * @see #EXTRA_SYSTEM_ID
3666 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3667 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3668 * @see #EXTRA_EMERGENCY_ONLY
3669 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3670 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3671 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3672 *
3673 * <p class="note">
3674 * Requires the READ_PHONE_STATE permission.
3675 *
3676 * <p class="note">This is a protected intent that can only be sent by the system.
3677 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003678 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003679 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3680 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3681 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3682 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003683 */
3684 @Deprecated
3685 @SystemApi
3686 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3687 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3688
3689 /**
3690 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3691 * state.
3692 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3693 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3694 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3695 * @see android.telephony.ServiceState#STATE_POWER_OFF
3696 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003697 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003698 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003699 */
3700 @Deprecated
3701 @SystemApi
3702 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3703
3704 /**
3705 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3706 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3707 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3708 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3709 * @see android.telephony.ServiceState#STATE_POWER_OFF
3710 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003711 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003712 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003713 */
3714 @Deprecated
3715 @SystemApi
3716 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3717
3718 /**
3719 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3720 * type.
3721 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003722 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003723 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003724 */
3725 @Deprecated
3726 @SystemApi
3727 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3728
3729 /**
3730 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3731 * type.
3732 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003733 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003734 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003735 */
3736 @Deprecated
3737 @SystemApi
3738 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3739
3740 /**
3741 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3742 * registered voice operator name in long alphanumeric format.
3743 * {@code null} if the operator name is not known or unregistered.
3744 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003745 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003746 * @deprecated Use
3747 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003748 */
3749 @Deprecated
3750 @SystemApi
3751 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3752
3753 /**
3754 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3755 * registered voice operator name in short alphanumeric format.
3756 * {@code null} if the operator name is not known or unregistered.
3757 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003758 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003759 * @deprecated Use
3760 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003761 */
3762 @Deprecated
3763 @SystemApi
3764 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3765
3766 /**
3767 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3768 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3769 * network.
3770 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003771 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003772 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003773 */
3774 @Deprecated
3775 @SystemApi
3776 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3777
3778 /**
3779 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3780 * registered data operator name in long alphanumeric format.
3781 * {@code null} if the operator name is not known or unregistered.
3782 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003783 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003784 * @deprecated Use
3785 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003786 */
3787 @Deprecated
3788 @SystemApi
3789 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3790
3791 /**
3792 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3793 * registered data operator name in short alphanumeric format.
3794 * {@code null} if the operator name is not known or unregistered.
3795 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003796 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003797 * @deprecated Use
3798 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003799 */
3800 @Deprecated
3801 @SystemApi
3802 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3803
3804 /**
3805 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3806 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3807 * data operator.
3808 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003809 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003810 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003811 */
3812 @Deprecated
3813 @SystemApi
3814 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3815
3816 /**
3817 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3818 * network selection mode is manual.
3819 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3820 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003821 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003822 * @deprecated Use
3823 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003824 */
3825 @Deprecated
3826 @SystemApi
3827 public static final String EXTRA_MANUAL = "manual";
3828
3829 /**
3830 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3831 * radio technology.
3832 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003833 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003834 * @deprecated Use
3835 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003836 */
3837 @Deprecated
3838 @SystemApi
3839 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3840
3841 /**
3842 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3843 * radio technology.
3844 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003845 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003846 * @deprecated Use
3847 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003848 */
3849 @Deprecated
3850 @SystemApi
3851 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3852
3853 /**
3854 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3855 * support on CDMA network.
3856 * Will be {@code true} if support, {@code false} otherwise.
3857 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003858 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003859 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003860 */
3861 @Deprecated
3862 @SystemApi
3863 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3864
3865 /**
3866 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3867 * id. {@code Integer.MAX_VALUE} if unknown.
3868 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003869 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003870 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003871 */
3872 @Deprecated
3873 @SystemApi
3874 public static final String EXTRA_NETWORK_ID = "networkId";
3875
3876 /**
3877 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3878 * {@code Integer.MAX_VALUE} if unknown.
3879 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003880 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003881 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003882 */
3883 @Deprecated
3884 @SystemApi
3885 public static final String EXTRA_SYSTEM_ID = "systemId";
3886
3887 /**
3888 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3889 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3890 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003891 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003892 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003893 */
3894 @Deprecated
3895 @SystemApi
3896 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3897
3898 /**
3899 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3900 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3901 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003902 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003903 * @deprecated Use
3904 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003905 */
3906 @Deprecated
3907 @SystemApi
3908 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3909
3910 /**
3911 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3912 * only mode.
3913 * {@code true} if in emergency only mode, {@code false} otherwise.
3914 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003915 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003916 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003917 */
3918 @Deprecated
3919 @SystemApi
3920 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3921
3922 /**
3923 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3924 * registration state is roaming.
3925 * {@code true} if registration indicates roaming, {@code false} otherwise
3926 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003927 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003928 * @deprecated Use
3929 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003930 */
3931 @Deprecated
3932 @SystemApi
3933 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3934 "isDataRoamingFromRegistration";
3935
3936 /**
3937 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3938 * aggregation is in use.
3939 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3940 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003941 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003942 * @deprecated Use
3943 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003944 */
3945 @Deprecated
3946 @SystemApi
3947 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3948
3949 /**
3950 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3951 * is reduced from the rsrp threshold while calculating signal strength level.
3952 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003953 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003954 */
3955 @Deprecated
3956 @SystemApi
3957 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3958
3959 /**
chen xu02811692018-10-03 19:07:09 -07003960 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
3961 * @hide
3962 */
3963 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
3964
3965 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003966 * The name of the extra used to define the text to be processed, as a
3967 * CharSequence. Note that this may be a styled CharSequence, so you must use
3968 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003969 */
3970 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3971 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003972 * 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 +00003973 */
3974 public static final String EXTRA_PROCESS_TEXT_READONLY =
3975 "android.intent.extra.PROCESS_TEXT_READONLY";
3976
Bryce Leebc58f592015-09-25 16:43:01 -07003977 /**
3978 * Broadcast action: reports when a new thermal event has been reached. When the device
3979 * is reaching its maximum temperatue, the thermal level reported
3980 * {@hide}
3981 */
3982 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3983 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3984
3985 /** {@hide} */
3986 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3987
3988 /**
3989 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003990 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003991 * {@hide}
3992 */
3993 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3994
3995 /**
3996 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003997 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003998 * {@hide}
3999 */
4000 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4001
4002 /**
4003 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004004 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004005 * {@hide}
4006 */
4007 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4008
lpeter318abc92018-05-04 16:13:14 +08004009 /**
4010 * Broadcast Action: Indicates the dock in idle state while device is docked.
4011 *
4012 * <p class="note">This is a protected intent that can only be sent
4013 * by the system.
4014 *
4015 * @hide
4016 */
4017 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4018
4019 /**
4020 * Broadcast Action: Indicates the dock in active state while device is docked.
4021 *
4022 * <p class="note">This is a protected intent that can only be sent
4023 * by the system.
4024 *
4025 * @hide
4026 */
4027 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4028
Bryce Leebc58f592015-09-25 16:43:01 -07004029
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004030 // ---------------------------------------------------------------------
4031 // ---------------------------------------------------------------------
4032 // Standard intent categories (see addCategory()).
4033
4034 /**
4035 * Set if the activity should be an option for the default action
4036 * (center press) to perform on a piece of data. Setting this will
4037 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004038 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004039 * Intent when initiating an action -- it is for use in intent filters
4040 * specified in packages.
4041 */
4042 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4043 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4044 /**
4045 * Activities that can be safely invoked from a browser must support this
4046 * category. For example, if the user is viewing a web page or an e-mail
4047 * and clicks on a link in the text, the Intent generated execute that
4048 * link will require the BROWSABLE category, so that only activities
4049 * supporting this category will be considered as possible actions. By
4050 * supporting this category, you are promising that there is nothing
4051 * damaging (without user intervention) that can happen by invoking any
4052 * matching Intent.
4053 */
4054 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4055 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4056 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004057 * Categories for activities that can participate in voice interaction.
4058 * An activity that supports this category must be prepared to run with
4059 * no UI shown at all (though in some case it may have a UI shown), and
4060 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4061 */
4062 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4063 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4064 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004065 * Set if the activity should be considered as an alternative action to
4066 * the data the user is currently viewing. See also
4067 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4068 * applies to the selection in a list of items.
4069 *
4070 * <p>Supporting this category means that you would like your activity to be
4071 * displayed in the set of alternative things the user can do, usually as
4072 * part of the current activity's options menu. You will usually want to
4073 * include a specific label in the &lt;intent-filter&gt; of this action
4074 * describing to the user what it does.
4075 *
4076 * <p>The action of IntentFilter with this category is important in that it
4077 * describes the specific action the target will perform. This generally
4078 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4079 * a specific name such as "com.android.camera.action.CROP. Only one
4080 * alternative of any particular action will be shown to the user, so using
4081 * a specific action like this makes sure that your alternative will be
4082 * displayed while also allowing other applications to provide their own
4083 * overrides of that particular action.
4084 */
4085 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4086 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4087 /**
4088 * Set if the activity should be considered as an alternative selection
4089 * action to the data the user has currently selected. This is like
4090 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4091 * of items from which the user can select, giving them alternatives to the
4092 * default action that will be performed on it.
4093 */
4094 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4095 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4096 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004097 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004098 */
4099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4100 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4101 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004102 * Should be displayed in the top-level launcher.
4103 */
4104 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4105 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4106 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004107 * Indicates an activity optimized for Leanback mode, and that should
4108 * be displayed in the Leanback launcher.
4109 */
4110 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4111 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4112 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004113 * Indicates the preferred entry-point activity when an application is launched from a Car
4114 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4115 * fallback, or exclude the application entirely.
4116 * @hide
4117 */
4118 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4119 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4120 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004121 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4122 * @hide
4123 */
4124 @SystemApi
4125 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4126 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004127 * Provides information about the package it is in; typically used if
4128 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4129 * a front-door to the user without having to be shown in the all apps list.
4130 */
4131 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4132 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4133 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004134 * This is the home activity, that is the first activity that is displayed
4135 * when the device boots.
4136 */
4137 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4138 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4139 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004140 * This is the home activity that is displayed when the device is finished setting up and ready
4141 * for use.
4142 * @hide
4143 */
4144 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4145 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4146 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004147 * This is the setup wizard activity, that is the first activity that is displayed
4148 * when the user sets up the device for the first time.
4149 * @hide
4150 */
4151 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4152 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4153 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004154 * This is the home activity, that is the activity that serves as the launcher app
4155 * from there the user can start other apps. Often components with lower/higher
4156 * priority intent filters handle the home intent, for example SetupWizard, to
4157 * setup the device and we need to be able to distinguish the home app from these
4158 * setup helpers.
4159 * @hide
4160 */
4161 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4162 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4163 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 * This activity is a preference panel.
4165 */
4166 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4167 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4168 /**
4169 * This activity is a development preference panel.
4170 */
4171 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4172 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4173 /**
4174 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004175 */
4176 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4177 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4178 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004179 * This activity allows the user to browse and download new applications.
4180 */
4181 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4182 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4183 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004184 * This activity may be exercised by the monkey or other automated test tools.
4185 */
4186 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4187 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4188 /**
4189 * To be used as a test (not part of the normal user experience).
4190 */
4191 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4192 /**
4193 * To be used as a unit test (run through the Test Harness).
4194 */
4195 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4196 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004197 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 * experience).
4199 */
4200 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004201
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004202 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004203 * Used to indicate that an intent only wants URIs that can be opened with
4204 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4205 * must support at least the columns defined in {@link OpenableColumns} when
4206 * queried.
4207 *
4208 * @see #ACTION_GET_CONTENT
4209 * @see #ACTION_OPEN_DOCUMENT
4210 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004211 */
4212 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4213 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4214
4215 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004216 * Used to indicate that an intent filter can accept files which are not necessarily
4217 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4218 * at least streamable via
4219 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4220 * using one of the stream types exposed via
4221 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4222 *
4223 * @see #ACTION_SEND
4224 * @see #ACTION_SEND_MULTIPLE
4225 */
4226 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4227 public static final String CATEGORY_TYPED_OPENABLE =
4228 "android.intent.category.TYPED_OPENABLE";
4229
4230 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004231 * To be used as code under test for framework instrumentation tests.
4232 */
4233 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4234 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004235 /**
4236 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004237 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4238 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004239 */
4240 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4241 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4242 /**
4243 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004244 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4245 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004246 */
4247 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4248 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004249 /**
4250 * An activity to run when device is inserted into a analog (low end) dock.
4251 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4252 * information, see {@link android.app.UiModeManager}.
4253 */
4254 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4255 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4256
4257 /**
4258 * An activity to run when device is inserted into a digital (high end) dock.
4259 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4260 * information, see {@link android.app.UiModeManager}.
4261 */
4262 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4263 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004264
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004265 /**
4266 * Used to indicate that the activity can be used in a car environment.
4267 */
4268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4269 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4270
Zak Cohendb6ca492017-01-26 14:09:00 -08004271 /**
4272 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4273 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4274 * information, see {@link android.app.UiModeManager}.
4275 */
4276 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4277 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004278 // ---------------------------------------------------------------------
4279 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004280 // Application launch intent categories (see addCategory()).
4281
4282 /**
4283 * Used with {@link #ACTION_MAIN} to launch the browser application.
4284 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004285 * <p>NOTE: This should not be used as the primary key of an Intent,
4286 * since it will not result in the app launching with the correct
4287 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004288 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004289 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004290 */
4291 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4292 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4293
4294 /**
4295 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4296 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004297 * <p>NOTE: This should not be used as the primary key of an Intent,
4298 * since it will not result in the app launching with the correct
4299 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004300 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004301 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004302 */
4303 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4304 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4305
4306 /**
4307 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4308 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004309 * <p>NOTE: This should not be used as the primary key of an Intent,
4310 * since it will not result in the app launching with the correct
4311 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004312 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004313 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004314 */
4315 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4316 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4317
4318 /**
4319 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4320 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004321 * <p>NOTE: This should not be used as the primary key of an Intent,
4322 * since it will not result in the app launching with the correct
4323 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004324 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004325 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004326 */
4327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4328 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4329
4330 /**
4331 * Used with {@link #ACTION_MAIN} to launch the email application.
4332 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004333 * <p>NOTE: This should not be used as the primary key of an Intent,
4334 * since it will not result in the app launching with the correct
4335 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004336 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004337 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004338 */
4339 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4340 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4341
4342 /**
4343 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4344 * The activity should be able to view and manipulate image and video files
4345 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004346 * <p>NOTE: This should not be used as the primary key of an Intent,
4347 * since it will not result in the app launching with the correct
4348 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004349 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004350 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004351 */
4352 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4353 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4354
4355 /**
4356 * Used with {@link #ACTION_MAIN} to launch the maps application.
4357 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004358 * <p>NOTE: This should not be used as the primary key of an Intent,
4359 * since it will not result in the app launching with the correct
4360 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004361 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004362 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004363 */
4364 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4365 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4366
4367 /**
4368 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4369 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004370 * <p>NOTE: This should not be used as the primary key of an Intent,
4371 * since it will not result in the app launching with the correct
4372 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004373 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004374 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004375 */
4376 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4377 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4378
4379 /**
4380 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004381 * The activity should be able to play, browse, or manipulate music files
4382 * stored on the device.
4383 * <p>NOTE: This should not be used as the primary key of an Intent,
4384 * since it will not result in the app launching with the correct
4385 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004386 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004387 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004388 */
4389 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4390 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4391
4392 // ---------------------------------------------------------------------
4393 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004394 // Standard extra data keys.
4395
4396 /**
4397 * The initial data to place in a newly created record. Use with
4398 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4399 * fields as would be given to the underlying ContentProvider.insert()
4400 * call.
4401 */
4402 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4403
4404 /**
4405 * A constant CharSequence that is associated with the Intent, used with
4406 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4407 * this may be a styled CharSequence, so you must use
4408 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4409 * retrieve it.
4410 */
4411 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4412
4413 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004414 * A constant String that is associated with the Intent, used with
4415 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4416 * as HTML formatted text. Note that you <em>must</em> also supply
4417 * {@link #EXTRA_TEXT}.
4418 */
4419 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4420
4421 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004422 * A content: URI holding a stream of data associated with the Intent,
4423 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004424 */
4425 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4426
4427 /**
4428 * A String[] holding e-mail addresses that should be delivered to.
4429 */
4430 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4431
4432 /**
4433 * A String[] holding e-mail addresses that should be carbon copied.
4434 */
4435 public static final String EXTRA_CC = "android.intent.extra.CC";
4436
4437 /**
4438 * A String[] holding e-mail addresses that should be blind carbon copied.
4439 */
4440 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4441
4442 /**
4443 * A constant string holding the desired subject line of a message.
4444 */
4445 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4446
4447 /**
4448 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004449 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004450 */
4451 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4452
4453 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004454 * An int representing the user id to be used.
4455 *
4456 * @hide
4457 */
4458 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4459
4460 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004461 * An int representing the task id to be retrieved. This is used when a launch from recents is
4462 * intercepted by another action such as credentials confirmation to remember which task should
4463 * be resumed when complete.
4464 *
4465 * @hide
4466 */
4467 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4468
4469 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004470 * An Intent[] describing additional, alternate choices you would like shown with
4471 * {@link #ACTION_CHOOSER}.
4472 *
4473 * <p>An app may be capable of providing several different payload types to complete a
4474 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4475 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4476 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4477 * photo data or a hosted link where the photos can be viewed.</p>
4478 *
4479 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4480 * first/primary/preferred intent in the set. Additional intents specified in
4481 * this extra are ordered; by default intents that appear earlier in the array will be
4482 * preferred over intents that appear later in the array as matches for the same
4483 * target component. To alter this preference, a calling app may also supply
4484 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4485 */
4486 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4487
4488 /**
Adam Powell52c39212016-04-07 15:14:18 -07004489 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4490 * and omitted from a list of components presented to the user.
4491 *
4492 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4493 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4494 * from your own package or other apps from your organization if the idea of sending to those
4495 * targets would be redundant with other app functionality. Filtered components will not
4496 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4497 */
4498 public static final String EXTRA_EXCLUDE_COMPONENTS
4499 = "android.intent.extra.EXCLUDE_COMPONENTS";
4500
4501 /**
4502 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4503 * describing additional high-priority deep-link targets for the chooser to present to the user.
4504 *
4505 * <p>Targets provided in this way will be presented inline with all other targets provided
4506 * by services from other apps. They will be prioritized before other service targets, but
4507 * after those targets provided by sources that the user has manually pinned to the front.</p>
4508 *
4509 * @see #ACTION_CHOOSER
4510 */
4511 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4512
4513 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004514 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4515 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4516 *
4517 * <p>An app preparing an action for another app to complete may wish to allow the user to
4518 * disambiguate between several options for completing the action based on the chosen target
4519 * or otherwise refine the action before it is invoked.
4520 * </p>
4521 *
4522 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4523 * <ul>
4524 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4525 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4526 * chosen target beyond the first</li>
4527 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4528 * should fill in and send once the disambiguation is complete</li>
4529 * </ul>
4530 */
4531 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4532 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4533
4534 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004535 * An {@code ArrayList} of {@code String} annotations describing content for
4536 * {@link #ACTION_CHOOSER}.
4537 *
4538 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4539 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4540 *
4541 * <p>Annotations should describe the major components or topics of the content. It is up to
4542 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4543 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004544 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4545 * character. Performance on customized annotations can suffer, if they are rarely used for
4546 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4547 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004548 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004549 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004550 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004551 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004552 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004553 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004554 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004555 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004556 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004557 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4558 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4559 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4560 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4561 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004562 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004563 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4564 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004565 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004566 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004567 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004568 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004569 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004570 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004571 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004572 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004573 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004574 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004575 * Christmas and Thanksgiving.</li>
4576 * </ul>
4577 */
4578 public static final String EXTRA_CONTENT_ANNOTATIONS
4579 = "android.intent.extra.CONTENT_ANNOTATIONS";
4580
4581 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004582 * A {@link ResultReceiver} used to return data back to the sender.
4583 *
4584 * <p>Used to complete an app-specific
4585 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4586 *
4587 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4588 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4589 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4590 * when the user selects a target component from the chooser. It is up to the recipient
4591 * to send a result to this ResultReceiver to signal that disambiguation is complete
4592 * and that the chooser should invoke the user's choice.</p>
4593 *
4594 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4595 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4596 * to match and fill in the final Intent or ChooserTarget before starting it.
4597 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4598 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4599 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4600 *
4601 * <p>The result code passed to the ResultReceiver should be
4602 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4603 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4604 * the chooser should finish without starting a target.</p>
4605 */
4606 public static final String EXTRA_RESULT_RECEIVER
4607 = "android.intent.extra.RESULT_RECEIVER";
4608
4609 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004610 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004611 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004612 */
4613 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4614
4615 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004616 * A Parcelable[] of {@link Intent} or
4617 * {@link android.content.pm.LabeledIntent} objects as set with
4618 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4619 * a the front of the list of choices, when shown to the user with a
4620 * {@link #ACTION_CHOOSER}.
4621 */
4622 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4623
4624 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004625 * A {@link IntentSender} to start after ephemeral installation success.
Patrick Baumann159cd022018-01-11 13:25:05 -08004626 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
4627 * @removed
Todd Kennedy7440f172015-12-09 14:31:22 -08004628 * @hide
4629 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004630 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004631 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4632
4633 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004634 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004635 * @hide
4636 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004637 @SystemApi
4638 public static final String EXTRA_INSTANT_APP_SUCCESS =
4639 "android.intent.extra.INSTANT_APP_SUCCESS";
4640
4641 /**
4642 * A {@link IntentSender} to start after ephemeral installation failure.
4643 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
4644 * @removed
4645 * @hide
4646 */
4647 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004648 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4649
4650 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004651 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004652 * @hide
4653 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004654 @SystemApi
4655 public static final String EXTRA_INSTANT_APP_FAILURE =
4656 "android.intent.extra.INSTANT_APP_FAILURE";
4657
4658 /**
4659 * The host name that triggered an ephemeral resolution.
4660 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
4661 * @removed
4662 * @hide
4663 */
4664 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004665 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4666
4667 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004668 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004669 * @hide
4670 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004671 @SystemApi
4672 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4673 "android.intent.extra.INSTANT_APP_HOSTNAME";
4674
4675 /**
4676 * An opaque token to track ephemeral resolution.
4677 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
4678 * @removed
4679 * @hide
4680 */
4681 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004682 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4683
4684 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004685 * An opaque token to track instant app resolution.
4686 * @hide
4687 */
4688 @SystemApi
4689 public static final String EXTRA_INSTANT_APP_TOKEN =
4690 "android.intent.extra.INSTANT_APP_TOKEN";
4691
4692 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004693 * The action that triggered an instant application resolution.
4694 * @hide
4695 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004696 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004697 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4698
4699 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004700 * An array of {@link Bundle}s containing details about resolved instant apps..
4701 * @hide
4702 */
4703 @SystemApi
4704 public static final String EXTRA_INSTANT_APP_BUNDLES =
4705 "android.intent.extra.INSTANT_APP_BUNDLES";
4706
4707 /**
4708 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004709 * installed. This data is populated from the response to
4710 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4711 * instant application resolver.
4712 * @hide
4713 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004714 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004715 public static final String EXTRA_INSTANT_APP_EXTRAS =
4716 "android.intent.extra.INSTANT_APP_EXTRAS";
4717
4718 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004719 * A boolean value indicating that the instant app resolver was unable to state with certainty
4720 * that it did or did not have an app for the sanitized {@link Intent} defined at
4721 * {@link #EXTRA_INTENT}.
4722 * @hide
4723 */
4724 @SystemApi
4725 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4726 "android.intent.extra.UNKNOWN_INSTANT_APP";
4727
4728 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004729 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004730 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004731 * @hide
4732 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004733 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004734 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4735
4736 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004737 * The version code of the app to install components from.
4738 * @hide
4739 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004740 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004741 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4742
4743 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004744 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004745 * @hide
4746 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004747 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004748 public static final String EXTRA_CALLING_PACKAGE
4749 = "android.intent.extra.CALLING_PACKAGE";
4750
4751 /**
4752 * Optional calling app provided bundle containing additional launch information the
4753 * installer may use.
4754 * @hide
4755 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004756 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004757 public static final String EXTRA_VERIFICATION_BUNDLE
4758 = "android.intent.extra.VERIFICATION_BUNDLE";
4759
4760 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004761 * A Bundle forming a mapping of potential target package names to different extras Bundles
4762 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4763 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4764 * be currently installed on the device.
4765 *
4766 * <p>An application may choose to provide alternate extras for the case where a user
4767 * selects an activity from a predetermined set of target packages. If the activity
4768 * the user selects from the chooser belongs to a package with its package name as
4769 * a key in this bundle, the corresponding extras for that package will be merged with
4770 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4771 * extra has the same key as an extra already present in the intent it will overwrite
4772 * the extra from the intent.</p>
4773 *
4774 * <p><em>Examples:</em>
4775 * <ul>
4776 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4777 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4778 * parameters for that target.</li>
4779 * <li>An application may offer additional metadata for known targets of a given intent
4780 * to pass along information only relevant to that target such as account or content
4781 * identifiers already known to that application.</li>
4782 * </ul></p>
4783 */
4784 public static final String EXTRA_REPLACEMENT_EXTRAS =
4785 "android.intent.extra.REPLACEMENT_EXTRAS";
4786
4787 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004788 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4789 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4790 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4791 * {@link ComponentName} of the chosen component.
4792 *
4793 * <p>In some situations this callback may never come, for example if the user abandons
4794 * the chooser, switches to another task or any number of other reasons. Apps should not
4795 * be written assuming that this callback will always occur.</p>
4796 */
4797 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4798 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4799
4800 /**
4801 * The {@link ComponentName} chosen by the user to complete an action.
4802 *
4803 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4804 */
4805 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4806
4807 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004808 * A {@link android.view.KeyEvent} object containing the event that
4809 * triggered the creation of the Intent it is in.
4810 */
4811 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4812
4813 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004814 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4815 * before shutting down.
4816 *
4817 * {@hide}
4818 */
4819 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4820
4821 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004822 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4823 * requested by the user.
4824 *
4825 * {@hide}
4826 */
4827 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4828 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4829
4830 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004831 * 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 -07004832 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4833 * of restarting the application.
4834 */
4835 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4836
4837 /**
4838 * A String holding the phone number originally entered in
4839 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4840 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4841 */
4842 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004843
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004844 /**
4845 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4846 * intents to supply the uid the package had been assigned. Also an optional
4847 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4848 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4849 * purpose.
4850 */
4851 public static final String EXTRA_UID = "android.intent.extra.UID";
4852
4853 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004854 * @hide String array of package names.
4855 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004856 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004857 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4858
4859 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004860 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4861 * intents to indicate whether this represents a full uninstall (removing
4862 * both the code and its data) or a partial uninstall (leaving its data,
4863 * implying that this is an update).
4864 */
4865 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004866
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004867 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004868 * @hide
4869 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4870 * intents to indicate that at this point the package has been removed for
4871 * all users on the device.
4872 */
4873 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4874 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4875
4876 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004877 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4878 * intents to indicate that this is a replacement of the package, so this
4879 * broadcast will immediately be followed by an add broadcast for a
4880 * different version of the same package.
4881 */
4882 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004883
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004884 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004885 * Used as an int extra field in {@link android.app.AlarmManager} intents
4886 * to tell the application being invoked how many pending alarms are being
4887 * delievered with the intent. For one-shot alarms this will always be 1.
4888 * For recurring alarms, this might be greater than 1 if the device was
4889 * asleep or powered off at the time an earlier alarm would have been
4890 * delivered.
4891 */
4892 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004893
Jacek Surazski86b6c532009-05-13 14:38:28 +02004894 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004895 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4896 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004897 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4898 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004899 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4900 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4901 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004902 */
4903 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4904
4905 /**
4906 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4907 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004908 */
4909 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4910
4911 /**
4912 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4913 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004914 */
4915 public static final int EXTRA_DOCK_STATE_DESK = 1;
4916
4917 /**
4918 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4919 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004920 */
4921 public static final int EXTRA_DOCK_STATE_CAR = 2;
4922
4923 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004924 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4925 * to represent that the phone is in a analog (low end) dock.
4926 */
4927 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4928
4929 /**
4930 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4931 * to represent that the phone is in a digital (high end) dock.
4932 */
4933 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4934
4935 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004936 * Boolean that can be supplied as meta-data with a dock activity, to
4937 * indicate that the dock should take over the home key when it is active.
4938 */
4939 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004940
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004941 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004942 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4943 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004944 */
4945 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4946
4947 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004948 * Used in the extra field in the remote intent. It's astring token passed with the
4949 * remote intent.
4950 */
4951 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4952 "android.intent.extra.remote_intent_token";
4953
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004954 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004955 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004956 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004957 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004958 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004959 "android.intent.extra.changed_component_name";
4960
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004961 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004962 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004963 * and contains a string array of all of the components that have changed. If
4964 * the state of the overall package has changed, then it will contain an entry
4965 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004966 */
4967 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4968 "android.intent.extra.changed_component_name_list";
4969
4970 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004971 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004972 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004973 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4974 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4975 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004976 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004977 */
4978 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4979 "android.intent.extra.changed_package_list";
4980
4981 /**
4982 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004983 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4984 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004985 * and contains an integer array of uids of all of the components
4986 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004987 */
4988 public static final String EXTRA_CHANGED_UID_LIST =
4989 "android.intent.extra.changed_uid_list";
4990
4991 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004992 * @hide
4993 * Magic extra system code can use when binding, to give a label for
4994 * who it is that has bound to a service. This is an integer giving
4995 * a framework string resource that can be displayed to the user.
4996 */
4997 public static final String EXTRA_CLIENT_LABEL =
4998 "android.intent.extra.client_label";
4999
5000 /**
5001 * @hide
5002 * Magic extra system code can use when binding, to give a PendingIntent object
5003 * that can be launched for the user to disable the system's use of this
5004 * service.
5005 */
5006 public static final String EXTRA_CLIENT_INTENT =
5007 "android.intent.extra.client_intent";
5008
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005009 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005010 * Extra used to indicate that an intent should only return data that is on
5011 * the local device. This is a boolean extra; the default is false. If true,
5012 * an implementation should only allow the user to select data that is
5013 * already on the device, not requiring it be downloaded from a remote
5014 * service when opened.
5015 *
5016 * @see #ACTION_GET_CONTENT
5017 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005018 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005019 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005020 */
5021 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005022 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005023
Amith Yamasani13593602012-03-22 16:16:17 -07005024 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005025 * Extra used to indicate that an intent can allow the user to select and
5026 * return multiple items. This is a boolean extra; the default is false. If
5027 * true, an implementation is allowed to present the user with a UI where
5028 * they can pick multiple items that are all returned to the caller. When
5029 * this happens, they should be returned as the {@link #getClipData()} part
5030 * of the result Intent.
5031 *
5032 * @see #ACTION_GET_CONTENT
5033 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005034 */
5035 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005036 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005037
5038 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005039 * The integer userHandle carried with broadcast intents related to addition, removal and
5040 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5041 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5042 *
Amith Yamasani13593602012-03-22 16:16:17 -07005043 * @hide
5044 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005045 public static final String EXTRA_USER_HANDLE =
5046 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005047
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005048 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005049 * The UserHandle carried with broadcasts intents related to addition and removal of managed
5050 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
5051 */
5052 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005053 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005054
5055 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005056 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005057 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5058 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005059 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005060 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5061
5062 /**
5063 * Extra sent in the intent to the BroadcastReceiver that handles
5064 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5065 * the restrictions as key/value pairs.
5066 */
5067 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5068 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005069
Amith Yamasani86118ba2013-03-28 14:33:16 -07005070 /**
5071 * Extra used in the response from a BroadcastReceiver that handles
5072 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5073 */
5074 public static final String EXTRA_RESTRICTIONS_INTENT =
5075 "android.intent.extra.restrictions_intent";
5076
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005077 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005078 * Extra used to communicate a set of acceptable MIME types. The type of the
5079 * extra is {@code String[]}. Values may be a combination of concrete MIME
5080 * types (such as "image/png") and/or partial MIME types (such as
5081 * "audio/*").
5082 *
5083 * @see #ACTION_GET_CONTENT
5084 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005085 */
5086 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5087
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005088 /**
5089 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5090 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005091 * When this is true, hardware devices can use this information to determine that
5092 * they shouldn't do a complete shutdown of their device since this is not a
5093 * complete shutdown down to the kernel, but only user space restarting.
5094 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005095 */
5096 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5097 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5098
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005099 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005100 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5101 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5102 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5103 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005104 *
5105 * @hide for internal use only.
5106 */
5107 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5108 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005109 /** @hide */
5110 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5111 /** @hide */
5112 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5113 /** @hide */
5114 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005115
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005116 /**
5117 * Intent extra: the reason that the operation associated with this intent is being performed.
5118 *
5119 * <p>Type: String
5120 * @hide
5121 */
5122 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005123 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5124
qingxi240c2bb2017-04-12 17:31:18 -07005125 /**
5126 * {@hide}
5127 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5128 */
Rubin Xue8490f12015-06-25 12:17:48 +01005129 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5130
Santos Cordon15a13782015-03-31 18:32:31 -07005131 /**
qingxi240c2bb2017-04-12 17:31:18 -07005132 * {@hide}
5133 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5134 * reset for the device with eSIM. This extra will be sent together with
5135 * {@link #ACTION_FACTORY_RESET}
5136 */
5137 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5138
5139 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005140 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5141 * activation request.
5142 * TODO: Add information about the structure and response data used with the pending intent.
5143 * @hide
5144 */
5145 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5146 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5147
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005148 /**
5149 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005150 *
5151 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005152 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005153 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005154 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5155
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005156 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005157 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5158 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5159 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005160 *
5161 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005162 * @see #ACTION_QUICK_VIEW
5163 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005164 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005165 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005166 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5167 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005168
5169 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005170 * An optional extra of {@code String[]} indicating which quick view features should be made
5171 * available to the user in the quick view UI while handing a
5172 * {@link Intent#ACTION_QUICK_VIEW} intent.
5173 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5174 * Quick viewer can implement features not listed below.
5175 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005176 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5177 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5178 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005179 * <p>
5180 * Requirements:
5181 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5182 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5183 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5184 * internal policies.
5185 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5186 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5187 * disable or hide features.
5188 *
5189 * @see #ACTION_QUICK_VIEW
5190 */
5191 public static final String EXTRA_QUICK_VIEW_FEATURES =
5192 "android.intent.extra.QUICK_VIEW_FEATURES";
5193
5194 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005195 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005196 * When a profile goes into quiet mode, all apps in the profile are killed and the
5197 * profile user is stopped. Widgets originating from the profile are masked, and app
5198 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005199 */
5200 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005201
5202 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005203 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005204 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005205 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5206 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005207 *
5208 * @hide
5209 */
5210 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5211 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5212
5213 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005214 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5215 * whether to show the chooser or not when there is only one application available
5216 * to choose from.
5217 *
5218 * @hide
5219 */
5220 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5221 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5222
5223 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005224 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005225 * to represent that a video codec is allowed to use.
5226 *
5227 * @hide
5228 */
5229 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5230
5231 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005232 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005233 * to represent that a audio codec is allowed to use.
5234 *
5235 * @hide
5236 */
5237 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5238
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005239 // ---------------------------------------------------------------------
5240 // ---------------------------------------------------------------------
5241 // Intent flags (see mFlags variable).
5242
Tor Norbyed9273d62013-05-30 15:59:53 -07005243 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005244 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005245 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5246 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005247 @Retention(RetentionPolicy.SOURCE)
5248 public @interface GrantUriMode {}
5249
Jeff Sharkey846318a2014-04-04 12:12:41 -07005250 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005251 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005252 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5253 @Retention(RetentionPolicy.SOURCE)
5254 public @interface AccessUriMode {}
5255
5256 /**
5257 * Test if given mode flags specify an access mode, which must be at least
5258 * read and/or write.
5259 *
5260 * @hide
5261 */
5262 public static boolean isAccessUriMode(int modeFlags) {
5263 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5264 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5265 }
5266
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005267 /** @hide */
5268 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5269 FLAG_GRANT_READ_URI_PERMISSION,
5270 FLAG_GRANT_WRITE_URI_PERMISSION,
5271 FLAG_FROM_BACKGROUND,
5272 FLAG_DEBUG_LOG_RESOLUTION,
5273 FLAG_EXCLUDE_STOPPED_PACKAGES,
5274 FLAG_INCLUDE_STOPPED_PACKAGES,
5275 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5276 FLAG_GRANT_PREFIX_URI_PERMISSION,
5277 FLAG_DEBUG_TRIAGED_MISSING,
5278 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005279 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005280 FLAG_ACTIVITY_NO_HISTORY,
5281 FLAG_ACTIVITY_SINGLE_TOP,
5282 FLAG_ACTIVITY_NEW_TASK,
5283 FLAG_ACTIVITY_MULTIPLE_TASK,
5284 FLAG_ACTIVITY_CLEAR_TOP,
5285 FLAG_ACTIVITY_FORWARD_RESULT,
5286 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5287 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5288 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5289 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5290 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5291 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5292 FLAG_ACTIVITY_NEW_DOCUMENT,
5293 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5294 FLAG_ACTIVITY_NO_USER_ACTION,
5295 FLAG_ACTIVITY_REORDER_TO_FRONT,
5296 FLAG_ACTIVITY_NO_ANIMATION,
5297 FLAG_ACTIVITY_CLEAR_TASK,
5298 FLAG_ACTIVITY_TASK_ON_HOME,
5299 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5300 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5301 FLAG_RECEIVER_REGISTERED_ONLY,
5302 FLAG_RECEIVER_REPLACE_PENDING,
5303 FLAG_RECEIVER_FOREGROUND,
5304 FLAG_RECEIVER_NO_ABORT,
5305 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5306 FLAG_RECEIVER_BOOT_UPGRADE,
5307 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5308 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5309 FLAG_RECEIVER_FROM_SHELL,
5310 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5311 })
5312 @Retention(RetentionPolicy.SOURCE)
5313 public @interface Flags {}
5314
5315 /** @hide */
5316 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5317 FLAG_FROM_BACKGROUND,
5318 FLAG_DEBUG_LOG_RESOLUTION,
5319 FLAG_EXCLUDE_STOPPED_PACKAGES,
5320 FLAG_INCLUDE_STOPPED_PACKAGES,
5321 FLAG_DEBUG_TRIAGED_MISSING,
5322 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005323 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005324 FLAG_ACTIVITY_NO_HISTORY,
5325 FLAG_ACTIVITY_SINGLE_TOP,
5326 FLAG_ACTIVITY_NEW_TASK,
5327 FLAG_ACTIVITY_MULTIPLE_TASK,
5328 FLAG_ACTIVITY_CLEAR_TOP,
5329 FLAG_ACTIVITY_FORWARD_RESULT,
5330 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5331 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5332 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5333 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5334 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5335 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5336 FLAG_ACTIVITY_NEW_DOCUMENT,
5337 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5338 FLAG_ACTIVITY_NO_USER_ACTION,
5339 FLAG_ACTIVITY_REORDER_TO_FRONT,
5340 FLAG_ACTIVITY_NO_ANIMATION,
5341 FLAG_ACTIVITY_CLEAR_TASK,
5342 FLAG_ACTIVITY_TASK_ON_HOME,
5343 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5344 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5345 FLAG_RECEIVER_REGISTERED_ONLY,
5346 FLAG_RECEIVER_REPLACE_PENDING,
5347 FLAG_RECEIVER_FOREGROUND,
5348 FLAG_RECEIVER_NO_ABORT,
5349 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5350 FLAG_RECEIVER_BOOT_UPGRADE,
5351 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5352 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5353 FLAG_RECEIVER_FROM_SHELL,
5354 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5355 })
5356 @Retention(RetentionPolicy.SOURCE)
5357 public @interface MutableFlags {}
5358
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359 /**
5360 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005361 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005362 * specified in its ClipData. When applying to an Intent's ClipData,
5363 * all URIs as well as recursive traversals through data or other ClipData
5364 * in Intent items will be granted; only the grant flags of the top-level
5365 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005366 */
5367 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5368 /**
5369 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005370 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005371 * specified in its ClipData. When applying to an Intent's ClipData,
5372 * all URIs as well as recursive traversals through data or other ClipData
5373 * in Intent items will be granted; only the grant flags of the top-level
5374 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005375 */
5376 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5377 /**
5378 * Can be set by the caller to indicate that this Intent is coming from
5379 * a background operation, not from direct user interaction.
5380 */
5381 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5382 /**
5383 * A flag you can enable for debugging: when set, log messages will be
5384 * printed during the resolution of this intent to show you what has
5385 * been found to create the final resolved list.
5386 */
5387 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005388 /**
5389 * If set, this intent will not match any components in packages that
5390 * are currently stopped. If this is not set, then the default behavior
5391 * is to include such applications in the result.
5392 */
5393 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5394 /**
5395 * If set, this intent will always match any components in packages that
5396 * are currently stopped. This is the default behavior when
5397 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5398 * flags are set, this one wins (it allows overriding of exclude for
5399 * places where the framework may automatically set the exclude flag).
5400 */
5401 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005402
5403 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005404 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005405 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005406 * persisted across device reboots until explicitly revoked with
5407 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5408 * grant for possible persisting; the receiving application must call
5409 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5410 * actually persist.
5411 *
5412 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5413 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5414 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005415 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005416 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005417 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005418
5419 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005420 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5421 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5422 * applies to any URI that is a prefix match against the original granted
5423 * URI. (Without this flag, the URI must match exactly for access to be
5424 * granted.) Another URI is considered a prefix match only when scheme,
5425 * authority, and all path segments defined by the prefix are an exact
5426 * match.
5427 */
5428 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5429
5430 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005431 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005432 * homework and verified that they correctly handle packages and components
5433 * that come and go over time. In particular:
5434 * <ul>
5435 * <li>Apps installed on external storage, which will appear to be
5436 * uninstalled while the the device is ejected.
5437 * <li>Apps with encryption unaware components, which will appear to not
5438 * exist while the device is locked.
5439 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005440 *
5441 * @hide
5442 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005443 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005444
5445 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005446 * Internal flag used to indicate ephemeral applications should not be
5447 * considered when resolving the intent.
5448 *
5449 * @hide
5450 */
5451 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5452
5453 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005454 * If set, the new activity is not kept in the history stack. As soon as
5455 * the user navigates away from it, the activity is finished. This may also
5456 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5457 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005458 *
5459 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5460 * is never invoked when the current activity starts a new activity which
5461 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005462 */
5463 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5464 /**
5465 * If set, the activity will not be launched if it is already running
5466 * at the top of the history stack.
5467 */
5468 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5469 /**
5470 * If set, this activity will become the start of a new task on this
5471 * history stack. A task (from the activity that started it to the
5472 * next task activity) defines an atomic group of activities that the
5473 * user can move to. Tasks can be moved to the foreground and background;
5474 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005475 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005476 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5477 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005478 *
5479 * <p>This flag is generally used by activities that want
5480 * to present a "launcher" style behavior: they give the user a list of
5481 * separate things that can be done, which otherwise run completely
5482 * independently of the activity launching them.
5483 *
5484 * <p>When using this flag, if a task is already running for the activity
5485 * you are now starting, then a new activity will not be started; instead,
5486 * the current task will simply be brought to the front of the screen with
5487 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5488 * to disable this behavior.
5489 *
5490 * <p>This flag can not be used when the caller is requesting a result from
5491 * the activity being launched.
5492 */
5493 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5494 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005495 * This flag is used to create a new task and launch an activity into it.
5496 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5497 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5498 * search through existing tasks for ones matching this Intent. Only if no such
5499 * task is found would a new task be created. When paired with
5500 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5501 * the search for a matching task and unconditionally start a new task.
5502 *
5503 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5504 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005505 * top-level application launcher.</strong> Used in conjunction with
5506 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5507 * behavior of bringing an existing task to the foreground. When set,
5508 * a new task is <em>always</em> started to host the Activity for the
5509 * Intent, regardless of whether there is already an existing task running
5510 * the same thing.
5511 *
5512 * <p><strong>Because the default system does not include graphical task management,
5513 * you should not use this flag unless you provide some way for a user to
5514 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005515 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005516 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5517 * creating new document tasks.
5518 *
5519 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005520 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005521 *
Scott Main7aee61f2011-02-08 11:25:01 -08005522 * <p>See
5523 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5524 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005525 *
5526 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5527 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005528 */
5529 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5530 /**
5531 * If set, and the activity being launched is already running in the
5532 * current task, then instead of launching a new instance of that activity,
5533 * all of the other activities on top of it will be closed and this Intent
5534 * will be delivered to the (now on top) old activity as a new Intent.
5535 *
5536 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5537 * If D calls startActivity() with an Intent that resolves to the component
5538 * of activity B, then C and D will be finished and B receive the given
5539 * Intent, resulting in the stack now being: A, B.
5540 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005541 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005542 * either receive the new intent you are starting here in its
5543 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005544 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005545 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5546 * the same intent, then it will be finished and re-created; for all other
5547 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5548 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005549 *
5550 * <p>This launch mode can also be used to good effect in conjunction with
5551 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5552 * of a task, it will bring any currently running instance of that task
5553 * to the foreground, and then clear it to its root state. This is
5554 * especially useful, for example, when launching an activity from the
5555 * notification manager.
5556 *
Scott Main7aee61f2011-02-08 11:25:01 -08005557 * <p>See
5558 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5559 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005560 */
5561 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5562 /**
5563 * If set and this intent is being used to launch a new activity from an
5564 * existing one, then the reply target of the existing activity will be
5565 * transfered to the new activity. This way the new activity can call
5566 * {@link android.app.Activity#setResult} and have that result sent back to
5567 * the reply target of the original activity.
5568 */
5569 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5570 /**
5571 * If set and this intent is being used to launch a new activity from an
5572 * existing one, the current activity will not be counted as the top
5573 * activity for deciding whether the new intent should be delivered to
5574 * the top instead of starting a new one. The previous activity will
5575 * be used as the top, with the assumption being that the current activity
5576 * will finish itself immediately.
5577 */
5578 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5579 /**
5580 * If set, the new activity is not kept in the list of recently launched
5581 * activities.
5582 */
5583 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5584 /**
5585 * This flag is not normally set by application code, but set for you by
5586 * the system as described in the
5587 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5588 * launchMode} documentation for the singleTask mode.
5589 */
5590 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5591 /**
5592 * If set, and this activity is either being started in a new task or
5593 * bringing to the top an existing task, then it will be launched as
5594 * the front door of the task. This will result in the application of
5595 * any affinities needed to have that task in the proper state (either
5596 * moving activities to or from it), or simply resetting that task to
5597 * its initial state if needed.
5598 */
5599 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5600 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005601 * This flag is not normally set by application code, but set for you by
5602 * the system if this activity is being launched from history
5603 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005604 */
5605 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005606 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005607 * @deprecated As of API 21 this performs identically to
5608 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005609 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005610 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005611 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005612 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005613 * This flag is used to open a document into a new task rooted at the activity launched
5614 * by this Intent. Through the use of this flag, or its equivalent attribute,
5615 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005616 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005617 *
Craig Mautner026596b2014-05-21 15:35:44 -07005618 * <p>The use of the activity attribute form of this,
5619 * {@link android.R.attr#documentLaunchMode}, is
5620 * preferred over the Intent flag described here. The attribute form allows the
5621 * Activity to specify multiple document behavior for all launchers of the Activity
5622 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005623 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005624 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5625 * it is kept after the activity is finished is different than the use of
5626 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5627 * this flag is being used to create a new recents entry, then by default that entry
5628 * will be removed once the activity is finished. You can modify this behavior with
5629 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5630 *
Craig Mautner026596b2014-05-21 15:35:44 -07005631 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5632 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5633 * equivalent of the Activity manifest specifying {@link
5634 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5635 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5636 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005637 *
Craig Mautner026596b2014-05-21 15:35:44 -07005638 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005639 *
Craig Mautner026596b2014-05-21 15:35:44 -07005640 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005641 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5642 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005643 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005644 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005645 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005646 * callback from occurring on the current frontmost activity before it is
5647 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005648 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005649 * <p>Typically, an activity can rely on that callback to indicate that an
5650 * explicit user action has caused their activity to be moved out of the
5651 * foreground. The callback marks an appropriate point in the activity's
5652 * lifecycle for it to dismiss any notifications that it intends to display
5653 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005654 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005655 * <p>If an activity is ever started via any non-user-driven events such as
5656 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5657 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005658 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005659 */
5660 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005661 /**
5662 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5663 * this flag will cause the launched activity to be brought to the front of its
5664 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005665 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005666 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5667 * If D calls startActivity() with an Intent that resolves to the component
5668 * of activity B, then B will be brought to the front of the history stack,
5669 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005670 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005671 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005672 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005673 */
5674 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005675 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005676 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5677 * this flag will prevent the system from applying an activity transition
5678 * animation to go to the next activity state. This doesn't mean an
5679 * animation will never run -- if another activity change happens that doesn't
5680 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005681 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005682 * when you are going to do a series of activity operations but the
5683 * animation seen by the user shouldn't be driven by the first activity
5684 * change but rather a later one.
5685 */
5686 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5687 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005688 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5689 * this flag will cause any existing task that would be associated with the
5690 * activity to be cleared before the activity is started. That is, the activity
5691 * becomes the new root of an otherwise empty task, and any old activities
5692 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5693 */
5694 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5695 /**
5696 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5697 * this flag will cause a newly launching task to be placed on top of the current
5698 * home activity task (if there is one). That is, pressing back from the task
5699 * will always return the user to home even if that was not the last activity they
5700 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5701 */
5702 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5703 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005704 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5705 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005706 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005707 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005708 * this flag. When set and the task's activity is finished, the recents
5709 * entry will remain in the interface for the user to re-launch it, like a
5710 * recents entry for a top-level application.
5711 * <p>
5712 * The receiving activity can override this request with
5713 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5714 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005715 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005716 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005717 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005718
5719 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005720 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5721 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005722 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5723 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005724 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005725 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005726
Patrick Baumann577d4022018-01-31 16:55:10 +00005727
5728 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005729 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5730 * this flag will attempt to launch an instant app if no full app on the device can already
5731 * handle the intent.
5732 * <p>
5733 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5734 * are supported:
5735 * <ul>
5736 * <li>{@link Intent#setAction(String)}</li>
5737 * <li>{@link Intent#addCategory(String)}</li>
5738 * <li>{@link Intent#setData(Uri)}</li>
5739 * <li>{@link Intent#setType(String)}</li>
5740 * <li>{@link Intent#setPackage(String)}</li>
5741 * <li>{@link Intent#addFlags(int)}</li>
5742 * </ul>
5743 * <p>
5744 * In the case that no instant app can be found, the installer will be launched to notify the
5745 * user that the intent could not be resolved. On devices that do not support instant apps,
5746 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005747 */
5748 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5749
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005751 * If set, when sending a broadcast only registered receivers will be
5752 * called -- no BroadcastReceiver components will be launched.
5753 */
5754 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005755 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005756 * If set, when sending a broadcast the new broadcast will replace
5757 * any existing pending broadcast that matches it. Matching is defined
5758 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5759 * true for the intents of the two broadcasts. When a match is found,
5760 * the new broadcast (and receivers associated with it) will replace the
5761 * existing one in the pending broadcast list, remaining at the same
5762 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005763 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005764 * <p>This flag is most typically used with sticky broadcasts, which
5765 * only care about delivering the most recent values of the broadcast
5766 * to their receivers.
5767 */
5768 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5769 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005770 * If set, when sending a broadcast the recipient is allowed to run at
5771 * foreground priority, with a shorter timeout interval. During normal
5772 * broadcasts the receivers are not automatically hoisted out of the
5773 * background priority class.
5774 */
5775 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5776 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005777 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5778 * They can still propagate results through to later receivers, but they can not prevent
5779 * later receivers from seeing the broadcast.
5780 */
5781 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5782 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005783 * If set, when sending a broadcast <i>before boot has completed</i> only
5784 * registered receivers will be called -- no BroadcastReceiver components
5785 * will be launched. Sticky intent state will be recorded properly even
5786 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5787 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005788 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005789 * <p>This flag is only for use by system sevices as a convenience to
5790 * avoid having to implement a more complex mechanism around detection
5791 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005792 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005793 * @hide
5794 */
Mathew Inwood1c77a112018-08-14 14:06:26 +01005795 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005796 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005797 /**
5798 * Set when this broadcast is for a boot upgrade, a special mode that
5799 * allows the broadcast to be sent before the system is ready and launches
5800 * the app process with no providers running in it.
5801 * @hide
5802 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005803 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005804 /**
5805 * If set, the broadcast will always go to manifest receivers in background (cached
5806 * or not running) apps, regardless of whether that would be done by default. By
5807 * default they will only receive broadcasts if the broadcast has specified an
5808 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005809 *
5810 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5811 * the broadcast code there must also be changed to match.
5812 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005813 * @hide
5814 */
5815 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5816 /**
5817 * If set, the broadcast will never go to manifest receivers in background (cached
5818 * or not running) apps, regardless of whether that would be done by default. By
5819 * default they will receive broadcasts if the broadcast has specified an
5820 * explicit component or package name.
5821 * @hide
5822 */
5823 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005824 /**
5825 * If set, this broadcast is being sent from the shell.
5826 * @hide
5827 */
5828 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005829
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005830 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005831 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5832 * will not receive broadcasts.
5833 *
5834 * <em>This flag has no effect when used by an Instant App.</em>
5835 */
5836 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5837
5838 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005839 * @hide Flags that can't be changed with PendingIntent.
5840 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005841 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5842 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5843 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005844
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005845 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005846 // ---------------------------------------------------------------------
5847 // toUri() and parseUri() options.
5848
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005849 /** @hide */
5850 @IntDef(flag = true, prefix = { "URI_" }, value = {
5851 URI_ALLOW_UNSAFE,
5852 URI_ANDROID_APP_SCHEME,
5853 URI_INTENT_SCHEME,
5854 })
5855 @Retention(RetentionPolicy.SOURCE)
5856 public @interface UriFlags {}
5857
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005858 /**
5859 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5860 * always has the "intent:" scheme. This syntax can be used when you want
5861 * to later disambiguate between URIs that are intended to describe an
5862 * Intent vs. all others that should be treated as raw URIs. When used
5863 * with {@link #parseUri}, any other scheme will result in a generic
5864 * VIEW action for that raw URI.
5865 */
5866 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005867
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005868 /**
5869 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5870 * always has the "android-app:" scheme. This is a variation of
5871 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5872 * http/https URI being delivered to a specific package name. The format
5873 * is:
5874 *
5875 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005876 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005877 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005878 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5879 * you must also include a scheme; including a path also requires both a host and a scheme.
5880 * The final #Intent; fragment can be used without a scheme, host, or path.
5881 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005882 * used with intents that have a {@link #setSelector}, since the base intent
5883 * will always have an explicit package name.</p>
5884 *
5885 * <p>Some examples of how this scheme maps to Intent objects:</p>
5886 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5887 * <colgroup align="left" />
5888 * <colgroup align="left" />
5889 * <thead>
5890 * <tr><th>URI</th> <th>Intent</th></tr>
5891 * </thead>
5892 *
5893 * <tbody>
5894 * <tr><td><code>android-app://com.example.app</code></td>
5895 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5896 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5897 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5898 * </table></td>
5899 * </tr>
5900 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5901 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5902 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5903 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5904 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5905 * </table></td>
5906 * </tr>
5907 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5908 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5909 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5910 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5911 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5912 * </table></td>
5913 * </tr>
5914 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5915 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5916 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5917 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5918 * </table></td>
5919 * </tr>
5920 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5921 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5922 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5923 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5924 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5925 * </table></td>
5926 * </tr>
5927 * <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>
5928 * <td><table border="" style="margin:0" >
5929 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5930 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5931 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5932 * </table></td>
5933 * </tr>
5934 * </tbody>
5935 * </table>
5936 */
5937 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5938
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005939 /**
5940 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5941 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5942 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5943 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5944 * generated Intent can not cause unexpected data access to happen.
5945 *
5946 * <p>If you do not trust the source of the URI being parsed, you should still do further
5947 * processing to protect yourself from it. In particular, when using it to start an
5948 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5949 * that can handle it.</p>
5950 */
5951 public static final int URI_ALLOW_UNSAFE = 1<<2;
5952
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005953 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005954
5955 private String mAction;
5956 private Uri mData;
5957 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005958 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005959 private ComponentName mComponent;
5960 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005961 private ArraySet<String> mCategories;
Mathew Inwood1c77a112018-08-14 14:06:26 +01005962 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005964 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005965 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005966 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005967 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005968 /** Token to track instant app launches. Local only; do not copy cross-process. */
5969 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005970
5971 // ---------------------------------------------------------------------
5972
Makoto Onuki97f82f22017-05-31 16:20:21 -07005973 private static final int COPY_MODE_ALL = 0;
5974 private static final int COPY_MODE_FILTER = 1;
5975 private static final int COPY_MODE_HISTORY = 2;
5976
5977 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005978 @IntDef(prefix = { "COPY_MODE_" }, value = {
5979 COPY_MODE_ALL,
5980 COPY_MODE_FILTER,
5981 COPY_MODE_HISTORY
5982 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005983 @Retention(RetentionPolicy.SOURCE)
5984 public @interface CopyMode {}
5985
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005986 /**
5987 * Create an empty intent.
5988 */
5989 public Intent() {
5990 }
5991
5992 /**
5993 * Copy constructor.
5994 */
5995 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005996 this(o, COPY_MODE_ALL);
5997 }
5998
5999 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006000 this.mAction = o.mAction;
6001 this.mData = o.mData;
6002 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006003 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006004 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006005
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006006 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006007 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006009
6010 if (copyMode != COPY_MODE_FILTER) {
6011 this.mFlags = o.mFlags;
6012 this.mContentUserHint = o.mContentUserHint;
6013 this.mLaunchToken = o.mLaunchToken;
6014 if (o.mSourceBounds != null) {
6015 this.mSourceBounds = new Rect(o.mSourceBounds);
6016 }
6017 if (o.mSelector != null) {
6018 this.mSelector = new Intent(o.mSelector);
6019 }
6020
6021 if (copyMode != COPY_MODE_HISTORY) {
6022 if (o.mExtras != null) {
6023 this.mExtras = new Bundle(o.mExtras);
6024 }
6025 if (o.mClipData != null) {
6026 this.mClipData = new ClipData(o.mClipData);
6027 }
6028 } else {
6029 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6030 this.mExtras = Bundle.STRIPPED;
6031 }
6032
6033 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6034 // history.
6035 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006036 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006037 }
6038
6039 @Override
6040 public Object clone() {
6041 return new Intent(this);
6042 }
6043
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006044 /**
6045 * Make a clone of only the parts of the Intent that are relevant for
6046 * filter matching: the action, data, type, component, and categories.
6047 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006048 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006049 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006050 }
6051
6052 /**
6053 * Create an intent with a given action. All other fields (data, type,
6054 * class) are null. Note that the action <em>must</em> be in a
6055 * namespace because Intents are used globally in the system -- for
6056 * example the system VIEW action is android.intent.action.VIEW; an
6057 * application's custom action would be something like
6058 * com.google.app.myapp.CUSTOM_ACTION.
6059 *
6060 * @param action The Intent action, such as ACTION_VIEW.
6061 */
6062 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006063 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006064 }
6065
6066 /**
6067 * Create an intent with a given action and for a given data url. Note
6068 * that the action <em>must</em> be in a namespace because Intents are
6069 * used globally in the system -- for example the system VIEW action is
6070 * android.intent.action.VIEW; an application's custom action would be
6071 * something like com.google.app.myapp.CUSTOM_ACTION.
6072 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006073 * <p><em>Note: scheme and host name matching in the Android framework is
6074 * case-sensitive, unlike the formal RFC. As a result,
6075 * you should always ensure that you write your Uri with these elements
6076 * using lower case letters, and normalize any Uris you receive from
6077 * outside of Android to ensure the scheme and host is lower case.</em></p>
6078 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006079 * @param action The Intent action, such as ACTION_VIEW.
6080 * @param uri The Intent data URI.
6081 */
6082 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006083 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006084 mData = uri;
6085 }
6086
6087 /**
6088 * Create an intent for a specific component. All other fields (action, data,
6089 * type, class) are null, though they can be modified later with explicit
6090 * calls. This provides a convenient way to create an intent that is
6091 * intended to execute a hard-coded class name, rather than relying on the
6092 * system to find an appropriate class for you; see {@link #setComponent}
6093 * for more information on the repercussions of this.
6094 *
6095 * @param packageContext A Context of the application package implementing
6096 * this class.
6097 * @param cls The component class that is to be used for the intent.
6098 *
6099 * @see #setClass
6100 * @see #setComponent
6101 * @see #Intent(String, android.net.Uri , Context, Class)
6102 */
6103 public Intent(Context packageContext, Class<?> cls) {
6104 mComponent = new ComponentName(packageContext, cls);
6105 }
6106
6107 /**
6108 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006109 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006110 * construct the Intent and then calling {@link #setClass} to set its
6111 * class.
6112 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006113 * <p><em>Note: scheme and host name matching in the Android framework is
6114 * case-sensitive, unlike the formal RFC. As a result,
6115 * you should always ensure that you write your Uri with these elements
6116 * using lower case letters, and normalize any Uris you receive from
6117 * outside of Android to ensure the scheme and host is lower case.</em></p>
6118 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006119 * @param action The Intent action, such as ACTION_VIEW.
6120 * @param uri The Intent data URI.
6121 * @param packageContext A Context of the application package implementing
6122 * this class.
6123 * @param cls The component class that is to be used for the intent.
6124 *
6125 * @see #Intent(String, android.net.Uri)
6126 * @see #Intent(Context, Class)
6127 * @see #setClass
6128 * @see #setComponent
6129 */
6130 public Intent(String action, Uri uri,
6131 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006132 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006133 mData = uri;
6134 mComponent = new ComponentName(packageContext, cls);
6135 }
6136
6137 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006138 * Create an intent to launch the main (root) activity of a task. This
6139 * is the Intent that is started when the application's is launched from
6140 * Home. For anything else that wants to launch an application in the
6141 * same way, it is important that they use an Intent structured the same
6142 * way, and can use this function to ensure this is the case.
6143 *
6144 * <p>The returned Intent has the given Activity component as its explicit
6145 * component, {@link #ACTION_MAIN} as its action, and includes the
6146 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6147 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6148 * to do that through {@link #addFlags(int)} on the returned Intent.
6149 *
6150 * @param mainActivity The main activity component that this Intent will
6151 * launch.
6152 * @return Returns a newly created Intent that can be used to launch the
6153 * activity as a main application entry.
6154 *
6155 * @see #setClass
6156 * @see #setComponent
6157 */
6158 public static Intent makeMainActivity(ComponentName mainActivity) {
6159 Intent intent = new Intent(ACTION_MAIN);
6160 intent.setComponent(mainActivity);
6161 intent.addCategory(CATEGORY_LAUNCHER);
6162 return intent;
6163 }
6164
6165 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006166 * Make an Intent for the main activity of an application, without
6167 * specifying a specific activity to run but giving a selector to find
6168 * the activity. This results in a final Intent that is structured
6169 * the same as when the application is launched from
6170 * Home. For anything else that wants to launch an application in the
6171 * same way, it is important that they use an Intent structured the same
6172 * way, and can use this function to ensure this is the case.
6173 *
6174 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6175 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6176 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6177 * to do that through {@link #addFlags(int)} on the returned Intent.
6178 *
6179 * @param selectorAction The action name of the Intent's selector.
6180 * @param selectorCategory The name of a category to add to the Intent's
6181 * selector.
6182 * @return Returns a newly created Intent that can be used to launch the
6183 * activity as a main application entry.
6184 *
6185 * @see #setSelector(Intent)
6186 */
6187 public static Intent makeMainSelectorActivity(String selectorAction,
6188 String selectorCategory) {
6189 Intent intent = new Intent(ACTION_MAIN);
6190 intent.addCategory(CATEGORY_LAUNCHER);
6191 Intent selector = new Intent();
6192 selector.setAction(selectorAction);
6193 selector.addCategory(selectorCategory);
6194 intent.setSelector(selector);
6195 return intent;
6196 }
6197
6198 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006199 * Make an Intent that can be used to re-launch an application's task
6200 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6201 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6202 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6203 *
6204 * @param mainActivity The activity component that is the root of the
6205 * task; this is the activity that has been published in the application's
6206 * manifest as the main launcher icon.
6207 *
6208 * @return Returns a newly created Intent that can be used to relaunch the
6209 * activity's task in its root state.
6210 */
6211 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6212 Intent intent = makeMainActivity(mainActivity);
6213 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6214 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6215 return intent;
6216 }
6217
6218 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006219 * Call {@link #parseUri} with 0 flags.
6220 * @deprecated Use {@link #parseUri} instead.
6221 */
6222 @Deprecated
6223 public static Intent getIntent(String uri) throws URISyntaxException {
6224 return parseUri(uri, 0);
6225 }
Tom Taylord4a47292009-12-21 13:59:18 -08006226
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006227 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006228 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006229 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006230 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006231 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006232 *
6233 * <p>The URI given here must not be relative -- that is, it must include
6234 * the scheme and full path.
6235 *
6236 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006237 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006238 *
6239 * @return Intent The newly created Intent object.
6240 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006241 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6242 * it bad (as parsed by the Uri class) or the Intent data within the
6243 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006244 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006245 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006246 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006247 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006248 int i = 0;
6249 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006250 final boolean androidApp = uri.startsWith("android-app:");
6251
6252 // Validate intent scheme if requested.
6253 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6254 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006255 Intent intent = new Intent(ACTION_VIEW);
6256 try {
6257 intent.setData(Uri.parse(uri));
6258 } catch (IllegalArgumentException e) {
6259 throw new URISyntaxException(uri, e.getMessage());
6260 }
6261 return intent;
6262 }
6263 }
Tom Taylord4a47292009-12-21 13:59:18 -08006264
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006265 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006266 // simple case
6267 if (i == -1) {
6268 if (!androidApp) {
6269 return new Intent(ACTION_VIEW, Uri.parse(uri));
6270 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006271
6272 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006273 } else if (!uri.startsWith("#Intent;", i)) {
6274 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006275 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006276 } else {
6277 i = -1;
6278 }
6279 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006280
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006281 // new format
6282 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006283 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006284 boolean explicitAction = false;
6285 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006286
6287 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006288 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006289 String data;
6290 if (i >= 0) {
6291 data = uri.substring(0, i);
6292 i += 8; // length of "#Intent;"
6293 } else {
6294 data = uri;
6295 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006296
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006297 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006298 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006299 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006300 if (eq < 0) eq = i-1;
6301 int semi = uri.indexOf(';', i);
6302 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006303
6304 // action
6305 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006306 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006307 if (!inSelector) {
6308 explicitAction = true;
6309 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006310 }
6311
6312 // categories
6313 else if (uri.startsWith("category=", i)) {
6314 intent.addCategory(value);
6315 }
6316
6317 // type
6318 else if (uri.startsWith("type=", i)) {
6319 intent.mType = value;
6320 }
6321
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006322 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006323 else if (uri.startsWith("launchFlags=", i)) {
6324 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006325 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6326 intent.mFlags &= ~IMMUTABLE_FLAGS;
6327 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006328 }
6329
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006330 // package
6331 else if (uri.startsWith("package=", i)) {
6332 intent.mPackage = value;
6333 }
6334
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006335 // component
6336 else if (uri.startsWith("component=", i)) {
6337 intent.mComponent = ComponentName.unflattenFromString(value);
6338 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006339
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006340 // scheme
6341 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006342 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006343 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006344 } else {
6345 scheme = value;
6346 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006347 }
6348
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006349 // source bounds
6350 else if (uri.startsWith("sourceBounds=", i)) {
6351 intent.mSourceBounds = Rect.unflattenFromString(value);
6352 }
6353
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006354 // selector
6355 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6356 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006357 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006358 }
6359
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006360 // extra
6361 else {
6362 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006363 // create Bundle if it doesn't already exist
6364 if (intent.mExtras == null) intent.mExtras = new Bundle();
6365 Bundle b = intent.mExtras;
6366 // add EXTRA
6367 if (uri.startsWith("S.", i)) b.putString(key, value);
6368 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6369 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6370 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6371 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6372 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6373 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6374 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6375 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6376 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6377 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006378
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006379 // move to the next item
6380 i = semi + 1;
6381 }
6382
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006383 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006384 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006385 if (baseIntent.mPackage == null) {
6386 baseIntent.setSelector(intent);
6387 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006388 intent = baseIntent;
6389 }
6390
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006391 if (data != null) {
6392 if (data.startsWith("intent:")) {
6393 data = data.substring(7);
6394 if (scheme != null) {
6395 data = scheme + ':' + data;
6396 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006397 } else if (data.startsWith("android-app:")) {
6398 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6399 // Correctly formed android-app, first part is package name.
6400 int end = data.indexOf('/', 14);
6401 if (end < 0) {
6402 // All we have is a package name.
6403 intent.mPackage = data.substring(14);
6404 if (!explicitAction) {
6405 intent.setAction(ACTION_MAIN);
6406 }
6407 data = "";
6408 } else {
6409 // Target the Intent at the given package name always.
6410 String authority = null;
6411 intent.mPackage = data.substring(14, end);
6412 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006413 if ((end+1) < data.length()) {
6414 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6415 // Found a scheme, remember it.
6416 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006417 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006418 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6419 // Found a authority, remember it.
6420 authority = data.substring(end+1, newEnd);
6421 end = newEnd;
6422 }
6423 } else {
6424 // All we have is a scheme.
6425 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006426 }
6427 }
6428 if (scheme == null) {
6429 // If there was no scheme, then this just targets the package.
6430 if (!explicitAction) {
6431 intent.setAction(ACTION_MAIN);
6432 }
6433 data = "";
6434 } else if (authority == null) {
6435 data = scheme + ":";
6436 } else {
6437 data = scheme + "://" + authority + data.substring(end);
6438 }
6439 }
6440 } else {
6441 data = "";
6442 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006443 }
Tom Taylord4a47292009-12-21 13:59:18 -08006444
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006445 if (data.length() > 0) {
6446 try {
6447 intent.mData = Uri.parse(data);
6448 } catch (IllegalArgumentException e) {
6449 throw new URISyntaxException(uri, e.getMessage());
6450 }
6451 }
6452 }
Tom Taylord4a47292009-12-21 13:59:18 -08006453
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006454 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006455
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006456 } catch (IndexOutOfBoundsException e) {
6457 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6458 }
6459 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006460
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006461 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006462 return getIntentOld(uri, 0);
6463 }
6464
6465 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006466 Intent intent;
6467
6468 int i = uri.lastIndexOf('#');
6469 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006470 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006471 final int intentFragmentStart = i;
6472 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006473
6474 i++;
6475
6476 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006477 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006478 i += 7;
6479 int j = uri.indexOf(')', i);
6480 action = uri.substring(i, j);
6481 i = j + 1;
6482 }
6483
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006484 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006485
6486 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006487 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006488 i += 11;
6489 int j = uri.indexOf(')', i);
6490 while (i < j) {
6491 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006492 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006493 if (i < sep) {
6494 intent.addCategory(uri.substring(i, sep));
6495 }
6496 i = sep + 1;
6497 }
6498 i = j + 1;
6499 }
6500
6501 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006502 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006503 i += 5;
6504 int j = uri.indexOf(')', i);
6505 intent.mType = uri.substring(i, j);
6506 i = j + 1;
6507 }
6508
6509 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006510 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006511 i += 12;
6512 int j = uri.indexOf(')', i);
6513 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006514 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6515 intent.mFlags &= ~IMMUTABLE_FLAGS;
6516 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006517 i = j + 1;
6518 }
6519
6520 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006521 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006522 i += 10;
6523 int j = uri.indexOf(')', i);
6524 int sep = uri.indexOf('!', i);
6525 if (sep >= 0 && sep < j) {
6526 String pkg = uri.substring(i, sep);
6527 String cls = uri.substring(sep + 1, j);
6528 intent.mComponent = new ComponentName(pkg, cls);
6529 }
6530 i = j + 1;
6531 }
6532
6533 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006534 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006535 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006536
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006537 final int closeParen = uri.indexOf(')', i);
6538 if (closeParen == -1) throw new URISyntaxException(uri,
6539 "EXTRA missing trailing ')'", i);
6540
6541 while (i < closeParen) {
6542 // fetch the key value
6543 int j = uri.indexOf('=', i);
6544 if (j <= i + 1 || i >= closeParen) {
6545 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6546 }
6547 char type = uri.charAt(i);
6548 i++;
6549 String key = uri.substring(i, j);
6550 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006551
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006552 // get type-value
6553 j = uri.indexOf('!', i);
6554 if (j == -1 || j >= closeParen) j = closeParen;
6555 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6556 String value = uri.substring(i, j);
6557 i = j;
6558
6559 // create Bundle if it doesn't already exist
6560 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006561
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006562 // add item to bundle
6563 try {
6564 switch (type) {
6565 case 'S':
6566 intent.mExtras.putString(key, Uri.decode(value));
6567 break;
6568 case 'B':
6569 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6570 break;
6571 case 'b':
6572 intent.mExtras.putByte(key, Byte.parseByte(value));
6573 break;
6574 case 'c':
6575 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6576 break;
6577 case 'd':
6578 intent.mExtras.putDouble(key, Double.parseDouble(value));
6579 break;
6580 case 'f':
6581 intent.mExtras.putFloat(key, Float.parseFloat(value));
6582 break;
6583 case 'i':
6584 intent.mExtras.putInt(key, Integer.parseInt(value));
6585 break;
6586 case 'l':
6587 intent.mExtras.putLong(key, Long.parseLong(value));
6588 break;
6589 case 's':
6590 intent.mExtras.putShort(key, Short.parseShort(value));
6591 break;
6592 default:
6593 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6594 }
6595 } catch (NumberFormatException e) {
6596 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6597 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006598
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006599 char ch = uri.charAt(i);
6600 if (ch == ')') break;
6601 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6602 i++;
6603 }
6604 }
6605
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006606 if (isIntentFragment) {
6607 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6608 } else {
6609 intent.mData = Uri.parse(uri);
6610 }
Tom Taylord4a47292009-12-21 13:59:18 -08006611
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006612 if (intent.mAction == null) {
6613 // By default, if no action is specified, then use VIEW.
6614 intent.mAction = ACTION_VIEW;
6615 }
6616
6617 } else {
6618 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6619 }
6620
6621 return intent;
6622 }
6623
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006624 /** @hide */
6625 public interface CommandOptionHandler {
6626 boolean handleOption(String opt, ShellCommand cmd);
6627 }
6628
6629 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +01006630 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006631 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6632 throws URISyntaxException {
6633 Intent intent = new Intent();
6634 Intent baseIntent = intent;
6635 boolean hasIntentInfo = false;
6636
6637 Uri data = null;
6638 String type = null;
6639
6640 String opt;
6641 while ((opt=cmd.getNextOption()) != null) {
6642 switch (opt) {
6643 case "-a":
6644 intent.setAction(cmd.getNextArgRequired());
6645 if (intent == baseIntent) {
6646 hasIntentInfo = true;
6647 }
6648 break;
6649 case "-d":
6650 data = Uri.parse(cmd.getNextArgRequired());
6651 if (intent == baseIntent) {
6652 hasIntentInfo = true;
6653 }
6654 break;
6655 case "-t":
6656 type = cmd.getNextArgRequired();
6657 if (intent == baseIntent) {
6658 hasIntentInfo = true;
6659 }
6660 break;
6661 case "-c":
6662 intent.addCategory(cmd.getNextArgRequired());
6663 if (intent == baseIntent) {
6664 hasIntentInfo = true;
6665 }
6666 break;
6667 case "-e":
6668 case "--es": {
6669 String key = cmd.getNextArgRequired();
6670 String value = cmd.getNextArgRequired();
6671 intent.putExtra(key, value);
6672 }
6673 break;
6674 case "--esn": {
6675 String key = cmd.getNextArgRequired();
6676 intent.putExtra(key, (String) null);
6677 }
6678 break;
6679 case "--ei": {
6680 String key = cmd.getNextArgRequired();
6681 String value = cmd.getNextArgRequired();
6682 intent.putExtra(key, Integer.decode(value));
6683 }
6684 break;
6685 case "--eu": {
6686 String key = cmd.getNextArgRequired();
6687 String value = cmd.getNextArgRequired();
6688 intent.putExtra(key, Uri.parse(value));
6689 }
6690 break;
6691 case "--ecn": {
6692 String key = cmd.getNextArgRequired();
6693 String value = cmd.getNextArgRequired();
6694 ComponentName cn = ComponentName.unflattenFromString(value);
6695 if (cn == null)
6696 throw new IllegalArgumentException("Bad component name: " + value);
6697 intent.putExtra(key, cn);
6698 }
6699 break;
6700 case "--eia": {
6701 String key = cmd.getNextArgRequired();
6702 String value = cmd.getNextArgRequired();
6703 String[] strings = value.split(",");
6704 int[] list = new int[strings.length];
6705 for (int i = 0; i < strings.length; i++) {
6706 list[i] = Integer.decode(strings[i]);
6707 }
6708 intent.putExtra(key, list);
6709 }
6710 break;
6711 case "--eial": {
6712 String key = cmd.getNextArgRequired();
6713 String value = cmd.getNextArgRequired();
6714 String[] strings = value.split(",");
6715 ArrayList<Integer> list = new ArrayList<>(strings.length);
6716 for (int i = 0; i < strings.length; i++) {
6717 list.add(Integer.decode(strings[i]));
6718 }
6719 intent.putExtra(key, list);
6720 }
6721 break;
6722 case "--el": {
6723 String key = cmd.getNextArgRequired();
6724 String value = cmd.getNextArgRequired();
6725 intent.putExtra(key, Long.valueOf(value));
6726 }
6727 break;
6728 case "--ela": {
6729 String key = cmd.getNextArgRequired();
6730 String value = cmd.getNextArgRequired();
6731 String[] strings = value.split(",");
6732 long[] list = new long[strings.length];
6733 for (int i = 0; i < strings.length; i++) {
6734 list[i] = Long.valueOf(strings[i]);
6735 }
6736 intent.putExtra(key, list);
6737 hasIntentInfo = true;
6738 }
6739 break;
6740 case "--elal": {
6741 String key = cmd.getNextArgRequired();
6742 String value = cmd.getNextArgRequired();
6743 String[] strings = value.split(",");
6744 ArrayList<Long> list = new ArrayList<>(strings.length);
6745 for (int i = 0; i < strings.length; i++) {
6746 list.add(Long.valueOf(strings[i]));
6747 }
6748 intent.putExtra(key, list);
6749 hasIntentInfo = true;
6750 }
6751 break;
6752 case "--ef": {
6753 String key = cmd.getNextArgRequired();
6754 String value = cmd.getNextArgRequired();
6755 intent.putExtra(key, Float.valueOf(value));
6756 hasIntentInfo = true;
6757 }
6758 break;
6759 case "--efa": {
6760 String key = cmd.getNextArgRequired();
6761 String value = cmd.getNextArgRequired();
6762 String[] strings = value.split(",");
6763 float[] list = new float[strings.length];
6764 for (int i = 0; i < strings.length; i++) {
6765 list[i] = Float.valueOf(strings[i]);
6766 }
6767 intent.putExtra(key, list);
6768 hasIntentInfo = true;
6769 }
6770 break;
6771 case "--efal": {
6772 String key = cmd.getNextArgRequired();
6773 String value = cmd.getNextArgRequired();
6774 String[] strings = value.split(",");
6775 ArrayList<Float> list = new ArrayList<>(strings.length);
6776 for (int i = 0; i < strings.length; i++) {
6777 list.add(Float.valueOf(strings[i]));
6778 }
6779 intent.putExtra(key, list);
6780 hasIntentInfo = true;
6781 }
6782 break;
6783 case "--esa": {
6784 String key = cmd.getNextArgRequired();
6785 String value = cmd.getNextArgRequired();
6786 // Split on commas unless they are preceeded by an escape.
6787 // The escape character must be escaped for the string and
6788 // again for the regex, thus four escape characters become one.
6789 String[] strings = value.split("(?<!\\\\),");
6790 intent.putExtra(key, strings);
6791 hasIntentInfo = true;
6792 }
6793 break;
6794 case "--esal": {
6795 String key = cmd.getNextArgRequired();
6796 String value = cmd.getNextArgRequired();
6797 // Split on commas unless they are preceeded by an escape.
6798 // The escape character must be escaped for the string and
6799 // again for the regex, thus four escape characters become one.
6800 String[] strings = value.split("(?<!\\\\),");
6801 ArrayList<String> list = new ArrayList<>(strings.length);
6802 for (int i = 0; i < strings.length; i++) {
6803 list.add(strings[i]);
6804 }
6805 intent.putExtra(key, list);
6806 hasIntentInfo = true;
6807 }
6808 break;
6809 case "--ez": {
6810 String key = cmd.getNextArgRequired();
6811 String value = cmd.getNextArgRequired().toLowerCase();
6812 // Boolean.valueOf() results in false for anything that is not "true", which is
6813 // error-prone in shell commands
6814 boolean arg;
6815 if ("true".equals(value) || "t".equals(value)) {
6816 arg = true;
6817 } else if ("false".equals(value) || "f".equals(value)) {
6818 arg = false;
6819 } else {
6820 try {
6821 arg = Integer.decode(value) != 0;
6822 } catch (NumberFormatException ex) {
6823 throw new IllegalArgumentException("Invalid boolean value: " + value);
6824 }
6825 }
6826
6827 intent.putExtra(key, arg);
6828 }
6829 break;
6830 case "-n": {
6831 String str = cmd.getNextArgRequired();
6832 ComponentName cn = ComponentName.unflattenFromString(str);
6833 if (cn == null)
6834 throw new IllegalArgumentException("Bad component name: " + str);
6835 intent.setComponent(cn);
6836 if (intent == baseIntent) {
6837 hasIntentInfo = true;
6838 }
6839 }
6840 break;
6841 case "-p": {
6842 String str = cmd.getNextArgRequired();
6843 intent.setPackage(str);
6844 if (intent == baseIntent) {
6845 hasIntentInfo = true;
6846 }
6847 }
6848 break;
6849 case "-f":
6850 String str = cmd.getNextArgRequired();
6851 intent.setFlags(Integer.decode(str).intValue());
6852 break;
6853 case "--grant-read-uri-permission":
6854 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6855 break;
6856 case "--grant-write-uri-permission":
6857 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6858 break;
6859 case "--grant-persistable-uri-permission":
6860 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6861 break;
6862 case "--grant-prefix-uri-permission":
6863 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6864 break;
6865 case "--exclude-stopped-packages":
6866 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6867 break;
6868 case "--include-stopped-packages":
6869 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6870 break;
6871 case "--debug-log-resolution":
6872 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6873 break;
6874 case "--activity-brought-to-front":
6875 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6876 break;
6877 case "--activity-clear-top":
6878 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6879 break;
6880 case "--activity-clear-when-task-reset":
6881 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6882 break;
6883 case "--activity-exclude-from-recents":
6884 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6885 break;
6886 case "--activity-launched-from-history":
6887 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6888 break;
6889 case "--activity-multiple-task":
6890 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6891 break;
6892 case "--activity-no-animation":
6893 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6894 break;
6895 case "--activity-no-history":
6896 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6897 break;
6898 case "--activity-no-user-action":
6899 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6900 break;
6901 case "--activity-previous-is-top":
6902 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6903 break;
6904 case "--activity-reorder-to-front":
6905 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6906 break;
6907 case "--activity-reset-task-if-needed":
6908 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6909 break;
6910 case "--activity-single-top":
6911 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6912 break;
6913 case "--activity-clear-task":
6914 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6915 break;
6916 case "--activity-task-on-home":
6917 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6918 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006919 case "--activity-match-external":
6920 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6921 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006922 case "--receiver-registered-only":
6923 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6924 break;
6925 case "--receiver-replace-pending":
6926 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6927 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006928 case "--receiver-foreground":
6929 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6930 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006931 case "--receiver-no-abort":
6932 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6933 break;
6934 case "--receiver-include-background":
6935 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6936 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006937 case "--selector":
6938 intent.setDataAndType(data, type);
6939 intent = new Intent();
6940 break;
6941 default:
6942 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6943 // Okay, caller handled this option.
6944 } else {
6945 throw new IllegalArgumentException("Unknown option: " + opt);
6946 }
6947 break;
6948 }
6949 }
6950 intent.setDataAndType(data, type);
6951
6952 final boolean hasSelector = intent != baseIntent;
6953 if (hasSelector) {
6954 // A selector was specified; fix up.
6955 baseIntent.setSelector(intent);
6956 intent = baseIntent;
6957 }
6958
6959 String arg = cmd.getNextArg();
6960 baseIntent = null;
6961 if (arg == null) {
6962 if (hasSelector) {
6963 // If a selector has been specified, and no arguments
6964 // have been supplied for the main Intent, then we can
6965 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6966 // need to have a component name specified yet, the
6967 // selector will take care of that.
6968 baseIntent = new Intent(Intent.ACTION_MAIN);
6969 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6970 }
6971 } else if (arg.indexOf(':') >= 0) {
6972 // The argument is a URI. Fully parse it, and use that result
6973 // to fill in any data not specified so far.
6974 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6975 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6976 } else if (arg.indexOf('/') >= 0) {
6977 // The argument is a component name. Build an Intent to launch
6978 // it.
6979 baseIntent = new Intent(Intent.ACTION_MAIN);
6980 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6981 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6982 } else {
6983 // Assume the argument is a package name.
6984 baseIntent = new Intent(Intent.ACTION_MAIN);
6985 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6986 baseIntent.setPackage(arg);
6987 }
6988 if (baseIntent != null) {
6989 Bundle extras = intent.getExtras();
6990 intent.replaceExtras((Bundle)null);
6991 Bundle uriExtras = baseIntent.getExtras();
6992 baseIntent.replaceExtras((Bundle)null);
6993 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6994 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6995 for (String c : cats) {
6996 baseIntent.removeCategory(c);
6997 }
6998 }
6999 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7000 if (extras == null) {
7001 extras = uriExtras;
7002 } else if (uriExtras != null) {
7003 uriExtras.putAll(extras);
7004 extras = uriExtras;
7005 }
7006 intent.replaceExtras(extras);
7007 hasIntentInfo = true;
7008 }
7009
7010 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7011 return intent;
7012 }
7013
7014 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +01007015 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007016 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7017 final String[] lines = new String[] {
7018 "<INTENT> specifications include these flags and arguments:",
7019 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7020 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007021 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007022 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7023 " [--esn <EXTRA_KEY> ...]",
7024 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7025 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7026 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7027 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7028 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7029 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7030 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7031 " (mutiple extras passed as Integer[])",
7032 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7033 " (mutiple extras passed as List<Integer>)",
7034 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7035 " (mutiple extras passed as Long[])",
7036 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7037 " (mutiple extras passed as List<Long>)",
7038 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7039 " (mutiple extras passed as Float[])",
7040 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7041 " (mutiple extras passed as List<Float>)",
7042 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7043 " (mutiple extras passed as String[]; to embed a comma into a string,",
7044 " escape it using \"\\,\")",
7045 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7046 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7047 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007048 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007049 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7050 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7051 " [--debug-log-resolution] [--exclude-stopped-packages]",
7052 " [--include-stopped-packages]",
7053 " [--activity-brought-to-front] [--activity-clear-top]",
7054 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7055 " [--activity-launched-from-history] [--activity-multiple-task]",
7056 " [--activity-no-animation] [--activity-no-history]",
7057 " [--activity-no-user-action] [--activity-previous-is-top]",
7058 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7059 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007060 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007061 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007062 " [--receiver-foreground] [--receiver-no-abort]",
7063 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007064 " [--selector]",
7065 " [<URI> | <PACKAGE> | <COMPONENT>]"
7066 };
7067 for (String line : lines) {
7068 pw.print(prefix);
7069 pw.println(line);
7070 }
7071 }
7072
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007073 /**
7074 * Retrieve the general action to be performed, such as
7075 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7076 * the information in the intent should be interpreted -- most importantly,
7077 * what to do with the data returned by {@link #getData}.
7078 *
7079 * @return The action of this intent or null if none is specified.
7080 *
7081 * @see #setAction
7082 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007083 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007084 return mAction;
7085 }
7086
7087 /**
7088 * Retrieve data this intent is operating on. This URI specifies the name
7089 * of the data; often it uses the content: scheme, specifying data in a
7090 * content provider. Other schemes may be handled by specific activities,
7091 * such as http: by the web browser.
7092 *
7093 * @return The URI of the data this intent is targeting or null.
7094 *
7095 * @see #getScheme
7096 * @see #setData
7097 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007098 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007099 return mData;
7100 }
7101
7102 /**
7103 * The same as {@link #getData()}, but returns the URI as an encoded
7104 * String.
7105 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007106 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007107 return mData != null ? mData.toString() : null;
7108 }
7109
7110 /**
7111 * Return the scheme portion of the intent's data. If the data is null or
7112 * does not include a scheme, null is returned. Otherwise, the scheme
7113 * prefix without the final ':' is returned, i.e. "http".
7114 *
7115 * <p>This is the same as calling getData().getScheme() (and checking for
7116 * null data).
7117 *
7118 * @return The scheme of this intent.
7119 *
7120 * @see #getData
7121 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007122 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007123 return mData != null ? mData.getScheme() : null;
7124 }
7125
7126 /**
7127 * Retrieve any explicit MIME type included in the intent. This is usually
7128 * null, as the type is determined by the intent data.
7129 *
7130 * @return If a type was manually set, it is returned; else null is
7131 * returned.
7132 *
7133 * @see #resolveType(ContentResolver)
7134 * @see #setType
7135 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007136 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007137 return mType;
7138 }
7139
7140 /**
7141 * Return the MIME data type of this intent. If the type field is
7142 * explicitly set, that is simply returned. Otherwise, if the data is set,
7143 * the type of that data is returned. If neither fields are set, a null is
7144 * returned.
7145 *
7146 * @return The MIME type of this intent.
7147 *
7148 * @see #getType
7149 * @see #resolveType(ContentResolver)
7150 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007151 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007152 return resolveType(context.getContentResolver());
7153 }
7154
7155 /**
7156 * Return the MIME data type of this intent. If the type field is
7157 * explicitly set, that is simply returned. Otherwise, if the data is set,
7158 * the type of that data is returned. If neither fields are set, a null is
7159 * returned.
7160 *
7161 * @param resolver A ContentResolver that can be used to determine the MIME
7162 * type of the intent's data.
7163 *
7164 * @return The MIME type of this intent.
7165 *
7166 * @see #getType
7167 * @see #resolveType(Context)
7168 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007169 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007170 if (mType != null) {
7171 return mType;
7172 }
7173 if (mData != null) {
7174 if ("content".equals(mData.getScheme())) {
7175 return resolver.getType(mData);
7176 }
7177 }
7178 return null;
7179 }
7180
7181 /**
7182 * Return the MIME data type of this intent, only if it will be needed for
7183 * intent resolution. This is not generally useful for application code;
7184 * it is used by the frameworks for communicating with back-end system
7185 * services.
7186 *
7187 * @param resolver A ContentResolver that can be used to determine the MIME
7188 * type of the intent's data.
7189 *
7190 * @return The MIME type of this intent, or null if it is unknown or not
7191 * needed.
7192 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007193 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007194 if (mComponent != null) {
7195 return mType;
7196 }
7197 return resolveType(resolver);
7198 }
7199
7200 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007201 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007202 *
7203 * @param category The category to check.
7204 *
7205 * @return boolean True if the intent contains the category, else false.
7206 *
7207 * @see #getCategories
7208 * @see #addCategory
7209 */
7210 public boolean hasCategory(String category) {
7211 return mCategories != null && mCategories.contains(category);
7212 }
7213
7214 /**
7215 * Return the set of all categories in the intent. If there are no categories,
7216 * returns NULL.
7217 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007218 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007219 *
7220 * @see #hasCategory
7221 * @see #addCategory
7222 */
7223 public Set<String> getCategories() {
7224 return mCategories;
7225 }
7226
7227 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007228 * Return the specific selector associated with this Intent. If there is
7229 * none, returns null. See {@link #setSelector} for more information.
7230 *
7231 * @see #setSelector
7232 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007233 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007234 return mSelector;
7235 }
7236
7237 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007238 * Return the {@link ClipData} associated with this Intent. If there is
7239 * none, returns null. See {@link #setClipData} for more information.
7240 *
John Spurlock125d1332013-11-25 11:58:37 -05007241 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007242 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007243 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007244 return mClipData;
7245 }
7246
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007247 /** @hide */
7248 public int getContentUserHint() {
7249 return mContentUserHint;
7250 }
7251
Todd Kennedyb3b431302017-03-20 16:05:48 -07007252 /** @hide */
7253 public String getLaunchToken() {
7254 return mLaunchToken;
7255 }
7256
7257 /** @hide */
7258 public void setLaunchToken(String launchToken) {
7259 mLaunchToken = launchToken;
7260 }
7261
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007262 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007263 * Sets the ClassLoader that will be used when unmarshalling
7264 * any Parcelable values from the extras of this Intent.
7265 *
7266 * @param loader a ClassLoader, or null to use the default loader
7267 * at the time of unmarshalling.
7268 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007269 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007270 if (mExtras != null) {
7271 mExtras.setClassLoader(loader);
7272 }
7273 }
7274
7275 /**
7276 * Returns true if an extra value is associated with the given name.
7277 * @param name the extra's name
7278 * @return true if the given extra is present.
7279 */
7280 public boolean hasExtra(String name) {
7281 return mExtras != null && mExtras.containsKey(name);
7282 }
7283
7284 /**
7285 * Returns true if the Intent's extras contain a parcelled file descriptor.
7286 * @return true if the Intent contains a parcelled file descriptor.
7287 */
7288 public boolean hasFileDescriptors() {
7289 return mExtras != null && mExtras.hasFileDescriptors();
7290 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007291
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007292 /** {@hide} */
Mathew Inwood1c77a112018-08-14 14:06:26 +01007293 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007294 public void setAllowFds(boolean allowFds) {
7295 if (mExtras != null) {
7296 mExtras.setAllowFds(allowFds);
7297 }
7298 }
7299
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007300 /** {@hide} */
7301 public void setDefusable(boolean defusable) {
7302 if (mExtras != null) {
7303 mExtras.setDefusable(defusable);
7304 }
7305 }
7306
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007307 /**
7308 * Retrieve extended data from the intent.
7309 *
7310 * @param name The name of the desired item.
7311 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007312 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007313 * or null if none was found.
7314 *
7315 * @deprecated
7316 * @hide
7317 */
7318 @Deprecated
Mathew Inwood1c77a112018-08-14 14:06:26 +01007319 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007320 public Object getExtra(String name) {
7321 return getExtra(name, null);
7322 }
7323
7324 /**
7325 * Retrieve extended data from the intent.
7326 *
7327 * @param name The name of the desired item.
7328 * @param defaultValue the value to be returned if no value of the desired
7329 * type is stored with the given name.
7330 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007331 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007332 * or the default value if none was found.
7333 *
7334 * @see #putExtra(String, boolean)
7335 */
7336 public boolean getBooleanExtra(String name, boolean defaultValue) {
7337 return mExtras == null ? defaultValue :
7338 mExtras.getBoolean(name, defaultValue);
7339 }
7340
7341 /**
7342 * Retrieve extended data from the intent.
7343 *
7344 * @param name The name of the desired item.
7345 * @param defaultValue the value to be returned if no value of the desired
7346 * type is stored with the given name.
7347 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007348 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007349 * or the default value if none was found.
7350 *
7351 * @see #putExtra(String, byte)
7352 */
7353 public byte getByteExtra(String name, byte defaultValue) {
7354 return mExtras == null ? defaultValue :
7355 mExtras.getByte(name, defaultValue);
7356 }
7357
7358 /**
7359 * Retrieve extended data from the intent.
7360 *
7361 * @param name The name of the desired item.
7362 * @param defaultValue the value to be returned if no value of the desired
7363 * type is stored with the given name.
7364 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007365 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007366 * or the default value if none was found.
7367 *
7368 * @see #putExtra(String, short)
7369 */
7370 public short getShortExtra(String name, short defaultValue) {
7371 return mExtras == null ? defaultValue :
7372 mExtras.getShort(name, defaultValue);
7373 }
7374
7375 /**
7376 * Retrieve extended data from the intent.
7377 *
7378 * @param name The name of the desired item.
7379 * @param defaultValue the value to be returned if no value of the desired
7380 * type is stored with the given name.
7381 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007382 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007383 * or the default value if none was found.
7384 *
7385 * @see #putExtra(String, char)
7386 */
7387 public char getCharExtra(String name, char defaultValue) {
7388 return mExtras == null ? defaultValue :
7389 mExtras.getChar(name, defaultValue);
7390 }
7391
7392 /**
7393 * Retrieve extended data from the intent.
7394 *
7395 * @param name The name of the desired item.
7396 * @param defaultValue the value to be returned if no value of the desired
7397 * type is stored with the given name.
7398 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007399 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 * or the default value if none was found.
7401 *
7402 * @see #putExtra(String, int)
7403 */
7404 public int getIntExtra(String name, int defaultValue) {
7405 return mExtras == null ? defaultValue :
7406 mExtras.getInt(name, defaultValue);
7407 }
7408
7409 /**
7410 * Retrieve extended data from the intent.
7411 *
7412 * @param name The name of the desired item.
7413 * @param defaultValue the value to be returned if no value of the desired
7414 * type is stored with the given name.
7415 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007416 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007417 * or the default value if none was found.
7418 *
7419 * @see #putExtra(String, long)
7420 */
7421 public long getLongExtra(String name, long defaultValue) {
7422 return mExtras == null ? defaultValue :
7423 mExtras.getLong(name, defaultValue);
7424 }
7425
7426 /**
7427 * Retrieve extended data from the intent.
7428 *
7429 * @param name The name of the desired item.
7430 * @param defaultValue the value to be returned if no value of the desired
7431 * type is stored with the given name.
7432 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007433 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007434 * or the default value if no such item is present
7435 *
7436 * @see #putExtra(String, float)
7437 */
7438 public float getFloatExtra(String name, float defaultValue) {
7439 return mExtras == null ? defaultValue :
7440 mExtras.getFloat(name, defaultValue);
7441 }
7442
7443 /**
7444 * Retrieve extended data from the intent.
7445 *
7446 * @param name The name of the desired item.
7447 * @param defaultValue the value to be returned if no value of the desired
7448 * type is stored with the given name.
7449 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007450 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007451 * or the default value if none was found.
7452 *
7453 * @see #putExtra(String, double)
7454 */
7455 public double getDoubleExtra(String name, double defaultValue) {
7456 return mExtras == null ? defaultValue :
7457 mExtras.getDouble(name, defaultValue);
7458 }
7459
7460 /**
7461 * Retrieve extended data from the intent.
7462 *
7463 * @param name The name of the desired item.
7464 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007465 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007466 * or null if no String value was found.
7467 *
7468 * @see #putExtra(String, String)
7469 */
7470 public String getStringExtra(String name) {
7471 return mExtras == null ? null : mExtras.getString(name);
7472 }
7473
7474 /**
7475 * Retrieve extended data from the intent.
7476 *
7477 * @param name The name of the desired item.
7478 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007479 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007480 * or null if no CharSequence value was found.
7481 *
7482 * @see #putExtra(String, CharSequence)
7483 */
7484 public CharSequence getCharSequenceExtra(String name) {
7485 return mExtras == null ? null : mExtras.getCharSequence(name);
7486 }
7487
7488 /**
7489 * Retrieve extended data from the intent.
7490 *
7491 * @param name The name of the desired item.
7492 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007493 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007494 * or null if no Parcelable value was found.
7495 *
7496 * @see #putExtra(String, Parcelable)
7497 */
7498 public <T extends Parcelable> T getParcelableExtra(String name) {
7499 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7500 }
7501
7502 /**
7503 * Retrieve extended data from the intent.
7504 *
7505 * @param name The name of the desired item.
7506 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007507 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007508 * or null if no Parcelable[] value was found.
7509 *
7510 * @see #putExtra(String, Parcelable[])
7511 */
7512 public Parcelable[] getParcelableArrayExtra(String name) {
7513 return mExtras == null ? null : mExtras.getParcelableArray(name);
7514 }
7515
7516 /**
7517 * Retrieve extended data from the intent.
7518 *
7519 * @param name The name of the desired item.
7520 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007521 * @return the value of an item previously added with
7522 * putParcelableArrayListExtra(), or null if no
7523 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007524 *
7525 * @see #putParcelableArrayListExtra(String, ArrayList)
7526 */
7527 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7528 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7529 }
7530
7531 /**
7532 * Retrieve extended data from the intent.
7533 *
7534 * @param name The name of the desired item.
7535 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007536 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007537 * or null if no Serializable value was found.
7538 *
7539 * @see #putExtra(String, Serializable)
7540 */
7541 public Serializable getSerializableExtra(String name) {
7542 return mExtras == null ? null : mExtras.getSerializable(name);
7543 }
7544
7545 /**
7546 * Retrieve extended data from the intent.
7547 *
7548 * @param name The name of the desired item.
7549 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007550 * @return the value of an item previously added with
7551 * putIntegerArrayListExtra(), or null if no
7552 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007553 *
7554 * @see #putIntegerArrayListExtra(String, ArrayList)
7555 */
7556 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7557 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7558 }
7559
7560 /**
7561 * Retrieve extended data from the intent.
7562 *
7563 * @param name The name of the desired item.
7564 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007565 * @return the value of an item previously added with
7566 * putStringArrayListExtra(), or null if no
7567 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007568 *
7569 * @see #putStringArrayListExtra(String, ArrayList)
7570 */
7571 public ArrayList<String> getStringArrayListExtra(String name) {
7572 return mExtras == null ? null : mExtras.getStringArrayList(name);
7573 }
7574
7575 /**
7576 * Retrieve extended data from the intent.
7577 *
7578 * @param name The name of the desired item.
7579 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007580 * @return the value of an item previously added with
7581 * putCharSequenceArrayListExtra, or null if no
7582 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007583 *
7584 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7585 */
7586 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7587 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7588 }
7589
7590 /**
7591 * Retrieve extended data from the intent.
7592 *
7593 * @param name The name of the desired item.
7594 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007595 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007596 * or null if no boolean array value was found.
7597 *
7598 * @see #putExtra(String, boolean[])
7599 */
7600 public boolean[] getBooleanArrayExtra(String name) {
7601 return mExtras == null ? null : mExtras.getBooleanArray(name);
7602 }
7603
7604 /**
7605 * Retrieve extended data from the intent.
7606 *
7607 * @param name The name of the desired item.
7608 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007609 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007610 * or null if no byte array value was found.
7611 *
7612 * @see #putExtra(String, byte[])
7613 */
7614 public byte[] getByteArrayExtra(String name) {
7615 return mExtras == null ? null : mExtras.getByteArray(name);
7616 }
7617
7618 /**
7619 * Retrieve extended data from the intent.
7620 *
7621 * @param name The name of the desired item.
7622 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007623 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007624 * or null if no short array value was found.
7625 *
7626 * @see #putExtra(String, short[])
7627 */
7628 public short[] getShortArrayExtra(String name) {
7629 return mExtras == null ? null : mExtras.getShortArray(name);
7630 }
7631
7632 /**
7633 * Retrieve extended data from the intent.
7634 *
7635 * @param name The name of the desired item.
7636 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007637 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007638 * or null if no char array value was found.
7639 *
7640 * @see #putExtra(String, char[])
7641 */
7642 public char[] getCharArrayExtra(String name) {
7643 return mExtras == null ? null : mExtras.getCharArray(name);
7644 }
7645
7646 /**
7647 * Retrieve extended data from the intent.
7648 *
7649 * @param name The name of the desired item.
7650 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007651 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007652 * or null if no int array value was found.
7653 *
7654 * @see #putExtra(String, int[])
7655 */
7656 public int[] getIntArrayExtra(String name) {
7657 return mExtras == null ? null : mExtras.getIntArray(name);
7658 }
7659
7660 /**
7661 * Retrieve extended data from the intent.
7662 *
7663 * @param name The name of the desired item.
7664 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007665 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007666 * or null if no long array value was found.
7667 *
7668 * @see #putExtra(String, long[])
7669 */
7670 public long[] getLongArrayExtra(String name) {
7671 return mExtras == null ? null : mExtras.getLongArray(name);
7672 }
7673
7674 /**
7675 * Retrieve extended data from the intent.
7676 *
7677 * @param name The name of the desired item.
7678 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007679 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007680 * or null if no float array value was found.
7681 *
7682 * @see #putExtra(String, float[])
7683 */
7684 public float[] getFloatArrayExtra(String name) {
7685 return mExtras == null ? null : mExtras.getFloatArray(name);
7686 }
7687
7688 /**
7689 * Retrieve extended data from the intent.
7690 *
7691 * @param name The name of the desired item.
7692 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007693 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007694 * or null if no double array value was found.
7695 *
7696 * @see #putExtra(String, double[])
7697 */
7698 public double[] getDoubleArrayExtra(String name) {
7699 return mExtras == null ? null : mExtras.getDoubleArray(name);
7700 }
7701
7702 /**
7703 * Retrieve extended data from the intent.
7704 *
7705 * @param name The name of the desired item.
7706 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007707 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007708 * or null if no String array value was found.
7709 *
7710 * @see #putExtra(String, String[])
7711 */
7712 public String[] getStringArrayExtra(String name) {
7713 return mExtras == null ? null : mExtras.getStringArray(name);
7714 }
7715
7716 /**
7717 * Retrieve extended data from the intent.
7718 *
7719 * @param name The name of the desired item.
7720 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007721 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007722 * or null if no CharSequence array value was found.
7723 *
7724 * @see #putExtra(String, CharSequence[])
7725 */
7726 public CharSequence[] getCharSequenceArrayExtra(String name) {
7727 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7728 }
7729
7730 /**
7731 * Retrieve extended data from the intent.
7732 *
7733 * @param name The name of the desired item.
7734 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007735 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007736 * or null if no Bundle value was found.
7737 *
7738 * @see #putExtra(String, Bundle)
7739 */
7740 public Bundle getBundleExtra(String name) {
7741 return mExtras == null ? null : mExtras.getBundle(name);
7742 }
7743
7744 /**
7745 * Retrieve extended data from the intent.
7746 *
7747 * @param name The name of the desired item.
7748 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007749 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007750 * or null if no IBinder value was found.
7751 *
7752 * @see #putExtra(String, IBinder)
7753 *
7754 * @deprecated
7755 * @hide
7756 */
7757 @Deprecated
Mathew Inwood1c77a112018-08-14 14:06:26 +01007758 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007759 public IBinder getIBinderExtra(String name) {
7760 return mExtras == null ? null : mExtras.getIBinder(name);
7761 }
7762
7763 /**
7764 * Retrieve extended data from the intent.
7765 *
7766 * @param name The name of the desired item.
7767 * @param defaultValue The default value to return in case no item is
7768 * associated with the key 'name'
7769 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007770 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007771 * or defaultValue if none was found.
7772 *
7773 * @see #putExtra
7774 *
7775 * @deprecated
7776 * @hide
7777 */
7778 @Deprecated
Mathew Inwood1c77a112018-08-14 14:06:26 +01007779 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007780 public Object getExtra(String name, Object defaultValue) {
7781 Object result = defaultValue;
7782 if (mExtras != null) {
7783 Object result2 = mExtras.get(name);
7784 if (result2 != null) {
7785 result = result2;
7786 }
7787 }
7788
7789 return result;
7790 }
7791
7792 /**
7793 * Retrieves a map of extended data from the intent.
7794 *
7795 * @return the map of all extras previously added with putExtra(),
7796 * or null if none have been added.
7797 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007798 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007799 return (mExtras != null)
7800 ? new Bundle(mExtras)
7801 : null;
7802 }
7803
7804 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007805 * Filter extras to only basic types.
7806 * @hide
7807 */
7808 public void removeUnsafeExtras() {
7809 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007810 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007811 }
7812 }
7813
7814 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007815 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7816 * return itself as-is.
7817 * @hide
7818 */
7819 public boolean canStripForHistory() {
7820 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7821 }
7822
7823 /**
7824 * Call it when the system needs to keep an intent for logging purposes to remove fields
7825 * that are not needed for logging.
7826 * @hide
7827 */
7828 public Intent maybeStripForHistory() {
7829 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7830
7831 if (!canStripForHistory()) {
7832 return this;
7833 }
7834 return new Intent(this, COPY_MODE_HISTORY);
7835 }
7836
7837 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 * Retrieve any special flags associated with this intent. You will
7839 * normally just set them with {@link #setFlags} and let the system
7840 * take the appropriate action with them.
7841 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007842 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007843 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007844 * @see #addFlags
7845 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007847 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 return mFlags;
7849 }
7850
Dianne Hackborne7f97212011-02-24 14:40:20 -08007851 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +01007852 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007853 public boolean isExcludingStopped() {
7854 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7855 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7856 }
7857
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007858 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007859 * Retrieve the application package name this Intent is limited to. When
7860 * resolving an Intent, if non-null this limits the resolution to only
7861 * components in the given application package.
7862 *
7863 * @return The name of the application package for the Intent.
7864 *
7865 * @see #resolveActivity
7866 * @see #setPackage
7867 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007868 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007869 return mPackage;
7870 }
7871
7872 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007873 * Retrieve the concrete component associated with the intent. When receiving
7874 * an intent, this is the component that was found to best handle it (that is,
7875 * yourself) and will always be non-null; in all other cases it will be
7876 * null unless explicitly set.
7877 *
7878 * @return The name of the application component to handle the intent.
7879 *
7880 * @see #resolveActivity
7881 * @see #setComponent
7882 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007883 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007884 return mComponent;
7885 }
7886
7887 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007888 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7889 * used as a hint to the receiver for animations and the like. Null means that there
7890 * is no source bounds.
7891 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007892 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007893 return mSourceBounds;
7894 }
7895
7896 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007897 * Return the Activity component that should be used to handle this intent.
7898 * The appropriate component is determined based on the information in the
7899 * intent, evaluated as follows:
7900 *
7901 * <p>If {@link #getComponent} returns an explicit class, that is returned
7902 * without any further consideration.
7903 *
7904 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7905 * category to be considered.
7906 *
7907 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7908 * action.
7909 *
7910 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7911 * this type.
7912 *
7913 * <p>If {@link #addCategory} has added any categories, the activity must
7914 * handle ALL of the categories specified.
7915 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007916 * <p>If {@link #getPackage} is non-NULL, only activity components in
7917 * that application package will be considered.
7918 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007919 * <p>If there are no activities that satisfy all of these conditions, a
7920 * null string is returned.
7921 *
7922 * <p>If multiple activities are found to satisfy the intent, the one with
7923 * the highest priority will be used. If there are multiple activities
7924 * with the same priority, the system will either pick the best activity
7925 * based on user preference, or resolve to a system class that will allow
7926 * the user to pick an activity and forward from there.
7927 *
7928 * <p>This method is implemented simply by calling
7929 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7930 * true.</p>
7931 * <p> This API is called for you as part of starting an activity from an
7932 * intent. You do not normally need to call it yourself.</p>
7933 *
7934 * @param pm The package manager with which to resolve the Intent.
7935 *
7936 * @return Name of the component implementing an activity that can
7937 * display the intent.
7938 *
7939 * @see #setComponent
7940 * @see #getComponent
7941 * @see #resolveActivityInfo
7942 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007943 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007944 if (mComponent != null) {
7945 return mComponent;
7946 }
7947
7948 ResolveInfo info = pm.resolveActivity(
7949 this, PackageManager.MATCH_DEFAULT_ONLY);
7950 if (info != null) {
7951 return new ComponentName(
7952 info.activityInfo.applicationInfo.packageName,
7953 info.activityInfo.name);
7954 }
7955
7956 return null;
7957 }
7958
7959 /**
7960 * Resolve the Intent into an {@link ActivityInfo}
7961 * describing the activity that should execute the intent. Resolution
7962 * follows the same rules as described for {@link #resolveActivity}, but
7963 * you get back the completely information about the resolved activity
7964 * instead of just its class name.
7965 *
7966 * @param pm The package manager with which to resolve the Intent.
7967 * @param flags Addition information to retrieve as per
7968 * {@link PackageManager#getActivityInfo(ComponentName, int)
7969 * PackageManager.getActivityInfo()}.
7970 *
7971 * @return PackageManager.ActivityInfo
7972 *
7973 * @see #resolveActivity
7974 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007975 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7976 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007977 ActivityInfo ai = null;
7978 if (mComponent != null) {
7979 try {
7980 ai = pm.getActivityInfo(mComponent, flags);
7981 } catch (PackageManager.NameNotFoundException e) {
7982 // ignore
7983 }
7984 } else {
7985 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007986 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007987 if (info != null) {
7988 ai = info.activityInfo;
7989 }
7990 }
7991
7992 return ai;
7993 }
7994
7995 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007996 * Special function for use by the system to resolve service
7997 * intents to system apps. Throws an exception if there are
7998 * multiple potential matches to the Intent. Returns null if
7999 * there are no matches.
8000 * @hide
8001 */
Mathew Inwood1c77a112018-08-14 14:06:26 +01008002 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008003 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8004 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008005 if (mComponent != null) {
8006 return mComponent;
8007 }
8008
8009 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8010 if (results == null) {
8011 return null;
8012 }
8013 ComponentName comp = null;
8014 for (int i=0; i<results.size(); i++) {
8015 ResolveInfo ri = results.get(i);
8016 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8017 continue;
8018 }
8019 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8020 ri.serviceInfo.name);
8021 if (comp != null) {
8022 throw new IllegalStateException("Multiple system services handle " + this
8023 + ": " + comp + ", " + foundComp);
8024 }
8025 comp = foundComp;
8026 }
8027 return comp;
8028 }
8029
8030 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008031 * Set the general action to be performed.
8032 *
8033 * @param action An action name, such as ACTION_VIEW. Application-specific
8034 * actions should be prefixed with the vendor's package name.
8035 *
8036 * @return Returns the same Intent object, for chaining multiple calls
8037 * into a single statement.
8038 *
8039 * @see #getAction
8040 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008041 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008042 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008043 return this;
8044 }
8045
8046 /**
8047 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008048 * clears any type that was previously set by {@link #setType} or
8049 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008050 *
Nick Pellyccae4122012-01-09 14:12:58 -08008051 * <p><em>Note: scheme matching in the Android framework is
8052 * case-sensitive, unlike the formal RFC. As a result,
8053 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008054 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008055 * {@link #setDataAndNormalize}
8056 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008057 *
Nick Pellyccae4122012-01-09 14:12:58 -08008058 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008059 *
8060 * @return Returns the same Intent object, for chaining multiple calls
8061 * into a single statement.
8062 *
8063 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008064 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008065 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008066 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008067 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008068 mData = data;
8069 mType = null;
8070 return this;
8071 }
8072
8073 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008074 * Normalize and set the data this intent is operating on.
8075 *
8076 * <p>This method automatically clears any type that was
8077 * previously set (for example, by {@link #setType}).
8078 *
8079 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008080 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008081 * so really this is just a convenience method for
8082 * <pre>
8083 * setData(data.normalize())
8084 * </pre>
8085 *
8086 * @param data The Uri of the data this intent is now targeting.
8087 *
8088 * @return Returns the same Intent object, for chaining multiple calls
8089 * into a single statement.
8090 *
8091 * @see #getData
8092 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008093 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008094 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008095 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008096 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008097 }
8098
8099 /**
8100 * Set an explicit MIME data type.
8101 *
8102 * <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.
8104 *
8105 * <p>This method automatically clears any data that was
8106 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008107 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008108 * <p><em>Note: MIME type matching in the Android framework is
8109 * case-sensitive, unlike formal RFC MIME types. As a result,
8110 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008111 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8112 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008113 *
8114 * @param type The MIME type of the data being handled by this intent.
8115 *
8116 * @return Returns the same Intent object, for chaining multiple calls
8117 * into a single statement.
8118 *
8119 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008120 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008121 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008122 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008124 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008125 mData = null;
8126 mType = type;
8127 return this;
8128 }
8129
8130 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008131 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008132 *
Nick Pellyccae4122012-01-09 14:12:58 -08008133 * <p>This is used to create intents that only specify a type and not data,
8134 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008135 *
Nick Pellyccae4122012-01-09 14:12:58 -08008136 * <p>This method automatically clears any data that was
8137 * previously set (for example by {@link #setData}).
8138 *
8139 * <p>The MIME type is normalized using
8140 * {@link #normalizeMimeType} before it is set,
8141 * so really this is just a convenience method for
8142 * <pre>
8143 * setType(Intent.normalizeMimeType(type))
8144 * </pre>
8145 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008146 * @param type The MIME type of the data being handled by this intent.
8147 *
8148 * @return Returns the same Intent object, for chaining multiple calls
8149 * into a single statement.
8150 *
Nick Pellyccae4122012-01-09 14:12:58 -08008151 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008152 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008153 * @see #normalizeMimeType
8154 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008155 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008156 return setType(normalizeMimeType(type));
8157 }
8158
8159 /**
8160 * (Usually optional) Set the data for the intent along with 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><em>Note: MIME type and Uri scheme matching in the
8166 * Android framework is case-sensitive, unlike the formal RFC definitions.
8167 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008168 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008169 * {@link #setDataAndTypeAndNormalize}
8170 * to ensure that they are converted to lower case.</em>
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 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008178 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008179 * @see #setData
8180 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008181 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008182 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008184 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008185 mData = data;
8186 mType = type;
8187 return this;
8188 }
8189
8190 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008191 * (Usually optional) Normalize and set both the data Uri and an explicit
8192 * MIME data type. This method should very rarely be used -- it allows you
8193 * to override the MIME type that would ordinarily be inferred from the
8194 * data with your own type given here.
8195 *
8196 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008197 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008198 * before they are set, so really this is just a convenience method for
8199 * <pre>
8200 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8201 * </pre>
8202 *
8203 * @param data The Uri of the data this intent is now targeting.
8204 * @param type The MIME type of the data being handled by this intent.
8205 *
8206 * @return Returns the same Intent object, for chaining multiple calls
8207 * into a single statement.
8208 *
8209 * @see #setType
8210 * @see #setData
8211 * @see #setDataAndType
8212 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008213 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008214 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008215 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008216 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008217 }
8218
8219 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008220 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008221 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008222 * activities that provide <em>all</em> of the requested categories will be
8223 * used.
8224 *
8225 * @param category The desired category. This can be either one of the
8226 * predefined Intent categories, or a custom category in your own
8227 * namespace.
8228 *
8229 * @return Returns the same Intent object, for chaining multiple calls
8230 * into a single statement.
8231 *
8232 * @see #hasCategory
8233 * @see #removeCategory
8234 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008235 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008236 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008237 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008238 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008239 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008240 return this;
8241 }
8242
8243 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008244 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008245 *
8246 * @param category The category to remove.
8247 *
8248 * @see #addCategory
8249 */
8250 public void removeCategory(String category) {
8251 if (mCategories != null) {
8252 mCategories.remove(category);
8253 if (mCategories.size() == 0) {
8254 mCategories = null;
8255 }
8256 }
8257 }
8258
8259 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008260 * Set a selector for this Intent. This is a modification to the kinds of
8261 * things the Intent will match. If the selector is set, it will be used
8262 * when trying to find entities that can handle the Intent, instead of the
8263 * main contents of the Intent. This allows you build an Intent containing
8264 * a generic protocol while targeting it more specifically.
8265 *
8266 * <p>An example of where this may be used is with things like
8267 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8268 * Intent that will launch the Browser application. However, the correct
8269 * main entry point of an application is actually {@link #ACTION_MAIN}
8270 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8271 * used to specify the actual Activity to launch. If you launch the browser
8272 * with something different, undesired behavior may happen if the user has
8273 * previously or later launches it the normal way, since they do not match.
8274 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8275 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8276 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8277 *
8278 * <p>Setting a selector does not impact the behavior of
8279 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8280 * desired behavior of a selector -- it does not impact the base meaning
8281 * of the Intent, just what kinds of things will be matched against it
8282 * when determining who can handle it.</p>
8283 *
8284 * <p>You can not use both a selector and {@link #setPackage(String)} on
8285 * the same base Intent.</p>
8286 *
8287 * @param selector The desired selector Intent; set to null to not use
8288 * a special selector.
8289 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008290 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008291 if (selector == this) {
8292 throw new IllegalArgumentException(
8293 "Intent being set as a selector of itself");
8294 }
8295 if (selector != null && mPackage != null) {
8296 throw new IllegalArgumentException(
8297 "Can't set selector when package name is already set");
8298 }
8299 mSelector = selector;
8300 }
8301
8302 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008303 * Set a {@link ClipData} associated with this Intent. This replaces any
8304 * previously set ClipData.
8305 *
8306 * <p>The ClipData in an intent is not used for Intent matching or other
8307 * such operations. Semantically it is like extras, used to transmit
8308 * additional data with the Intent. The main feature of using this over
8309 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8310 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8311 * items included in the clip data. This is useful, in particular, if
8312 * you want to transmit an Intent containing multiple <code>content:</code>
8313 * URIs for which the recipient may not have global permission to access the
8314 * content provider.
8315 *
8316 * <p>If the ClipData contains items that are themselves Intents, any
8317 * grant flags in those Intents will be ignored. Only the top-level flags
8318 * of the main Intent are respected, and will be applied to all Uri or
8319 * Intent items in the clip (or sub-items of the clip).
8320 *
8321 * <p>The MIME type, label, and icon in the ClipData object are not
8322 * directly used by Intent. Applications should generally rely on the
8323 * MIME type of the Intent itself, not what it may find in the ClipData.
8324 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008325 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008326 *
8327 * @param clip The new clip to set. May be null to clear the current clip.
8328 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008329 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008330 mClipData = clip;
8331 }
8332
8333 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008334 * This is NOT a secure mechanism to identify the user who sent the intent.
8335 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8336 * who sent the intent.
8337 * @hide
8338 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008339 public void prepareToLeaveUser(int userId) {
8340 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8341 // We want mContentUserHint to refer to the original user, so don't do anything.
8342 if (mContentUserHint == UserHandle.USER_CURRENT) {
8343 mContentUserHint = userId;
8344 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008345 }
8346
8347 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008348 * Add extended data to the intent. The name must include a package
8349 * prefix, for example the app com.android.contacts would use names
8350 * like "com.android.contacts.ShowAll".
8351 *
8352 * @param name The name of the extra data, with package prefix.
8353 * @param value The boolean data value.
8354 *
8355 * @return Returns the same Intent object, for chaining multiple calls
8356 * into a single statement.
8357 *
8358 * @see #putExtras
8359 * @see #removeExtra
8360 * @see #getBooleanExtra(String, boolean)
8361 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008362 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008363 if (mExtras == null) {
8364 mExtras = new Bundle();
8365 }
8366 mExtras.putBoolean(name, value);
8367 return this;
8368 }
8369
8370 /**
8371 * Add extended data to the intent. The name must include a package
8372 * prefix, for example the app com.android.contacts would use names
8373 * like "com.android.contacts.ShowAll".
8374 *
8375 * @param name The name of the extra data, with package prefix.
8376 * @param value The byte data value.
8377 *
8378 * @return Returns the same Intent object, for chaining multiple calls
8379 * into a single statement.
8380 *
8381 * @see #putExtras
8382 * @see #removeExtra
8383 * @see #getByteExtra(String, byte)
8384 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008385 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008386 if (mExtras == null) {
8387 mExtras = new Bundle();
8388 }
8389 mExtras.putByte(name, value);
8390 return this;
8391 }
8392
8393 /**
8394 * Add extended data to the intent. The name must include a package
8395 * prefix, for example the app com.android.contacts would use names
8396 * like "com.android.contacts.ShowAll".
8397 *
8398 * @param name The name of the extra data, with package prefix.
8399 * @param value The char data value.
8400 *
8401 * @return Returns the same Intent object, for chaining multiple calls
8402 * into a single statement.
8403 *
8404 * @see #putExtras
8405 * @see #removeExtra
8406 * @see #getCharExtra(String, char)
8407 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008408 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008409 if (mExtras == null) {
8410 mExtras = new Bundle();
8411 }
8412 mExtras.putChar(name, value);
8413 return this;
8414 }
8415
8416 /**
8417 * Add extended data to the intent. The name must include a package
8418 * prefix, for example the app com.android.contacts would use names
8419 * like "com.android.contacts.ShowAll".
8420 *
8421 * @param name The name of the extra data, with package prefix.
8422 * @param value The short data value.
8423 *
8424 * @return Returns the same Intent object, for chaining multiple calls
8425 * into a single statement.
8426 *
8427 * @see #putExtras
8428 * @see #removeExtra
8429 * @see #getShortExtra(String, short)
8430 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008431 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008432 if (mExtras == null) {
8433 mExtras = new Bundle();
8434 }
8435 mExtras.putShort(name, value);
8436 return this;
8437 }
8438
8439 /**
8440 * Add extended data to the intent. The name must include a package
8441 * prefix, for example the app com.android.contacts would use names
8442 * like "com.android.contacts.ShowAll".
8443 *
8444 * @param name The name of the extra data, with package prefix.
8445 * @param value The integer data value.
8446 *
8447 * @return Returns the same Intent object, for chaining multiple calls
8448 * into a single statement.
8449 *
8450 * @see #putExtras
8451 * @see #removeExtra
8452 * @see #getIntExtra(String, int)
8453 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008454 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008455 if (mExtras == null) {
8456 mExtras = new Bundle();
8457 }
8458 mExtras.putInt(name, value);
8459 return this;
8460 }
8461
8462 /**
8463 * Add extended data to the intent. The name must include a package
8464 * prefix, for example the app com.android.contacts would use names
8465 * like "com.android.contacts.ShowAll".
8466 *
8467 * @param name The name of the extra data, with package prefix.
8468 * @param value The long data value.
8469 *
8470 * @return Returns the same Intent object, for chaining multiple calls
8471 * into a single statement.
8472 *
8473 * @see #putExtras
8474 * @see #removeExtra
8475 * @see #getLongExtra(String, long)
8476 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008477 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008478 if (mExtras == null) {
8479 mExtras = new Bundle();
8480 }
8481 mExtras.putLong(name, value);
8482 return this;
8483 }
8484
8485 /**
8486 * Add extended data to the intent. The name must include a package
8487 * prefix, for example the app com.android.contacts would use names
8488 * like "com.android.contacts.ShowAll".
8489 *
8490 * @param name The name of the extra data, with package prefix.
8491 * @param value The float data value.
8492 *
8493 * @return Returns the same Intent object, for chaining multiple calls
8494 * into a single statement.
8495 *
8496 * @see #putExtras
8497 * @see #removeExtra
8498 * @see #getFloatExtra(String, float)
8499 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008500 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008501 if (mExtras == null) {
8502 mExtras = new Bundle();
8503 }
8504 mExtras.putFloat(name, value);
8505 return this;
8506 }
8507
8508 /**
8509 * Add extended data to the intent. The name must include a package
8510 * prefix, for example the app com.android.contacts would use names
8511 * like "com.android.contacts.ShowAll".
8512 *
8513 * @param name The name of the extra data, with package prefix.
8514 * @param value The double data value.
8515 *
8516 * @return Returns the same Intent object, for chaining multiple calls
8517 * into a single statement.
8518 *
8519 * @see #putExtras
8520 * @see #removeExtra
8521 * @see #getDoubleExtra(String, double)
8522 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008523 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 if (mExtras == null) {
8525 mExtras = new Bundle();
8526 }
8527 mExtras.putDouble(name, value);
8528 return this;
8529 }
8530
8531 /**
8532 * Add extended data to the intent. The name must include a package
8533 * prefix, for example the app com.android.contacts would use names
8534 * like "com.android.contacts.ShowAll".
8535 *
8536 * @param name The name of the extra data, with package prefix.
8537 * @param value The String data value.
8538 *
8539 * @return Returns the same Intent object, for chaining multiple calls
8540 * into a single statement.
8541 *
8542 * @see #putExtras
8543 * @see #removeExtra
8544 * @see #getStringExtra(String)
8545 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008546 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008547 if (mExtras == null) {
8548 mExtras = new Bundle();
8549 }
8550 mExtras.putString(name, value);
8551 return this;
8552 }
8553
8554 /**
8555 * Add extended data to the intent. The name must include a package
8556 * prefix, for example the app com.android.contacts would use names
8557 * like "com.android.contacts.ShowAll".
8558 *
8559 * @param name The name of the extra data, with package prefix.
8560 * @param value The CharSequence data value.
8561 *
8562 * @return Returns the same Intent object, for chaining multiple calls
8563 * into a single statement.
8564 *
8565 * @see #putExtras
8566 * @see #removeExtra
8567 * @see #getCharSequenceExtra(String)
8568 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008569 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008570 if (mExtras == null) {
8571 mExtras = new Bundle();
8572 }
8573 mExtras.putCharSequence(name, value);
8574 return this;
8575 }
8576
8577 /**
8578 * Add extended data to the intent. The name must include a package
8579 * prefix, for example the app com.android.contacts would use names
8580 * like "com.android.contacts.ShowAll".
8581 *
8582 * @param name The name of the extra data, with package prefix.
8583 * @param value The Parcelable data value.
8584 *
8585 * @return Returns the same Intent object, for chaining multiple calls
8586 * into a single statement.
8587 *
8588 * @see #putExtras
8589 * @see #removeExtra
8590 * @see #getParcelableExtra(String)
8591 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008592 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008593 if (mExtras == null) {
8594 mExtras = new Bundle();
8595 }
8596 mExtras.putParcelable(name, value);
8597 return this;
8598 }
8599
8600 /**
8601 * Add extended data to the intent. The name must include a package
8602 * prefix, for example the app com.android.contacts would use names
8603 * like "com.android.contacts.ShowAll".
8604 *
8605 * @param name The name of the extra data, with package prefix.
8606 * @param value The Parcelable[] data value.
8607 *
8608 * @return Returns the same Intent object, for chaining multiple calls
8609 * into a single statement.
8610 *
8611 * @see #putExtras
8612 * @see #removeExtra
8613 * @see #getParcelableArrayExtra(String)
8614 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008615 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 if (mExtras == null) {
8617 mExtras = new Bundle();
8618 }
8619 mExtras.putParcelableArray(name, value);
8620 return this;
8621 }
8622
8623 /**
8624 * Add extended data to the intent. The name must include a package
8625 * prefix, for example the app com.android.contacts would use names
8626 * like "com.android.contacts.ShowAll".
8627 *
8628 * @param name The name of the extra data, with package prefix.
8629 * @param value The ArrayList<Parcelable> data value.
8630 *
8631 * @return Returns the same Intent object, for chaining multiple calls
8632 * into a single statement.
8633 *
8634 * @see #putExtras
8635 * @see #removeExtra
8636 * @see #getParcelableArrayListExtra(String)
8637 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008638 public @NonNull Intent putParcelableArrayListExtra(String name,
8639 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008640 if (mExtras == null) {
8641 mExtras = new Bundle();
8642 }
8643 mExtras.putParcelableArrayList(name, value);
8644 return this;
8645 }
8646
8647 /**
8648 * Add extended data to the intent. The name must include a package
8649 * prefix, for example the app com.android.contacts would use names
8650 * like "com.android.contacts.ShowAll".
8651 *
8652 * @param name The name of the extra data, with package prefix.
8653 * @param value The ArrayList<Integer> data value.
8654 *
8655 * @return Returns the same Intent object, for chaining multiple calls
8656 * into a single statement.
8657 *
8658 * @see #putExtras
8659 * @see #removeExtra
8660 * @see #getIntegerArrayListExtra(String)
8661 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008662 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008663 if (mExtras == null) {
8664 mExtras = new Bundle();
8665 }
8666 mExtras.putIntegerArrayList(name, value);
8667 return this;
8668 }
8669
8670 /**
8671 * Add extended data to the intent. The name must include a package
8672 * prefix, for example the app com.android.contacts would use names
8673 * like "com.android.contacts.ShowAll".
8674 *
8675 * @param name The name of the extra data, with package prefix.
8676 * @param value The ArrayList<String> data value.
8677 *
8678 * @return Returns the same Intent object, for chaining multiple calls
8679 * into a single statement.
8680 *
8681 * @see #putExtras
8682 * @see #removeExtra
8683 * @see #getStringArrayListExtra(String)
8684 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008685 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008686 if (mExtras == null) {
8687 mExtras = new Bundle();
8688 }
8689 mExtras.putStringArrayList(name, value);
8690 return this;
8691 }
8692
8693 /**
8694 * Add extended data to the intent. The name must include a package
8695 * prefix, for example the app com.android.contacts would use names
8696 * like "com.android.contacts.ShowAll".
8697 *
8698 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008699 * @param value The ArrayList<CharSequence> data value.
8700 *
8701 * @return Returns the same Intent object, for chaining multiple calls
8702 * into a single statement.
8703 *
8704 * @see #putExtras
8705 * @see #removeExtra
8706 * @see #getCharSequenceArrayListExtra(String)
8707 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008708 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8709 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008710 if (mExtras == null) {
8711 mExtras = new Bundle();
8712 }
8713 mExtras.putCharSequenceArrayList(name, value);
8714 return this;
8715 }
8716
8717 /**
8718 * Add extended data to the intent. The name must include a package
8719 * prefix, for example the app com.android.contacts would use names
8720 * like "com.android.contacts.ShowAll".
8721 *
8722 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008723 * @param value The Serializable data value.
8724 *
8725 * @return Returns the same Intent object, for chaining multiple calls
8726 * into a single statement.
8727 *
8728 * @see #putExtras
8729 * @see #removeExtra
8730 * @see #getSerializableExtra(String)
8731 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008732 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008733 if (mExtras == null) {
8734 mExtras = new Bundle();
8735 }
8736 mExtras.putSerializable(name, value);
8737 return this;
8738 }
8739
8740 /**
8741 * Add extended data to the intent. The name must include a package
8742 * prefix, for example the app com.android.contacts would use names
8743 * like "com.android.contacts.ShowAll".
8744 *
8745 * @param name The name of the extra data, with package prefix.
8746 * @param value The boolean array data value.
8747 *
8748 * @return Returns the same Intent object, for chaining multiple calls
8749 * into a single statement.
8750 *
8751 * @see #putExtras
8752 * @see #removeExtra
8753 * @see #getBooleanArrayExtra(String)
8754 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008755 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008756 if (mExtras == null) {
8757 mExtras = new Bundle();
8758 }
8759 mExtras.putBooleanArray(name, value);
8760 return this;
8761 }
8762
8763 /**
8764 * Add extended data to the intent. The name must include a package
8765 * prefix, for example the app com.android.contacts would use names
8766 * like "com.android.contacts.ShowAll".
8767 *
8768 * @param name The name of the extra data, with package prefix.
8769 * @param value The byte array data value.
8770 *
8771 * @return Returns the same Intent object, for chaining multiple calls
8772 * into a single statement.
8773 *
8774 * @see #putExtras
8775 * @see #removeExtra
8776 * @see #getByteArrayExtra(String)
8777 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008778 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008779 if (mExtras == null) {
8780 mExtras = new Bundle();
8781 }
8782 mExtras.putByteArray(name, value);
8783 return this;
8784 }
8785
8786 /**
8787 * Add extended data to the intent. The name must include a package
8788 * prefix, for example the app com.android.contacts would use names
8789 * like "com.android.contacts.ShowAll".
8790 *
8791 * @param name The name of the extra data, with package prefix.
8792 * @param value The short array data value.
8793 *
8794 * @return Returns the same Intent object, for chaining multiple calls
8795 * into a single statement.
8796 *
8797 * @see #putExtras
8798 * @see #removeExtra
8799 * @see #getShortArrayExtra(String)
8800 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008801 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008802 if (mExtras == null) {
8803 mExtras = new Bundle();
8804 }
8805 mExtras.putShortArray(name, value);
8806 return this;
8807 }
8808
8809 /**
8810 * Add extended data to the intent. The name must include a package
8811 * prefix, for example the app com.android.contacts would use names
8812 * like "com.android.contacts.ShowAll".
8813 *
8814 * @param name The name of the extra data, with package prefix.
8815 * @param value The char array data value.
8816 *
8817 * @return Returns the same Intent object, for chaining multiple calls
8818 * into a single statement.
8819 *
8820 * @see #putExtras
8821 * @see #removeExtra
8822 * @see #getCharArrayExtra(String)
8823 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008824 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008825 if (mExtras == null) {
8826 mExtras = new Bundle();
8827 }
8828 mExtras.putCharArray(name, value);
8829 return this;
8830 }
8831
8832 /**
8833 * Add extended data to the intent. The name must include a package
8834 * prefix, for example the app com.android.contacts would use names
8835 * like "com.android.contacts.ShowAll".
8836 *
8837 * @param name The name of the extra data, with package prefix.
8838 * @param value The int array data value.
8839 *
8840 * @return Returns the same Intent object, for chaining multiple calls
8841 * into a single statement.
8842 *
8843 * @see #putExtras
8844 * @see #removeExtra
8845 * @see #getIntArrayExtra(String)
8846 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008847 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008848 if (mExtras == null) {
8849 mExtras = new Bundle();
8850 }
8851 mExtras.putIntArray(name, value);
8852 return this;
8853 }
8854
8855 /**
8856 * Add extended data to the intent. The name must include a package
8857 * prefix, for example the app com.android.contacts would use names
8858 * like "com.android.contacts.ShowAll".
8859 *
8860 * @param name The name of the extra data, with package prefix.
8861 * @param value The byte array data value.
8862 *
8863 * @return Returns the same Intent object, for chaining multiple calls
8864 * into a single statement.
8865 *
8866 * @see #putExtras
8867 * @see #removeExtra
8868 * @see #getLongArrayExtra(String)
8869 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008870 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008871 if (mExtras == null) {
8872 mExtras = new Bundle();
8873 }
8874 mExtras.putLongArray(name, value);
8875 return this;
8876 }
8877
8878 /**
8879 * Add extended data to the intent. The name must include a package
8880 * prefix, for example the app com.android.contacts would use names
8881 * like "com.android.contacts.ShowAll".
8882 *
8883 * @param name The name of the extra data, with package prefix.
8884 * @param value The float array data value.
8885 *
8886 * @return Returns the same Intent object, for chaining multiple calls
8887 * into a single statement.
8888 *
8889 * @see #putExtras
8890 * @see #removeExtra
8891 * @see #getFloatArrayExtra(String)
8892 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008893 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008894 if (mExtras == null) {
8895 mExtras = new Bundle();
8896 }
8897 mExtras.putFloatArray(name, value);
8898 return this;
8899 }
8900
8901 /**
8902 * Add extended data to the intent. The name must include a package
8903 * prefix, for example the app com.android.contacts would use names
8904 * like "com.android.contacts.ShowAll".
8905 *
8906 * @param name The name of the extra data, with package prefix.
8907 * @param value The double array data value.
8908 *
8909 * @return Returns the same Intent object, for chaining multiple calls
8910 * into a single statement.
8911 *
8912 * @see #putExtras
8913 * @see #removeExtra
8914 * @see #getDoubleArrayExtra(String)
8915 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008916 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008917 if (mExtras == null) {
8918 mExtras = new Bundle();
8919 }
8920 mExtras.putDoubleArray(name, value);
8921 return this;
8922 }
8923
8924 /**
8925 * Add extended data to the intent. The name must include a package
8926 * prefix, for example the app com.android.contacts would use names
8927 * like "com.android.contacts.ShowAll".
8928 *
8929 * @param name The name of the extra data, with package prefix.
8930 * @param value The String array data value.
8931 *
8932 * @return Returns the same Intent object, for chaining multiple calls
8933 * into a single statement.
8934 *
8935 * @see #putExtras
8936 * @see #removeExtra
8937 * @see #getStringArrayExtra(String)
8938 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008939 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008940 if (mExtras == null) {
8941 mExtras = new Bundle();
8942 }
8943 mExtras.putStringArray(name, value);
8944 return this;
8945 }
8946
8947 /**
8948 * Add extended data to the intent. The name must include a package
8949 * prefix, for example the app com.android.contacts would use names
8950 * like "com.android.contacts.ShowAll".
8951 *
8952 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008953 * @param value The CharSequence array data value.
8954 *
8955 * @return Returns the same Intent object, for chaining multiple calls
8956 * into a single statement.
8957 *
8958 * @see #putExtras
8959 * @see #removeExtra
8960 * @see #getCharSequenceArrayExtra(String)
8961 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008962 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008963 if (mExtras == null) {
8964 mExtras = new Bundle();
8965 }
8966 mExtras.putCharSequenceArray(name, value);
8967 return this;
8968 }
8969
8970 /**
8971 * Add extended data to the intent. The name must include a package
8972 * prefix, for example the app com.android.contacts would use names
8973 * like "com.android.contacts.ShowAll".
8974 *
8975 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008976 * @param value The Bundle data value.
8977 *
8978 * @return Returns the same Intent object, for chaining multiple calls
8979 * into a single statement.
8980 *
8981 * @see #putExtras
8982 * @see #removeExtra
8983 * @see #getBundleExtra(String)
8984 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008985 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008986 if (mExtras == null) {
8987 mExtras = new Bundle();
8988 }
8989 mExtras.putBundle(name, value);
8990 return this;
8991 }
8992
8993 /**
8994 * Add extended data to the intent. The name must include a package
8995 * prefix, for example the app com.android.contacts would use names
8996 * like "com.android.contacts.ShowAll".
8997 *
8998 * @param name The name of the extra data, with package prefix.
8999 * @param value The IBinder data value.
9000 *
9001 * @return Returns the same Intent object, for chaining multiple calls
9002 * into a single statement.
9003 *
9004 * @see #putExtras
9005 * @see #removeExtra
9006 * @see #getIBinderExtra(String)
9007 *
9008 * @deprecated
9009 * @hide
9010 */
9011 @Deprecated
Mathew Inwood1c77a112018-08-14 14:06:26 +01009012 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009013 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009014 if (mExtras == null) {
9015 mExtras = new Bundle();
9016 }
9017 mExtras.putIBinder(name, value);
9018 return this;
9019 }
9020
9021 /**
9022 * Copy all extras in 'src' in to this intent.
9023 *
9024 * @param src Contains the extras to copy.
9025 *
9026 * @see #putExtra
9027 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009028 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009029 if (src.mExtras != null) {
9030 if (mExtras == null) {
9031 mExtras = new Bundle(src.mExtras);
9032 } else {
9033 mExtras.putAll(src.mExtras);
9034 }
9035 }
9036 return this;
9037 }
9038
9039 /**
9040 * Add a set of extended data to the intent. The keys must include a package
9041 * prefix, for example the app com.android.contacts would use names
9042 * like "com.android.contacts.ShowAll".
9043 *
9044 * @param extras The Bundle of extras to add to this intent.
9045 *
9046 * @see #putExtra
9047 * @see #removeExtra
9048 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009049 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009050 if (mExtras == null) {
9051 mExtras = new Bundle();
9052 }
9053 mExtras.putAll(extras);
9054 return this;
9055 }
9056
9057 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009058 * Completely replace the extras in the Intent with the extras in the
9059 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009060 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009061 * @param src The exact extras contained in this Intent are copied
9062 * into the target intent, replacing any that were previously there.
9063 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009064 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009065 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9066 return this;
9067 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009068
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009069 /**
9070 * Completely replace the extras in the Intent with the given Bundle of
9071 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009072 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009073 * @param extras The new set of extras in the Intent, or null to erase
9074 * all extras.
9075 */
Tobias Thierer13991172018-12-23 14:25:58 +00009076 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009077 mExtras = extras != null ? new Bundle(extras) : null;
9078 return this;
9079 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009080
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009081 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009082 * Remove extended data from the intent.
9083 *
9084 * @see #putExtra
9085 */
9086 public void removeExtra(String name) {
9087 if (mExtras != null) {
9088 mExtras.remove(name);
9089 if (mExtras.size() == 0) {
9090 mExtras = null;
9091 }
9092 }
9093 }
9094
9095 /**
9096 * Set special flags controlling how this intent is handled. Most values
9097 * here depend on the type of component being executed by the Intent,
9098 * specifically the FLAG_ACTIVITY_* flags are all for use with
9099 * {@link Context#startActivity Context.startActivity()} and the
9100 * FLAG_RECEIVER_* flags are all for use with
9101 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9102 *
Scott Main7aee61f2011-02-08 11:25:01 -08009103 * <p>See the
9104 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9105 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009106 * the behavior of your application.
9107 *
9108 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009109 * @return Returns the same Intent object, for chaining multiple calls
9110 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009111 * @see #getFlags
9112 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009113 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009115 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 mFlags = flags;
9117 return this;
9118 }
9119
9120 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009121 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009122 *
9123 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009124 * @return Returns the same Intent object, for chaining multiple calls into
9125 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009126 * @see #setFlags
9127 * @see #getFlags
9128 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009129 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009130 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009131 mFlags |= flags;
9132 return this;
9133 }
9134
9135 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009136 * Remove these flags from the intent.
9137 *
9138 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009139 * @see #setFlags
9140 * @see #getFlags
9141 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009142 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009143 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009144 mFlags &= ~flags;
9145 }
9146
9147 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009148 * (Usually optional) Set an explicit application package name that limits
9149 * the components this Intent will resolve to. If left to the default
9150 * value of null, all components in all applications will considered.
9151 * If non-null, the Intent can only match the components in the given
9152 * application package.
9153 *
9154 * @param packageName The name of the application package to handle the
9155 * intent, or null to allow any application package.
9156 *
9157 * @return Returns the same Intent object, for chaining multiple calls
9158 * into a single statement.
9159 *
9160 * @see #getPackage
9161 * @see #resolveActivity
9162 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009163 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009164 if (packageName != null && mSelector != null) {
9165 throw new IllegalArgumentException(
9166 "Can't set package name when selector is already set");
9167 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009168 mPackage = packageName;
9169 return this;
9170 }
9171
9172 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009173 * (Usually optional) Explicitly set the component to handle the intent.
9174 * If left with the default value of null, the system will determine the
9175 * appropriate class to use based on the other fields (action, data,
9176 * type, categories) in the Intent. If this class is defined, the
9177 * specified class will always be used regardless of the other fields. You
9178 * should only set this value when you know you absolutely want a specific
9179 * class to be used; otherwise it is better to let the system find the
9180 * appropriate class so that you will respect the installed applications
9181 * and user preferences.
9182 *
9183 * @param component The name of the application component to handle the
9184 * intent, or null to let the system find one for you.
9185 *
9186 * @return Returns the same Intent object, for chaining multiple calls
9187 * into a single statement.
9188 *
9189 * @see #setClass
9190 * @see #setClassName(Context, String)
9191 * @see #setClassName(String, String)
9192 * @see #getComponent
9193 * @see #resolveActivity
9194 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009195 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009196 mComponent = component;
9197 return this;
9198 }
9199
9200 /**
9201 * Convenience for calling {@link #setComponent} with an
9202 * explicit class name.
9203 *
9204 * @param packageContext A Context of the application package implementing
9205 * this class.
9206 * @param className The name of a class inside of the application package
9207 * that will be used as the component for this Intent.
9208 *
9209 * @return Returns the same Intent object, for chaining multiple calls
9210 * into a single statement.
9211 *
9212 * @see #setComponent
9213 * @see #setClass
9214 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009215 public @NonNull Intent setClassName(@NonNull Context packageContext,
9216 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009217 mComponent = new ComponentName(packageContext, className);
9218 return this;
9219 }
9220
9221 /**
9222 * Convenience for calling {@link #setComponent} with an
9223 * explicit application package name and class name.
9224 *
9225 * @param packageName The name of the package implementing the desired
9226 * component.
9227 * @param className The name of a class inside of the application package
9228 * that will be used as the component for this Intent.
9229 *
9230 * @return Returns the same Intent object, for chaining multiple calls
9231 * into a single statement.
9232 *
9233 * @see #setComponent
9234 * @see #setClass
9235 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009236 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009237 mComponent = new ComponentName(packageName, className);
9238 return this;
9239 }
9240
9241 /**
9242 * Convenience for calling {@link #setComponent(ComponentName)} with the
9243 * name returned by a {@link Class} object.
9244 *
9245 * @param packageContext A Context of the application package implementing
9246 * this class.
9247 * @param cls The class name to set, equivalent to
9248 * <code>setClassName(context, cls.getName())</code>.
9249 *
9250 * @return Returns the same Intent object, for chaining multiple calls
9251 * into a single statement.
9252 *
9253 * @see #setComponent
9254 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009255 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009256 mComponent = new ComponentName(packageContext, cls);
9257 return this;
9258 }
9259
9260 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009261 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9262 * used as a hint to the receiver for animations and the like. Null means that there
9263 * is no source bounds.
9264 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009265 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009266 if (r != null) {
9267 mSourceBounds = new Rect(r);
9268 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009269 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009270 }
9271 }
9272
Tor Norbyed9273d62013-05-30 15:59:53 -07009273 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009274 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9275 FILL_IN_ACTION,
9276 FILL_IN_DATA,
9277 FILL_IN_CATEGORIES,
9278 FILL_IN_COMPONENT,
9279 FILL_IN_PACKAGE,
9280 FILL_IN_SOURCE_BOUNDS,
9281 FILL_IN_SELECTOR,
9282 FILL_IN_CLIP_DATA
9283 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009284 @Retention(RetentionPolicy.SOURCE)
9285 public @interface FillInFlags {}
9286
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009287 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009288 * Use with {@link #fillIn} to allow the current action value to be
9289 * overwritten, even if it is already set.
9290 */
9291 public static final int FILL_IN_ACTION = 1<<0;
9292
9293 /**
9294 * Use with {@link #fillIn} to allow the current data or type value
9295 * overwritten, even if it is already set.
9296 */
9297 public static final int FILL_IN_DATA = 1<<1;
9298
9299 /**
9300 * Use with {@link #fillIn} to allow the current categories to be
9301 * overwritten, even if they are already set.
9302 */
9303 public static final int FILL_IN_CATEGORIES = 1<<2;
9304
9305 /**
9306 * Use with {@link #fillIn} to allow the current component value to be
9307 * overwritten, even if it is already set.
9308 */
9309 public static final int FILL_IN_COMPONENT = 1<<3;
9310
9311 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009312 * Use with {@link #fillIn} to allow the current package value to be
9313 * overwritten, even if it is already set.
9314 */
9315 public static final int FILL_IN_PACKAGE = 1<<4;
9316
9317 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009318 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009319 * overwritten, even if it is already set.
9320 */
9321 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9322
9323 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009324 * Use with {@link #fillIn} to allow the current selector to be
9325 * overwritten, even if it is already set.
9326 */
9327 public static final int FILL_IN_SELECTOR = 1<<6;
9328
9329 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009330 * Use with {@link #fillIn} to allow the current ClipData to be
9331 * overwritten, even if it is already set.
9332 */
9333 public static final int FILL_IN_CLIP_DATA = 1<<7;
9334
9335 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009336 * Copy the contents of <var>other</var> in to this object, but only
9337 * where fields are not defined by this object. For purposes of a field
9338 * being defined, the following pieces of data in the Intent are
9339 * considered to be separate fields:
9340 *
9341 * <ul>
9342 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009343 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009344 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9345 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009346 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009347 * <li> component, as set by {@link #setComponent(ComponentName)} or
9348 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009349 * <li> source bounds, as set by {@link #setSourceBounds}.
9350 * <li> selector, as set by {@link #setSelector(Intent)}.
9351 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009352 * <li> each top-level name in the associated extras.
9353 * </ul>
9354 *
9355 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009356 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009357 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9358 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9359 * the restriction where the corresponding field will not be replaced if
9360 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009361 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009362 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9363 * is explicitly specified. The selector will only be copied if
9364 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009365 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009366 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9367 * and Intent B with {action="gotit", data-type="some/thing",
9368 * categories="one","two"}.
9369 *
9370 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9371 * containing: {action="gotit", data-type="some/thing",
9372 * categories="bar"}.
9373 *
9374 * @param other Another Intent whose values are to be used to fill in
9375 * the current one.
9376 * @param flags Options to control which fields can be filled in.
9377 *
9378 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009379 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009380 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009381 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009382 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009383 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009384 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009385 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009386 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009387 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009388 if (other.mAction != null
9389 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009390 mAction = other.mAction;
9391 changes |= FILL_IN_ACTION;
9392 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009393 if ((other.mData != null || other.mType != null)
9394 && ((mData == null && mType == null)
9395 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009396 mData = other.mData;
9397 mType = other.mType;
9398 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009399 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009400 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009401 if (other.mCategories != null
9402 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009403 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009404 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009405 }
9406 changes |= FILL_IN_CATEGORIES;
9407 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009408 if (other.mPackage != null
9409 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009410 // Only do this if mSelector is not set.
9411 if (mSelector == null) {
9412 mPackage = other.mPackage;
9413 changes |= FILL_IN_PACKAGE;
9414 }
9415 }
9416 // Selector is special: it can only be set if explicitly allowed,
9417 // for the same reason as the component name.
9418 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9419 if (mPackage == null) {
9420 mSelector = new Intent(other.mSelector);
9421 mPackage = null;
9422 changes |= FILL_IN_SELECTOR;
9423 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009424 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009425 if (other.mClipData != null
9426 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9427 mClipData = other.mClipData;
9428 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009429 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009430 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009431 // Component is special: it can -only- be set if explicitly allowed,
9432 // since otherwise the sender could force the intent somewhere the
9433 // originator didn't intend.
9434 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009435 mComponent = other.mComponent;
9436 changes |= FILL_IN_COMPONENT;
9437 }
9438 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009439 if (other.mSourceBounds != null
9440 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9441 mSourceBounds = new Rect(other.mSourceBounds);
9442 changes |= FILL_IN_SOURCE_BOUNDS;
9443 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009444 if (mExtras == null) {
9445 if (other.mExtras != null) {
9446 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009447 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009448 }
9449 } else if (other.mExtras != null) {
9450 try {
9451 Bundle newb = new Bundle(other.mExtras);
9452 newb.putAll(mExtras);
9453 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009454 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009455 } catch (RuntimeException e) {
9456 // Modifying the extras can cause us to unparcel the contents
9457 // of the bundle, and if we do this in the system process that
9458 // may fail. We really should handle this (i.e., the Bundle
9459 // impl shouldn't be on top of a plain map), but for now just
9460 // ignore it and keep the original contents. :(
9461 Log.w("Intent", "Failure filling in extras", e);
9462 }
9463 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009464 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9465 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9466 mContentUserHint = other.mContentUserHint;
9467 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009468 return changes;
9469 }
9470
9471 /**
9472 * Wrapper class holding an Intent and implementing comparisons on it for
9473 * the purpose of filtering. The class implements its
9474 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9475 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9476 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9477 * on the wrapped Intent.
9478 */
9479 public static final class FilterComparison {
9480 private final Intent mIntent;
9481 private final int mHashCode;
9482
9483 public FilterComparison(Intent intent) {
9484 mIntent = intent;
9485 mHashCode = intent.filterHashCode();
9486 }
9487
9488 /**
9489 * Return the Intent that this FilterComparison represents.
9490 * @return Returns the Intent held by the FilterComparison. Do
9491 * not modify!
9492 */
9493 public Intent getIntent() {
9494 return mIntent;
9495 }
9496
9497 @Override
9498 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009499 if (obj instanceof FilterComparison) {
9500 Intent other = ((FilterComparison)obj).mIntent;
9501 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009502 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009503 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009504 }
9505
9506 @Override
9507 public int hashCode() {
9508 return mHashCode;
9509 }
9510 }
9511
9512 /**
9513 * Determine if two intents are the same for the purposes of intent
9514 * resolution (filtering). That is, if their action, data, type,
9515 * class, and categories are the same. This does <em>not</em> compare
9516 * any extra data included in the intents.
9517 *
9518 * @param other The other Intent to compare against.
9519 *
9520 * @return Returns true if action, data, type, class, and categories
9521 * are the same.
9522 */
9523 public boolean filterEquals(Intent other) {
9524 if (other == null) {
9525 return false;
9526 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009527 if (!Objects.equals(this.mAction, other.mAction)) return false;
9528 if (!Objects.equals(this.mData, other.mData)) return false;
9529 if (!Objects.equals(this.mType, other.mType)) return false;
9530 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9531 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9532 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009533
9534 return true;
9535 }
9536
9537 /**
9538 * Generate hash code that matches semantics of filterEquals().
9539 *
9540 * @return Returns the hash value of the action, data, type, class, and
9541 * categories.
9542 *
9543 * @see #filterEquals
9544 */
9545 public int filterHashCode() {
9546 int code = 0;
9547 if (mAction != null) {
9548 code += mAction.hashCode();
9549 }
9550 if (mData != null) {
9551 code += mData.hashCode();
9552 }
9553 if (mType != null) {
9554 code += mType.hashCode();
9555 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009556 if (mPackage != null) {
9557 code += mPackage.hashCode();
9558 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009559 if (mComponent != null) {
9560 code += mComponent.hashCode();
9561 }
9562 if (mCategories != null) {
9563 code += mCategories.hashCode();
9564 }
9565 return code;
9566 }
9567
9568 @Override
9569 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009570 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009571
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009572 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009573 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009574 b.append(" }");
9575
9576 return b.toString();
9577 }
9578
9579 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +01009580 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009581 public String toInsecureString() {
9582 StringBuilder b = new StringBuilder(128);
9583
9584 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009585 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009586 b.append(" }");
9587
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009588 return b.toString();
9589 }
Romain Guy4969af72009-06-17 10:53:19 -07009590
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009591 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009592 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009593 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009594
9595 b.append("Intent { ");
9596 toShortString(b, false, true, true, true);
9597 b.append(" }");
9598
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009599 return b.toString();
9600 }
9601
9602 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009603 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9604 StringBuilder b = new StringBuilder(128);
9605 toShortString(b, secure, comp, extras, clip);
9606 return b.toString();
9607 }
9608
9609 /** @hide */
9610 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9611 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009612 boolean first = true;
9613 if (mAction != null) {
9614 b.append("act=").append(mAction);
9615 first = false;
9616 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009617 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009618 if (!first) {
9619 b.append(' ');
9620 }
9621 first = false;
9622 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009623 for (int i=0; i<mCategories.size(); i++) {
9624 if (i > 0) b.append(',');
9625 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009626 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009627 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009628 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009629 if (mData != null) {
9630 if (!first) {
9631 b.append(' ');
9632 }
9633 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009634 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009635 if (secure) {
9636 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009637 } else {
9638 b.append(mData);
9639 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009640 }
9641 if (mType != null) {
9642 if (!first) {
9643 b.append(' ');
9644 }
9645 first = false;
9646 b.append("typ=").append(mType);
9647 }
9648 if (mFlags != 0) {
9649 if (!first) {
9650 b.append(' ');
9651 }
9652 first = false;
9653 b.append("flg=0x").append(Integer.toHexString(mFlags));
9654 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009655 if (mPackage != null) {
9656 if (!first) {
9657 b.append(' ');
9658 }
9659 first = false;
9660 b.append("pkg=").append(mPackage);
9661 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009662 if (comp && mComponent != null) {
9663 if (!first) {
9664 b.append(' ');
9665 }
9666 first = false;
9667 b.append("cmp=").append(mComponent.flattenToShortString());
9668 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009669 if (mSourceBounds != null) {
9670 if (!first) {
9671 b.append(' ');
9672 }
9673 first = false;
9674 b.append("bnds=").append(mSourceBounds.toShortString());
9675 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009676 if (mClipData != null) {
9677 if (!first) {
9678 b.append(' ');
9679 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009680 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009681 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009682 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009683 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009684 if (mClipData.getDescription() != null) {
9685 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9686 } else {
9687 first = true;
9688 }
9689 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009690 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009691 first = false;
9692 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009693 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009694 if (extras && mExtras != null) {
9695 if (!first) {
9696 b.append(' ');
9697 }
9698 first = false;
9699 b.append("(has extras)");
9700 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009701 if (mContentUserHint != UserHandle.USER_CURRENT) {
9702 if (!first) {
9703 b.append(' ');
9704 }
9705 first = false;
9706 b.append("u=").append(mContentUserHint);
9707 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009708 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009709 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009710 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009711 b.append("}");
9712 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009713 }
9714
Yi Jin129fc6c2017-09-28 15:48:38 -07009715 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009716 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9717 // Same input parameters that toString() gives to toShortString().
9718 writeToProto(proto, fieldId, true, true, true, false);
9719 }
9720
9721 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009722 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9723 boolean extras, boolean clip) {
9724 long token = proto.start(fieldId);
9725 if (mAction != null) {
9726 proto.write(IntentProto.ACTION, mAction);
9727 }
9728 if (mCategories != null) {
9729 for (String category : mCategories) {
9730 proto.write(IntentProto.CATEGORIES, category);
9731 }
9732 }
9733 if (mData != null) {
9734 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9735 }
9736 if (mType != null) {
9737 proto.write(IntentProto.TYPE, mType);
9738 }
9739 if (mFlags != 0) {
9740 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9741 }
9742 if (mPackage != null) {
9743 proto.write(IntentProto.PACKAGE, mPackage);
9744 }
9745 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009746 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009747 }
9748 if (mSourceBounds != null) {
9749 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9750 }
9751 if (mClipData != null) {
9752 StringBuilder b = new StringBuilder();
9753 if (clip) {
9754 mClipData.toShortString(b);
9755 } else {
9756 mClipData.toShortStringShortItems(b, false);
9757 }
9758 proto.write(IntentProto.CLIP_DATA, b.toString());
9759 }
9760 if (extras && mExtras != null) {
9761 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9762 }
9763 if (mContentUserHint != 0) {
9764 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9765 }
9766 if (mSelector != null) {
9767 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9768 }
9769 proto.end(token);
9770 }
9771
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009772 /**
9773 * Call {@link #toUri} with 0 flags.
9774 * @deprecated Use {@link #toUri} instead.
9775 */
9776 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009777 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009778 return toUri(0);
9779 }
9780
9781 /**
9782 * Convert this Intent into a String holding a URI representation of it.
9783 * The returned URI string has been properly URI encoded, so it can be
9784 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9785 * Intent's data as the base URI, with an additional fragment describing
9786 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009787 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009788 * <p>You can convert the returned string back to an Intent with
9789 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009790 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009791 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009792 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009793 * @return Returns a URI encoding URI string describing the entire contents
9794 * of the Intent.
9795 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009796 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009797 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009798 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9799 if (mPackage == null) {
9800 throw new IllegalArgumentException(
9801 "Intent must include an explicit package name to build an android-app: "
9802 + this);
9803 }
9804 uri.append("android-app://");
9805 uri.append(mPackage);
9806 String scheme = null;
9807 if (mData != null) {
9808 scheme = mData.getScheme();
9809 if (scheme != null) {
9810 uri.append('/');
9811 uri.append(scheme);
9812 String authority = mData.getEncodedAuthority();
9813 if (authority != null) {
9814 uri.append('/');
9815 uri.append(authority);
9816 String path = mData.getEncodedPath();
9817 if (path != null) {
9818 uri.append(path);
9819 }
9820 String queryParams = mData.getEncodedQuery();
9821 if (queryParams != null) {
9822 uri.append('?');
9823 uri.append(queryParams);
9824 }
9825 String fragment = mData.getEncodedFragment();
9826 if (fragment != null) {
9827 uri.append('#');
9828 uri.append(fragment);
9829 }
9830 }
9831 }
9832 }
9833 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9834 mPackage, flags);
9835 return uri.toString();
9836 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009837 String scheme = null;
9838 if (mData != null) {
9839 String data = mData.toString();
9840 if ((flags&URI_INTENT_SCHEME) != 0) {
9841 final int N = data.length();
9842 for (int i=0; i<N; i++) {
9843 char c = data.charAt(i);
9844 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009845 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009846 continue;
9847 }
9848 if (c == ':' && i > 0) {
9849 // Valid scheme.
9850 scheme = data.substring(0, i);
9851 uri.append("intent:");
9852 data = data.substring(i+1);
9853 break;
9854 }
Tom Taylord4a47292009-12-21 13:59:18 -08009855
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009856 // No scheme.
9857 break;
9858 }
9859 }
9860 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009861
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009862 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9863 uri.append("intent:");
9864 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009865
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009866 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009867
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009868 return uri.toString();
9869 }
9870
9871 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9872 String defPackage, int flags) {
9873 StringBuilder frag = new StringBuilder(128);
9874
9875 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009876 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009877 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009878 // Note that for now we are not going to try to handle the
9879 // data part; not clear how to represent this as a URI, and
9880 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009881 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9882 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009883 }
9884
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009885 if (frag.length() > 0) {
9886 uri.append("#Intent;");
9887 uri.append(frag);
9888 uri.append("end");
9889 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009890 }
9891
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009892 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9893 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009894 if (scheme != null) {
9895 uri.append("scheme=").append(scheme).append(';');
9896 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009897 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009898 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009899 }
9900 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009901 for (int i=0; i<mCategories.size(); i++) {
9902 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009903 }
9904 }
9905 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009906 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009907 }
9908 if (mFlags != 0) {
9909 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9910 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009911 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009912 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9913 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009914 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009915 uri.append("component=").append(Uri.encode(
9916 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009917 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009918 if (mSourceBounds != null) {
9919 uri.append("sourceBounds=")
9920 .append(Uri.encode(mSourceBounds.flattenToString()))
9921 .append(';');
9922 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009923 if (mExtras != null) {
9924 for (String key : mExtras.keySet()) {
9925 final Object value = mExtras.get(key);
9926 char entryType =
9927 value instanceof String ? 'S' :
9928 value instanceof Boolean ? 'B' :
9929 value instanceof Byte ? 'b' :
9930 value instanceof Character ? 'c' :
9931 value instanceof Double ? 'd' :
9932 value instanceof Float ? 'f' :
9933 value instanceof Integer ? 'i' :
9934 value instanceof Long ? 'l' :
9935 value instanceof Short ? 's' :
9936 '\0';
9937
9938 if (entryType != '\0') {
9939 uri.append(entryType);
9940 uri.append('.');
9941 uri.append(Uri.encode(key));
9942 uri.append('=');
9943 uri.append(Uri.encode(value.toString()));
9944 uri.append(';');
9945 }
9946 }
9947 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009948 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009949
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009950 public int describeContents() {
9951 return (mExtras != null) ? mExtras.describeContents() : 0;
9952 }
9953
9954 public void writeToParcel(Parcel out, int flags) {
9955 out.writeString(mAction);
9956 Uri.writeToParcel(out, mData);
9957 out.writeString(mType);
9958 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009959 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009960 ComponentName.writeToParcel(mComponent, out);
9961
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009962 if (mSourceBounds != null) {
9963 out.writeInt(1);
9964 mSourceBounds.writeToParcel(out, flags);
9965 } else {
9966 out.writeInt(0);
9967 }
9968
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009969 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009970 final int N = mCategories.size();
9971 out.writeInt(N);
9972 for (int i=0; i<N; i++) {
9973 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009974 }
9975 } else {
9976 out.writeInt(0);
9977 }
9978
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009979 if (mSelector != null) {
9980 out.writeInt(1);
9981 mSelector.writeToParcel(out, flags);
9982 } else {
9983 out.writeInt(0);
9984 }
9985
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009986 if (mClipData != null) {
9987 out.writeInt(1);
9988 mClipData.writeToParcel(out, flags);
9989 } else {
9990 out.writeInt(0);
9991 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009992 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009993 out.writeBundle(mExtras);
9994 }
9995
9996 public static final Parcelable.Creator<Intent> CREATOR
9997 = new Parcelable.Creator<Intent>() {
9998 public Intent createFromParcel(Parcel in) {
9999 return new Intent(in);
10000 }
10001 public Intent[] newArray(int size) {
10002 return new Intent[size];
10003 }
10004 };
10005
Dianne Hackborneb034652009-09-07 00:49:58 -070010006 /** @hide */
10007 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010008 readFromParcel(in);
10009 }
10010
10011 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010012 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010013 mData = Uri.CREATOR.createFromParcel(in);
10014 mType = in.readString();
10015 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010016 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010017 mComponent = ComponentName.readFromParcel(in);
10018
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010019 if (in.readInt() != 0) {
10020 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10021 }
10022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010023 int N = in.readInt();
10024 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010025 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010026 int i;
10027 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010028 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010029 }
10030 } else {
10031 mCategories = null;
10032 }
10033
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010034 if (in.readInt() != 0) {
10035 mSelector = new Intent(in);
10036 }
10037
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010038 if (in.readInt() != 0) {
10039 mClipData = new ClipData(in);
10040 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010041 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010042 mExtras = in.readBundle();
10043 }
10044
10045 /**
10046 * Parses the "intent" element (and its children) from XML and instantiates
10047 * an Intent object. The given XML parser should be located at the tag
10048 * where parsing should start (often named "intent"), from which the
10049 * basic action, data, type, and package and class name will be
10050 * retrieved. The function will then parse in to any child elements,
10051 * looking for <category android:name="xxx"> tags to add categories and
10052 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10053 * to the intent.
10054 *
10055 * @param resources The Resources to use when inflating resources.
10056 * @param parser The XML parser pointing at an "intent" tag.
10057 * @param attrs The AttributeSet interface for retrieving extended
10058 * attribute data at the current <var>parser</var> location.
10059 * @return An Intent object matching the XML data.
10060 * @throws XmlPullParserException If there was an XML parsing error.
10061 * @throws IOException If there was an I/O error.
10062 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010063 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10064 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010065 throws XmlPullParserException, IOException {
10066 Intent intent = new Intent();
10067
10068 TypedArray sa = resources.obtainAttributes(attrs,
10069 com.android.internal.R.styleable.Intent);
10070
10071 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10072
10073 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10074 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10075 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10076
10077 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10078 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10079 if (packageName != null && className != null) {
10080 intent.setComponent(new ComponentName(packageName, className));
10081 }
10082
10083 sa.recycle();
10084
10085 int outerDepth = parser.getDepth();
10086 int type;
10087 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10088 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10089 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10090 continue;
10091 }
10092
10093 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010094 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010095 sa = resources.obtainAttributes(attrs,
10096 com.android.internal.R.styleable.IntentCategory);
10097 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10098 sa.recycle();
10099
10100 if (cat != null) {
10101 intent.addCategory(cat);
10102 }
10103 XmlUtils.skipCurrentTag(parser);
10104
Craig Mautner21d24a22014-04-23 11:45:37 -070010105 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010106 if (intent.mExtras == null) {
10107 intent.mExtras = new Bundle();
10108 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010109 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010110 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010111
10112 } else {
10113 XmlUtils.skipCurrentTag(parser);
10114 }
10115 }
10116
10117 return intent;
10118 }
Nick Pellyccae4122012-01-09 14:12:58 -080010119
Craig Mautner21d24a22014-04-23 11:45:37 -070010120 /** @hide */
10121 public void saveToXml(XmlSerializer out) throws IOException {
10122 if (mAction != null) {
10123 out.attribute(null, ATTR_ACTION, mAction);
10124 }
10125 if (mData != null) {
10126 out.attribute(null, ATTR_DATA, mData.toString());
10127 }
10128 if (mType != null) {
10129 out.attribute(null, ATTR_TYPE, mType);
10130 }
10131 if (mComponent != null) {
10132 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10133 }
10134 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10135
10136 if (mCategories != null) {
10137 out.startTag(null, TAG_CATEGORIES);
10138 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10139 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10140 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010141 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010142 }
10143 }
10144
10145 /** @hide */
10146 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10147 XmlPullParserException {
10148 Intent intent = new Intent();
10149 final int outerDepth = in.getDepth();
10150
10151 int attrCount = in.getAttributeCount();
10152 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10153 final String attrName = in.getAttributeName(attrNdx);
10154 final String attrValue = in.getAttributeValue(attrNdx);
10155 if (ATTR_ACTION.equals(attrName)) {
10156 intent.setAction(attrValue);
10157 } else if (ATTR_DATA.equals(attrName)) {
10158 intent.setData(Uri.parse(attrValue));
10159 } else if (ATTR_TYPE.equals(attrName)) {
10160 intent.setType(attrValue);
10161 } else if (ATTR_COMPONENT.equals(attrName)) {
10162 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10163 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010164 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010165 } else {
10166 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10167 }
10168 }
10169
10170 int event;
10171 String name;
10172 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10173 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10174 if (event == XmlPullParser.START_TAG) {
10175 name = in.getName();
10176 if (TAG_CATEGORIES.equals(name)) {
10177 attrCount = in.getAttributeCount();
10178 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10179 intent.addCategory(in.getAttributeValue(attrNdx));
10180 }
10181 } else {
10182 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10183 XmlUtils.skipCurrentTag(in);
10184 }
10185 }
10186 }
10187
10188 return intent;
10189 }
10190
Nick Pellyccae4122012-01-09 14:12:58 -080010191 /**
10192 * Normalize a MIME data type.
10193 *
10194 * <p>A normalized MIME type has white-space trimmed,
10195 * content-type parameters removed, and is lower-case.
10196 * This aligns the type with Android best practices for
10197 * intent filtering.
10198 *
10199 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10200 * "text/x-vCard" becomes "text/x-vcard".
10201 *
10202 * <p>All MIME types received from outside Android (such as user input,
10203 * or external sources like Bluetooth, NFC, or the Internet) should
10204 * be normalized before they are used to create an Intent.
10205 *
10206 * @param type MIME data type to normalize
10207 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010208 * @see #setType
10209 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010210 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010211 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010212 if (type == null) {
10213 return null;
10214 }
10215
Elliott Hughescb64d432013-08-02 10:00:44 -070010216 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010217
10218 final int semicolonIndex = type.indexOf(';');
10219 if (semicolonIndex != -1) {
10220 type = type.substring(0, semicolonIndex);
10221 }
10222 return type;
10223 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010224
10225 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010226 * Prepare this {@link Intent} to leave an app process.
10227 *
10228 * @hide
10229 */
Mathew Inwood1c77a112018-08-14 14:06:26 +010010230 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010231 public void prepareToLeaveProcess(Context context) {
10232 final boolean leavingPackage = (mComponent == null)
10233 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10234 prepareToLeaveProcess(leavingPackage);
10235 }
10236
10237 /**
10238 * Prepare this {@link Intent} to leave an app process.
10239 *
10240 * @hide
10241 */
10242 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010243 setAllowFds(false);
10244
10245 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010246 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010247 }
10248 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010249 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010250 }
10251
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010252 if (mExtras != null && !mExtras.isParcelled()) {
10253 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10254 if (intent instanceof Intent) {
10255 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10256 }
10257 }
10258
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010259 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10260 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010261 switch (mAction) {
10262 case ACTION_MEDIA_REMOVED:
10263 case ACTION_MEDIA_UNMOUNTED:
10264 case ACTION_MEDIA_CHECKING:
10265 case ACTION_MEDIA_NOFS:
10266 case ACTION_MEDIA_MOUNTED:
10267 case ACTION_MEDIA_SHARED:
10268 case ACTION_MEDIA_UNSHARED:
10269 case ACTION_MEDIA_BAD_REMOVAL:
10270 case ACTION_MEDIA_UNMOUNTABLE:
10271 case ACTION_MEDIA_EJECT:
10272 case ACTION_MEDIA_SCANNER_STARTED:
10273 case ACTION_MEDIA_SCANNER_FINISHED:
10274 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010275 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10276 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010277 // Ignore legacy actions
10278 break;
10279 default:
10280 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010281 }
10282 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010283
10284 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10285 && leavingPackage) {
10286 switch (mAction) {
10287 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010288 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010289 // Ignore actions that don't need to grant
10290 break;
10291 default:
10292 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10293 }
10294 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010295 }
10296
10297 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010298 * @hide
10299 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010300 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010301 // We just entered destination process, so we should be able to read all
10302 // parcelables inside.
10303 setDefusable(true);
10304
10305 if (mSelector != null) {
10306 mSelector.prepareToEnterProcess();
10307 }
10308 if (mClipData != null) {
10309 mClipData.prepareToEnterProcess();
10310 }
10311
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010312 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010313 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10314 fixUris(mContentUserHint);
10315 mContentUserHint = UserHandle.USER_CURRENT;
10316 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010317 }
10318 }
10319
Patrick Baumann577d4022018-01-31 16:55:10 +000010320 /** @hide */
10321 public boolean hasWebURI() {
10322 if (getData() == null) {
10323 return false;
10324 }
10325 final String scheme = getScheme();
10326 if (TextUtils.isEmpty(scheme)) {
10327 return false;
10328 }
10329 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10330 }
10331
10332 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010333 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010334 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010335 && hasWebURI();
10336 }
10337
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010338 /**
10339 * @hide
10340 */
10341 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010342 Uri data = getData();
10343 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010344 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010345 }
10346 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010347 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010348 }
10349 String action = getAction();
10350 if (ACTION_SEND.equals(action)) {
10351 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10352 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010353 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010354 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010355 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010356 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10357 if (streams != null) {
10358 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10359 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010360 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010361 }
10362 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10363 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010364 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10365 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10366 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10367 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10368 if (output != null) {
10369 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10370 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010371 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010372 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010373
10374 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010375 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010376 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10377 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010378 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010379 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010380 * @hide
10381 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010382 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010383 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010384 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010385
10386 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010387 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010388
10389 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010390 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010391 // Inspect contained intents to see if we need to migrate extras. We
10392 // don't promote ClipData to the parent, since ChooserActivity will
10393 // already start the picked item as the caller, and we can't combine
10394 // the flags in a safe way.
10395
10396 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010397 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010398 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10399 if (intent != null) {
10400 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010401 }
10402 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010403 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010404 try {
10405 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10406 if (intents != null) {
10407 for (int i = 0; i < intents.length; i++) {
10408 final Intent intent = (Intent) intents[i];
10409 if (intent != null) {
10410 migrated |= intent.migrateExtraStreamToClipData();
10411 }
10412 }
10413 }
10414 } catch (ClassCastException e) {
10415 }
10416 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010417
10418 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010419 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010420 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10421 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10422 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10423 if (stream != null || text != null || htmlText != null) {
10424 final ClipData clipData = new ClipData(
10425 null, new String[] { getType() },
10426 new ClipData.Item(text, htmlText, null, stream));
10427 setClipData(clipData);
10428 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010429 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010430 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010431 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010432 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010433
10434 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010435 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010436 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10437 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10438 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10439 int num = -1;
10440 if (streams != null) {
10441 num = streams.size();
10442 }
10443 if (texts != null) {
10444 if (num >= 0 && num != texts.size()) {
10445 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010446 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010447 }
10448 num = texts.size();
10449 }
10450 if (htmlTexts != null) {
10451 if (num >= 0 && num != htmlTexts.size()) {
10452 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010453 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010454 }
10455 num = htmlTexts.size();
10456 }
10457 if (num > 0) {
10458 final ClipData clipData = new ClipData(
10459 null, new String[] { getType() },
10460 makeClipItem(streams, texts, htmlTexts, 0));
10461
10462 for (int i = 1; i < num; i++) {
10463 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10464 }
10465
10466 setClipData(clipData);
10467 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010468 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010469 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010470 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010471 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010472 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10473 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10474 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10475 final Uri output;
10476 try {
10477 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10478 } catch (ClassCastException e) {
10479 return false;
10480 }
10481 if (output != null) {
10482 setClipData(ClipData.newRawUri("", output));
10483 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10484 return true;
10485 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010486 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010487
10488 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010489 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010490
Michael Wright19859762017-09-18 20:57:58 +010010491 /**
10492 * Convert the dock state to a human readable format.
10493 * @hide
10494 */
10495 public static String dockStateToString(int dock) {
10496 switch (dock) {
10497 case EXTRA_DOCK_STATE_HE_DESK:
10498 return "EXTRA_DOCK_STATE_HE_DESK";
10499 case EXTRA_DOCK_STATE_LE_DESK:
10500 return "EXTRA_DOCK_STATE_LE_DESK";
10501 case EXTRA_DOCK_STATE_CAR:
10502 return "EXTRA_DOCK_STATE_CAR";
10503 case EXTRA_DOCK_STATE_DESK:
10504 return "EXTRA_DOCK_STATE_DESK";
10505 case EXTRA_DOCK_STATE_UNDOCKED:
10506 return "EXTRA_DOCK_STATE_UNDOCKED";
10507 default:
10508 return Integer.toString(dock);
10509 }
10510 }
10511
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010512 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10513 ArrayList<String> htmlTexts, int which) {
10514 Uri uri = streams != null ? streams.get(which) : null;
10515 CharSequence text = texts != null ? texts.get(which) : null;
10516 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10517 return new ClipData.Item(text, htmlText, null, uri);
10518 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010519
10520 /** @hide */
10521 public boolean isDocument() {
10522 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10523 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010524}