blob: ce322785c229b325d1f83c077beadc74a9c5cd36 [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;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070029import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050030import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060031import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.content.pm.PackageManager;
33import android.content.pm.ResolveInfo;
34import android.content.res.Resources;
35import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080036import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060038import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.os.Bundle;
40import android.os.IBinder;
41import android.os.Parcel;
42import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000043import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050044import android.os.ResultReceiver;
45import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070046import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010047import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070048import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070049import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070050import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070052import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000053import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050054import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070055import android.util.AttributeSet;
56import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070057import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070058
Dianne Hackborn2269d1572010-02-24 19:54:22 -080059import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070060
Jason Monk2f68e8a2016-02-23 17:57:28 -050061import org.xmlpull.v1.XmlPullParser;
62import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070063import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070064
65import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080066import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070067import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070068import java.lang.annotation.Retention;
69import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070import java.net.URISyntaxException;
71import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080072import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070073import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080074import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070075import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070076import java.util.Set;
77
78/**
79 * An intent is an abstract description of an operation to be performed. It
80 * can be used with {@link Context#startActivity(Intent) startActivity} to
81 * launch an {@link android.app.Activity},
82 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
83 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
84 * and {@link android.content.Context#startService} or
85 * {@link android.content.Context#bindService} to communicate with a
86 * background {@link android.app.Service}.
87 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070088 * <p>An Intent provides a facility for performing late runtime binding between the code in
89 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070090 * can be thought of as the glue between activities. It is basically a passive data structure
91 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070092 *
93 * <div class="special reference">
94 * <h3>Developer Guides</h3>
95 * <p>For information about how to create and resolve intents, read the
96 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
97 * developer guide.</p>
98 * </div>
99 *
100 * <a name="IntentStructure"></a>
101 * <h3>Intent Structure</h3>
102 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700103 *
104 * <ul>
105 * <li> <p><b>action</b> -- The general action to be performed, such as
106 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
107 * etc.</p>
108 * </li>
109 * <li> <p><b>data</b> -- The data to operate on, such as a person record
110 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
111 * </li>
112 * </ul>
113 *
114 *
115 * <p>Some examples of action/data pairs are:</p>
116 *
117 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700118 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700119 * information about the person whose identifier is "1".</p>
120 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700121 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700122 * the phone dialer with the person filled in.</p>
123 * </li>
124 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
125 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700126 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * a particular URI.</p>
128 * </li>
129 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
130 * the phone dialer with the given number filled in.</p>
131 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700132 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700133 * information about the person whose identifier is "1".</p>
134 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700135 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700136 * a list of people, which the user can browse through. This example is a
137 * typical top-level entry into the Contacts application, showing you the
138 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700139 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700140 * being used to start an activity to display that person.</p>
141 * </li>
142 * </ul>
143 *
144 * <p>In addition to these primary attributes, there are a number of secondary
145 * attributes that you can also include with an intent:</p>
146 *
147 * <ul>
148 * <li> <p><b>category</b> -- Gives additional information about the action
149 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
150 * appear in the Launcher as a top-level application, while
151 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
152 * of alternative actions the user can perform on a piece of data.</p>
153 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
154 * intent data. Normally the type is inferred from the data itself.
155 * By setting this attribute, you disable that evaluation and force
156 * an explicit type.</p>
157 * <li> <p><b>component</b> -- Specifies an explicit name of a component
158 * class to use for the intent. Normally this is determined by looking
159 * at the other information in the intent (the action, data/type, and
160 * categories) and matching that with a component that can handle it.
161 * If this attribute is set then none of the evaluation is performed,
162 * and this component is used exactly as is. By specifying this attribute,
163 * all of the other Intent attributes become optional.</p>
164 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
165 * This can be used to provide extended information to the component.
166 * For example, if we have a action to send an e-mail message, we could
167 * also include extra pieces of data here to supply a subject, body,
168 * etc.</p>
169 * </ul>
170 *
171 * <p>Here are some examples of other operations you can specify as intents
172 * using these additional parameters:</p>
173 *
174 * <ul>
175 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
176 * Launch the home screen.</p>
177 * </li>
178 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
180 * vnd.android.cursor.item/phone}</i></b>
181 * -- Display the list of people's phone numbers, allowing the user to
182 * browse through them and pick one and return it to the parent activity.</p>
183 * </li>
184 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
185 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
186 * -- Display all pickers for data that can be opened with
187 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
188 * allowing the user to pick one of them and then some data inside of it
189 * and returning the resulting URI to the caller. This can be used,
190 * for example, in an e-mail application to allow the user to pick some
191 * data to include as an attachment.</p>
192 * </li>
193 * </ul>
194 *
195 * <p>There are a variety of standard Intent action and category constants
196 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700197 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700198 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700199 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700200 *
201 * <p>Put together, the set of actions, data types, categories, and extra data
202 * defines a language for the system allowing for the expression of phrases
203 * such as "call john smith's cell". As applications are added to the system,
204 * they can extend this language by adding new actions, types, and categories, or
205 * they can modify the behavior of existing phrases by supplying their own
206 * activities that handle them.</p>
207 *
208 * <a name="IntentResolution"></a>
209 * <h3>Intent Resolution</h3>
210 *
211 * <p>There are two primary forms of intents you will use.
212 *
213 * <ul>
214 * <li> <p><b>Explicit Intents</b> have specified a component (via
215 * {@link #setComponent} or {@link #setClass}), which provides the exact
216 * class to be run. Often these will not include any other information,
217 * simply being a way for an application to launch various internal
218 * activities it has as the user interacts with the application.
219 *
220 * <li> <p><b>Implicit Intents</b> have not specified a component;
221 * instead, they must include enough information for the system to
222 * determine which of the available components is best to run for that
223 * intent.
224 * </ul>
225 *
226 * <p>When using implicit intents, given such an arbitrary intent we need to
227 * know what to do with it. This is handled by the process of <em>Intent
228 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
229 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
230 * more activities/receivers) that can handle it.</p>
231 *
232 * <p>The intent resolution mechanism basically revolves around matching an
233 * Intent against all of the &lt;intent-filter&gt; descriptions in the
234 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
235 * objects explicitly registered with {@link Context#registerReceiver}.) More
236 * details on this can be found in the documentation on the {@link
237 * IntentFilter} class.</p>
238 *
239 * <p>There are three pieces of information in the Intent that are used for
240 * resolution: the action, type, and category. Using this information, a query
241 * is done on the {@link PackageManager} for a component that can handle the
242 * intent. The appropriate component is determined based on the intent
243 * information supplied in the <code>AndroidManifest.xml</code> file as
244 * follows:</p>
245 *
246 * <ul>
247 * <li> <p>The <b>action</b>, if given, must be listed by the component as
248 * one it handles.</p>
249 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
250 * already supplied in the Intent. Like the action, if a type is
251 * included in the intent (either explicitly or implicitly in its
252 * data), then this must be listed by the component as one it handles.</p>
253 * <li> For data that is not a <code>content:</code> URI and where no explicit
254 * type is included in the Intent, instead the <b>scheme</b> of the
255 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
256 * considered. Again like the action, if we are matching a scheme it
257 * must be listed by the component as one it can handle.
258 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
259 * by the activity as categories it handles. That is, if you include
260 * the categories {@link #CATEGORY_LAUNCHER} and
261 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
262 * with an intent that lists <em>both</em> of those categories.
263 * Activities will very often need to support the
264 * {@link #CATEGORY_DEFAULT} so that they can be found by
265 * {@link Context#startActivity Context.startActivity()}.</p>
266 * </ul>
267 *
268 * <p>For example, consider the Note Pad sample application that
269 * allows user to browse through a list of notes data and view details about
270 * individual items. Text in italics indicate places were you would replace a
271 * name with one specific to your own package.</p>
272 *
273 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
274 * package="<i>com.android.notepad</i>"&gt;
275 * &lt;application android:icon="@drawable/app_notes"
276 * android:label="@string/app_name"&gt;
277 *
278 * &lt;provider class=".NotePadProvider"
279 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
280 *
281 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
282 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700283 * &lt;action android:name="android.intent.action.MAIN" /&gt;
284 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700285 * &lt;/intent-filter&gt;
286 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700287 * &lt;action android:name="android.intent.action.VIEW" /&gt;
288 * &lt;action android:name="android.intent.action.EDIT" /&gt;
289 * &lt;action android:name="android.intent.action.PICK" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700292 * &lt;/intent-filter&gt;
293 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
295 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
296 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700297 * &lt;/intent-filter&gt;
298 * &lt;/activity&gt;
299 *
300 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
301 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700302 * &lt;action android:name="android.intent.action.VIEW" /&gt;
303 * &lt;action android:name="android.intent.action.EDIT" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700306 * &lt;/intent-filter&gt;
307 *
308 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700309 * &lt;action android:name="android.intent.action.INSERT" /&gt;
310 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
311 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700312 * &lt;/intent-filter&gt;
313 *
314 * &lt;/activity&gt;
315 *
316 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
317 * android:theme="@android:style/Theme.Dialog"&gt;
318 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700319 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
320 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
321 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
322 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
323 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700324 * &lt;/intent-filter&gt;
325 * &lt;/activity&gt;
326 *
327 * &lt;/application&gt;
328 * &lt;/manifest&gt;</pre>
329 *
330 * <p>The first activity,
331 * <code>com.android.notepad.NotesList</code>, serves as our main
332 * entry into the app. It can do three things as described by its three intent
333 * templates:
334 * <ol>
335 * <li><pre>
336 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700337 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
338 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700339 * &lt;/intent-filter&gt;</pre>
340 * <p>This provides a top-level entry into the NotePad application: the standard
341 * MAIN action is a main entry point (not requiring any other information in
342 * the Intent), and the LAUNCHER category says that this entry point should be
343 * listed in the application launcher.</p>
344 * <li><pre>
345 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700346 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
347 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
348 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
349 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700350 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700351 * &lt;/intent-filter&gt;</pre>
352 * <p>This declares the things that the activity can do on a directory of
353 * notes. The type being supported is given with the &lt;type&gt; tag, where
354 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
355 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
356 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
357 * The activity allows the user to view or edit the directory of data (via
358 * the VIEW and EDIT actions), or to pick a particular note and return it
359 * to the caller (via the PICK action). Note also the DEFAULT category
360 * supplied here: this is <em>required</em> for the
361 * {@link Context#startActivity Context.startActivity} method to resolve your
362 * activity when its component name is not explicitly specified.</p>
363 * <li><pre>
364 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700365 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
366 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
367 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700368 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700369 * <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 -0700370 * the user without needing to know where it came from. The data type
371 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
372 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
373 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
374 * The GET_CONTENT action is similar to the PICK action, where the activity
375 * will return to its caller a piece of data selected by the user. Here,
376 * however, the caller specifies the type of data they desire instead of
377 * the type of data the user will be picking from.</p>
378 * </ol>
379 *
380 * <p>Given these capabilities, the following intents will resolve to the
381 * NotesList activity:</p>
382 *
383 * <ul>
384 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
385 * activities that can be used as top-level entry points into an
386 * application.</p>
387 * <li> <p><b>{ action=android.app.action.MAIN,
388 * category=android.app.category.LAUNCHER }</b> is the actual intent
389 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700390 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700391 * data=content://com.google.provider.NotePad/notes }</b>
392 * displays a list of all the notes under
393 * "content://com.google.provider.NotePad/notes", which
394 * the user can browse through and see the details on.</p>
395 * <li> <p><b>{ action=android.app.action.PICK
396 * data=content://com.google.provider.NotePad/notes }</b>
397 * provides a list of the notes under
398 * "content://com.google.provider.NotePad/notes", from which
399 * the user can pick a note whose data URL is returned back to the caller.</p>
400 * <li> <p><b>{ action=android.app.action.GET_CONTENT
401 * type=vnd.android.cursor.item/vnd.google.note }</b>
402 * is similar to the pick action, but allows the caller to specify the
403 * kind of data they want back so that the system can find the appropriate
404 * activity to pick something of that data type.</p>
405 * </ul>
406 *
407 * <p>The second activity,
408 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
409 * note entry and allows them to edit it. It can do two things as described
410 * by its two intent templates:
411 * <ol>
412 * <li><pre>
413 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700414 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
415 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
416 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
417 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700418 * &lt;/intent-filter&gt;</pre>
419 * <p>The first, primary, purpose of this activity is to let the user interact
420 * with a single note, as decribed by the MIME type
421 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
422 * either VIEW a note or allow the user to EDIT it. Again we support the
423 * DEFAULT category to allow the activity to be launched without explicitly
424 * specifying its component.</p>
425 * <li><pre>
426 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700427 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
428 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
429 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700430 * &lt;/intent-filter&gt;</pre>
431 * <p>The secondary use of this activity is to insert a new note entry into
432 * an existing directory of notes. This is used when the user creates a new
433 * note: the INSERT action is executed on the directory of notes, causing
434 * this activity to run and have the user create the new note data which
435 * it then adds to the content provider.</p>
436 * </ol>
437 *
438 * <p>Given these capabilities, the following intents will resolve to the
439 * NoteEditor activity:</p>
440 *
441 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700442 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700443 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
444 * shows the user the content of note <var>{ID}</var>.</p>
445 * <li> <p><b>{ action=android.app.action.EDIT
446 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
447 * allows the user to edit the content of note <var>{ID}</var>.</p>
448 * <li> <p><b>{ action=android.app.action.INSERT
449 * data=content://com.google.provider.NotePad/notes }</b>
450 * creates a new, empty note in the notes list at
451 * "content://com.google.provider.NotePad/notes"
452 * and allows the user to edit it. If they keep their changes, the URI
453 * of the newly created note is returned to the caller.</p>
454 * </ul>
455 *
456 * <p>The last activity,
457 * <code>com.android.notepad.TitleEditor</code>, allows the user to
458 * edit the title of a note. This could be implemented as a class that the
459 * application directly invokes (by explicitly setting its component in
460 * the Intent), but here we show a way you can publish alternative
461 * operations on existing data:</p>
462 *
463 * <pre>
464 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700465 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
466 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
467 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
468 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
469 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700470 * &lt;/intent-filter&gt;</pre>
471 *
472 * <p>In the single intent template here, we
473 * have created our own private action called
474 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
475 * edit the title of a note. It must be invoked on a specific note
476 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
477 * view and edit actions, but here displays and edits the title contained
478 * in the note data.
479 *
480 * <p>In addition to supporting the default category as usual, our title editor
481 * also supports two other standard categories: ALTERNATIVE and
482 * SELECTED_ALTERNATIVE. Implementing
483 * these categories allows others to find the special action it provides
484 * without directly knowing about it, through the
485 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
486 * more often to build dynamic menu items with
487 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
488 * template here was also supply an explicit name for the template
489 * (via <code>android:label="@string/resolve_title"</code>) to better control
490 * what the user sees when presented with this activity as an alternative
491 * action to the data they are viewing.
492 *
493 * <p>Given these capabilities, the following intent will resolve to the
494 * TitleEditor activity:</p>
495 *
496 * <ul>
497 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
498 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
499 * displays and allows the user to edit the title associated
500 * with note <var>{ID}</var>.</p>
501 * </ul>
502 *
503 * <h3>Standard Activity Actions</h3>
504 *
505 * <p>These are the current standard actions that Intent defines for launching
506 * activities (usually through {@link Context#startActivity}. The most
507 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
508 * {@link #ACTION_EDIT}.
509 *
510 * <ul>
511 * <li> {@link #ACTION_MAIN}
512 * <li> {@link #ACTION_VIEW}
513 * <li> {@link #ACTION_ATTACH_DATA}
514 * <li> {@link #ACTION_EDIT}
515 * <li> {@link #ACTION_PICK}
516 * <li> {@link #ACTION_CHOOSER}
517 * <li> {@link #ACTION_GET_CONTENT}
518 * <li> {@link #ACTION_DIAL}
519 * <li> {@link #ACTION_CALL}
520 * <li> {@link #ACTION_SEND}
521 * <li> {@link #ACTION_SENDTO}
522 * <li> {@link #ACTION_ANSWER}
523 * <li> {@link #ACTION_INSERT}
524 * <li> {@link #ACTION_DELETE}
525 * <li> {@link #ACTION_RUN}
526 * <li> {@link #ACTION_SYNC}
527 * <li> {@link #ACTION_PICK_ACTIVITY}
528 * <li> {@link #ACTION_SEARCH}
529 * <li> {@link #ACTION_WEB_SEARCH}
530 * <li> {@link #ACTION_FACTORY_TEST}
531 * </ul>
532 *
533 * <h3>Standard Broadcast Actions</h3>
534 *
535 * <p>These are the current standard actions that Intent defines for receiving
536 * broadcasts (usually through {@link Context#registerReceiver} or a
537 * &lt;receiver&gt; tag in a manifest).
538 *
539 * <ul>
540 * <li> {@link #ACTION_TIME_TICK}
541 * <li> {@link #ACTION_TIME_CHANGED}
542 * <li> {@link #ACTION_TIMEZONE_CHANGED}
543 * <li> {@link #ACTION_BOOT_COMPLETED}
544 * <li> {@link #ACTION_PACKAGE_ADDED}
545 * <li> {@link #ACTION_PACKAGE_CHANGED}
546 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 * <li> {@link #ACTION_PACKAGE_RESTARTED}
548 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000549 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
550 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700551 * <li> {@link #ACTION_UID_REMOVED}
552 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700553 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700554 * <li> {@link #ACTION_POWER_DISCONNECTED}
555 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700556 * </ul>
557 *
558 * <h3>Standard Categories</h3>
559 *
560 * <p>These are the current standard categories that can be used to further
561 * clarify an Intent via {@link #addCategory}.
562 *
563 * <ul>
564 * <li> {@link #CATEGORY_DEFAULT}
565 * <li> {@link #CATEGORY_BROWSABLE}
566 * <li> {@link #CATEGORY_TAB}
567 * <li> {@link #CATEGORY_ALTERNATIVE}
568 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
569 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800570 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700571 * <li> {@link #CATEGORY_HOME}
572 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400574 * <li> {@link #CATEGORY_CAR_DOCK}
575 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500576 * <li> {@link #CATEGORY_LE_DESK_DOCK}
577 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200578 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700579 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800580 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700581 * </ul>
582 *
583 * <h3>Standard Extra Data</h3>
584 *
585 * <p>These are the current standard fields that can be used as extra data via
586 * {@link #putExtra}.
587 *
588 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800589 * <li> {@link #EXTRA_ALARM_COUNT}
590 * <li> {@link #EXTRA_BCC}
591 * <li> {@link #EXTRA_CC}
592 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
593 * <li> {@link #EXTRA_DATA_REMOVED}
594 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500595 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
596 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_DOCK_STATE_CAR}
598 * <li> {@link #EXTRA_DOCK_STATE_DESK}
599 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
600 * <li> {@link #EXTRA_DONT_KILL_APP}
601 * <li> {@link #EXTRA_EMAIL}
602 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700603 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800604 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700605 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700607 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
609 * <li> {@link #EXTRA_REPLACING}
610 * <li> {@link #EXTRA_SHORTCUT_ICON}
611 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
612 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800614 * <li> {@link #EXTRA_SHORTCUT_NAME}
615 * <li> {@link #EXTRA_SUBJECT}
616 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700617 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800618 * <li> {@link #EXTRA_TITLE}
619 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 * </ul>
621 *
622 * <h3>Flags</h3>
623 *
624 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800625 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
626 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700627 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800628public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700629 private static final String ATTR_ACTION = "action";
630 private static final String TAG_CATEGORIES = "categories";
631 private static final String ATTR_CATEGORY = "category";
632 private static final String TAG_EXTRA = "extra";
633 private static final String ATTR_TYPE = "type";
634 private static final String ATTR_COMPONENT = "component";
635 private static final String ATTR_DATA = "data";
636 private static final String ATTR_FLAGS = "flags";
637
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700638 // ---------------------------------------------------------------------
639 // ---------------------------------------------------------------------
640 // Standard intent activity actions (see action variable).
641
642 /**
643 * Activity Action: Start as a main entry point, does not expect to
644 * receive data.
645 * <p>Input: nothing
646 * <p>Output: nothing
647 */
648 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
649 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800650
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700651 /**
652 * Activity Action: Display the data to the user. This is the most common
653 * action performed on data -- it is the generic action you can use on
654 * a piece of data to get the most reasonable thing to occur. For example,
655 * when used on a contacts entry it will view the entry; when used on a
656 * mailto: URI it will bring up a compose window filled with the information
657 * supplied by the URI; when used with a tel: URI it will invoke the
658 * dialer.
659 * <p>Input: {@link #getData} is URI from which to retrieve data.
660 * <p>Output: nothing.
661 */
662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
663 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700666 * Extra that can be included on activity intents coming from the storage UI
667 * when it launches sub-activities to manage various types of storage. For example,
668 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
669 * the images on the device, and in that case also include this extra to tell the
670 * app it is coming from the storage UI so should help the user manage storage of
671 * this type.
672 */
673 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
674
675 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700676 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
677 * performed on a piece of data.
678 */
679 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800680
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700681 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900682 * Activity Action: Quick view the data. Launches a quick viewer for
683 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900684 * <p>Activities handling this intent action should handle the vast majority of
685 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700686 * <p>Quick viewers must render the quick view image locally, and must not send
687 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900688 * <p>Input: {@link #getData} is a mandatory content URI of the item to
689 * preview. {@link #getClipData} contains an optional list of content URIs
690 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
691 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700692 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
693 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700694 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900695 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700696 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700697 */
698 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
699 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
700
701 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 * Used to indicate that some piece of data should be attached to some other
703 * place. For example, image data could be attached to a contact. It is up
704 * to the recipient to decide where the data should be attached; the intent
705 * does not specify the ultimate destination.
706 * <p>Input: {@link #getData} is URI of data to be attached.
707 * <p>Output: nothing.
708 */
709 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
710 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800711
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700712 /**
713 * Activity Action: Provide explicit editable access to the given data.
714 * <p>Input: {@link #getData} is URI of data to be edited.
715 * <p>Output: nothing.
716 */
717 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
718 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700720 /**
721 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
722 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
723 * The extras can contain type specific data to pass through to the editing/creating
724 * activity.
725 * <p>Output: The URI of the item that was picked. This must be a content:
726 * URI so that any receiver can access it.
727 */
728 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
729 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800730
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700731 /**
732 * Activity Action: Pick an item from the data, returning what was selected.
733 * <p>Input: {@link #getData} is URI containing a directory of data
734 * (vnd.android.cursor.dir/*) from which to pick an item.
735 * <p>Output: The URI of the item that was picked.
736 */
737 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
738 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800739
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700740 /**
741 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800742 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800743 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
744 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700745 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
746 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800747 * (value: ShortcutIconResource).</p>
748 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 * @see #EXTRA_SHORTCUT_INTENT
751 * @see #EXTRA_SHORTCUT_NAME
752 * @see #EXTRA_SHORTCUT_ICON
753 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
754 * @see android.content.Intent.ShortcutIconResource
755 */
756 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
757 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
758
759 /**
760 * The name of the extra used to define the Intent of a shortcut.
761 *
762 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
767 /**
768 * The name of the extra used to define the name of a shortcut.
769 *
770 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800771 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700772 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
775 /**
776 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
777 *
778 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800779 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700780 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800781 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
783 /**
784 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
785 *
786 * @see #ACTION_CREATE_SHORTCUT
787 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800788 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700789 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800790 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700791 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
792 "android.intent.extra.shortcut.ICON_RESOURCE";
793
794 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500795 * An activity that provides a user interface for adjusting application preferences.
796 * Optional but recommended settings for all applications which have settings.
797 */
798 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
799 public static final String ACTION_APPLICATION_PREFERENCES
800 = "android.intent.action.APPLICATION_PREFERENCES";
801
802 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700803 * Activity Action: Launch an activity showing the app information.
804 * For applications which install other applications (such as app stores), it is recommended
805 * to handle this action for providing the app information to the user.
806 *
807 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
808 * to be displayed.
809 * <p>Output: Nothing.
810 */
811 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
812 public static final String ACTION_SHOW_APP_INFO
813 = "android.intent.action.SHOW_APP_INFO";
814
815 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800816 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700817 *
818 * @see Intent#ACTION_CREATE_SHORTCUT
819 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800820 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
821 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700822 */
823 public static class ShortcutIconResource implements Parcelable {
824 /**
825 * The package name of the application containing the icon.
826 */
827 public String packageName;
828
829 /**
830 * The resource name of the icon, including package, name and type.
831 */
832 public String resourceName;
833
834 /**
835 * Creates a new ShortcutIconResource for the specified context and resource
836 * identifier.
837 *
838 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700839 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700840 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700841 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700842 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700843 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700844 ShortcutIconResource icon = new ShortcutIconResource();
845 icon.packageName = context.getPackageName();
846 icon.resourceName = context.getResources().getResourceName(resourceId);
847 return icon;
848 }
849
850 /**
851 * Used to read a ShortcutIconResource from a Parcel.
852 */
853 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
854 new Parcelable.Creator<ShortcutIconResource>() {
855
856 public ShortcutIconResource createFromParcel(Parcel source) {
857 ShortcutIconResource icon = new ShortcutIconResource();
858 icon.packageName = source.readString();
859 icon.resourceName = source.readString();
860 return icon;
861 }
862
863 public ShortcutIconResource[] newArray(int size) {
864 return new ShortcutIconResource[size];
865 }
866 };
867
868 /**
869 * No special parcel contents.
870 */
871 public int describeContents() {
872 return 0;
873 }
874
875 public void writeToParcel(Parcel dest, int flags) {
876 dest.writeString(packageName);
877 dest.writeString(resourceName);
878 }
879
880 @Override
881 public String toString() {
882 return resourceName;
883 }
884 }
885
886 /**
887 * Activity Action: Display an activity chooser, allowing the user to pick
888 * what they want to before proceeding. This can be used as an alternative
889 * to the standard activity picker that is displayed by the system when
890 * you try to start an activity with multiple possible matches, with these
891 * differences in behavior:
892 * <ul>
893 * <li>You can specify the title that will appear in the activity chooser.
894 * <li>The user does not have the option to make one of the matching
895 * activities a preferred activity, and all possible activities will
896 * always be shown even if one of them is currently marked as the
897 * preferred activity.
898 * </ul>
899 * <p>
900 * This action should be used when the user will naturally expect to
901 * select an activity in order to proceed. An example if when not to use
902 * it is when the user clicks on a "mailto:" link. They would naturally
903 * expect to go directly to their mail app, so startActivity() should be
904 * called directly: it will
905 * either launch the current preferred app, or put up a dialog allowing the
906 * user to pick an app to use and optionally marking that as preferred.
907 * <p>
908 * In contrast, if the user is selecting a menu item to send a picture
909 * they are viewing to someone else, there are many different things they
910 * may want to do at this point: send it through e-mail, upload it to a
911 * web service, etc. In this case the CHOOSER action should be used, to
912 * always present to the user a list of the things they can do, with a
913 * nice title given by the caller such as "Send this photo with:".
914 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700915 * If you need to grant URI permissions through a chooser, you must specify
916 * the permissions to be granted on the ACTION_CHOOSER Intent
917 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
918 * {@link #setClipData} to specify the URIs to be granted as well as
919 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
920 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
921 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700922 * As a convenience, an Intent of this form can be created with the
923 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700924 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700925 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700926 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
927 * and can optionally have a {@link #EXTRA_TITLE} field containing the
928 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929 * <p>
930 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700931 */
932 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
933 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
934
935 /**
936 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
937 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700938 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
939 * target intent, also optionally supplying a title. If the target
940 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
941 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
942 * set in the returned chooser intent, with its ClipData set appropriately:
943 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500944 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700945 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700946 * @param target The Intent that the user will be selecting an activity
947 * to perform.
948 * @param title Optional title that will be displayed in the chooser.
949 * @return Return a new Intent object that you can hand to
950 * {@link Context#startActivity(Intent) Context.startActivity()} and
951 * related methods.
952 */
953 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700954 return createChooser(target, title, null);
955 }
956
957 /**
958 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
959 *
960 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
961 * target intent, also optionally supplying a title. If the target
962 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
963 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
964 * set in the returned chooser intent, with its ClipData set appropriately:
965 * either a direct reflection of {@link #getClipData()} if that is non-null,
966 * or a new ClipData built from {@link #getData()}.</p>
967 *
968 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
969 * when the user makes a choice. This can be useful if the calling application wants
970 * to remember the last chosen target and surface it as a more prominent or one-touch
971 * affordance elsewhere in the UI for next time.</p>
972 *
973 * @param target The Intent that the user will be selecting an activity
974 * to perform.
975 * @param title Optional title that will be displayed in the chooser.
976 * @param sender Optional IntentSender to be called when a choice is made.
977 * @return Return a new Intent object that you can hand to
978 * {@link Context#startActivity(Intent) Context.startActivity()} and
979 * related methods.
980 */
981 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700982 Intent intent = new Intent(ACTION_CHOOSER);
983 intent.putExtra(EXTRA_INTENT, target);
984 if (title != null) {
985 intent.putExtra(EXTRA_TITLE, title);
986 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700987
Adam Powell0b3c1122014-10-09 12:50:14 -0700988 if (sender != null) {
989 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
990 }
991
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700992 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700993 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
994 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
995 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700996 if (permFlags != 0) {
997 ClipData targetClipData = target.getClipData();
998 if (targetClipData == null && target.getData() != null) {
999 ClipData.Item item = new ClipData.Item(target.getData());
1000 String[] mimeTypes;
1001 if (target.getType() != null) {
1002 mimeTypes = new String[] { target.getType() };
1003 } else {
1004 mimeTypes = new String[] { };
1005 }
1006 targetClipData = new ClipData(null, mimeTypes, item);
1007 }
1008 if (targetClipData != null) {
1009 intent.setClipData(targetClipData);
1010 intent.addFlags(permFlags);
1011 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001012 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001013
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001014 return intent;
1015 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001016
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001017 /**
1018 * Activity Action: Allow the user to select a particular kind of data and
1019 * return it. This is different than {@link #ACTION_PICK} in that here we
1020 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001021 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001022 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001023 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001024 * etc.
1025 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001026 * 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 -07001027 * of data, such as a person contact, you set the MIME type to the kind of
1028 * data you want and launch it with {@link Context#startActivity(Intent)}.
1029 * The system will then launch the best application to select that kind
1030 * of data for you.
1031 * <p>
1032 * You may also be interested in any of a set of types of content the user
1033 * can pick. For example, an e-mail application that wants to allow the
1034 * user to add an attachment to an e-mail message can use this action to
1035 * bring up a list of all of the types of content the user can attach.
1036 * <p>
1037 * In this case, you should wrap the GET_CONTENT intent with a chooser
1038 * (through {@link #createChooser}), which will give the proper interface
1039 * for the user to pick how to send your data and allow you to specify
1040 * a prompt indicating what they are doing. You will usually specify a
1041 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1042 * broad range of content types the user can select from.
1043 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001044 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001045 * only pick from data that can be represented as a stream. This is
1046 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1047 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001048 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001049 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001050 * is locally available on the device. For example, if this extra is set
1051 * to true then an image picker should not show any pictures that are available
1052 * from a remote server but not already on the local device (thus requiring
1053 * they be downloaded when opened).
1054 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001055 * If the caller can handle multiple returned items (the user performing
1056 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1057 * to indicate this.
1058 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001059 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1060 * that no URI is supplied in the intent, as there are no constraints on
1061 * where the returned data originally comes from. You may also include the
1062 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001063 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001064 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1065 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001066 * <p>
1067 * Output: The URI of the item that was picked. This must be a content:
1068 * URI so that any receiver can access it.
1069 */
1070 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1071 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1072 /**
1073 * Activity Action: Dial a number as specified by the data. This shows a
1074 * UI with the number being dialed, allowing the user to explicitly
1075 * initiate the call.
1076 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1077 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1078 * number.
1079 * <p>Output: nothing.
1080 */
1081 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1082 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1083 /**
1084 * Activity Action: Perform a call to someone specified by the data.
1085 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1086 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1087 * number.
1088 * <p>Output: nothing.
1089 *
1090 * <p>Note: there will be restrictions on which applications can initiate a
1091 * call; most applications should use the {@link #ACTION_DIAL}.
1092 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1093 * numbers. Applications can <strong>dial</strong> emergency numbers using
1094 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001095 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001096 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001097 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001098 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001099 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001100 */
1101 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1102 public static final String ACTION_CALL = "android.intent.action.CALL";
1103 /**
1104 * Activity Action: Perform a call to an emergency number specified by the
1105 * data.
1106 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1107 * tel: URI of an explicit phone number.
1108 * <p>Output: nothing.
1109 * @hide
1110 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001111 @SystemApi
1112 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001113 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1114 /**
1115 * Activity action: Perform a call to any number (emergency or not)
1116 * specified by the data.
1117 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1118 * tel: URI of an explicit phone number.
1119 * <p>Output: nothing.
1120 * @hide
1121 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001122 @SystemApi
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001124 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001125
Santos Cordon15a13782015-03-31 18:32:31 -07001126 /**
fionaxuadfe7002017-02-17 17:20:46 -08001127 * Activity Action: Main entry point for carrier setup apps.
1128 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1129 * carrier service and typically require
1130 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1131 * fulfill their duties.
1132 */
1133 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1134 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1135 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001136 * Activity Action: Send a message to someone specified by the data.
1137 * <p>Input: {@link #getData} is URI describing the target.
1138 * <p>Output: nothing.
1139 */
1140 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1141 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1142 /**
1143 * Activity Action: Deliver some data to someone else. Who the data is
1144 * being delivered to is not specified; it is up to the receiver of this
1145 * action to ask the user where the data should be sent.
1146 * <p>
1147 * When launching a SEND intent, you should usually wrap it in a chooser
1148 * (through {@link #createChooser}), which will give the proper interface
1149 * for the user to pick how to send your data and allow you to specify
1150 * a prompt indicating what they are doing.
1151 * <p>
1152 * Input: {@link #getType} is the MIME type of the data being sent.
1153 * get*Extra can have either a {@link #EXTRA_TEXT}
1154 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1155 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1156 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1157 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001158 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1159 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1160 * your text with HTML formatting.
1161 * <p>
1162 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1163 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1164 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1165 * content: URIs and other advanced features of {@link ClipData}. If
1166 * using this approach, you still must supply the same data through the
1167 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1168 * for compatibility with old applications. If you don't set a ClipData,
1169 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001170 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001171 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1172 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1173 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1174 * be openable only as asset typed files using
1175 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1176 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001177 * Optional standard extras, which may be interpreted by some recipients as
1178 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1179 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1180 * <p>
1181 * Output: nothing.
1182 */
1183 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1184 public static final String ACTION_SEND = "android.intent.action.SEND";
1185 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001186 * Activity Action: Deliver multiple data to someone else.
1187 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001188 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001189 * <p>
1190 * Input: {@link #getType} is the MIME type of the data being sent.
1191 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001192 * #EXTRA_STREAM} field, containing the data to be sent. If using
1193 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1194 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001195 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001196 * Multiple types are supported, and receivers should handle mixed types
1197 * whenever possible. The right way for the receiver to check them is to
1198 * use the content resolver on each URI. The intent sender should try to
1199 * put the most concrete mime type in the intent type, but it can fall
1200 * back to {@literal <type>/*} or {@literal *}/* as needed.
1201 * <p>
1202 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1203 * be image/jpg, but if you are sending image/jpg and image/png, then the
1204 * intent's type should be image/*.
1205 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001206 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1207 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1208 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1209 * content: URIs and other advanced features of {@link ClipData}. If
1210 * using this approach, you still must supply the same data through the
1211 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1212 * for compatibility with old applications. If you don't set a ClipData,
1213 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1214 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001215 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1216 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1217 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1218 * be openable only as asset typed files using
1219 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1220 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001221 * Optional standard extras, which may be interpreted by some recipients as
1222 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1223 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1224 * <p>
1225 * Output: nothing.
1226 */
1227 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1228 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1229 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001230 * Activity Action: Handle an incoming phone call.
1231 * <p>Input: nothing.
1232 * <p>Output: nothing.
1233 */
1234 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1235 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1236 /**
1237 * Activity Action: Insert an empty item into the given container.
1238 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1239 * in which to place the data.
1240 * <p>Output: URI of the new data that was created.
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1244 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001245 * Activity Action: Create a new item in the given container, initializing it
1246 * from the current contents of the clipboard.
1247 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1248 * in which to place the data.
1249 * <p>Output: URI of the new data that was created.
1250 */
1251 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1252 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1253 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001254 * Activity Action: Delete the given data from its container.
1255 * <p>Input: {@link #getData} is URI of data to be deleted.
1256 * <p>Output: nothing.
1257 */
1258 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1259 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1260 /**
1261 * Activity Action: Run the data, whatever that means.
1262 * <p>Input: ? (Note: this is currently specific to the test harness.)
1263 * <p>Output: nothing.
1264 */
1265 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1266 public static final String ACTION_RUN = "android.intent.action.RUN";
1267 /**
1268 * Activity Action: Perform a data synchronization.
1269 * <p>Input: ?
1270 * <p>Output: ?
1271 */
1272 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1273 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1274 /**
1275 * Activity Action: Pick an activity given an intent, returning the class
1276 * selected.
1277 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1278 * used with {@link PackageManager#queryIntentActivities} to determine the
1279 * set of activities from which to pick.
1280 * <p>Output: Class name of the activity that was selected.
1281 */
1282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1283 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1284 /**
1285 * Activity Action: Perform a search.
1286 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1287 * is the text to search for. If empty, simply
1288 * enter your search results Activity with the search UI activated.
1289 * <p>Output: nothing.
1290 */
1291 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1292 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1293 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001294 * Activity Action: Start the platform-defined tutorial
1295 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1296 * is the text to search for. If empty, simply
1297 * enter your search results Activity with the search UI activated.
1298 * <p>Output: nothing.
1299 */
1300 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1301 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1302 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001303 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001304 * <p>
1305 * Input: {@link android.app.SearchManager#QUERY
1306 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1307 * a url starts with http or https, the site will be opened. If it is plain
1308 * text, Google search will be applied.
1309 * <p>
1310 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001311 */
1312 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1313 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001314
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001315 /**
Jim Miller07994402012-05-02 14:22:27 -07001316 * Activity Action: Perform assist action.
1317 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001318 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1319 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001320 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1321 * information.
Jim Miller07994402012-05-02 14:22:27 -07001322 * Output: nothing.
1323 */
1324 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1325 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001326
1327 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001328 * Activity Action: Perform voice assist action.
1329 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001330 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1331 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001332 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001333 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001334 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001335 */
Amith Yamasani16452032017-03-03 10:15:57 -08001336 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001337 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1338 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1339
1340 /**
Adam Skory7140a252013-09-11 12:04:58 +01001341 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1342 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001343 */
1344 public static final String EXTRA_ASSIST_PACKAGE
1345 = "android.intent.extra.ASSIST_PACKAGE";
1346
1347 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001348 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1349 * application package at the time the assist was invoked.
1350 */
1351 public static final String EXTRA_ASSIST_UID
1352 = "android.intent.extra.ASSIST_UID";
1353
1354 /**
Adam Skory7140a252013-09-11 12:04:58 +01001355 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1356 * information supplied by the current foreground app at the time of the assist request.
1357 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001358 */
1359 public static final String EXTRA_ASSIST_CONTEXT
1360 = "android.intent.extra.ASSIST_CONTEXT";
1361
Jim Miller07994402012-05-02 14:22:27 -07001362 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001363 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1364 * keyboard as the primary input device for assistance.
1365 */
1366 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1367 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1368
1369 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001370 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1371 * that was used to invoke the assist.
1372 */
1373 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1374 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1375
1376 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001377 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001378 * <p>Input: Nothing.
1379 * <p>Output: nothing.
1380 */
1381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1382 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1383 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001384 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001385 * <p>Input: Nothing.
1386 * <p>Output: Nothing.
1387 */
1388 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1389 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1390
1391 /**
1392 * Activity Action: Show activity for reporting a bug.
1393 * <p>Input: Nothing.
1394 * <p>Output: Nothing.
1395 */
1396 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1397 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1398
1399 /**
1400 * Activity Action: Main entry point for factory tests. Only used when
1401 * the device is booting in factory test node. The implementing package
1402 * must be installed in the system image.
1403 * <p>Input: nothing
1404 * <p>Output: nothing
1405 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001407 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1408
1409 /**
1410 * Activity Action: The user pressed the "call" button to go to the dialer
1411 * or other appropriate UI for placing a call.
1412 * <p>Input: Nothing.
1413 * <p>Output: Nothing.
1414 */
1415 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1416 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1417
1418 /**
1419 * Activity Action: Start Voice Command.
1420 * <p>Input: Nothing.
1421 * <p>Output: Nothing.
1422 */
1423 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1424 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001425
1426 /**
1427 * Activity Action: Start action associated with long pressing on the
1428 * search key.
1429 * <p>Input: Nothing.
1430 * <p>Output: Nothing.
1431 */
1432 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1433 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001434
Jacek Surazski86b6c532009-05-13 14:38:28 +02001435 /**
1436 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1437 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001438 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001439 * <p>Input: No data is specified. The bug report is passed in using
1440 * an {@link #EXTRA_BUG_REPORT} field.
1441 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001442 *
1443 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001444 */
1445 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1446 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001447
1448 /**
1449 * Activity Action: Show power usage information to the user.
1450 * <p>Input: Nothing.
1451 * <p>Output: Nothing.
1452 */
1453 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1454 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001455
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001456 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001457 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1458 * to run.
1459 * <p>Input: Nothing.
1460 * <p>Output: Nothing.
1461 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1462 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1463 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001464 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001465 */
1466 @Deprecated
1467 @SystemApi
1468 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1469 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1470
1471 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001472 * Activity Action: Setup wizard to launch after a platform update. This
1473 * activity should have a string meta-data field associated with it,
1474 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1475 * the platform for setup. The activity will be launched only if
1476 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1477 * same value.
1478 * <p>Input: Nothing.
1479 * <p>Output: Nothing.
1480 * @hide
1481 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001482 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001483 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1484 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001485
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001486 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001487 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1488 * <p>Input: Nothing.
1489 * <p>Output: Nothing.
1490 * @hide
1491 */
1492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1493 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001494 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001495
1496 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001497 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1498 * <p>Input: Nothing.
1499 * <p>Output: Nothing.
1500 * @hide
1501 */
1502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1503 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001504 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001505
1506 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001507 * Activity Action: Show settings for managing network data usage of a
1508 * specific application. Applications should define an activity that offers
1509 * options to control data usage.
1510 */
1511 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1512 public static final String ACTION_MANAGE_NETWORK_USAGE =
1513 "android.intent.action.MANAGE_NETWORK_USAGE";
1514
1515 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001516 * Activity Action: Launch application installer.
1517 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001518 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001519 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1520 * you can also use "package:<package-name>" to install an application for the
1521 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001522 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1523 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1524 * <p>
1525 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1526 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001527 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001528 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001529 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1530 * in order to launch the application installer.
1531 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001532 *
1533 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1534 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1535 * @see #EXTRA_RETURN_RESULT
1536 */
1537 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1538 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1539
1540 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001541 * Activity Action: Activity to handle split installation failures.
1542 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1543 * but the split that contains the application isn't installed. When a split is
1544 * installed in this manner, the containing package usually doesn't know this is
1545 * happening. However, if an error occurs during installation, the containing
1546 * package can define a single activity handling this action to deal with such
1547 * failures.
1548 * <p>The activity handling this action must be in the base package.
1549 * <p>
1550 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1551 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1552 */
1553 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1554 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1555
1556 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001557 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001558 * <p class="note">
1559 * This is a protected intent that can only be sent by the system.
1560 * </p>
1561 *
1562 * @hide
1563 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001564 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001565 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001566 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1567 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001568
1569 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001570 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001571 * <p>
1572 * The system will have a persistent connection to this service.
1573 * This is a protected intent that can only be sent by the system.
1574 * </p>
1575 *
1576 * @hide
1577 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001579 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001580 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1581 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001582
1583 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001584 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001585 *
1586 * <p class="note">
1587 * This is a protected intent that can only be sent by the system.
1588 * </p>
1589 *
1590 * @hide
1591 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001592 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001593 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001594 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1595 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001596
1597 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001598 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1599 * package. Specifies the installer package name; this package will receive the
1600 * {@link #ACTION_APP_ERROR} intent.
1601 */
1602 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1603 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1604
1605 /**
1606 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1607 * package. Specifies that the application being installed should not be
1608 * treated as coming from an unknown source, but as coming from the app
1609 * invoking the Intent. For this to work you must start the installer with
1610 * startActivityForResult().
1611 */
1612 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1613 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1614
1615 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001616 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1617 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001618 * data field originated from.
1619 */
rich cannings706e8ba2012-08-20 13:20:14 -07001620 public static final String EXTRA_ORIGINATING_URI
1621 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001622
1623 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001624 * This extra can be used with any Intent used to launch an activity, supplying information
1625 * about who is launching that activity. This field contains a {@link android.net.Uri}
1626 * object, typically an http: or https: URI of the web site that the referral came from;
1627 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1628 * a native application that it came from.
1629 *
1630 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1631 * instead of directly retrieving the extra. It is also valid for applications to
1632 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1633 * a string, not a Uri; the field here, if supplied, will always take precedence,
1634 * however.</p>
1635 *
1636 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001637 */
1638 public static final String EXTRA_REFERRER
1639 = "android.intent.extra.REFERRER";
1640
1641 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001642 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1643 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1644 * not be created, in particular when Intent extras are supplied through the
1645 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1646 * schemes.
1647 *
1648 * @see #EXTRA_REFERRER
1649 */
1650 public static final String EXTRA_REFERRER_NAME
1651 = "android.intent.extra.REFERRER_NAME";
1652
1653 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001654 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001655 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001656 * Currently only a system app that hosts the provider authority "downloads" or holds the
1657 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001658 * @hide
1659 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001660 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001661 public static final String EXTRA_ORIGINATING_UID
1662 = "android.intent.extra.ORIGINATING_UID";
1663
1664 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001665 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1666 * package. Tells the installer UI to skip the confirmation with the user
1667 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001668 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1669 * will no longer show an interstitial message about updating existing
1670 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001671 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001672 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001673 public static final String EXTRA_ALLOW_REPLACE
1674 = "android.intent.extra.ALLOW_REPLACE";
1675
1676 /**
1677 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1678 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1679 * return to the application the result code of the install/uninstall. The returned result
1680 * code will be {@link android.app.Activity#RESULT_OK} on success or
1681 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1682 */
1683 public static final String EXTRA_RETURN_RESULT
1684 = "android.intent.extra.RETURN_RESULT";
1685
1686 /**
1687 * Package manager install result code. @hide because result codes are not
1688 * yet ready to be exposed.
1689 */
1690 public static final String EXTRA_INSTALL_RESULT
1691 = "android.intent.extra.INSTALL_RESULT";
1692
1693 /**
1694 * Activity Action: Launch application uninstaller.
1695 * <p>
1696 * Input: The data must be a package: URI whose scheme specific part is
1697 * the package name of the current installed package to be uninstalled.
1698 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1699 * <p>
1700 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1701 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001702 * <p>
1703 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1704 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001705 */
1706 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1707 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1708
1709 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001710 * Specify whether the package should be uninstalled for all users.
1711 * @hide because these should not be part of normal application flow.
1712 */
1713 public static final String EXTRA_UNINSTALL_ALL_USERS
1714 = "android.intent.extra.UNINSTALL_ALL_USERS";
1715
1716 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001717 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1718 * describing the last run version of the platform that was setup.
1719 * @hide
1720 */
1721 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1722
Svet Ganov3695b8a2015-03-24 16:30:25 -07001723 /**
1724 * Activity action: Launch UI to manage the permissions of an app.
1725 * <p>
1726 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1727 * will be managed by the launched UI.
1728 * </p>
1729 * <p>
1730 * Output: Nothing.
1731 * </p>
1732 *
1733 * @see #EXTRA_PACKAGE_NAME
1734 *
1735 * @hide
1736 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001737 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001738 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1739 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1740 "android.intent.action.MANAGE_APP_PERMISSIONS";
1741
1742 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001743 * Activity action: Launch UI to manage permissions.
1744 * <p>
1745 * Input: Nothing.
1746 * </p>
1747 * <p>
1748 * Output: Nothing.
1749 * </p>
1750 *
1751 * @hide
1752 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001753 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001754 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1755 public static final String ACTION_MANAGE_PERMISSIONS =
1756 "android.intent.action.MANAGE_PERMISSIONS";
1757
1758 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001759 * Activity action: Launch UI to review permissions for an app.
1760 * The system uses this intent if permission review for apps not
1761 * supporting the new runtime permissions model is enabled. In
1762 * this mode a permission review is required before any of the
1763 * app components can run.
1764 * <p>
1765 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1766 * permissions will be reviewed (mandatory).
1767 * </p>
1768 * <p>
1769 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1770 * be fired after the permission review (optional).
1771 * </p>
1772 * <p>
1773 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1774 * be invoked after the permission review (optional).
1775 * </p>
1776 * <p>
1777 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1778 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1779 * </p>
1780 * <p>
1781 * Output: Nothing.
1782 * </p>
1783 *
1784 * @see #EXTRA_PACKAGE_NAME
1785 * @see #EXTRA_INTENT
1786 * @see #EXTRA_REMOTE_CALLBACK
1787 * @see #EXTRA_RESULT_NEEDED
1788 *
1789 * @hide
1790 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001791 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001792 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1793 public static final String ACTION_REVIEW_PERMISSIONS =
1794 "android.intent.action.REVIEW_PERMISSIONS";
1795
1796 /**
1797 * Intent extra: A callback for reporting remote result as a bundle.
1798 * <p>
1799 * Type: IRemoteCallback
1800 * </p>
1801 *
1802 * @hide
1803 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001804 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001805 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1806
1807 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001808 * Intent extra: An app package name.
1809 * <p>
1810 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001811 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001812 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001813 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001814 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1815
1816 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001817 * Intent extra: An app split name.
1818 * <p>
1819 * Type: String
1820 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001821 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001822 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1823
1824 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001825 * Intent extra: A {@link ComponentName} value.
1826 * <p>
1827 * Type: String
1828 * </p>
1829 */
1830 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1831
1832 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001833 * Intent extra: An extra for specifying whether a result is needed.
1834 * <p>
1835 * Type: boolean
1836 * </p>
1837 *
1838 * @hide
1839 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001840 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001841 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1842
1843 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001844 * Activity action: Launch UI to manage which apps have a given permission.
1845 * <p>
1846 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1847 * to which will be managed by the launched UI.
1848 * </p>
1849 * <p>
1850 * Output: Nothing.
1851 * </p>
1852 *
1853 * @see #EXTRA_PERMISSION_NAME
1854 *
1855 * @hide
1856 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001857 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001858 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1859 public static final String ACTION_MANAGE_PERMISSION_APPS =
1860 "android.intent.action.MANAGE_PERMISSION_APPS";
1861
1862 /**
1863 * Intent extra: The name of a permission.
1864 * <p>
1865 * Type: String
1866 * </p>
1867 *
1868 * @hide
1869 */
1870 @SystemApi
1871 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1872
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001873 // ---------------------------------------------------------------------
1874 // ---------------------------------------------------------------------
1875 // Standard intent broadcast actions (see action variable).
1876
1877 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001878 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1879 * <p>
1880 * For historical reasons, the name of this broadcast action refers to the power
1881 * state of the screen but it is actually sent in response to changes in the
1882 * overall interactive state of the device.
1883 * </p><p>
1884 * This broadcast is sent when the device becomes non-interactive which may have
1885 * nothing to do with the screen turning off. To determine the
1886 * actual state of the screen, use {@link android.view.Display#getState}.
1887 * </p><p>
1888 * See {@link android.os.PowerManager#isInteractive} for details.
1889 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001890 * You <em>cannot</em> receive this through components declared in
1891 * manifests, only by explicitly registering for it with
1892 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1893 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001895 * <p class="note">This is a protected intent that can only be sent
1896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1899 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001900
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001901 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001902 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1903 * <p>
1904 * For historical reasons, the name of this broadcast action refers to the power
1905 * state of the screen but it is actually sent in response to changes in the
1906 * overall interactive state of the device.
1907 * </p><p>
1908 * This broadcast is sent when the device becomes interactive which may have
1909 * nothing to do with the screen turning on. To determine the
1910 * actual state of the screen, use {@link android.view.Display#getState}.
1911 * </p><p>
1912 * See {@link android.os.PowerManager#isInteractive} for details.
1913 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001914 * You <em>cannot</em> receive this through components declared in
1915 * manifests, only by explicitly registering for it with
1916 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1917 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001918 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001919 * <p class="note">This is a protected intent that can only be sent
1920 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001921 */
1922 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1923 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001924
1925 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001926 * Broadcast Action: Sent after the system stops dreaming.
1927 *
1928 * <p class="note">This is a protected intent that can only be sent by the system.
1929 * It is only sent to registered receivers.</p>
1930 */
1931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1933
1934 /**
1935 * Broadcast Action: Sent after the system starts dreaming.
1936 *
1937 * <p class="note">This is a protected intent that can only be sent by the system.
1938 * It is only sent to registered receivers.</p>
1939 */
1940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1941 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1942
1943 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001944 * 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 -07001945 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001946 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001947 * <p class="note">This is a protected intent that can only be sent
1948 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001949 */
1950 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001951 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001952
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001953 /**
1954 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001955 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001956 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001957 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1958 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001959 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001960 * <p class="note">This is a protected intent that can only be sent
1961 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 */
1963 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1964 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1965 /**
1966 * Broadcast Action: The time was set.
1967 */
1968 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1969 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1970 /**
1971 * Broadcast Action: The date has changed.
1972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1975 /**
1976 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1977 * <ul>
1978 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1979 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001980 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001981 * <p class="note">This is a protected intent that can only be sent
1982 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1985 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1986 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001987 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1988 * DNS entries should be tossed.
1989 * @hide
1990 */
1991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1993 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001994 * Alarm Changed Action: This is broadcast when the AlarmClock
1995 * application's alarm is set or unset. It is used by the
1996 * AlarmClock application and the StatusBar service.
1997 * @hide
1998 */
1999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2000 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002001
2002 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002003 * Broadcast Action: This is broadcast once, after the user has finished
2004 * booting, but while still in the "locked" state. It can be used to perform
2005 * application-specific initialization, such as installing alarms. You must
2006 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2007 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002008 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002009 * This broadcast is sent immediately at boot by all devices (regardless of
2010 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2011 * higher. Upon receipt of this broadcast, the user is still locked and only
2012 * device-protected storage can be accessed safely. If you want to access
2013 * credential-protected storage, you need to wait for the user to be
2014 * unlocked (typically by entering their lock pattern or PIN for the first
2015 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2016 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2017 * <p>
2018 * To receive this broadcast, your receiver component must be marked as
2019 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002020 * <p class="note">
2021 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002022 *
2023 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002024 */
2025 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2026 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2027
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002028 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002029 * Broadcast Action: This is broadcast once, after the user has finished
2030 * booting. It can be used to perform application-specific initialization,
2031 * such as installing alarms. You must hold the
2032 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2033 * order to receive this broadcast.
2034 * <p>
2035 * This broadcast is sent at boot by all devices (both with and without
2036 * direct boot support). Upon receipt of this broadcast, the user is
2037 * unlocked and both device-protected and credential-protected storage can
2038 * accessed safely.
2039 * <p>
2040 * If you need to run while the user is still locked (before they've entered
2041 * their lock pattern or PIN for the first time), you can listen for the
2042 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2043 * <p class="note">
2044 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002047 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002048 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002049
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002050 /**
2051 * Broadcast Action: This is broadcast when a user action should request a
2052 * temporary system dialog to dismiss. Some examples of temporary system
2053 * dialogs are the notification window-shade and the recent tasks dialog.
2054 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002056 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2057 /**
2058 * Broadcast Action: Trigger the download and eventual installation
2059 * of a package.
2060 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002061 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002062 * <p class="note">This is a protected intent that can only be sent
2063 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002064 *
2065 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002067 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002068 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2069 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2070 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002071 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002072 * device. The data contains the name of the package. Note that the
2073 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002074 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002075 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002076 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2077 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002078 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2079 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002080 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002081 * <p class="note">This is a protected intent that can only be sent
2082 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002083 */
2084 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2085 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2086 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002087 * Broadcast Action: A new version of an application package has been
2088 * installed, replacing an existing version that was previously installed.
2089 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002090 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002091 * <ul>
2092 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2093 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002094 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002095 * <p class="note">This is a protected intent that can only be sent
2096 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002097 */
2098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2099 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2100 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002101 * Broadcast Action: A new version of your application has been installed
2102 * over an existing one. This is only sent to the application that was
2103 * replaced. It does not contain any additional data; to receive it, just
2104 * use an intent filter for this action.
2105 *
2106 * <p class="note">This is a protected intent that can only be sent
2107 * by the system.
2108 */
2109 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2110 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2111 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002112 * Broadcast Action: An existing application package has been removed from
2113 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002114 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002115 * <ul>
2116 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2117 * to the package.
2118 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2119 * application -- data and code -- is being removed.
2120 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2121 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2122 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002123 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2129 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002130 * Broadcast Action: An existing application package has been completely
2131 * removed from the device. The data contains the name of the package.
2132 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2133 * {@link #EXTRA_DATA_REMOVED} is true and
2134 * {@link #EXTRA_REPLACING} is false of that broadcast.
2135 *
2136 * <ul>
2137 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2138 * to the package.
2139 * </ul>
2140 *
2141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system.
2143 */
2144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2145 public static final String ACTION_PACKAGE_FULLY_REMOVED
2146 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2147 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002148 * Broadcast Action: An existing application package has been changed (for
2149 * example, a component has been enabled or disabled). The data contains
2150 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002151 * <ul>
2152 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002153 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002154 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002155 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2156 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002157 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002158 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002159 * <p class="note">This is a protected intent that can only be sent
2160 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002161 */
2162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2163 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2164 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002165 * @hide
2166 * Broadcast Action: Ask system services if there is any reason to
2167 * restart the given package. The data contains the name of the
2168 * package.
2169 * <ul>
2170 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2171 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2172 * </ul>
2173 *
2174 * <p class="note">This is a protected intent that can only be sent
2175 * by the system.
2176 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002177 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2180 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002181 * Broadcast Action: The user has restarted a package, and all of its
2182 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002183 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002184 * be removed. Note that the restarted package does <em>not</em>
2185 * receive this broadcast.
2186 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002187 * <ul>
2188 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2189 * </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_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2196 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002197 * Broadcast Action: The user has cleared the data of a package. This should
2198 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002199 * its persistent data is erased and this broadcast sent.
2200 * Note that the cleared package does <em>not</em>
2201 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002202 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002203 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2204 * package whose data was cleared is an uninstalled instant app, then the UID
2205 * will be -1. The platform keeps some meta-data associated with instant apps
2206 * after they are uninstalled.
2207 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2208 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002209 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002210 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002211 * <p class="note">This is a protected intent that can only be sent
2212 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002213 */
2214 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2215 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2216 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002217 * Broadcast Action: Packages have been suspended.
2218 * <p>Includes the following extras:
2219 * <ul>
2220 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2221 * </ul>
2222 *
2223 * <p class="note">This is a protected intent that can only be sent
2224 * by the system. It is only sent to registered receivers.
2225 */
2226 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2227 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2228 /**
2229 * Broadcast Action: Packages have been unsuspended.
2230 * <p>Includes the following extras:
2231 * <ul>
2232 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2233 * </ul>
2234 *
2235 * <p class="note">This is a protected intent that can only be sent
2236 * by the system. It is only sent to registered receivers.
2237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2240 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002241 * Broadcast Action: A user ID has been removed from the system. The user
2242 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002243 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002244 * <p class="note">This is a protected intent that can only be sent
2245 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002246 */
2247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2248 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002249
2250 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002251 * Broadcast Action: Sent to the installer package of an application when
2252 * that application is first launched (that is the first time it is moved
2253 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002254 *
2255 * <p class="note">This is a protected intent that can only be sent
2256 * by the system.
2257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2259 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2260
2261 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002262 * Broadcast Action: Sent to the system package verifier when a package
2263 * needs to be verified. The data contains the package URI.
2264 * <p class="note">
2265 * This is a protected intent that can only be sent by the system.
2266 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002267 */
2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2269 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2270
2271 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002272 * Broadcast Action: Sent to the system package verifier when a package is
2273 * verified. The data contains the package URI.
2274 * <p class="note">
2275 * This is a protected intent that can only be sent by the system.
2276 */
2277 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2278 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2279
2280 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002281 * Broadcast Action: Sent to the system intent filter verifier when an
2282 * intent filter needs to be verified. The data contains the filter data
2283 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002284 * <p class="note">
2285 * This is a protected intent that can only be sent by the system.
2286 * </p>
2287 *
2288 * @hide
2289 */
2290 @SystemApi
2291 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2292 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2293
2294 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002295 * Broadcast Action: Resources for a set of packages (which were
2296 * previously unavailable) are currently
2297 * available since the media on which they exist is available.
2298 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2299 * list of packages whose availability changed.
2300 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2301 * list of uids of packages whose availability changed.
2302 * Note that the
2303 * packages in this list do <em>not</em> receive this broadcast.
2304 * The specified set of packages are now available on the system.
2305 * <p>Includes the following extras:
2306 * <ul>
2307 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2308 * whose resources(were previously unavailable) are currently available.
2309 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2310 * packages whose resources(were previously unavailable)
2311 * are currently available.
2312 * </ul>
2313 *
2314 * <p class="note">This is a protected intent that can only be sent
2315 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002316 */
2317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002318 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2319 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002320
2321 /**
2322 * Broadcast Action: Resources for a set of packages are currently
2323 * unavailable since the media on which they exist is unavailable.
2324 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2325 * list of packages whose availability changed.
2326 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2327 * list of uids of packages whose availability changed.
2328 * The specified set of packages can no longer be
2329 * launched and are practically unavailable on the system.
2330 * <p>Inclues the following extras:
2331 * <ul>
2332 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2333 * whose resources are no longer available.
2334 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2335 * whose resources are no longer available.
2336 * </ul>
2337 *
2338 * <p class="note">This is a protected intent that can only be sent
2339 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002340 */
2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002342 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002343 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002344
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002345 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002346 * Broadcast Action: preferred activities have changed *explicitly*.
2347 *
2348 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2349 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2350 * be sent.
2351 *
2352 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2353 *
2354 * @hide
2355 */
2356 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2357 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2358 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2359
2360
2361 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002362 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002363 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002364 * This should <em>only</em> be used to determine when the wallpaper
2365 * has changed to show the new wallpaper to the user. You should certainly
2366 * never, in response to this, change the wallpaper or other attributes of
2367 * it such as the suggested size. That would be crazy, right? You'd cause
2368 * all kinds of loops, especially if other apps are doing similar things,
2369 * right? Of course. So please don't do this.
2370 *
2371 * @deprecated Modern applications should use
2372 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2373 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2374 * shown behind their UI, rather than watching for this broadcast and
2375 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002376 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002377 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002378 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2379 /**
2380 * Broadcast Action: The current device {@link android.content.res.Configuration}
2381 * (orientation, locale, etc) has changed. When such a change happens, the
2382 * UIs (view hierarchy) will need to be rebuilt based on this new
2383 * information; for the most part, applications don't need to worry about
2384 * this, because the system will take care of stopping and restarting the
2385 * application to make sure it sees the new changes. Some system code that
2386 * can not be restarted will need to watch for this action and handle it
2387 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002388 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002389 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002390 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002391 * in manifests, only by explicitly registering for it with
2392 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2393 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002394 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002395 * <p class="note">This is a protected intent that can only be sent
2396 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002397 *
2398 * @see android.content.res.Configuration
2399 */
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002402
2403 /**
2404 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2405 * such that the device may be eligible for the installation of additional configuration splits.
2406 * Configuration properties that can trigger this broadcast include locale and display density.
2407 *
2408 * <p class="note">
2409 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2410 * components declared in manifests. However, the receiver <em>must</em> hold the
2411 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2412 *
2413 * <p class="note">
2414 * This is a protected intent that can only be sent by the system.
2415 *
2416 * @hide
2417 */
2418 @SystemApi
2419 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2420 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2421 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002423 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002424 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002425 * <p class="note">This is a protected intent that can only be sent
2426 * by the system.
2427 */
2428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2429 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2430 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002431 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2432 * charging state, level, and other information about the battery.
2433 * See {@link android.os.BatteryManager} for documentation on the
2434 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002435 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002437 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002438 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002439 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002440 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2441 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2442 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2443 * broadcasts that are sent and can be received through manifest
2444 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002445 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002446 * <p class="note">This is a protected intent that can only be sent
2447 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2450 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002451
2452
2453 /**
2454 * Broadcast Action: Sent when the current battery level changes.
2455 *
2456 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2457 * instances representing individual battery level changes with associated
2458 * extras from {@link #ACTION_BATTERY_CHANGED}.
2459 *
2460 * <p class="note">
2461 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2462 *
2463 * @hide
2464 */
2465 @SystemApi
2466 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2467 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 /**
2469 * Broadcast Action: Indicates low battery condition on the device.
2470 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002471 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002472 * <p class="note">This is a protected intent that can only be sent
2473 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2476 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2477 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002478 * Broadcast Action: Indicates the battery is now okay after being low.
2479 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2480 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002481 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002482 * <p class="note">This is a protected intent that can only be sent
2483 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2486 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2487 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002488 * Broadcast Action: External power has been connected to the device.
2489 * This is intended for applications that wish to register specifically to this notification.
2490 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2491 * stay active to receive this notification. This action can be used to implement actions
2492 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002493 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002494 * <p class="note">This is a protected intent that can only be sent
2495 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002498 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002499 /**
2500 * Broadcast Action: External power has been removed from the device.
2501 * This is intended for applications that wish to register specifically to this notification.
2502 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2503 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002504 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002505 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002506 * <p class="note">This is a protected intent that can only be sent
2507 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002508 */
2509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002510 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002511 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002512 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002513 * Broadcast Action: Device is shutting down.
2514 * This is broadcast when the device is being shut down (completely turned
2515 * off, not sleeping). Once the broadcast is complete, the final shutdown
2516 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002517 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002518 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2519 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2520 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002521 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002522 * <p class="note">This is a protected intent that can only be sent
2523 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002524 * <p>May include the following extras:
2525 * <ul>
2526 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2527 * shutdown is only for userspace processes. If not set, assumed to be false.
2528 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002529 */
2530 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002531 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002532 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002533 * Activity Action: Start this activity to request system shutdown.
2534 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002535 * to request confirmation from the user before shutting down. The optional boolean
2536 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2537 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002538 *
2539 * <p class="note">This is a protected intent that can only be sent
2540 * by the system.
2541 *
2542 * {@hide}
2543 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002544 public static final String ACTION_REQUEST_SHUTDOWN
2545 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002546 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002547 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002548 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 * <p class="note">
2550 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002551 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2553 * or above, this broadcast will no longer be delivered to any
2554 * {@link BroadcastReceiver} defined in your manifest. Instead,
2555 * apps are strongly encouraged to use the improved
2556 * {@link Context#getCacheDir()} behavior so the system can
2557 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002558 */
2559 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002560 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002561 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2562 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002563 * Broadcast Action: Indicates low storage space condition on the device no
2564 * longer exists
2565 * <p class="note">
2566 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002567 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002568 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2569 * or above, this broadcast will no longer be delivered to any
2570 * {@link BroadcastReceiver} defined in your manifest. Instead,
2571 * apps are strongly encouraged to use the improved
2572 * {@link Context#getCacheDir()} behavior so the system can
2573 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002576 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002577 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2578 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002579 * Broadcast Action: A sticky broadcast that indicates a storage space full
2580 * condition on the device. This is intended for activities that want to be
2581 * able to fill the data partition completely, leaving only enough free
2582 * space to prevent system-wide SQLite failures.
2583 * <p class="note">
2584 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002585 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002586 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2587 * or above, this broadcast will no longer be delivered to any
2588 * {@link BroadcastReceiver} defined in your manifest. Instead,
2589 * apps are strongly encouraged to use the improved
2590 * {@link Context#getCacheDir()} behavior so the system can
2591 * automatically free up storage when needed.
2592 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002593 */
2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002595 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002596 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2597 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002598 * Broadcast Action: Indicates storage space full condition on the device no
2599 * longer exists.
2600 * <p class="note">
2601 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002602 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002603 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2604 * or above, this broadcast will no longer be delivered to any
2605 * {@link BroadcastReceiver} defined in your manifest. Instead,
2606 * apps are strongly encouraged to use the improved
2607 * {@link Context#getCacheDir()} behavior so the system can
2608 * automatically free up storage when needed.
2609 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002610 */
2611 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002612 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002613 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2614 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2616 * and package management should be started.
2617 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2618 * notification.
2619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2622 /**
2623 * Broadcast Action: The device has entered USB Mass Storage mode.
2624 * This is used mainly for the USB Settings panel.
2625 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2626 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002627 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002628 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002629 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002631 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2632
2633 /**
2634 * Broadcast Action: The device has exited USB Mass Storage mode.
2635 * This is used mainly for the USB Settings panel.
2636 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2637 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002638 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002639 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002640 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002642 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2643
2644 /**
2645 * Broadcast Action: External media has been removed.
2646 * The path to the mount point for the removed media is contained in the Intent.mData field.
2647 */
2648 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2649 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2650
2651 /**
2652 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002653 * 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 -07002654 */
2655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2656 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2657
2658 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002659 * Broadcast Action: External media is present, and being disk-checked
2660 * 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 -08002661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2664
2665 /**
2666 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2667 * 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 -08002668 */
2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2670 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2671
2672 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002674 * 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 -07002675 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2676 * media was mounted read only.
2677 */
2678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2679 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2680
2681 /**
2682 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002683 * 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 -07002684 */
2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2686 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2687
2688 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002689 * Broadcast Action: External media is no longer being shared via USB mass storage.
2690 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2691 *
2692 * @hide
2693 */
2694 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2695
2696 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002697 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2698 * The path to the mount point for the removed media is contained in the Intent.mData field.
2699 */
2700 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2701 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2702
2703 /**
2704 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002705 * 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 -07002706 */
2707 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2708 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2709
2710 /**
2711 * Broadcast Action: User has expressed the desire to remove the external storage media.
2712 * Applications should close all files they have open within the mount point when they receive this intent.
2713 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2714 */
2715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2716 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2717
2718 /**
2719 * Broadcast Action: The media scanner has started scanning a directory.
2720 * The path to the directory being scanned is contained in the Intent.mData field.
2721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2724
2725 /**
2726 * Broadcast Action: The media scanner has finished scanning a directory.
2727 * The path to the scanned directory is contained in the Intent.mData field.
2728 */
2729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2730 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2731
2732 /**
2733 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2734 * The path to the file is contained in the Intent.mData field.
2735 */
2736 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2737 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2738
2739 /**
2740 * Broadcast Action: The "Media Button" was pressed. Includes a single
2741 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2742 * caused the broadcast.
2743 */
2744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2746
2747 /**
2748 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2749 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2750 * caused the broadcast.
2751 */
2752 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2753 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2754
2755 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2756 // location; they are not general-purpose actions.
2757
2758 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002759 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2763 "android.intent.action.GTALK_CONNECTED";
2764
2765 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002766 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 */
2768 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2769 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2770 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002771
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002772 /**
2773 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002774 */
2775 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2776 public static final String ACTION_INPUT_METHOD_CHANGED =
2777 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778
2779 /**
2780 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2781 * more radios have been turned off or on. The intent will have the following extra value:</p>
2782 * <ul>
2783 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2784 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2785 * turned off</li>
2786 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002787 *
Peng Xua35b5532016-01-20 00:05:45 -08002788 * <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 -07002789 */
2790 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2791 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2792
2793 /**
2794 * Broadcast Action: Some content providers have parts of their namespace
2795 * where they publish new events or items that the user may be especially
2796 * interested in. For these things, they may broadcast this action when the
2797 * set of interesting items change.
2798 *
2799 * For example, GmailProvider sends this notification when the set of unread
2800 * mail in the inbox changes.
2801 *
2802 * <p>The data of the intent identifies which part of which provider
2803 * changed. When queried through the content resolver, the data URI will
2804 * return the data set in question.
2805 *
2806 * <p>The intent will have the following extra values:
2807 * <ul>
2808 * <li><em>count</em> - The number of items in the data set. This is the
2809 * same as the number of items in the cursor returned by querying the
2810 * data URI. </li>
2811 * </ul>
2812 *
2813 * This intent will be sent at boot (if the count is non-zero) and when the
2814 * data set changes. It is possible for the data set to change without the
2815 * count changing (for example, if a new unread message arrives in the same
2816 * sync operation in which a message is archived). The phone should still
2817 * ring/vibrate/etc as normal in this case.
2818 */
2819 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2820 public static final String ACTION_PROVIDER_CHANGED =
2821 "android.intent.action.PROVIDER_CHANGED";
2822
2823 /**
2824 * Broadcast Action: Wired Headset plugged in or unplugged.
2825 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002826 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2827 * and documentation.
2828 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002829 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002830 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002831 */
2832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002833 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002834
2835 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002836 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2837 * <ul>
2838 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2839 * </ul>
2840 *
2841 * <p class="note">This is a protected intent that can only be sent
2842 * by the system.
2843 *
2844 * @hide
2845 */
2846 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2847 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2848 = "android.intent.action.ADVANCED_SETTINGS";
2849
2850 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002851 * Broadcast Action: Sent after application restrictions are changed.
2852 *
2853 * <p class="note">This is a protected intent that can only be sent
2854 * by the system.</p>
2855 */
2856 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2857 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2858 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2859
2860 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002861 * Broadcast Action: An outgoing call is about to be placed.
2862 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002863 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002864 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002865 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002866 * the phone number originally intended to be dialed.</li>
2867 * </ul>
2868 * <p>Once the broadcast is finished, the resultData is used as the actual
2869 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002870 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002871 * outgoing call in turn: for example, a parental control application
2872 * might verify that the user is authorized to place the call at that
2873 * time, then a number-rewriting application might add an area code if
2874 * one was not specified.</p>
2875 * <p>For consistency, any receiver whose purpose is to prohibit phone
2876 * calls should have a priority of 0, to ensure it will see the final
2877 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002878 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002879 * should have a positive priority.
2880 * Negative priorities are reserved for the system for this broadcast;
2881 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002882 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2883 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002884 * <p>Emergency calls cannot be intercepted using this mechanism, and
2885 * other calls cannot be modified to call emergency numbers using this
2886 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002887 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2888 * call to use their own service instead. Those apps should first prevent
2889 * the call from being placed by setting resultData to <code>null</code>
2890 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002891 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002892 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2893 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002895 * <p class="note">This is a protected intent that can only be sent
2896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002897 */
2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2899 public static final String ACTION_NEW_OUTGOING_CALL =
2900 "android.intent.action.NEW_OUTGOING_CALL";
2901
2902 /**
2903 * Broadcast Action: Have the device reboot. This is only for use by
2904 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002905 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002906 * <p class="note">This is a protected intent that can only be sent
2907 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002908 */
2909 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2910 public static final String ACTION_REBOOT =
2911 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002912
Wei Huang97ecc9c2009-05-11 17:44:20 -07002913 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002914 * Broadcast Action: A sticky broadcast for changes in the physical
2915 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002916 *
2917 * <p>The intent will have the following extra values:
2918 * <ul>
2919 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002920 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002921 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002922 * <p>This is intended for monitoring the current physical dock state.
2923 * See {@link android.app.UiModeManager} for the normal API dealing with
2924 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002925 */
2926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2927 public static final String ACTION_DOCK_EVENT =
2928 "android.intent.action.DOCK_EVENT";
2929
2930 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002931 * Broadcast Action: A broadcast when idle maintenance can be started.
2932 * This means that the user is not interacting with the device and is
2933 * not expected to do so soon. Typical use of the idle maintenance is
2934 * to perform somehow expensive tasks that can be postponed at a moment
2935 * when they will not degrade user experience.
2936 * <p>
2937 * <p class="note">In order to keep the device responsive in case of an
2938 * unexpected user interaction, implementations of a maintenance task
2939 * should be interruptible. In such a scenario a broadcast with action
2940 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2941 * should not do the maintenance work in
2942 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2943 * maintenance service by {@link Context#startService(Intent)}. Also
2944 * you should hold a wake lock while your maintenance service is running
2945 * to prevent the device going to sleep.
2946 * </p>
2947 * <p>
2948 * <p class="note">This is a protected intent that can only be sent by
2949 * the system.
2950 * </p>
2951 *
2952 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002953 *
2954 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002955 */
2956 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2957 public static final String ACTION_IDLE_MAINTENANCE_START =
2958 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2959
2960 /**
2961 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2962 * This means that the user was not interacting with the device as a result
2963 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2964 * was sent and now the user started interacting with the device. Typical
2965 * use of the idle maintenance is to perform somehow expensive tasks that
2966 * can be postponed at a moment when they will not degrade user experience.
2967 * <p>
2968 * <p class="note">In order to keep the device responsive in case of an
2969 * unexpected user interaction, implementations of a maintenance task
2970 * should be interruptible. Hence, on receiving a broadcast with this
2971 * action, the maintenance task should be interrupted as soon as possible.
2972 * In other words, you should not do the maintenance work in
2973 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2974 * maintenance service that was started on receiving of
2975 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2976 * lock you acquired when your maintenance service started.
2977 * </p>
2978 * <p class="note">This is a protected intent that can only be sent
2979 * by the system.
2980 *
2981 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002982 *
2983 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002984 */
2985 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2986 public static final String ACTION_IDLE_MAINTENANCE_END =
2987 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2988
2989 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002990 * Broadcast Action: a remote intent is to be broadcasted.
2991 *
2992 * A remote intent is used for remote RPC between devices. The remote intent
2993 * is serialized and sent from one device to another device. The receiving
2994 * device parses the remote intent and broadcasts it. Note that anyone can
2995 * broadcast a remote intent. However, if the intent receiver of the remote intent
2996 * does not trust intent broadcasts from arbitrary intent senders, it should require
2997 * the sender to hold certain permissions so only trusted sender's broadcast will be
2998 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002999 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003000 */
3001 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003002 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003003
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003004 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003005 * Broadcast Action: This is broadcast once when the user is booting after a
3006 * system update. It can be used to perform cleanup or upgrades after a
3007 * system update.
3008 * <p>
3009 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3010 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3011 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3012 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003013 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003014 * @hide
3015 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003016 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003017 public static final String ACTION_PRE_BOOT_COMPLETED =
3018 "android.intent.action.PRE_BOOT_COMPLETED";
3019
Amith Yamasani13593602012-03-22 16:16:17 -07003020 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003021 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003022 * on restricted users. The broadcast intent contains an extra
3023 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3024 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3025 * String[] depending on the restriction type.<p/>
3026 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003027 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3028 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3029 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003030 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3031 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003032 * @see RestrictionEntry
3033 */
3034 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3035 "android.intent.action.GET_RESTRICTION_ENTRIES";
3036
3037 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003038 * Sent the first time a user is starting, to allow system apps to
3039 * perform one time initialization. (This will not be seen by third
3040 * party applications because a newly initialized user does not have any
3041 * third party applications installed for it.) This is sent early in
3042 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003043 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3044 * broadcast, since it is part of a visible user interaction; be as quick
3045 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003046 */
3047 public static final String ACTION_USER_INITIALIZE =
3048 "android.intent.action.USER_INITIALIZE";
3049
3050 /**
3051 * Sent when a user switch is happening, causing the process's user to be
3052 * brought to the foreground. This is only sent to receivers registered
3053 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3054 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003055 * foreground. This is sent as a foreground
3056 * broadcast, since it is part of a visible user interaction; be as quick
3057 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003058 */
3059 public static final String ACTION_USER_FOREGROUND =
3060 "android.intent.action.USER_FOREGROUND";
3061
3062 /**
3063 * Sent when a user switch is happening, causing the process's user to be
3064 * sent to the background. This is only sent to receivers registered
3065 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3066 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003067 * background. This is sent as a foreground
3068 * broadcast, since it is part of a visible user interaction; be as quick
3069 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003070 */
3071 public static final String ACTION_USER_BACKGROUND =
3072 "android.intent.action.USER_BACKGROUND";
3073
3074 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003075 * Broadcast sent to the system when a user is added. Carries an extra
3076 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3077 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003078 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003079 * @hide
3080 */
3081 public static final String ACTION_USER_ADDED =
3082 "android.intent.action.USER_ADDED";
3083
3084 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003085 * Broadcast sent by the system when a user is started. Carries an extra
3086 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003087 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003088 * that has been started. This is sent as a foreground
3089 * broadcast, since it is part of a visible user interaction; be as quick
3090 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003091 * @hide
3092 */
3093 public static final String ACTION_USER_STARTED =
3094 "android.intent.action.USER_STARTED";
3095
3096 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003097 * Broadcast sent when a user is in the process of starting. Carries an extra
3098 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3099 * sent to registered receivers, not manifest receivers. It is sent to all
3100 * users (including the one that is being started). You must hold
3101 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3102 * this broadcast. This is sent as a background broadcast, since
3103 * its result is not part of the primary UX flow; to safely keep track of
3104 * started/stopped state of a user you can use this in conjunction with
3105 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3106 * other user state broadcasts since those are foreground broadcasts so can
3107 * execute in a different order.
3108 * @hide
3109 */
3110 public static final String ACTION_USER_STARTING =
3111 "android.intent.action.USER_STARTING";
3112
3113 /**
3114 * Broadcast sent when a user is going to be stopped. Carries an extra
3115 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3116 * sent to registered receivers, not manifest receivers. It is sent to all
3117 * users (including the one that is being stopped). You must hold
3118 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3119 * this broadcast. The user will not stop until all receivers have
3120 * handled the broadcast. This is sent as a background broadcast, since
3121 * its result is not part of the primary UX flow; to safely keep track of
3122 * started/stopped state of a user you can use this in conjunction with
3123 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3124 * other user state broadcasts since those are foreground broadcasts so can
3125 * execute in a different order.
3126 * @hide
3127 */
3128 public static final String ACTION_USER_STOPPING =
3129 "android.intent.action.USER_STOPPING";
3130
3131 /**
3132 * Broadcast sent to the system when a user is stopped. Carries an extra
3133 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3134 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3135 * specific package. This is only sent to registered receivers, not manifest
3136 * receivers. It is sent to all running users <em>except</em> the one that
3137 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003138 * @hide
3139 */
3140 public static final String ACTION_USER_STOPPED =
3141 "android.intent.action.USER_STOPPED";
3142
3143 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003144 * 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 -07003145 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003146 * one that has been removed. The user will not be completely removed until all receivers have
3147 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003148 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003149 * @hide
3150 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003151 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003152 public static final String ACTION_USER_REMOVED =
3153 "android.intent.action.USER_REMOVED";
3154
3155 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003156 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003157 * the userHandle of the user to become the current one. This is only sent to
3158 * registered receivers, not manifest receivers. It is sent to all running users.
3159 * You must hold
3160 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003161 * @hide
3162 */
3163 public static final String ACTION_USER_SWITCHED =
3164 "android.intent.action.USER_SWITCHED";
3165
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003166 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003167 * Broadcast Action: Sent when the credential-encrypted private storage has
3168 * become unlocked for the target user. This is only sent to registered
3169 * receivers, not manifest receivers.
3170 */
3171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3172 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3173
3174 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003175 * Broadcast sent to the system when a user's information changes. Carries an extra
3176 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003177 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003178 * @hide
3179 */
3180 public static final String ACTION_USER_INFO_CHANGED =
3181 "android.intent.action.USER_INFO_CHANGED";
3182
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003183 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003184 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3185 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003186 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3187 * that need to display merged content across both primary and managed profiles need to
3188 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003189 * not manifest receivers.
3190 */
3191 public static final String ACTION_MANAGED_PROFILE_ADDED =
3192 "android.intent.action.MANAGED_PROFILE_ADDED";
3193
3194 /**
3195 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003196 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3197 * Only applications (for example Launchers) that need to display merged content across both
3198 * primary and managed profiles need to worry about this broadcast. This is only sent to
3199 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003200 */
3201 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3202 "android.intent.action.MANAGED_PROFILE_REMOVED";
3203
3204 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003205 * Broadcast sent to the primary user when the credential-encrypted private storage for
3206 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3207 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3208 * Launchers) that need to display merged content across both primary and managed profiles
3209 * need to worry about this broadcast. This is only sent to registered receivers,
3210 * not manifest receivers.
3211 */
3212 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3213 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3214
3215 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003216 * Broadcast sent to the primary user when an associated managed profile has become available.
3217 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003218 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3219 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3220 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003221 */
Rubin Xue95057a2016-04-01 16:49:25 +01003222 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3223 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3224
3225 /**
3226 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3227 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3228 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3229 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3230 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3231 */
3232 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3233 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003234
3235 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003236 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3237 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3238 * the device was locked or unlocked.
3239 *
3240 * This is only sent to registered receivers.
3241 *
3242 * @hide
3243 */
3244 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3245 "android.intent.action.DEVICE_LOCKED_CHANGED";
3246
3247 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003248 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3249 */
3250 public static final String ACTION_QUICK_CLOCK =
3251 "android.intent.action.QUICK_CLOCK";
3252
Michael Wright0087a142013-02-05 16:29:39 -08003253 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003254 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003255 * @hide
3256 */
3257 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003258 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003259
Justin Kohd378ad72013-04-01 12:18:26 -07003260 /**
3261 * Broadcast Action: A global button was pressed. Includes a single
3262 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3263 * caused the broadcast.
3264 * @hide
3265 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003266 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003267 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3268
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003269 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003270 * Broadcast Action: Sent when media resource is granted.
3271 * <p>
3272 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3273 * granted.
3274 * </p>
3275 * <p class="note">
3276 * This is a protected intent that can only be sent by the system.
3277 * </p>
3278 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003279 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003280 * </p>
3281 *
3282 * @hide
3283 */
3284 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3285 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3286
3287 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003288 * Broadcast Action: An overlay package has changed. The data contains the
3289 * name of the overlay package which has changed. This is broadcast on all
3290 * changes to the OverlayInfo returned by {@link
3291 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3292 * most common change is a state change that will change whether the
3293 * overlay is enabled or not.
3294 * @hide
3295 */
3296 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3297
3298 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003299 * Activity Action: Allow the user to select and return one or more existing
3300 * documents. When invoked, the system will display the various
3301 * {@link DocumentsProvider} instances installed on the device, letting the
3302 * user interactively navigate through them. These documents include local
3303 * media, such as photos and video, and documents provided by installed
3304 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003305 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003306 * Each document is represented as a {@code content://} URI backed by a
3307 * {@link DocumentsProvider}, which can be opened as a stream with
3308 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3309 * {@link android.provider.DocumentsContract.Document} metadata.
3310 * <p>
3311 * All selected documents are returned to the calling application with
3312 * persistable read and write permission grants. If you want to maintain
3313 * access to the documents across device reboots, you need to explicitly
3314 * take the persistable permissions using
3315 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3316 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003317 * Callers must indicate the acceptable document MIME types through
3318 * {@link #setType(String)}. For example, to select photos, use
3319 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3320 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3321 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003322 * <p>
3323 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003324 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3325 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003326 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003327 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3328 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003329 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003330 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003331 * Callers can set a document URI through
3332 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3333 * location of documents navigator. System will do its best to launch the
3334 * navigator in the specified document if it's a folder, or the folder that
3335 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003336 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003337 * Output: The URI of the item that was picked, returned in
3338 * {@link #getData()}. This must be a {@code content://} URI so that any
3339 * receiver can access it. If multiple documents were selected, they are
3340 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003341 *
3342 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003343 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003344 * @see #ACTION_CREATE_DOCUMENT
3345 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003346 */
3347 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3348 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3349
3350 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003351 * Activity Action: Allow the user to create a new document. When invoked,
3352 * the system will display the various {@link DocumentsProvider} instances
3353 * installed on the device, letting the user navigate through them. The
3354 * returned document may be a newly created document with no content, or it
3355 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003356 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003357 * Each document is represented as a {@code content://} URI backed by a
3358 * {@link DocumentsProvider}, which can be opened as a stream with
3359 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3360 * {@link android.provider.DocumentsContract.Document} metadata.
3361 * <p>
3362 * Callers must indicate the concrete MIME type of the document being
3363 * created by setting {@link #setType(String)}. This MIME type cannot be
3364 * changed after the document is created.
3365 * <p>
3366 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3367 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003368 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003369 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3370 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003371 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003372 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003373 * Callers can set a document URI through
3374 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3375 * location of documents navigator. System will do its best to launch the
3376 * navigator in the specified document if it's a folder, or the folder that
3377 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003378 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003379 * Output: The URI of the item that was created. This must be a
3380 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003381 *
3382 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003383 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003384 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003385 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003386 */
3387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3388 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3389
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003390 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003391 * Activity Action: Allow the user to pick a directory subtree. When
3392 * invoked, the system will display the various {@link DocumentsProvider}
3393 * instances installed on the device, letting the user navigate through
3394 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003395 * <p>
3396 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003397 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3398 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3399 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003400 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003401 * Callers can set a document URI through
3402 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3403 * location of documents navigator. System will do its best to launch the
3404 * navigator in the specified document if it's a folder, or the folder that
3405 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003406 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003407 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003408 *
3409 * @see DocumentsContract
3410 */
3411 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003412 public static final String
3413 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003414
Felipe Lemec7b1f892016-01-15 15:02:31 -08003415 /**
Peng Xua35b5532016-01-20 00:05:45 -08003416 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3417 * exisiting sensor being disconnected.
3418 *
3419 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3420 *
3421 * {@hide}
3422 */
3423 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3424 public static final String
3425 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3426
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003427 /**
Sam Line707f832017-04-13 17:00:55 -07003428 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003429 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003430 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003431 */
3432 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003433 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003434 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3435
Christopher Tate6597e342015-02-17 12:15:25 -08003436 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003437 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3438 * is about to be performed.
3439 * @hide
3440 */
3441 @SystemApi
3442 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3443 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3444 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3445
3446 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003447 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3448 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3449 *
3450 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3451 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003452 * @hide
3453 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003454 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003455 public static final String EXTRA_FORCE_MASTER_CLEAR =
3456 "android.intent.extra.FORCE_MASTER_CLEAR";
3457
3458 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003459 * A broadcast action to trigger a factory reset.
3460 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003461 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3462 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003463 *
3464 * <p>Not for use by third-party applications.
3465 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003466 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003467 *
3468 * {@hide}
3469 */
3470 @SystemApi
3471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3472 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3473
3474 /**
3475 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3476 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3477 *
3478 * <p>Not for use by third-party applications.
3479 *
3480 * @hide
3481 */
3482 @SystemApi
3483 public static final String EXTRA_FORCE_FACTORY_RESET =
3484 "android.intent.extra.FORCE_FACTORY_RESET";
3485
3486 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003487 * Broadcast action: report that a settings element is being restored from backup. The intent
3488 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3489 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3490 * is the value of that settings entry prior to the restore operation, and
3491 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3492 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3493 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003494 *
3495 * <p>This broadcast is sent only for settings provider entries known to require special handling
3496 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3497 * the provider's backup agent implementation.
3498 *
3499 * @see #EXTRA_SETTING_NAME
3500 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3501 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003502 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003503 * {@hide}
3504 */
3505 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3506
3507 /** {@hide} */
3508 public static final String EXTRA_SETTING_NAME = "setting_name";
3509 /** {@hide} */
3510 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3511 /** {@hide} */
3512 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003513 /** {@hide} */
3514 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003515
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003516 /**
3517 * Activity Action: Process a piece of text.
3518 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3519 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3520 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3521 */
3522 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3523 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003524
3525 /**
3526 * Broadcast Action: The sim card state has changed.
3527 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3528 * because TelephonyIntents is an internal class.
3529 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003530 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3531 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003532 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003533 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003534 @SystemApi
3535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3536 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3537
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003538 /**
fionaxu90fee272017-03-31 12:45:12 -07003539 * Broadcast Action: indicate that the phone service state has changed.
3540 * The intent will have the following extra values:</p>
3541 * <p>
3542 * @see #EXTRA_VOICE_REG_STATE
3543 * @see #EXTRA_DATA_REG_STATE
3544 * @see #EXTRA_VOICE_ROAMING_TYPE
3545 * @see #EXTRA_DATA_ROAMING_TYPE
3546 * @see #EXTRA_OPERATOR_ALPHA_LONG
3547 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3548 * @see #EXTRA_OPERATOR_NUMERIC
3549 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3550 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3551 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3552 * @see #EXTRA_MANUAL
3553 * @see #EXTRA_VOICE_RADIO_TECH
3554 * @see #EXTRA_DATA_RADIO_TECH
3555 * @see #EXTRA_CSS_INDICATOR
3556 * @see #EXTRA_NETWORK_ID
3557 * @see #EXTRA_SYSTEM_ID
3558 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3559 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3560 * @see #EXTRA_EMERGENCY_ONLY
3561 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3562 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3563 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3564 *
3565 * <p class="note">
3566 * Requires the READ_PHONE_STATE permission.
3567 *
3568 * <p class="note">This is a protected intent that can only be sent by the system.
3569 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003570 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003571 */
3572 @Deprecated
3573 @SystemApi
3574 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3575 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3576
3577 /**
3578 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3579 * state.
3580 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3581 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3582 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3583 * @see android.telephony.ServiceState#STATE_POWER_OFF
3584 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003585 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003586 */
3587 @Deprecated
3588 @SystemApi
3589 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3590
3591 /**
3592 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3593 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3594 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3595 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3596 * @see android.telephony.ServiceState#STATE_POWER_OFF
3597 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003598 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003599 */
3600 @Deprecated
3601 @SystemApi
3602 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3603
3604 /**
3605 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3606 * type.
3607 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003608 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003609 */
3610 @Deprecated
3611 @SystemApi
3612 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3613
3614 /**
3615 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3616 * type.
3617 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003618 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003619 */
3620 @Deprecated
3621 @SystemApi
3622 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3623
3624 /**
3625 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3626 * registered voice operator name in long alphanumeric format.
3627 * {@code null} if the operator name is not known or unregistered.
3628 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003629 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003630 */
3631 @Deprecated
3632 @SystemApi
3633 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3634
3635 /**
3636 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3637 * registered voice operator name in short alphanumeric format.
3638 * {@code null} if the operator name is not known or unregistered.
3639 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003640 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003641 */
3642 @Deprecated
3643 @SystemApi
3644 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3645
3646 /**
3647 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3648 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3649 * network.
3650 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003651 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003652 */
3653 @Deprecated
3654 @SystemApi
3655 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3656
3657 /**
3658 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3659 * registered data operator name in long alphanumeric format.
3660 * {@code null} if the operator name is not known or unregistered.
3661 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003662 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003663 */
3664 @Deprecated
3665 @SystemApi
3666 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3667
3668 /**
3669 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3670 * registered data operator name in short alphanumeric format.
3671 * {@code null} if the operator name is not known or unregistered.
3672 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003673 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003674 */
3675 @Deprecated
3676 @SystemApi
3677 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3678
3679 /**
3680 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3681 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3682 * data operator.
3683 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003684 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003685 */
3686 @Deprecated
3687 @SystemApi
3688 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3689
3690 /**
3691 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3692 * network selection mode is manual.
3693 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3694 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003695 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003696 */
3697 @Deprecated
3698 @SystemApi
3699 public static final String EXTRA_MANUAL = "manual";
3700
3701 /**
3702 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3703 * radio technology.
3704 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003705 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003706 */
3707 @Deprecated
3708 @SystemApi
3709 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3710
3711 /**
3712 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3713 * radio technology.
3714 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003715 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003716 */
3717 @Deprecated
3718 @SystemApi
3719 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3720
3721 /**
3722 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3723 * support on CDMA network.
3724 * Will be {@code true} if support, {@code false} otherwise.
3725 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003726 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003727 */
3728 @Deprecated
3729 @SystemApi
3730 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3731
3732 /**
3733 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3734 * id. {@code Integer.MAX_VALUE} if unknown.
3735 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003736 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003737 */
3738 @Deprecated
3739 @SystemApi
3740 public static final String EXTRA_NETWORK_ID = "networkId";
3741
3742 /**
3743 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3744 * {@code Integer.MAX_VALUE} if unknown.
3745 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003746 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003747 */
3748 @Deprecated
3749 @SystemApi
3750 public static final String EXTRA_SYSTEM_ID = "systemId";
3751
3752 /**
3753 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3754 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3755 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003756 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003757 */
3758 @Deprecated
3759 @SystemApi
3760 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3761
3762 /**
3763 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3764 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3765 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003766 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003767 */
3768 @Deprecated
3769 @SystemApi
3770 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3771
3772 /**
3773 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3774 * only mode.
3775 * {@code true} if in emergency only mode, {@code false} otherwise.
3776 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003777 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003778 */
3779 @Deprecated
3780 @SystemApi
3781 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3782
3783 /**
3784 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3785 * registration state is roaming.
3786 * {@code true} if registration indicates roaming, {@code false} otherwise
3787 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003788 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003789 */
3790 @Deprecated
3791 @SystemApi
3792 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3793 "isDataRoamingFromRegistration";
3794
3795 /**
3796 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3797 * aggregation is in use.
3798 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3799 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003800 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003801 */
3802 @Deprecated
3803 @SystemApi
3804 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3805
3806 /**
3807 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3808 * is reduced from the rsrp threshold while calculating signal strength level.
3809 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003810 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003811 */
3812 @Deprecated
3813 @SystemApi
3814 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3815
3816 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003817 * The name of the extra used to define the text to be processed, as a
3818 * CharSequence. Note that this may be a styled CharSequence, so you must use
3819 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003820 */
3821 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3822 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003823 * 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 +00003824 */
3825 public static final String EXTRA_PROCESS_TEXT_READONLY =
3826 "android.intent.extra.PROCESS_TEXT_READONLY";
3827
Bryce Leebc58f592015-09-25 16:43:01 -07003828 /**
3829 * Broadcast action: reports when a new thermal event has been reached. When the device
3830 * is reaching its maximum temperatue, the thermal level reported
3831 * {@hide}
3832 */
3833 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3834 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3835
3836 /** {@hide} */
3837 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3838
3839 /**
3840 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003841 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003842 * {@hide}
3843 */
3844 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3845
3846 /**
3847 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003848 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003849 * {@hide}
3850 */
3851 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3852
3853 /**
3854 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003855 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003856 * {@hide}
3857 */
3858 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3859
3860
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003861 // ---------------------------------------------------------------------
3862 // ---------------------------------------------------------------------
3863 // Standard intent categories (see addCategory()).
3864
3865 /**
3866 * Set if the activity should be an option for the default action
3867 * (center press) to perform on a piece of data. Setting this will
3868 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003869 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003870 * Intent when initiating an action -- it is for use in intent filters
3871 * specified in packages.
3872 */
3873 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3874 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3875 /**
3876 * Activities that can be safely invoked from a browser must support this
3877 * category. For example, if the user is viewing a web page or an e-mail
3878 * and clicks on a link in the text, the Intent generated execute that
3879 * link will require the BROWSABLE category, so that only activities
3880 * supporting this category will be considered as possible actions. By
3881 * supporting this category, you are promising that there is nothing
3882 * damaging (without user intervention) that can happen by invoking any
3883 * matching Intent.
3884 */
3885 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3886 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3887 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003888 * Categories for activities that can participate in voice interaction.
3889 * An activity that supports this category must be prepared to run with
3890 * no UI shown at all (though in some case it may have a UI shown), and
3891 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3892 */
3893 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3894 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3895 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003896 * Set if the activity should be considered as an alternative action to
3897 * the data the user is currently viewing. See also
3898 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3899 * applies to the selection in a list of items.
3900 *
3901 * <p>Supporting this category means that you would like your activity to be
3902 * displayed in the set of alternative things the user can do, usually as
3903 * part of the current activity's options menu. You will usually want to
3904 * include a specific label in the &lt;intent-filter&gt; of this action
3905 * describing to the user what it does.
3906 *
3907 * <p>The action of IntentFilter with this category is important in that it
3908 * describes the specific action the target will perform. This generally
3909 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3910 * a specific name such as "com.android.camera.action.CROP. Only one
3911 * alternative of any particular action will be shown to the user, so using
3912 * a specific action like this makes sure that your alternative will be
3913 * displayed while also allowing other applications to provide their own
3914 * overrides of that particular action.
3915 */
3916 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3917 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3918 /**
3919 * Set if the activity should be considered as an alternative selection
3920 * action to the data the user has currently selected. This is like
3921 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3922 * of items from which the user can select, giving them alternatives to the
3923 * default action that will be performed on it.
3924 */
3925 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3926 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3927 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003928 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003929 */
3930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3931 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3932 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003933 * Should be displayed in the top-level launcher.
3934 */
3935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3936 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3937 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003938 * Indicates an activity optimized for Leanback mode, and that should
3939 * be displayed in the Leanback launcher.
3940 */
3941 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3942 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3943 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08003944 * Indicates the preferred entry-point activity when an application is launched from a Car
3945 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
3946 * fallback, or exclude the application entirely.
3947 * @hide
3948 */
3949 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3950 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
3951 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003952 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3953 * @hide
3954 */
3955 @SystemApi
3956 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3957 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003958 * Provides information about the package it is in; typically used if
3959 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3960 * a front-door to the user without having to be shown in the all apps list.
3961 */
3962 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3963 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3964 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003965 * This is the home activity, that is the first activity that is displayed
3966 * when the device boots.
3967 */
3968 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3969 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3970 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003971 * This is the home activity that is displayed when the device is finished setting up and ready
3972 * for use.
3973 * @hide
3974 */
3975 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3976 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3977 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003978 * This is the setup wizard activity, that is the first activity that is displayed
3979 * when the user sets up the device for the first time.
3980 * @hide
3981 */
3982 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3983 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3984 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07003985 * This is the home activity, that is the activity that serves as the launcher app
3986 * from there the user can start other apps. Often components with lower/higher
3987 * priority intent filters handle the home intent, for example SetupWizard, to
3988 * setup the device and we need to be able to distinguish the home app from these
3989 * setup helpers.
3990 * @hide
3991 */
3992 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3993 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
3994 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003995 * This activity is a preference panel.
3996 */
3997 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3998 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3999 /**
4000 * This activity is a development preference panel.
4001 */
4002 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4003 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4004 /**
4005 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004006 */
4007 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4008 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4009 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004010 * This activity allows the user to browse and download new applications.
4011 */
4012 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4013 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4014 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004015 * This activity may be exercised by the monkey or other automated test tools.
4016 */
4017 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4018 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4019 /**
4020 * To be used as a test (not part of the normal user experience).
4021 */
4022 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4023 /**
4024 * To be used as a unit test (run through the Test Harness).
4025 */
4026 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4027 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004028 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004029 * experience).
4030 */
4031 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004033 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004034 * Used to indicate that an intent only wants URIs that can be opened with
4035 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4036 * must support at least the columns defined in {@link OpenableColumns} when
4037 * queried.
4038 *
4039 * @see #ACTION_GET_CONTENT
4040 * @see #ACTION_OPEN_DOCUMENT
4041 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004042 */
4043 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4044 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4045
4046 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004047 * Used to indicate that an intent filter can accept files which are not necessarily
4048 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4049 * at least streamable via
4050 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4051 * using one of the stream types exposed via
4052 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4053 *
4054 * @see #ACTION_SEND
4055 * @see #ACTION_SEND_MULTIPLE
4056 */
4057 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4058 public static final String CATEGORY_TYPED_OPENABLE =
4059 "android.intent.category.TYPED_OPENABLE";
4060
4061 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004062 * To be used as code under test for framework instrumentation tests.
4063 */
4064 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4065 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004066 /**
4067 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004068 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4069 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004070 */
4071 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4072 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4073 /**
4074 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004075 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4076 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004077 */
4078 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4079 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004080 /**
4081 * An activity to run when device is inserted into a analog (low end) dock.
4082 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4083 * information, see {@link android.app.UiModeManager}.
4084 */
4085 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4086 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4087
4088 /**
4089 * An activity to run when device is inserted into a digital (high end) dock.
4090 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4091 * information, see {@link android.app.UiModeManager}.
4092 */
4093 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4094 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004095
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004096 /**
4097 * Used to indicate that the activity can be used in a car environment.
4098 */
4099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4100 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4101
Zak Cohendb6ca492017-01-26 14:09:00 -08004102 /**
4103 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4104 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4105 * information, see {@link android.app.UiModeManager}.
4106 */
4107 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4108 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004109 // ---------------------------------------------------------------------
4110 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004111 // Application launch intent categories (see addCategory()).
4112
4113 /**
4114 * Used with {@link #ACTION_MAIN} to launch the browser application.
4115 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004116 * <p>NOTE: This should not be used as the primary key of an Intent,
4117 * since it will not result in the app launching with the correct
4118 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004119 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004120 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004121 */
4122 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4123 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4124
4125 /**
4126 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4127 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004128 * <p>NOTE: This should not be used as the primary key of an Intent,
4129 * since it will not result in the app launching with the correct
4130 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004131 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004132 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004133 */
4134 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4135 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4136
4137 /**
4138 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4139 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004140 * <p>NOTE: This should not be used as the primary key of an Intent,
4141 * since it will not result in the app launching with the correct
4142 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004143 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004144 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004145 */
4146 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4147 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4148
4149 /**
4150 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4151 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004152 * <p>NOTE: This should not be used as the primary key of an Intent,
4153 * since it will not result in the app launching with the correct
4154 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004155 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004156 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004157 */
4158 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4159 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4160
4161 /**
4162 * Used with {@link #ACTION_MAIN} to launch the email application.
4163 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004164 * <p>NOTE: This should not be used as the primary key of an Intent,
4165 * since it will not result in the app launching with the correct
4166 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004167 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004168 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004169 */
4170 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4171 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4172
4173 /**
4174 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4175 * The activity should be able to view and manipulate image and video files
4176 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004177 * <p>NOTE: This should not be used as the primary key of an Intent,
4178 * since it will not result in the app launching with the correct
4179 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004180 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004181 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004182 */
4183 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4184 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4185
4186 /**
4187 * Used with {@link #ACTION_MAIN} to launch the maps application.
4188 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004189 * <p>NOTE: This should not be used as the primary key of an Intent,
4190 * since it will not result in the app launching with the correct
4191 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004192 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004193 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004194 */
4195 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4196 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4197
4198 /**
4199 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4200 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004201 * <p>NOTE: This should not be used as the primary key of an Intent,
4202 * since it will not result in the app launching with the correct
4203 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004204 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004205 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004206 */
4207 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4208 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4209
4210 /**
4211 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004212 * The activity should be able to play, browse, or manipulate music files
4213 * stored on the device.
4214 * <p>NOTE: This should not be used as the primary key of an Intent,
4215 * since it will not result in the app launching with the correct
4216 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004217 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004218 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004219 */
4220 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4221 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4222
4223 // ---------------------------------------------------------------------
4224 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004225 // Standard extra data keys.
4226
4227 /**
4228 * The initial data to place in a newly created record. Use with
4229 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4230 * fields as would be given to the underlying ContentProvider.insert()
4231 * call.
4232 */
4233 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4234
4235 /**
4236 * A constant CharSequence that is associated with the Intent, used with
4237 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4238 * this may be a styled CharSequence, so you must use
4239 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4240 * retrieve it.
4241 */
4242 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4243
4244 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004245 * A constant String that is associated with the Intent, used with
4246 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4247 * as HTML formatted text. Note that you <em>must</em> also supply
4248 * {@link #EXTRA_TEXT}.
4249 */
4250 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4251
4252 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004253 * A content: URI holding a stream of data associated with the Intent,
4254 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004255 */
4256 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4257
4258 /**
4259 * A String[] holding e-mail addresses that should be delivered to.
4260 */
4261 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4262
4263 /**
4264 * A String[] holding e-mail addresses that should be carbon copied.
4265 */
4266 public static final String EXTRA_CC = "android.intent.extra.CC";
4267
4268 /**
4269 * A String[] holding e-mail addresses that should be blind carbon copied.
4270 */
4271 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4272
4273 /**
4274 * A constant string holding the desired subject line of a message.
4275 */
4276 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4277
4278 /**
4279 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004280 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004281 */
4282 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4283
4284 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004285 * An int representing the user id to be used.
4286 *
4287 * @hide
4288 */
4289 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4290
4291 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004292 * An int representing the task id to be retrieved. This is used when a launch from recents is
4293 * intercepted by another action such as credentials confirmation to remember which task should
4294 * be resumed when complete.
4295 *
4296 * @hide
4297 */
4298 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4299
4300 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004301 * An Intent[] describing additional, alternate choices you would like shown with
4302 * {@link #ACTION_CHOOSER}.
4303 *
4304 * <p>An app may be capable of providing several different payload types to complete a
4305 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4306 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4307 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4308 * photo data or a hosted link where the photos can be viewed.</p>
4309 *
4310 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4311 * first/primary/preferred intent in the set. Additional intents specified in
4312 * this extra are ordered; by default intents that appear earlier in the array will be
4313 * preferred over intents that appear later in the array as matches for the same
4314 * target component. To alter this preference, a calling app may also supply
4315 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4316 */
4317 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4318
4319 /**
Adam Powell52c39212016-04-07 15:14:18 -07004320 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4321 * and omitted from a list of components presented to the user.
4322 *
4323 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4324 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4325 * from your own package or other apps from your organization if the idea of sending to those
4326 * targets would be redundant with other app functionality. Filtered components will not
4327 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4328 */
4329 public static final String EXTRA_EXCLUDE_COMPONENTS
4330 = "android.intent.extra.EXCLUDE_COMPONENTS";
4331
4332 /**
4333 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4334 * describing additional high-priority deep-link targets for the chooser to present to the user.
4335 *
4336 * <p>Targets provided in this way will be presented inline with all other targets provided
4337 * by services from other apps. They will be prioritized before other service targets, but
4338 * after those targets provided by sources that the user has manually pinned to the front.</p>
4339 *
4340 * @see #ACTION_CHOOSER
4341 */
4342 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4343
4344 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004345 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4346 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4347 *
4348 * <p>An app preparing an action for another app to complete may wish to allow the user to
4349 * disambiguate between several options for completing the action based on the chosen target
4350 * or otherwise refine the action before it is invoked.
4351 * </p>
4352 *
4353 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4354 * <ul>
4355 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4356 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4357 * chosen target beyond the first</li>
4358 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4359 * should fill in and send once the disambiguation is complete</li>
4360 * </ul>
4361 */
4362 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4363 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4364
4365 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004366 * An {@code ArrayList} of {@code String} annotations describing content for
4367 * {@link #ACTION_CHOOSER}.
4368 *
4369 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4370 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4371 *
4372 * <p>Annotations should describe the major components or topics of the content. It is up to
4373 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4374 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004375 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4376 * character. Performance on customized annotations can suffer, if they are rarely used for
4377 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4378 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004379 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004380 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004381 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004382 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004383 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004384 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004385 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004386 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004387 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004388 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4389 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4390 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4391 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4392 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004393 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004394 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4395 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004396 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004397 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004398 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004399 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004400 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004401 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004402 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004403 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004404 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004405 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004406 * Christmas and Thanksgiving.</li>
4407 * </ul>
4408 */
4409 public static final String EXTRA_CONTENT_ANNOTATIONS
4410 = "android.intent.extra.CONTENT_ANNOTATIONS";
4411
4412 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004413 * A {@link ResultReceiver} used to return data back to the sender.
4414 *
4415 * <p>Used to complete an app-specific
4416 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4417 *
4418 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4419 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4420 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4421 * when the user selects a target component from the chooser. It is up to the recipient
4422 * to send a result to this ResultReceiver to signal that disambiguation is complete
4423 * and that the chooser should invoke the user's choice.</p>
4424 *
4425 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4426 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4427 * to match and fill in the final Intent or ChooserTarget before starting it.
4428 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4429 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4430 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4431 *
4432 * <p>The result code passed to the ResultReceiver should be
4433 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4434 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4435 * the chooser should finish without starting a target.</p>
4436 */
4437 public static final String EXTRA_RESULT_RECEIVER
4438 = "android.intent.extra.RESULT_RECEIVER";
4439
4440 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004441 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004442 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004443 */
4444 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4445
4446 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004447 * A Parcelable[] of {@link Intent} or
4448 * {@link android.content.pm.LabeledIntent} objects as set with
4449 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4450 * a the front of the list of choices, when shown to the user with a
4451 * {@link #ACTION_CHOOSER}.
4452 */
4453 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4454
4455 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004456 * A {@link IntentSender} to start after ephemeral installation success.
Patrick Baumann159cd022018-01-11 13:25:05 -08004457 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
4458 * @removed
Todd Kennedy7440f172015-12-09 14:31:22 -08004459 * @hide
4460 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004461 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004462 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4463
4464 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004465 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004466 * @hide
4467 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004468 @SystemApi
4469 public static final String EXTRA_INSTANT_APP_SUCCESS =
4470 "android.intent.extra.INSTANT_APP_SUCCESS";
4471
4472 /**
4473 * A {@link IntentSender} to start after ephemeral installation failure.
4474 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
4475 * @removed
4476 * @hide
4477 */
4478 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004479 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4480
4481 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004482 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004483 * @hide
4484 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004485 @SystemApi
4486 public static final String EXTRA_INSTANT_APP_FAILURE =
4487 "android.intent.extra.INSTANT_APP_FAILURE";
4488
4489 /**
4490 * The host name that triggered an ephemeral resolution.
4491 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
4492 * @removed
4493 * @hide
4494 */
4495 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004496 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4497
4498 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004499 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004500 * @hide
4501 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004502 @SystemApi
4503 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4504 "android.intent.extra.INSTANT_APP_HOSTNAME";
4505
4506 /**
4507 * An opaque token to track ephemeral resolution.
4508 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
4509 * @removed
4510 * @hide
4511 */
4512 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004513 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4514
4515 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004516 * An opaque token to track instant app resolution.
4517 * @hide
4518 */
4519 @SystemApi
4520 public static final String EXTRA_INSTANT_APP_TOKEN =
4521 "android.intent.extra.INSTANT_APP_TOKEN";
4522
4523 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004524 * The action that triggered an instant application resolution.
4525 * @hide
4526 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004527 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004528 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4529
4530 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004531 * An array of {@link Bundle}s containing details about resolved instant apps..
4532 * @hide
4533 */
4534 @SystemApi
4535 public static final String EXTRA_INSTANT_APP_BUNDLES =
4536 "android.intent.extra.INSTANT_APP_BUNDLES";
4537
4538 /**
4539 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004540 * installed. This data is populated from the response to
4541 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4542 * instant application resolver.
4543 * @hide
4544 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004545 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004546 public static final String EXTRA_INSTANT_APP_EXTRAS =
4547 "android.intent.extra.INSTANT_APP_EXTRAS";
4548
4549 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004550 * A boolean value indicating that the instant app resolver was unable to state with certainty
4551 * that it did or did not have an app for the sanitized {@link Intent} defined at
4552 * {@link #EXTRA_INTENT}.
4553 * @hide
4554 */
4555 @SystemApi
4556 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4557 "android.intent.extra.UNKNOWN_INSTANT_APP";
4558
4559 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004560 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004561 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004562 * @hide
4563 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004564 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004565 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4566
4567 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004568 * The version code of the app to install components from.
4569 * @hide
4570 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004571 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004572 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4573
4574 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004575 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004576 * @hide
4577 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004578 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004579 public static final String EXTRA_CALLING_PACKAGE
4580 = "android.intent.extra.CALLING_PACKAGE";
4581
4582 /**
4583 * Optional calling app provided bundle containing additional launch information the
4584 * installer may use.
4585 * @hide
4586 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004587 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004588 public static final String EXTRA_VERIFICATION_BUNDLE
4589 = "android.intent.extra.VERIFICATION_BUNDLE";
4590
4591 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004592 * A Bundle forming a mapping of potential target package names to different extras Bundles
4593 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4594 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4595 * be currently installed on the device.
4596 *
4597 * <p>An application may choose to provide alternate extras for the case where a user
4598 * selects an activity from a predetermined set of target packages. If the activity
4599 * the user selects from the chooser belongs to a package with its package name as
4600 * a key in this bundle, the corresponding extras for that package will be merged with
4601 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4602 * extra has the same key as an extra already present in the intent it will overwrite
4603 * the extra from the intent.</p>
4604 *
4605 * <p><em>Examples:</em>
4606 * <ul>
4607 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4608 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4609 * parameters for that target.</li>
4610 * <li>An application may offer additional metadata for known targets of a given intent
4611 * to pass along information only relevant to that target such as account or content
4612 * identifiers already known to that application.</li>
4613 * </ul></p>
4614 */
4615 public static final String EXTRA_REPLACEMENT_EXTRAS =
4616 "android.intent.extra.REPLACEMENT_EXTRAS";
4617
4618 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004619 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4620 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4621 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4622 * {@link ComponentName} of the chosen component.
4623 *
4624 * <p>In some situations this callback may never come, for example if the user abandons
4625 * the chooser, switches to another task or any number of other reasons. Apps should not
4626 * be written assuming that this callback will always occur.</p>
4627 */
4628 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4629 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4630
4631 /**
4632 * The {@link ComponentName} chosen by the user to complete an action.
4633 *
4634 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4635 */
4636 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4637
4638 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004639 * A {@link android.view.KeyEvent} object containing the event that
4640 * triggered the creation of the Intent it is in.
4641 */
4642 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4643
4644 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004645 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4646 * before shutting down.
4647 *
4648 * {@hide}
4649 */
4650 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4651
4652 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004653 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4654 * requested by the user.
4655 *
4656 * {@hide}
4657 */
4658 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4659 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4660
4661 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004662 * 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 -07004663 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4664 * of restarting the application.
4665 */
4666 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4667
4668 /**
4669 * A String holding the phone number originally entered in
4670 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4671 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4672 */
4673 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004674
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004675 /**
4676 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4677 * intents to supply the uid the package had been assigned. Also an optional
4678 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4679 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4680 * purpose.
4681 */
4682 public static final String EXTRA_UID = "android.intent.extra.UID";
4683
4684 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004685 * @hide String array of package names.
4686 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004687 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004688 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4689
4690 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004691 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4692 * intents to indicate whether this represents a full uninstall (removing
4693 * both the code and its data) or a partial uninstall (leaving its data,
4694 * implying that this is an update).
4695 */
4696 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004697
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004698 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004699 * @hide
4700 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4701 * intents to indicate that at this point the package has been removed for
4702 * all users on the device.
4703 */
4704 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4705 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4706
4707 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004708 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4709 * intents to indicate that this is a replacement of the package, so this
4710 * broadcast will immediately be followed by an add broadcast for a
4711 * different version of the same package.
4712 */
4713 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004714
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004715 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004716 * Used as an int extra field in {@link android.app.AlarmManager} intents
4717 * to tell the application being invoked how many pending alarms are being
4718 * delievered with the intent. For one-shot alarms this will always be 1.
4719 * For recurring alarms, this might be greater than 1 if the device was
4720 * asleep or powered off at the time an earlier alarm would have been
4721 * delivered.
4722 */
4723 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004724
Jacek Surazski86b6c532009-05-13 14:38:28 +02004725 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004726 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4727 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004728 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4729 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004730 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4731 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4732 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004733 */
4734 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4735
4736 /**
4737 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4738 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004739 */
4740 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4741
4742 /**
4743 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4744 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004745 */
4746 public static final int EXTRA_DOCK_STATE_DESK = 1;
4747
4748 /**
4749 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4750 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004751 */
4752 public static final int EXTRA_DOCK_STATE_CAR = 2;
4753
4754 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004755 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4756 * to represent that the phone is in a analog (low end) dock.
4757 */
4758 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4759
4760 /**
4761 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4762 * to represent that the phone is in a digital (high end) dock.
4763 */
4764 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4765
4766 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004767 * Boolean that can be supplied as meta-data with a dock activity, to
4768 * indicate that the dock should take over the home key when it is active.
4769 */
4770 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004771
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004772 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004773 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4774 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004775 */
4776 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4777
4778 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004779 * Used in the extra field in the remote intent. It's astring token passed with the
4780 * remote intent.
4781 */
4782 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4783 "android.intent.extra.remote_intent_token";
4784
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004785 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004786 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004787 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004788 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004789 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004790 "android.intent.extra.changed_component_name";
4791
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004792 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004793 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004794 * and contains a string array of all of the components that have changed. If
4795 * the state of the overall package has changed, then it will contain an entry
4796 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004797 */
4798 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4799 "android.intent.extra.changed_component_name_list";
4800
4801 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004802 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004803 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004804 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4805 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4806 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004807 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004808 */
4809 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4810 "android.intent.extra.changed_package_list";
4811
4812 /**
4813 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004814 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4815 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004816 * and contains an integer array of uids of all of the components
4817 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004818 */
4819 public static final String EXTRA_CHANGED_UID_LIST =
4820 "android.intent.extra.changed_uid_list";
4821
4822 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004823 * @hide
4824 * Magic extra system code can use when binding, to give a label for
4825 * who it is that has bound to a service. This is an integer giving
4826 * a framework string resource that can be displayed to the user.
4827 */
4828 public static final String EXTRA_CLIENT_LABEL =
4829 "android.intent.extra.client_label";
4830
4831 /**
4832 * @hide
4833 * Magic extra system code can use when binding, to give a PendingIntent object
4834 * that can be launched for the user to disable the system's use of this
4835 * service.
4836 */
4837 public static final String EXTRA_CLIENT_INTENT =
4838 "android.intent.extra.client_intent";
4839
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004840 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004841 * Extra used to indicate that an intent should only return data that is on
4842 * the local device. This is a boolean extra; the default is false. If true,
4843 * an implementation should only allow the user to select data that is
4844 * already on the device, not requiring it be downloaded from a remote
4845 * service when opened.
4846 *
4847 * @see #ACTION_GET_CONTENT
4848 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004849 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004850 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004851 */
4852 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004853 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004854
Amith Yamasani13593602012-03-22 16:16:17 -07004855 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004856 * Extra used to indicate that an intent can allow the user to select and
4857 * return multiple items. This is a boolean extra; the default is false. If
4858 * true, an implementation is allowed to present the user with a UI where
4859 * they can pick multiple items that are all returned to the caller. When
4860 * this happens, they should be returned as the {@link #getClipData()} part
4861 * of the result Intent.
4862 *
4863 * @see #ACTION_GET_CONTENT
4864 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004865 */
4866 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004867 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004868
4869 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004870 * The integer userHandle carried with broadcast intents related to addition, removal and
4871 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4872 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4873 *
Amith Yamasani13593602012-03-22 16:16:17 -07004874 * @hide
4875 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004876 public static final String EXTRA_USER_HANDLE =
4877 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004878
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004879 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004880 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4881 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4882 */
4883 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004884 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004885
4886 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004887 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004888 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4889 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004890 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004891 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4892
4893 /**
4894 * Extra sent in the intent to the BroadcastReceiver that handles
4895 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4896 * the restrictions as key/value pairs.
4897 */
4898 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4899 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004900
Amith Yamasani86118ba2013-03-28 14:33:16 -07004901 /**
4902 * Extra used in the response from a BroadcastReceiver that handles
4903 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4904 */
4905 public static final String EXTRA_RESTRICTIONS_INTENT =
4906 "android.intent.extra.restrictions_intent";
4907
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004908 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004909 * Extra used to communicate a set of acceptable MIME types. The type of the
4910 * extra is {@code String[]}. Values may be a combination of concrete MIME
4911 * types (such as "image/png") and/or partial MIME types (such as
4912 * "audio/*").
4913 *
4914 * @see #ACTION_GET_CONTENT
4915 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004916 */
4917 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4918
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004919 /**
4920 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4921 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004922 * When this is true, hardware devices can use this information to determine that
4923 * they shouldn't do a complete shutdown of their device since this is not a
4924 * complete shutdown down to the kernel, but only user space restarting.
4925 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004926 */
4927 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4928 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4929
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004930 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004931 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4932 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4933 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4934 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004935 *
4936 * @hide for internal use only.
4937 */
4938 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4939 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004940 /** @hide */
4941 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4942 /** @hide */
4943 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4944 /** @hide */
4945 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004946
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07004947 /**
4948 * Intent extra: the reason that the operation associated with this intent is being performed.
4949 *
4950 * <p>Type: String
4951 * @hide
4952 */
4953 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004954 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4955
qingxi240c2bb2017-04-12 17:31:18 -07004956 /**
4957 * {@hide}
4958 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4959 */
Rubin Xue8490f12015-06-25 12:17:48 +01004960 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4961
Santos Cordon15a13782015-03-31 18:32:31 -07004962 /**
qingxi240c2bb2017-04-12 17:31:18 -07004963 * {@hide}
4964 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4965 * reset for the device with eSIM. This extra will be sent together with
4966 * {@link #ACTION_FACTORY_RESET}
4967 */
4968 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4969
4970 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004971 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4972 * activation request.
4973 * TODO: Add information about the structure and response data used with the pending intent.
4974 * @hide
4975 */
4976 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4977 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4978
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004979 /**
4980 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004981 *
4982 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004983 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004984 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004985 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4986
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004987 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004988 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4989 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4990 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004991 *
4992 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004993 * @see #ACTION_QUICK_VIEW
4994 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004995 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004996 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004997 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4998 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004999
5000 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005001 * An optional extra of {@code String[]} indicating which quick view features should be made
5002 * available to the user in the quick view UI while handing a
5003 * {@link Intent#ACTION_QUICK_VIEW} intent.
5004 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5005 * Quick viewer can implement features not listed below.
5006 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005007 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5008 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5009 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005010 * <p>
5011 * Requirements:
5012 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5013 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5014 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5015 * internal policies.
5016 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5017 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5018 * disable or hide features.
5019 *
5020 * @see #ACTION_QUICK_VIEW
5021 */
5022 public static final String EXTRA_QUICK_VIEW_FEATURES =
5023 "android.intent.extra.QUICK_VIEW_FEATURES";
5024
5025 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005026 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005027 * When a profile goes into quiet mode, all apps in the profile are killed and the
5028 * profile user is stopped. Widgets originating from the profile are masked, and app
5029 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005030 */
5031 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005032
5033 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005034 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005035 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005036 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5037 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005038 *
5039 * @hide
5040 */
5041 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5042 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5043
5044 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005045 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5046 * whether to show the chooser or not when there is only one application available
5047 * to choose from.
5048 *
5049 * @hide
5050 */
5051 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5052 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5053
5054 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005055 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005056 * to represent that a video codec is allowed to use.
5057 *
5058 * @hide
5059 */
5060 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5061
5062 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005063 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005064 * to represent that a audio codec is allowed to use.
5065 *
5066 * @hide
5067 */
5068 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5069
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005070 // ---------------------------------------------------------------------
5071 // ---------------------------------------------------------------------
5072 // Intent flags (see mFlags variable).
5073
Tor Norbyed9273d62013-05-30 15:59:53 -07005074 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005075 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005076 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5077 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005078 @Retention(RetentionPolicy.SOURCE)
5079 public @interface GrantUriMode {}
5080
Jeff Sharkey846318a2014-04-04 12:12:41 -07005081 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005082 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005083 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5084 @Retention(RetentionPolicy.SOURCE)
5085 public @interface AccessUriMode {}
5086
5087 /**
5088 * Test if given mode flags specify an access mode, which must be at least
5089 * read and/or write.
5090 *
5091 * @hide
5092 */
5093 public static boolean isAccessUriMode(int modeFlags) {
5094 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5095 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5096 }
5097
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005098 /** @hide */
5099 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5100 FLAG_GRANT_READ_URI_PERMISSION,
5101 FLAG_GRANT_WRITE_URI_PERMISSION,
5102 FLAG_FROM_BACKGROUND,
5103 FLAG_DEBUG_LOG_RESOLUTION,
5104 FLAG_EXCLUDE_STOPPED_PACKAGES,
5105 FLAG_INCLUDE_STOPPED_PACKAGES,
5106 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5107 FLAG_GRANT_PREFIX_URI_PERMISSION,
5108 FLAG_DEBUG_TRIAGED_MISSING,
5109 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005110 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005111 FLAG_ACTIVITY_NO_HISTORY,
5112 FLAG_ACTIVITY_SINGLE_TOP,
5113 FLAG_ACTIVITY_NEW_TASK,
5114 FLAG_ACTIVITY_MULTIPLE_TASK,
5115 FLAG_ACTIVITY_CLEAR_TOP,
5116 FLAG_ACTIVITY_FORWARD_RESULT,
5117 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5118 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5119 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5120 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5121 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5122 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5123 FLAG_ACTIVITY_NEW_DOCUMENT,
5124 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5125 FLAG_ACTIVITY_NO_USER_ACTION,
5126 FLAG_ACTIVITY_REORDER_TO_FRONT,
5127 FLAG_ACTIVITY_NO_ANIMATION,
5128 FLAG_ACTIVITY_CLEAR_TASK,
5129 FLAG_ACTIVITY_TASK_ON_HOME,
5130 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5131 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5132 FLAG_RECEIVER_REGISTERED_ONLY,
5133 FLAG_RECEIVER_REPLACE_PENDING,
5134 FLAG_RECEIVER_FOREGROUND,
5135 FLAG_RECEIVER_NO_ABORT,
5136 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5137 FLAG_RECEIVER_BOOT_UPGRADE,
5138 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5139 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5140 FLAG_RECEIVER_FROM_SHELL,
5141 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5142 })
5143 @Retention(RetentionPolicy.SOURCE)
5144 public @interface Flags {}
5145
5146 /** @hide */
5147 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5148 FLAG_FROM_BACKGROUND,
5149 FLAG_DEBUG_LOG_RESOLUTION,
5150 FLAG_EXCLUDE_STOPPED_PACKAGES,
5151 FLAG_INCLUDE_STOPPED_PACKAGES,
5152 FLAG_DEBUG_TRIAGED_MISSING,
5153 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005154 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005155 FLAG_ACTIVITY_NO_HISTORY,
5156 FLAG_ACTIVITY_SINGLE_TOP,
5157 FLAG_ACTIVITY_NEW_TASK,
5158 FLAG_ACTIVITY_MULTIPLE_TASK,
5159 FLAG_ACTIVITY_CLEAR_TOP,
5160 FLAG_ACTIVITY_FORWARD_RESULT,
5161 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5162 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5163 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5164 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5165 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5166 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5167 FLAG_ACTIVITY_NEW_DOCUMENT,
5168 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5169 FLAG_ACTIVITY_NO_USER_ACTION,
5170 FLAG_ACTIVITY_REORDER_TO_FRONT,
5171 FLAG_ACTIVITY_NO_ANIMATION,
5172 FLAG_ACTIVITY_CLEAR_TASK,
5173 FLAG_ACTIVITY_TASK_ON_HOME,
5174 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5175 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5176 FLAG_RECEIVER_REGISTERED_ONLY,
5177 FLAG_RECEIVER_REPLACE_PENDING,
5178 FLAG_RECEIVER_FOREGROUND,
5179 FLAG_RECEIVER_NO_ABORT,
5180 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5181 FLAG_RECEIVER_BOOT_UPGRADE,
5182 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5183 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5184 FLAG_RECEIVER_FROM_SHELL,
5185 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5186 })
5187 @Retention(RetentionPolicy.SOURCE)
5188 public @interface MutableFlags {}
5189
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005190 /**
5191 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005192 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005193 * specified in its ClipData. When applying to an Intent's ClipData,
5194 * all URIs as well as recursive traversals through data or other ClipData
5195 * in Intent items will be granted; only the grant flags of the top-level
5196 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005197 */
5198 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5199 /**
5200 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005201 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005202 * specified in its ClipData. When applying to an Intent's ClipData,
5203 * all URIs as well as recursive traversals through data or other ClipData
5204 * in Intent items will be granted; only the grant flags of the top-level
5205 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005206 */
5207 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5208 /**
5209 * Can be set by the caller to indicate that this Intent is coming from
5210 * a background operation, not from direct user interaction.
5211 */
5212 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5213 /**
5214 * A flag you can enable for debugging: when set, log messages will be
5215 * printed during the resolution of this intent to show you what has
5216 * been found to create the final resolved list.
5217 */
5218 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005219 /**
5220 * If set, this intent will not match any components in packages that
5221 * are currently stopped. If this is not set, then the default behavior
5222 * is to include such applications in the result.
5223 */
5224 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5225 /**
5226 * If set, this intent will always match any components in packages that
5227 * are currently stopped. This is the default behavior when
5228 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5229 * flags are set, this one wins (it allows overriding of exclude for
5230 * places where the framework may automatically set the exclude flag).
5231 */
5232 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005233
5234 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005235 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005236 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005237 * persisted across device reboots until explicitly revoked with
5238 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5239 * grant for possible persisting; the receiving application must call
5240 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5241 * actually persist.
5242 *
5243 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5244 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5245 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005246 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005247 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005248 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005249
5250 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005251 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5252 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5253 * applies to any URI that is a prefix match against the original granted
5254 * URI. (Without this flag, the URI must match exactly for access to be
5255 * granted.) Another URI is considered a prefix match only when scheme,
5256 * authority, and all path segments defined by the prefix are an exact
5257 * match.
5258 */
5259 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5260
5261 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005262 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005263 * homework and verified that they correctly handle packages and components
5264 * that come and go over time. In particular:
5265 * <ul>
5266 * <li>Apps installed on external storage, which will appear to be
5267 * uninstalled while the the device is ejected.
5268 * <li>Apps with encryption unaware components, which will appear to not
5269 * exist while the device is locked.
5270 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005271 *
5272 * @hide
5273 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005274 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005275
5276 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005277 * Internal flag used to indicate ephemeral applications should not be
5278 * considered when resolving the intent.
5279 *
5280 * @hide
5281 */
5282 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5283
5284 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005285 * If set, the new activity is not kept in the history stack. As soon as
5286 * the user navigates away from it, the activity is finished. This may also
5287 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5288 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005289 *
5290 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5291 * is never invoked when the current activity starts a new activity which
5292 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005293 */
5294 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5295 /**
5296 * If set, the activity will not be launched if it is already running
5297 * at the top of the history stack.
5298 */
5299 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5300 /**
5301 * If set, this activity will become the start of a new task on this
5302 * history stack. A task (from the activity that started it to the
5303 * next task activity) defines an atomic group of activities that the
5304 * user can move to. Tasks can be moved to the foreground and background;
5305 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005306 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005307 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5308 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005309 *
5310 * <p>This flag is generally used by activities that want
5311 * to present a "launcher" style behavior: they give the user a list of
5312 * separate things that can be done, which otherwise run completely
5313 * independently of the activity launching them.
5314 *
5315 * <p>When using this flag, if a task is already running for the activity
5316 * you are now starting, then a new activity will not be started; instead,
5317 * the current task will simply be brought to the front of the screen with
5318 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5319 * to disable this behavior.
5320 *
5321 * <p>This flag can not be used when the caller is requesting a result from
5322 * the activity being launched.
5323 */
5324 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5325 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005326 * This flag is used to create a new task and launch an activity into it.
5327 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5328 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5329 * search through existing tasks for ones matching this Intent. Only if no such
5330 * task is found would a new task be created. When paired with
5331 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5332 * the search for a matching task and unconditionally start a new task.
5333 *
5334 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5335 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005336 * top-level application launcher.</strong> Used in conjunction with
5337 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5338 * behavior of bringing an existing task to the foreground. When set,
5339 * a new task is <em>always</em> started to host the Activity for the
5340 * Intent, regardless of whether there is already an existing task running
5341 * the same thing.
5342 *
5343 * <p><strong>Because the default system does not include graphical task management,
5344 * you should not use this flag unless you provide some way for a user to
5345 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005346 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005347 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5348 * creating new document tasks.
5349 *
5350 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005351 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005352 *
Scott Main7aee61f2011-02-08 11:25:01 -08005353 * <p>See
5354 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5355 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005356 *
5357 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5358 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359 */
5360 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5361 /**
5362 * If set, and the activity being launched is already running in the
5363 * current task, then instead of launching a new instance of that activity,
5364 * all of the other activities on top of it will be closed and this Intent
5365 * will be delivered to the (now on top) old activity as a new Intent.
5366 *
5367 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5368 * If D calls startActivity() with an Intent that resolves to the component
5369 * of activity B, then C and D will be finished and B receive the given
5370 * Intent, resulting in the stack now being: A, B.
5371 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005372 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005373 * either receive the new intent you are starting here in its
5374 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005375 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005376 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5377 * the same intent, then it will be finished and re-created; for all other
5378 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5379 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380 *
5381 * <p>This launch mode can also be used to good effect in conjunction with
5382 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5383 * of a task, it will bring any currently running instance of that task
5384 * to the foreground, and then clear it to its root state. This is
5385 * especially useful, for example, when launching an activity from the
5386 * notification manager.
5387 *
Scott Main7aee61f2011-02-08 11:25:01 -08005388 * <p>See
5389 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5390 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005391 */
5392 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5393 /**
5394 * If set and this intent is being used to launch a new activity from an
5395 * existing one, then the reply target of the existing activity will be
5396 * transfered to the new activity. This way the new activity can call
5397 * {@link android.app.Activity#setResult} and have that result sent back to
5398 * the reply target of the original activity.
5399 */
5400 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5401 /**
5402 * If set and this intent is being used to launch a new activity from an
5403 * existing one, the current activity will not be counted as the top
5404 * activity for deciding whether the new intent should be delivered to
5405 * the top instead of starting a new one. The previous activity will
5406 * be used as the top, with the assumption being that the current activity
5407 * will finish itself immediately.
5408 */
5409 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5410 /**
5411 * If set, the new activity is not kept in the list of recently launched
5412 * activities.
5413 */
5414 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5415 /**
5416 * This flag is not normally set by application code, but set for you by
5417 * the system as described in the
5418 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5419 * launchMode} documentation for the singleTask mode.
5420 */
5421 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5422 /**
5423 * If set, and this activity is either being started in a new task or
5424 * bringing to the top an existing task, then it will be launched as
5425 * the front door of the task. This will result in the application of
5426 * any affinities needed to have that task in the proper state (either
5427 * moving activities to or from it), or simply resetting that task to
5428 * its initial state if needed.
5429 */
5430 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5431 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005432 * This flag is not normally set by application code, but set for you by
5433 * the system if this activity is being launched from history
5434 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005435 */
5436 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005437 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005438 * @deprecated As of API 21 this performs identically to
5439 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005440 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005441 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005442 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005443 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005444 * This flag is used to open a document into a new task rooted at the activity launched
5445 * by this Intent. Through the use of this flag, or its equivalent attribute,
5446 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005447 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005448 *
Craig Mautner026596b2014-05-21 15:35:44 -07005449 * <p>The use of the activity attribute form of this,
5450 * {@link android.R.attr#documentLaunchMode}, is
5451 * preferred over the Intent flag described here. The attribute form allows the
5452 * Activity to specify multiple document behavior for all launchers of the Activity
5453 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005454 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005455 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5456 * it is kept after the activity is finished is different than the use of
5457 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5458 * this flag is being used to create a new recents entry, then by default that entry
5459 * will be removed once the activity is finished. You can modify this behavior with
5460 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5461 *
Craig Mautner026596b2014-05-21 15:35:44 -07005462 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5463 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5464 * equivalent of the Activity manifest specifying {@link
5465 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5466 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5467 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005468 *
Craig Mautner026596b2014-05-21 15:35:44 -07005469 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005470 *
Craig Mautner026596b2014-05-21 15:35:44 -07005471 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005472 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5473 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005474 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005475 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005476 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005477 * callback from occurring on the current frontmost activity before it is
5478 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005479 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005480 * <p>Typically, an activity can rely on that callback to indicate that an
5481 * explicit user action has caused their activity to be moved out of the
5482 * foreground. The callback marks an appropriate point in the activity's
5483 * lifecycle for it to dismiss any notifications that it intends to display
5484 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005485 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005486 * <p>If an activity is ever started via any non-user-driven events such as
5487 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5488 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005489 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005490 */
5491 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005492 /**
5493 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5494 * this flag will cause the launched activity to be brought to the front of its
5495 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005496 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005497 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5498 * If D calls startActivity() with an Intent that resolves to the component
5499 * of activity B, then B will be brought to the front of the history stack,
5500 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005501 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005502 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005503 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005504 */
5505 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005506 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005507 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5508 * this flag will prevent the system from applying an activity transition
5509 * animation to go to the next activity state. This doesn't mean an
5510 * animation will never run -- if another activity change happens that doesn't
5511 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005512 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005513 * when you are going to do a series of activity operations but the
5514 * animation seen by the user shouldn't be driven by the first activity
5515 * change but rather a later one.
5516 */
5517 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5518 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005519 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5520 * this flag will cause any existing task that would be associated with the
5521 * activity to be cleared before the activity is started. That is, the activity
5522 * becomes the new root of an otherwise empty task, and any old activities
5523 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5524 */
5525 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5526 /**
5527 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5528 * this flag will cause a newly launching task to be placed on top of the current
5529 * home activity task (if there is one). That is, pressing back from the task
5530 * will always return the user to home even if that was not the last activity they
5531 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5532 */
5533 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5534 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005535 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5536 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005537 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005538 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005539 * this flag. When set and the task's activity is finished, the recents
5540 * entry will remain in the interface for the user to re-launch it, like a
5541 * recents entry for a top-level application.
5542 * <p>
5543 * The receiving activity can override this request with
5544 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5545 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005546 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005547 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005548 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005549
5550 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005551 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5552 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005553 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5554 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005555 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005556 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005557
Patrick Baumann577d4022018-01-31 16:55:10 +00005558
5559 /**
5560 * If set, resolution of this intent may take place via an instant app not
5561 * yet on the device if there does not yet exist an app on device to
5562 * resolve it.
5563 */
5564 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5565
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005566 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005567 * If set, when sending a broadcast only registered receivers will be
5568 * called -- no BroadcastReceiver components will be launched.
5569 */
5570 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005571 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005572 * If set, when sending a broadcast the new broadcast will replace
5573 * any existing pending broadcast that matches it. Matching is defined
5574 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5575 * true for the intents of the two broadcasts. When a match is found,
5576 * the new broadcast (and receivers associated with it) will replace the
5577 * existing one in the pending broadcast list, remaining at the same
5578 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005579 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005580 * <p>This flag is most typically used with sticky broadcasts, which
5581 * only care about delivering the most recent values of the broadcast
5582 * to their receivers.
5583 */
5584 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5585 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005586 * If set, when sending a broadcast the recipient is allowed to run at
5587 * foreground priority, with a shorter timeout interval. During normal
5588 * broadcasts the receivers are not automatically hoisted out of the
5589 * background priority class.
5590 */
5591 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5592 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005593 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5594 * They can still propagate results through to later receivers, but they can not prevent
5595 * later receivers from seeing the broadcast.
5596 */
5597 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5598 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005599 * If set, when sending a broadcast <i>before boot has completed</i> only
5600 * registered receivers will be called -- no BroadcastReceiver components
5601 * will be launched. Sticky intent state will be recorded properly even
5602 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5603 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005604 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005605 * <p>This flag is only for use by system sevices as a convenience to
5606 * avoid having to implement a more complex mechanism around detection
5607 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005608 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005609 * @hide
5610 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005611 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005612 /**
5613 * Set when this broadcast is for a boot upgrade, a special mode that
5614 * allows the broadcast to be sent before the system is ready and launches
5615 * the app process with no providers running in it.
5616 * @hide
5617 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005618 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005619 /**
5620 * If set, the broadcast will always go to manifest receivers in background (cached
5621 * or not running) apps, regardless of whether that would be done by default. By
5622 * default they will only receive broadcasts if the broadcast has specified an
5623 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005624 *
5625 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5626 * the broadcast code there must also be changed to match.
5627 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005628 * @hide
5629 */
5630 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5631 /**
5632 * If set, the broadcast will never go to manifest receivers in background (cached
5633 * or not running) apps, regardless of whether that would be done by default. By
5634 * default they will receive broadcasts if the broadcast has specified an
5635 * explicit component or package name.
5636 * @hide
5637 */
5638 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005639 /**
5640 * If set, this broadcast is being sent from the shell.
5641 * @hide
5642 */
5643 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005644
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005645 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005646 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5647 * will not receive broadcasts.
5648 *
5649 * <em>This flag has no effect when used by an Instant App.</em>
5650 */
5651 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5652
5653 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005654 * @hide Flags that can't be changed with PendingIntent.
5655 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005656 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5657 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5658 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005660 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005661 // ---------------------------------------------------------------------
5662 // toUri() and parseUri() options.
5663
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005664 /** @hide */
5665 @IntDef(flag = true, prefix = { "URI_" }, value = {
5666 URI_ALLOW_UNSAFE,
5667 URI_ANDROID_APP_SCHEME,
5668 URI_INTENT_SCHEME,
5669 })
5670 @Retention(RetentionPolicy.SOURCE)
5671 public @interface UriFlags {}
5672
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005673 /**
5674 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5675 * always has the "intent:" scheme. This syntax can be used when you want
5676 * to later disambiguate between URIs that are intended to describe an
5677 * Intent vs. all others that should be treated as raw URIs. When used
5678 * with {@link #parseUri}, any other scheme will result in a generic
5679 * VIEW action for that raw URI.
5680 */
5681 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005682
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005683 /**
5684 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5685 * always has the "android-app:" scheme. This is a variation of
5686 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5687 * http/https URI being delivered to a specific package name. The format
5688 * is:
5689 *
5690 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005691 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005692 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005693 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5694 * you must also include a scheme; including a path also requires both a host and a scheme.
5695 * The final #Intent; fragment can be used without a scheme, host, or path.
5696 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005697 * used with intents that have a {@link #setSelector}, since the base intent
5698 * will always have an explicit package name.</p>
5699 *
5700 * <p>Some examples of how this scheme maps to Intent objects:</p>
5701 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5702 * <colgroup align="left" />
5703 * <colgroup align="left" />
5704 * <thead>
5705 * <tr><th>URI</th> <th>Intent</th></tr>
5706 * </thead>
5707 *
5708 * <tbody>
5709 * <tr><td><code>android-app://com.example.app</code></td>
5710 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5711 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5712 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5713 * </table></td>
5714 * </tr>
5715 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5716 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5717 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5718 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5719 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5720 * </table></td>
5721 * </tr>
5722 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5723 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5724 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5725 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5726 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5727 * </table></td>
5728 * </tr>
5729 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5730 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5731 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5732 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5733 * </table></td>
5734 * </tr>
5735 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5736 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5737 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5738 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5739 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5740 * </table></td>
5741 * </tr>
5742 * <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>
5743 * <td><table border="" style="margin:0" >
5744 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5745 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5746 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5747 * </table></td>
5748 * </tr>
5749 * </tbody>
5750 * </table>
5751 */
5752 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5753
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005754 /**
5755 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5756 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5757 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5758 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5759 * generated Intent can not cause unexpected data access to happen.
5760 *
5761 * <p>If you do not trust the source of the URI being parsed, you should still do further
5762 * processing to protect yourself from it. In particular, when using it to start an
5763 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5764 * that can handle it.</p>
5765 */
5766 public static final int URI_ALLOW_UNSAFE = 1<<2;
5767
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005768 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005769
5770 private String mAction;
5771 private Uri mData;
5772 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005773 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 private ComponentName mComponent;
5775 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005776 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005777 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005778 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005779 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005780 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005781 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005782 /** Token to track instant app launches. Local only; do not copy cross-process. */
5783 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005784
5785 // ---------------------------------------------------------------------
5786
Makoto Onuki97f82f22017-05-31 16:20:21 -07005787 private static final int COPY_MODE_ALL = 0;
5788 private static final int COPY_MODE_FILTER = 1;
5789 private static final int COPY_MODE_HISTORY = 2;
5790
5791 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005792 @IntDef(prefix = { "COPY_MODE_" }, value = {
5793 COPY_MODE_ALL,
5794 COPY_MODE_FILTER,
5795 COPY_MODE_HISTORY
5796 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005797 @Retention(RetentionPolicy.SOURCE)
5798 public @interface CopyMode {}
5799
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005800 /**
5801 * Create an empty intent.
5802 */
5803 public Intent() {
5804 }
5805
5806 /**
5807 * Copy constructor.
5808 */
5809 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005810 this(o, COPY_MODE_ALL);
5811 }
5812
5813 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005814 this.mAction = o.mAction;
5815 this.mData = o.mData;
5816 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005817 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005818 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005819
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005820 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005821 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005823
5824 if (copyMode != COPY_MODE_FILTER) {
5825 this.mFlags = o.mFlags;
5826 this.mContentUserHint = o.mContentUserHint;
5827 this.mLaunchToken = o.mLaunchToken;
5828 if (o.mSourceBounds != null) {
5829 this.mSourceBounds = new Rect(o.mSourceBounds);
5830 }
5831 if (o.mSelector != null) {
5832 this.mSelector = new Intent(o.mSelector);
5833 }
5834
5835 if (copyMode != COPY_MODE_HISTORY) {
5836 if (o.mExtras != null) {
5837 this.mExtras = new Bundle(o.mExtras);
5838 }
5839 if (o.mClipData != null) {
5840 this.mClipData = new ClipData(o.mClipData);
5841 }
5842 } else {
5843 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5844 this.mExtras = Bundle.STRIPPED;
5845 }
5846
5847 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5848 // history.
5849 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005850 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005851 }
5852
5853 @Override
5854 public Object clone() {
5855 return new Intent(this);
5856 }
5857
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005858 /**
5859 * Make a clone of only the parts of the Intent that are relevant for
5860 * filter matching: the action, data, type, component, and categories.
5861 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005862 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005863 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005864 }
5865
5866 /**
5867 * Create an intent with a given action. All other fields (data, type,
5868 * class) are null. Note that the action <em>must</em> be in a
5869 * namespace because Intents are used globally in the system -- for
5870 * example the system VIEW action is android.intent.action.VIEW; an
5871 * application's custom action would be something like
5872 * com.google.app.myapp.CUSTOM_ACTION.
5873 *
5874 * @param action The Intent action, such as ACTION_VIEW.
5875 */
5876 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005877 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005878 }
5879
5880 /**
5881 * Create an intent with a given action and for a given data url. Note
5882 * that the action <em>must</em> be in a namespace because Intents are
5883 * used globally in the system -- for example the system VIEW action is
5884 * android.intent.action.VIEW; an application's custom action would be
5885 * something like com.google.app.myapp.CUSTOM_ACTION.
5886 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005887 * <p><em>Note: scheme and host name matching in the Android framework is
5888 * case-sensitive, unlike the formal RFC. As a result,
5889 * you should always ensure that you write your Uri with these elements
5890 * using lower case letters, and normalize any Uris you receive from
5891 * outside of Android to ensure the scheme and host is lower case.</em></p>
5892 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005893 * @param action The Intent action, such as ACTION_VIEW.
5894 * @param uri The Intent data URI.
5895 */
5896 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005897 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005898 mData = uri;
5899 }
5900
5901 /**
5902 * Create an intent for a specific component. All other fields (action, data,
5903 * type, class) are null, though they can be modified later with explicit
5904 * calls. This provides a convenient way to create an intent that is
5905 * intended to execute a hard-coded class name, rather than relying on the
5906 * system to find an appropriate class for you; see {@link #setComponent}
5907 * for more information on the repercussions of this.
5908 *
5909 * @param packageContext A Context of the application package implementing
5910 * this class.
5911 * @param cls The component class that is to be used for the intent.
5912 *
5913 * @see #setClass
5914 * @see #setComponent
5915 * @see #Intent(String, android.net.Uri , Context, Class)
5916 */
5917 public Intent(Context packageContext, Class<?> cls) {
5918 mComponent = new ComponentName(packageContext, cls);
5919 }
5920
5921 /**
5922 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005923 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005924 * construct the Intent and then calling {@link #setClass} to set its
5925 * class.
5926 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005927 * <p><em>Note: scheme and host name matching in the Android framework is
5928 * case-sensitive, unlike the formal RFC. As a result,
5929 * you should always ensure that you write your Uri with these elements
5930 * using lower case letters, and normalize any Uris you receive from
5931 * outside of Android to ensure the scheme and host is lower case.</em></p>
5932 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005933 * @param action The Intent action, such as ACTION_VIEW.
5934 * @param uri The Intent data URI.
5935 * @param packageContext A Context of the application package implementing
5936 * this class.
5937 * @param cls The component class that is to be used for the intent.
5938 *
5939 * @see #Intent(String, android.net.Uri)
5940 * @see #Intent(Context, Class)
5941 * @see #setClass
5942 * @see #setComponent
5943 */
5944 public Intent(String action, Uri uri,
5945 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005946 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005947 mData = uri;
5948 mComponent = new ComponentName(packageContext, cls);
5949 }
5950
5951 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005952 * Create an intent to launch the main (root) activity of a task. This
5953 * is the Intent that is started when the application's is launched from
5954 * Home. For anything else that wants to launch an application in the
5955 * same way, it is important that they use an Intent structured the same
5956 * way, and can use this function to ensure this is the case.
5957 *
5958 * <p>The returned Intent has the given Activity component as its explicit
5959 * component, {@link #ACTION_MAIN} as its action, and includes the
5960 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5961 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5962 * to do that through {@link #addFlags(int)} on the returned Intent.
5963 *
5964 * @param mainActivity The main activity component that this Intent will
5965 * launch.
5966 * @return Returns a newly created Intent that can be used to launch the
5967 * activity as a main application entry.
5968 *
5969 * @see #setClass
5970 * @see #setComponent
5971 */
5972 public static Intent makeMainActivity(ComponentName mainActivity) {
5973 Intent intent = new Intent(ACTION_MAIN);
5974 intent.setComponent(mainActivity);
5975 intent.addCategory(CATEGORY_LAUNCHER);
5976 return intent;
5977 }
5978
5979 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005980 * Make an Intent for the main activity of an application, without
5981 * specifying a specific activity to run but giving a selector to find
5982 * the activity. This results in a final Intent that is structured
5983 * the same as when the application is launched from
5984 * Home. For anything else that wants to launch an application in the
5985 * same way, it is important that they use an Intent structured the same
5986 * way, and can use this function to ensure this is the case.
5987 *
5988 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5989 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5990 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5991 * to do that through {@link #addFlags(int)} on the returned Intent.
5992 *
5993 * @param selectorAction The action name of the Intent's selector.
5994 * @param selectorCategory The name of a category to add to the Intent's
5995 * selector.
5996 * @return Returns a newly created Intent that can be used to launch the
5997 * activity as a main application entry.
5998 *
5999 * @see #setSelector(Intent)
6000 */
6001 public static Intent makeMainSelectorActivity(String selectorAction,
6002 String selectorCategory) {
6003 Intent intent = new Intent(ACTION_MAIN);
6004 intent.addCategory(CATEGORY_LAUNCHER);
6005 Intent selector = new Intent();
6006 selector.setAction(selectorAction);
6007 selector.addCategory(selectorCategory);
6008 intent.setSelector(selector);
6009 return intent;
6010 }
6011
6012 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006013 * Make an Intent that can be used to re-launch an application's task
6014 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6015 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6016 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6017 *
6018 * @param mainActivity The activity component that is the root of the
6019 * task; this is the activity that has been published in the application's
6020 * manifest as the main launcher icon.
6021 *
6022 * @return Returns a newly created Intent that can be used to relaunch the
6023 * activity's task in its root state.
6024 */
6025 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6026 Intent intent = makeMainActivity(mainActivity);
6027 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6028 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6029 return intent;
6030 }
6031
6032 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006033 * Call {@link #parseUri} with 0 flags.
6034 * @deprecated Use {@link #parseUri} instead.
6035 */
6036 @Deprecated
6037 public static Intent getIntent(String uri) throws URISyntaxException {
6038 return parseUri(uri, 0);
6039 }
Tom Taylord4a47292009-12-21 13:59:18 -08006040
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006041 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006042 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006043 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006044 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006045 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006046 *
6047 * <p>The URI given here must not be relative -- that is, it must include
6048 * the scheme and full path.
6049 *
6050 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006051 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006052 *
6053 * @return Intent The newly created Intent object.
6054 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006055 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6056 * it bad (as parsed by the Uri class) or the Intent data within the
6057 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006058 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006059 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006060 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006061 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006062 int i = 0;
6063 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006064 final boolean androidApp = uri.startsWith("android-app:");
6065
6066 // Validate intent scheme if requested.
6067 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6068 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006069 Intent intent = new Intent(ACTION_VIEW);
6070 try {
6071 intent.setData(Uri.parse(uri));
6072 } catch (IllegalArgumentException e) {
6073 throw new URISyntaxException(uri, e.getMessage());
6074 }
6075 return intent;
6076 }
6077 }
Tom Taylord4a47292009-12-21 13:59:18 -08006078
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006079 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006080 // simple case
6081 if (i == -1) {
6082 if (!androidApp) {
6083 return new Intent(ACTION_VIEW, Uri.parse(uri));
6084 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006085
6086 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006087 } else if (!uri.startsWith("#Intent;", i)) {
6088 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006089 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006090 } else {
6091 i = -1;
6092 }
6093 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006094
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006095 // new format
6096 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006097 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006098 boolean explicitAction = false;
6099 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006100
6101 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006102 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006103 String data;
6104 if (i >= 0) {
6105 data = uri.substring(0, i);
6106 i += 8; // length of "#Intent;"
6107 } else {
6108 data = uri;
6109 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006110
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006111 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006112 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006113 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006114 if (eq < 0) eq = i-1;
6115 int semi = uri.indexOf(';', i);
6116 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006117
6118 // action
6119 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006120 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006121 if (!inSelector) {
6122 explicitAction = true;
6123 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006124 }
6125
6126 // categories
6127 else if (uri.startsWith("category=", i)) {
6128 intent.addCategory(value);
6129 }
6130
6131 // type
6132 else if (uri.startsWith("type=", i)) {
6133 intent.mType = value;
6134 }
6135
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006136 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006137 else if (uri.startsWith("launchFlags=", i)) {
6138 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006139 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6140 intent.mFlags &= ~IMMUTABLE_FLAGS;
6141 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006142 }
6143
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006144 // package
6145 else if (uri.startsWith("package=", i)) {
6146 intent.mPackage = value;
6147 }
6148
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006149 // component
6150 else if (uri.startsWith("component=", i)) {
6151 intent.mComponent = ComponentName.unflattenFromString(value);
6152 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006153
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006154 // scheme
6155 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006156 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006157 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006158 } else {
6159 scheme = value;
6160 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006161 }
6162
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006163 // source bounds
6164 else if (uri.startsWith("sourceBounds=", i)) {
6165 intent.mSourceBounds = Rect.unflattenFromString(value);
6166 }
6167
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006168 // selector
6169 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6170 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006171 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006172 }
6173
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006174 // extra
6175 else {
6176 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006177 // create Bundle if it doesn't already exist
6178 if (intent.mExtras == null) intent.mExtras = new Bundle();
6179 Bundle b = intent.mExtras;
6180 // add EXTRA
6181 if (uri.startsWith("S.", i)) b.putString(key, value);
6182 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6183 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6184 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6185 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6186 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6187 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6188 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6189 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6190 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6191 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006192
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006193 // move to the next item
6194 i = semi + 1;
6195 }
6196
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006197 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006198 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006199 if (baseIntent.mPackage == null) {
6200 baseIntent.setSelector(intent);
6201 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006202 intent = baseIntent;
6203 }
6204
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006205 if (data != null) {
6206 if (data.startsWith("intent:")) {
6207 data = data.substring(7);
6208 if (scheme != null) {
6209 data = scheme + ':' + data;
6210 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006211 } else if (data.startsWith("android-app:")) {
6212 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6213 // Correctly formed android-app, first part is package name.
6214 int end = data.indexOf('/', 14);
6215 if (end < 0) {
6216 // All we have is a package name.
6217 intent.mPackage = data.substring(14);
6218 if (!explicitAction) {
6219 intent.setAction(ACTION_MAIN);
6220 }
6221 data = "";
6222 } else {
6223 // Target the Intent at the given package name always.
6224 String authority = null;
6225 intent.mPackage = data.substring(14, end);
6226 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006227 if ((end+1) < data.length()) {
6228 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6229 // Found a scheme, remember it.
6230 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006231 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006232 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6233 // Found a authority, remember it.
6234 authority = data.substring(end+1, newEnd);
6235 end = newEnd;
6236 }
6237 } else {
6238 // All we have is a scheme.
6239 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006240 }
6241 }
6242 if (scheme == null) {
6243 // If there was no scheme, then this just targets the package.
6244 if (!explicitAction) {
6245 intent.setAction(ACTION_MAIN);
6246 }
6247 data = "";
6248 } else if (authority == null) {
6249 data = scheme + ":";
6250 } else {
6251 data = scheme + "://" + authority + data.substring(end);
6252 }
6253 }
6254 } else {
6255 data = "";
6256 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006257 }
Tom Taylord4a47292009-12-21 13:59:18 -08006258
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006259 if (data.length() > 0) {
6260 try {
6261 intent.mData = Uri.parse(data);
6262 } catch (IllegalArgumentException e) {
6263 throw new URISyntaxException(uri, e.getMessage());
6264 }
6265 }
6266 }
Tom Taylord4a47292009-12-21 13:59:18 -08006267
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006268 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006269
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006270 } catch (IndexOutOfBoundsException e) {
6271 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6272 }
6273 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006274
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006275 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006276 return getIntentOld(uri, 0);
6277 }
6278
6279 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006280 Intent intent;
6281
6282 int i = uri.lastIndexOf('#');
6283 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006284 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006285 final int intentFragmentStart = i;
6286 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006287
6288 i++;
6289
6290 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006291 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006292 i += 7;
6293 int j = uri.indexOf(')', i);
6294 action = uri.substring(i, j);
6295 i = j + 1;
6296 }
6297
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006298 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006299
6300 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006301 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006302 i += 11;
6303 int j = uri.indexOf(')', i);
6304 while (i < j) {
6305 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006306 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006307 if (i < sep) {
6308 intent.addCategory(uri.substring(i, sep));
6309 }
6310 i = sep + 1;
6311 }
6312 i = j + 1;
6313 }
6314
6315 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006316 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006317 i += 5;
6318 int j = uri.indexOf(')', i);
6319 intent.mType = uri.substring(i, j);
6320 i = j + 1;
6321 }
6322
6323 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006324 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006325 i += 12;
6326 int j = uri.indexOf(')', i);
6327 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006328 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6329 intent.mFlags &= ~IMMUTABLE_FLAGS;
6330 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006331 i = j + 1;
6332 }
6333
6334 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006335 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006336 i += 10;
6337 int j = uri.indexOf(')', i);
6338 int sep = uri.indexOf('!', i);
6339 if (sep >= 0 && sep < j) {
6340 String pkg = uri.substring(i, sep);
6341 String cls = uri.substring(sep + 1, j);
6342 intent.mComponent = new ComponentName(pkg, cls);
6343 }
6344 i = j + 1;
6345 }
6346
6347 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006348 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006349 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006350
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006351 final int closeParen = uri.indexOf(')', i);
6352 if (closeParen == -1) throw new URISyntaxException(uri,
6353 "EXTRA missing trailing ')'", i);
6354
6355 while (i < closeParen) {
6356 // fetch the key value
6357 int j = uri.indexOf('=', i);
6358 if (j <= i + 1 || i >= closeParen) {
6359 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6360 }
6361 char type = uri.charAt(i);
6362 i++;
6363 String key = uri.substring(i, j);
6364 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006365
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006366 // get type-value
6367 j = uri.indexOf('!', i);
6368 if (j == -1 || j >= closeParen) j = closeParen;
6369 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6370 String value = uri.substring(i, j);
6371 i = j;
6372
6373 // create Bundle if it doesn't already exist
6374 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006375
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006376 // add item to bundle
6377 try {
6378 switch (type) {
6379 case 'S':
6380 intent.mExtras.putString(key, Uri.decode(value));
6381 break;
6382 case 'B':
6383 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6384 break;
6385 case 'b':
6386 intent.mExtras.putByte(key, Byte.parseByte(value));
6387 break;
6388 case 'c':
6389 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6390 break;
6391 case 'd':
6392 intent.mExtras.putDouble(key, Double.parseDouble(value));
6393 break;
6394 case 'f':
6395 intent.mExtras.putFloat(key, Float.parseFloat(value));
6396 break;
6397 case 'i':
6398 intent.mExtras.putInt(key, Integer.parseInt(value));
6399 break;
6400 case 'l':
6401 intent.mExtras.putLong(key, Long.parseLong(value));
6402 break;
6403 case 's':
6404 intent.mExtras.putShort(key, Short.parseShort(value));
6405 break;
6406 default:
6407 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6408 }
6409 } catch (NumberFormatException e) {
6410 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6411 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006412
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006413 char ch = uri.charAt(i);
6414 if (ch == ')') break;
6415 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6416 i++;
6417 }
6418 }
6419
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006420 if (isIntentFragment) {
6421 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6422 } else {
6423 intent.mData = Uri.parse(uri);
6424 }
Tom Taylord4a47292009-12-21 13:59:18 -08006425
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006426 if (intent.mAction == null) {
6427 // By default, if no action is specified, then use VIEW.
6428 intent.mAction = ACTION_VIEW;
6429 }
6430
6431 } else {
6432 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6433 }
6434
6435 return intent;
6436 }
6437
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006438 /** @hide */
6439 public interface CommandOptionHandler {
6440 boolean handleOption(String opt, ShellCommand cmd);
6441 }
6442
6443 /** @hide */
6444 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6445 throws URISyntaxException {
6446 Intent intent = new Intent();
6447 Intent baseIntent = intent;
6448 boolean hasIntentInfo = false;
6449
6450 Uri data = null;
6451 String type = null;
6452
6453 String opt;
6454 while ((opt=cmd.getNextOption()) != null) {
6455 switch (opt) {
6456 case "-a":
6457 intent.setAction(cmd.getNextArgRequired());
6458 if (intent == baseIntent) {
6459 hasIntentInfo = true;
6460 }
6461 break;
6462 case "-d":
6463 data = Uri.parse(cmd.getNextArgRequired());
6464 if (intent == baseIntent) {
6465 hasIntentInfo = true;
6466 }
6467 break;
6468 case "-t":
6469 type = cmd.getNextArgRequired();
6470 if (intent == baseIntent) {
6471 hasIntentInfo = true;
6472 }
6473 break;
6474 case "-c":
6475 intent.addCategory(cmd.getNextArgRequired());
6476 if (intent == baseIntent) {
6477 hasIntentInfo = true;
6478 }
6479 break;
6480 case "-e":
6481 case "--es": {
6482 String key = cmd.getNextArgRequired();
6483 String value = cmd.getNextArgRequired();
6484 intent.putExtra(key, value);
6485 }
6486 break;
6487 case "--esn": {
6488 String key = cmd.getNextArgRequired();
6489 intent.putExtra(key, (String) null);
6490 }
6491 break;
6492 case "--ei": {
6493 String key = cmd.getNextArgRequired();
6494 String value = cmd.getNextArgRequired();
6495 intent.putExtra(key, Integer.decode(value));
6496 }
6497 break;
6498 case "--eu": {
6499 String key = cmd.getNextArgRequired();
6500 String value = cmd.getNextArgRequired();
6501 intent.putExtra(key, Uri.parse(value));
6502 }
6503 break;
6504 case "--ecn": {
6505 String key = cmd.getNextArgRequired();
6506 String value = cmd.getNextArgRequired();
6507 ComponentName cn = ComponentName.unflattenFromString(value);
6508 if (cn == null)
6509 throw new IllegalArgumentException("Bad component name: " + value);
6510 intent.putExtra(key, cn);
6511 }
6512 break;
6513 case "--eia": {
6514 String key = cmd.getNextArgRequired();
6515 String value = cmd.getNextArgRequired();
6516 String[] strings = value.split(",");
6517 int[] list = new int[strings.length];
6518 for (int i = 0; i < strings.length; i++) {
6519 list[i] = Integer.decode(strings[i]);
6520 }
6521 intent.putExtra(key, list);
6522 }
6523 break;
6524 case "--eial": {
6525 String key = cmd.getNextArgRequired();
6526 String value = cmd.getNextArgRequired();
6527 String[] strings = value.split(",");
6528 ArrayList<Integer> list = new ArrayList<>(strings.length);
6529 for (int i = 0; i < strings.length; i++) {
6530 list.add(Integer.decode(strings[i]));
6531 }
6532 intent.putExtra(key, list);
6533 }
6534 break;
6535 case "--el": {
6536 String key = cmd.getNextArgRequired();
6537 String value = cmd.getNextArgRequired();
6538 intent.putExtra(key, Long.valueOf(value));
6539 }
6540 break;
6541 case "--ela": {
6542 String key = cmd.getNextArgRequired();
6543 String value = cmd.getNextArgRequired();
6544 String[] strings = value.split(",");
6545 long[] list = new long[strings.length];
6546 for (int i = 0; i < strings.length; i++) {
6547 list[i] = Long.valueOf(strings[i]);
6548 }
6549 intent.putExtra(key, list);
6550 hasIntentInfo = true;
6551 }
6552 break;
6553 case "--elal": {
6554 String key = cmd.getNextArgRequired();
6555 String value = cmd.getNextArgRequired();
6556 String[] strings = value.split(",");
6557 ArrayList<Long> list = new ArrayList<>(strings.length);
6558 for (int i = 0; i < strings.length; i++) {
6559 list.add(Long.valueOf(strings[i]));
6560 }
6561 intent.putExtra(key, list);
6562 hasIntentInfo = true;
6563 }
6564 break;
6565 case "--ef": {
6566 String key = cmd.getNextArgRequired();
6567 String value = cmd.getNextArgRequired();
6568 intent.putExtra(key, Float.valueOf(value));
6569 hasIntentInfo = true;
6570 }
6571 break;
6572 case "--efa": {
6573 String key = cmd.getNextArgRequired();
6574 String value = cmd.getNextArgRequired();
6575 String[] strings = value.split(",");
6576 float[] list = new float[strings.length];
6577 for (int i = 0; i < strings.length; i++) {
6578 list[i] = Float.valueOf(strings[i]);
6579 }
6580 intent.putExtra(key, list);
6581 hasIntentInfo = true;
6582 }
6583 break;
6584 case "--efal": {
6585 String key = cmd.getNextArgRequired();
6586 String value = cmd.getNextArgRequired();
6587 String[] strings = value.split(",");
6588 ArrayList<Float> list = new ArrayList<>(strings.length);
6589 for (int i = 0; i < strings.length; i++) {
6590 list.add(Float.valueOf(strings[i]));
6591 }
6592 intent.putExtra(key, list);
6593 hasIntentInfo = true;
6594 }
6595 break;
6596 case "--esa": {
6597 String key = cmd.getNextArgRequired();
6598 String value = cmd.getNextArgRequired();
6599 // Split on commas unless they are preceeded by an escape.
6600 // The escape character must be escaped for the string and
6601 // again for the regex, thus four escape characters become one.
6602 String[] strings = value.split("(?<!\\\\),");
6603 intent.putExtra(key, strings);
6604 hasIntentInfo = true;
6605 }
6606 break;
6607 case "--esal": {
6608 String key = cmd.getNextArgRequired();
6609 String value = cmd.getNextArgRequired();
6610 // Split on commas unless they are preceeded by an escape.
6611 // The escape character must be escaped for the string and
6612 // again for the regex, thus four escape characters become one.
6613 String[] strings = value.split("(?<!\\\\),");
6614 ArrayList<String> list = new ArrayList<>(strings.length);
6615 for (int i = 0; i < strings.length; i++) {
6616 list.add(strings[i]);
6617 }
6618 intent.putExtra(key, list);
6619 hasIntentInfo = true;
6620 }
6621 break;
6622 case "--ez": {
6623 String key = cmd.getNextArgRequired();
6624 String value = cmd.getNextArgRequired().toLowerCase();
6625 // Boolean.valueOf() results in false for anything that is not "true", which is
6626 // error-prone in shell commands
6627 boolean arg;
6628 if ("true".equals(value) || "t".equals(value)) {
6629 arg = true;
6630 } else if ("false".equals(value) || "f".equals(value)) {
6631 arg = false;
6632 } else {
6633 try {
6634 arg = Integer.decode(value) != 0;
6635 } catch (NumberFormatException ex) {
6636 throw new IllegalArgumentException("Invalid boolean value: " + value);
6637 }
6638 }
6639
6640 intent.putExtra(key, arg);
6641 }
6642 break;
6643 case "-n": {
6644 String str = cmd.getNextArgRequired();
6645 ComponentName cn = ComponentName.unflattenFromString(str);
6646 if (cn == null)
6647 throw new IllegalArgumentException("Bad component name: " + str);
6648 intent.setComponent(cn);
6649 if (intent == baseIntent) {
6650 hasIntentInfo = true;
6651 }
6652 }
6653 break;
6654 case "-p": {
6655 String str = cmd.getNextArgRequired();
6656 intent.setPackage(str);
6657 if (intent == baseIntent) {
6658 hasIntentInfo = true;
6659 }
6660 }
6661 break;
6662 case "-f":
6663 String str = cmd.getNextArgRequired();
6664 intent.setFlags(Integer.decode(str).intValue());
6665 break;
6666 case "--grant-read-uri-permission":
6667 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6668 break;
6669 case "--grant-write-uri-permission":
6670 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6671 break;
6672 case "--grant-persistable-uri-permission":
6673 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6674 break;
6675 case "--grant-prefix-uri-permission":
6676 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6677 break;
6678 case "--exclude-stopped-packages":
6679 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6680 break;
6681 case "--include-stopped-packages":
6682 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6683 break;
6684 case "--debug-log-resolution":
6685 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6686 break;
6687 case "--activity-brought-to-front":
6688 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6689 break;
6690 case "--activity-clear-top":
6691 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6692 break;
6693 case "--activity-clear-when-task-reset":
6694 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6695 break;
6696 case "--activity-exclude-from-recents":
6697 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6698 break;
6699 case "--activity-launched-from-history":
6700 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6701 break;
6702 case "--activity-multiple-task":
6703 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6704 break;
6705 case "--activity-no-animation":
6706 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6707 break;
6708 case "--activity-no-history":
6709 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6710 break;
6711 case "--activity-no-user-action":
6712 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6713 break;
6714 case "--activity-previous-is-top":
6715 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6716 break;
6717 case "--activity-reorder-to-front":
6718 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6719 break;
6720 case "--activity-reset-task-if-needed":
6721 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6722 break;
6723 case "--activity-single-top":
6724 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6725 break;
6726 case "--activity-clear-task":
6727 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6728 break;
6729 case "--activity-task-on-home":
6730 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6731 break;
6732 case "--receiver-registered-only":
6733 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6734 break;
6735 case "--receiver-replace-pending":
6736 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6737 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006738 case "--receiver-foreground":
6739 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6740 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006741 case "--receiver-no-abort":
6742 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6743 break;
6744 case "--receiver-include-background":
6745 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6746 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006747 case "--selector":
6748 intent.setDataAndType(data, type);
6749 intent = new Intent();
6750 break;
6751 default:
6752 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6753 // Okay, caller handled this option.
6754 } else {
6755 throw new IllegalArgumentException("Unknown option: " + opt);
6756 }
6757 break;
6758 }
6759 }
6760 intent.setDataAndType(data, type);
6761
6762 final boolean hasSelector = intent != baseIntent;
6763 if (hasSelector) {
6764 // A selector was specified; fix up.
6765 baseIntent.setSelector(intent);
6766 intent = baseIntent;
6767 }
6768
6769 String arg = cmd.getNextArg();
6770 baseIntent = null;
6771 if (arg == null) {
6772 if (hasSelector) {
6773 // If a selector has been specified, and no arguments
6774 // have been supplied for the main Intent, then we can
6775 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6776 // need to have a component name specified yet, the
6777 // selector will take care of that.
6778 baseIntent = new Intent(Intent.ACTION_MAIN);
6779 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6780 }
6781 } else if (arg.indexOf(':') >= 0) {
6782 // The argument is a URI. Fully parse it, and use that result
6783 // to fill in any data not specified so far.
6784 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6785 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6786 } else if (arg.indexOf('/') >= 0) {
6787 // The argument is a component name. Build an Intent to launch
6788 // it.
6789 baseIntent = new Intent(Intent.ACTION_MAIN);
6790 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6791 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6792 } else {
6793 // Assume the argument is a package name.
6794 baseIntent = new Intent(Intent.ACTION_MAIN);
6795 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6796 baseIntent.setPackage(arg);
6797 }
6798 if (baseIntent != null) {
6799 Bundle extras = intent.getExtras();
6800 intent.replaceExtras((Bundle)null);
6801 Bundle uriExtras = baseIntent.getExtras();
6802 baseIntent.replaceExtras((Bundle)null);
6803 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6804 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6805 for (String c : cats) {
6806 baseIntent.removeCategory(c);
6807 }
6808 }
6809 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6810 if (extras == null) {
6811 extras = uriExtras;
6812 } else if (uriExtras != null) {
6813 uriExtras.putAll(extras);
6814 extras = uriExtras;
6815 }
6816 intent.replaceExtras(extras);
6817 hasIntentInfo = true;
6818 }
6819
6820 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6821 return intent;
6822 }
6823
6824 /** @hide */
6825 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6826 final String[] lines = new String[] {
6827 "<INTENT> specifications include these flags and arguments:",
6828 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6829 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6830 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6831 " [--esn <EXTRA_KEY> ...]",
6832 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6833 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6834 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6835 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6836 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6837 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6838 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6839 " (mutiple extras passed as Integer[])",
6840 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6841 " (mutiple extras passed as List<Integer>)",
6842 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6843 " (mutiple extras passed as Long[])",
6844 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6845 " (mutiple extras passed as List<Long>)",
6846 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6847 " (mutiple extras passed as Float[])",
6848 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6849 " (mutiple extras passed as List<Float>)",
6850 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6851 " (mutiple extras passed as String[]; to embed a comma into a string,",
6852 " escape it using \"\\,\")",
6853 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6854 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6855 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006856 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006857 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6858 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6859 " [--debug-log-resolution] [--exclude-stopped-packages]",
6860 " [--include-stopped-packages]",
6861 " [--activity-brought-to-front] [--activity-clear-top]",
6862 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6863 " [--activity-launched-from-history] [--activity-multiple-task]",
6864 " [--activity-no-animation] [--activity-no-history]",
6865 " [--activity-no-user-action] [--activity-previous-is-top]",
6866 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6867 " [--activity-single-top] [--activity-clear-task]",
6868 " [--activity-task-on-home]",
6869 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006870 " [--receiver-foreground] [--receiver-no-abort]",
6871 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006872 " [--selector]",
6873 " [<URI> | <PACKAGE> | <COMPONENT>]"
6874 };
6875 for (String line : lines) {
6876 pw.print(prefix);
6877 pw.println(line);
6878 }
6879 }
6880
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006881 /**
6882 * Retrieve the general action to be performed, such as
6883 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6884 * the information in the intent should be interpreted -- most importantly,
6885 * what to do with the data returned by {@link #getData}.
6886 *
6887 * @return The action of this intent or null if none is specified.
6888 *
6889 * @see #setAction
6890 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006891 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006892 return mAction;
6893 }
6894
6895 /**
6896 * Retrieve data this intent is operating on. This URI specifies the name
6897 * of the data; often it uses the content: scheme, specifying data in a
6898 * content provider. Other schemes may be handled by specific activities,
6899 * such as http: by the web browser.
6900 *
6901 * @return The URI of the data this intent is targeting or null.
6902 *
6903 * @see #getScheme
6904 * @see #setData
6905 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006906 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006907 return mData;
6908 }
6909
6910 /**
6911 * The same as {@link #getData()}, but returns the URI as an encoded
6912 * String.
6913 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006914 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006915 return mData != null ? mData.toString() : null;
6916 }
6917
6918 /**
6919 * Return the scheme portion of the intent's data. If the data is null or
6920 * does not include a scheme, null is returned. Otherwise, the scheme
6921 * prefix without the final ':' is returned, i.e. "http".
6922 *
6923 * <p>This is the same as calling getData().getScheme() (and checking for
6924 * null data).
6925 *
6926 * @return The scheme of this intent.
6927 *
6928 * @see #getData
6929 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006930 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006931 return mData != null ? mData.getScheme() : null;
6932 }
6933
6934 /**
6935 * Retrieve any explicit MIME type included in the intent. This is usually
6936 * null, as the type is determined by the intent data.
6937 *
6938 * @return If a type was manually set, it is returned; else null is
6939 * returned.
6940 *
6941 * @see #resolveType(ContentResolver)
6942 * @see #setType
6943 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006944 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006945 return mType;
6946 }
6947
6948 /**
6949 * Return the MIME data type of this intent. If the type field is
6950 * explicitly set, that is simply returned. Otherwise, if the data is set,
6951 * the type of that data is returned. If neither fields are set, a null is
6952 * returned.
6953 *
6954 * @return The MIME type of this intent.
6955 *
6956 * @see #getType
6957 * @see #resolveType(ContentResolver)
6958 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006959 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006960 return resolveType(context.getContentResolver());
6961 }
6962
6963 /**
6964 * Return the MIME data type of this intent. If the type field is
6965 * explicitly set, that is simply returned. Otherwise, if the data is set,
6966 * the type of that data is returned. If neither fields are set, a null is
6967 * returned.
6968 *
6969 * @param resolver A ContentResolver that can be used to determine the MIME
6970 * type of the intent's data.
6971 *
6972 * @return The MIME type of this intent.
6973 *
6974 * @see #getType
6975 * @see #resolveType(Context)
6976 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006977 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006978 if (mType != null) {
6979 return mType;
6980 }
6981 if (mData != null) {
6982 if ("content".equals(mData.getScheme())) {
6983 return resolver.getType(mData);
6984 }
6985 }
6986 return null;
6987 }
6988
6989 /**
6990 * Return the MIME data type of this intent, only if it will be needed for
6991 * intent resolution. This is not generally useful for application code;
6992 * it is used by the frameworks for communicating with back-end system
6993 * services.
6994 *
6995 * @param resolver A ContentResolver that can be used to determine the MIME
6996 * type of the intent's data.
6997 *
6998 * @return The MIME type of this intent, or null if it is unknown or not
6999 * needed.
7000 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007001 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007002 if (mComponent != null) {
7003 return mType;
7004 }
7005 return resolveType(resolver);
7006 }
7007
7008 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007009 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007010 *
7011 * @param category The category to check.
7012 *
7013 * @return boolean True if the intent contains the category, else false.
7014 *
7015 * @see #getCategories
7016 * @see #addCategory
7017 */
7018 public boolean hasCategory(String category) {
7019 return mCategories != null && mCategories.contains(category);
7020 }
7021
7022 /**
7023 * Return the set of all categories in the intent. If there are no categories,
7024 * returns NULL.
7025 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007026 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007027 *
7028 * @see #hasCategory
7029 * @see #addCategory
7030 */
7031 public Set<String> getCategories() {
7032 return mCategories;
7033 }
7034
7035 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007036 * Return the specific selector associated with this Intent. If there is
7037 * none, returns null. See {@link #setSelector} for more information.
7038 *
7039 * @see #setSelector
7040 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007041 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007042 return mSelector;
7043 }
7044
7045 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007046 * Return the {@link ClipData} associated with this Intent. If there is
7047 * none, returns null. See {@link #setClipData} for more information.
7048 *
John Spurlock125d1332013-11-25 11:58:37 -05007049 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007050 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007051 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007052 return mClipData;
7053 }
7054
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007055 /** @hide */
7056 public int getContentUserHint() {
7057 return mContentUserHint;
7058 }
7059
Todd Kennedyb3b431302017-03-20 16:05:48 -07007060 /** @hide */
7061 public String getLaunchToken() {
7062 return mLaunchToken;
7063 }
7064
7065 /** @hide */
7066 public void setLaunchToken(String launchToken) {
7067 mLaunchToken = launchToken;
7068 }
7069
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007070 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007071 * Sets the ClassLoader that will be used when unmarshalling
7072 * any Parcelable values from the extras of this Intent.
7073 *
7074 * @param loader a ClassLoader, or null to use the default loader
7075 * at the time of unmarshalling.
7076 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007077 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007078 if (mExtras != null) {
7079 mExtras.setClassLoader(loader);
7080 }
7081 }
7082
7083 /**
7084 * Returns true if an extra value is associated with the given name.
7085 * @param name the extra's name
7086 * @return true if the given extra is present.
7087 */
7088 public boolean hasExtra(String name) {
7089 return mExtras != null && mExtras.containsKey(name);
7090 }
7091
7092 /**
7093 * Returns true if the Intent's extras contain a parcelled file descriptor.
7094 * @return true if the Intent contains a parcelled file descriptor.
7095 */
7096 public boolean hasFileDescriptors() {
7097 return mExtras != null && mExtras.hasFileDescriptors();
7098 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007099
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007100 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007101 public void setAllowFds(boolean allowFds) {
7102 if (mExtras != null) {
7103 mExtras.setAllowFds(allowFds);
7104 }
7105 }
7106
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007107 /** {@hide} */
7108 public void setDefusable(boolean defusable) {
7109 if (mExtras != null) {
7110 mExtras.setDefusable(defusable);
7111 }
7112 }
7113
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007114 /**
7115 * Retrieve extended data from the intent.
7116 *
7117 * @param name The name of the desired item.
7118 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007119 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007120 * or null if none was found.
7121 *
7122 * @deprecated
7123 * @hide
7124 */
7125 @Deprecated
7126 public Object getExtra(String name) {
7127 return getExtra(name, null);
7128 }
7129
7130 /**
7131 * Retrieve extended data from the intent.
7132 *
7133 * @param name The name of the desired item.
7134 * @param defaultValue the value to be returned if no value of the desired
7135 * type is stored with the given name.
7136 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007137 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007138 * or the default value if none was found.
7139 *
7140 * @see #putExtra(String, boolean)
7141 */
7142 public boolean getBooleanExtra(String name, boolean defaultValue) {
7143 return mExtras == null ? defaultValue :
7144 mExtras.getBoolean(name, defaultValue);
7145 }
7146
7147 /**
7148 * Retrieve extended data from the intent.
7149 *
7150 * @param name The name of the desired item.
7151 * @param defaultValue the value to be returned if no value of the desired
7152 * type is stored with the given name.
7153 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007154 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007155 * or the default value if none was found.
7156 *
7157 * @see #putExtra(String, byte)
7158 */
7159 public byte getByteExtra(String name, byte defaultValue) {
7160 return mExtras == null ? defaultValue :
7161 mExtras.getByte(name, defaultValue);
7162 }
7163
7164 /**
7165 * Retrieve extended data from the intent.
7166 *
7167 * @param name The name of the desired item.
7168 * @param defaultValue the value to be returned if no value of the desired
7169 * type is stored with the given name.
7170 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007171 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007172 * or the default value if none was found.
7173 *
7174 * @see #putExtra(String, short)
7175 */
7176 public short getShortExtra(String name, short defaultValue) {
7177 return mExtras == null ? defaultValue :
7178 mExtras.getShort(name, defaultValue);
7179 }
7180
7181 /**
7182 * Retrieve extended data from the intent.
7183 *
7184 * @param name The name of the desired item.
7185 * @param defaultValue the value to be returned if no value of the desired
7186 * type is stored with the given name.
7187 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007188 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007189 * or the default value if none was found.
7190 *
7191 * @see #putExtra(String, char)
7192 */
7193 public char getCharExtra(String name, char defaultValue) {
7194 return mExtras == null ? defaultValue :
7195 mExtras.getChar(name, defaultValue);
7196 }
7197
7198 /**
7199 * Retrieve extended data from the intent.
7200 *
7201 * @param name The name of the desired item.
7202 * @param defaultValue the value to be returned if no value of the desired
7203 * type is stored with the given name.
7204 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007205 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007206 * or the default value if none was found.
7207 *
7208 * @see #putExtra(String, int)
7209 */
7210 public int getIntExtra(String name, int defaultValue) {
7211 return mExtras == null ? defaultValue :
7212 mExtras.getInt(name, defaultValue);
7213 }
7214
7215 /**
7216 * Retrieve extended data from the intent.
7217 *
7218 * @param name The name of the desired item.
7219 * @param defaultValue the value to be returned if no value of the desired
7220 * type is stored with the given name.
7221 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007222 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007223 * or the default value if none was found.
7224 *
7225 * @see #putExtra(String, long)
7226 */
7227 public long getLongExtra(String name, long defaultValue) {
7228 return mExtras == null ? defaultValue :
7229 mExtras.getLong(name, defaultValue);
7230 }
7231
7232 /**
7233 * Retrieve extended data from the intent.
7234 *
7235 * @param name The name of the desired item.
7236 * @param defaultValue the value to be returned if no value of the desired
7237 * type is stored with the given name.
7238 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007239 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007240 * or the default value if no such item is present
7241 *
7242 * @see #putExtra(String, float)
7243 */
7244 public float getFloatExtra(String name, float defaultValue) {
7245 return mExtras == null ? defaultValue :
7246 mExtras.getFloat(name, defaultValue);
7247 }
7248
7249 /**
7250 * Retrieve extended data from the intent.
7251 *
7252 * @param name The name of the desired item.
7253 * @param defaultValue the value to be returned if no value of the desired
7254 * type is stored with the given name.
7255 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007256 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007257 * or the default value if none was found.
7258 *
7259 * @see #putExtra(String, double)
7260 */
7261 public double getDoubleExtra(String name, double defaultValue) {
7262 return mExtras == null ? defaultValue :
7263 mExtras.getDouble(name, defaultValue);
7264 }
7265
7266 /**
7267 * Retrieve extended data from the intent.
7268 *
7269 * @param name The name of the desired item.
7270 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007271 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007272 * or null if no String value was found.
7273 *
7274 * @see #putExtra(String, String)
7275 */
7276 public String getStringExtra(String name) {
7277 return mExtras == null ? null : mExtras.getString(name);
7278 }
7279
7280 /**
7281 * Retrieve extended data from the intent.
7282 *
7283 * @param name The name of the desired item.
7284 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007285 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007286 * or null if no CharSequence value was found.
7287 *
7288 * @see #putExtra(String, CharSequence)
7289 */
7290 public CharSequence getCharSequenceExtra(String name) {
7291 return mExtras == null ? null : mExtras.getCharSequence(name);
7292 }
7293
7294 /**
7295 * Retrieve extended data from the intent.
7296 *
7297 * @param name The name of the desired item.
7298 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007299 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007300 * or null if no Parcelable value was found.
7301 *
7302 * @see #putExtra(String, Parcelable)
7303 */
7304 public <T extends Parcelable> T getParcelableExtra(String name) {
7305 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7306 }
7307
7308 /**
7309 * Retrieve extended data from the intent.
7310 *
7311 * @param name The name of the desired item.
7312 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007313 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007314 * or null if no Parcelable[] value was found.
7315 *
7316 * @see #putExtra(String, Parcelable[])
7317 */
7318 public Parcelable[] getParcelableArrayExtra(String name) {
7319 return mExtras == null ? null : mExtras.getParcelableArray(name);
7320 }
7321
7322 /**
7323 * Retrieve extended data from the intent.
7324 *
7325 * @param name The name of the desired item.
7326 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007327 * @return the value of an item previously added with
7328 * putParcelableArrayListExtra(), or null if no
7329 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007330 *
7331 * @see #putParcelableArrayListExtra(String, ArrayList)
7332 */
7333 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7334 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7335 }
7336
7337 /**
7338 * Retrieve extended data from the intent.
7339 *
7340 * @param name The name of the desired item.
7341 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007342 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007343 * or null if no Serializable value was found.
7344 *
7345 * @see #putExtra(String, Serializable)
7346 */
7347 public Serializable getSerializableExtra(String name) {
7348 return mExtras == null ? null : mExtras.getSerializable(name);
7349 }
7350
7351 /**
7352 * Retrieve extended data from the intent.
7353 *
7354 * @param name The name of the desired item.
7355 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007356 * @return the value of an item previously added with
7357 * putIntegerArrayListExtra(), or null if no
7358 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007359 *
7360 * @see #putIntegerArrayListExtra(String, ArrayList)
7361 */
7362 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7363 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7364 }
7365
7366 /**
7367 * Retrieve extended data from the intent.
7368 *
7369 * @param name The name of the desired item.
7370 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007371 * @return the value of an item previously added with
7372 * putStringArrayListExtra(), or null if no
7373 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007374 *
7375 * @see #putStringArrayListExtra(String, ArrayList)
7376 */
7377 public ArrayList<String> getStringArrayListExtra(String name) {
7378 return mExtras == null ? null : mExtras.getStringArrayList(name);
7379 }
7380
7381 /**
7382 * Retrieve extended data from the intent.
7383 *
7384 * @param name The name of the desired item.
7385 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007386 * @return the value of an item previously added with
7387 * putCharSequenceArrayListExtra, or null if no
7388 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007389 *
7390 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7391 */
7392 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7393 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7394 }
7395
7396 /**
7397 * Retrieve extended data from the intent.
7398 *
7399 * @param name The name of the desired item.
7400 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007401 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007402 * or null if no boolean array value was found.
7403 *
7404 * @see #putExtra(String, boolean[])
7405 */
7406 public boolean[] getBooleanArrayExtra(String name) {
7407 return mExtras == null ? null : mExtras.getBooleanArray(name);
7408 }
7409
7410 /**
7411 * Retrieve extended data from the intent.
7412 *
7413 * @param name The name of the desired item.
7414 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007415 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007416 * or null if no byte array value was found.
7417 *
7418 * @see #putExtra(String, byte[])
7419 */
7420 public byte[] getByteArrayExtra(String name) {
7421 return mExtras == null ? null : mExtras.getByteArray(name);
7422 }
7423
7424 /**
7425 * Retrieve extended data from the intent.
7426 *
7427 * @param name The name of the desired item.
7428 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007429 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007430 * or null if no short array value was found.
7431 *
7432 * @see #putExtra(String, short[])
7433 */
7434 public short[] getShortArrayExtra(String name) {
7435 return mExtras == null ? null : mExtras.getShortArray(name);
7436 }
7437
7438 /**
7439 * Retrieve extended data from the intent.
7440 *
7441 * @param name The name of the desired item.
7442 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007443 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007444 * or null if no char array value was found.
7445 *
7446 * @see #putExtra(String, char[])
7447 */
7448 public char[] getCharArrayExtra(String name) {
7449 return mExtras == null ? null : mExtras.getCharArray(name);
7450 }
7451
7452 /**
7453 * Retrieve extended data from the intent.
7454 *
7455 * @param name The name of the desired item.
7456 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007457 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007458 * or null if no int array value was found.
7459 *
7460 * @see #putExtra(String, int[])
7461 */
7462 public int[] getIntArrayExtra(String name) {
7463 return mExtras == null ? null : mExtras.getIntArray(name);
7464 }
7465
7466 /**
7467 * Retrieve extended data from the intent.
7468 *
7469 * @param name The name of the desired item.
7470 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007471 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007472 * or null if no long array value was found.
7473 *
7474 * @see #putExtra(String, long[])
7475 */
7476 public long[] getLongArrayExtra(String name) {
7477 return mExtras == null ? null : mExtras.getLongArray(name);
7478 }
7479
7480 /**
7481 * Retrieve extended data from the intent.
7482 *
7483 * @param name The name of the desired item.
7484 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007485 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007486 * or null if no float array value was found.
7487 *
7488 * @see #putExtra(String, float[])
7489 */
7490 public float[] getFloatArrayExtra(String name) {
7491 return mExtras == null ? null : mExtras.getFloatArray(name);
7492 }
7493
7494 /**
7495 * Retrieve extended data from the intent.
7496 *
7497 * @param name The name of the desired item.
7498 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007499 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007500 * or null if no double array value was found.
7501 *
7502 * @see #putExtra(String, double[])
7503 */
7504 public double[] getDoubleArrayExtra(String name) {
7505 return mExtras == null ? null : mExtras.getDoubleArray(name);
7506 }
7507
7508 /**
7509 * Retrieve extended data from the intent.
7510 *
7511 * @param name The name of the desired item.
7512 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007513 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007514 * or null if no String array value was found.
7515 *
7516 * @see #putExtra(String, String[])
7517 */
7518 public String[] getStringArrayExtra(String name) {
7519 return mExtras == null ? null : mExtras.getStringArray(name);
7520 }
7521
7522 /**
7523 * Retrieve extended data from the intent.
7524 *
7525 * @param name The name of the desired item.
7526 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007527 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007528 * or null if no CharSequence array value was found.
7529 *
7530 * @see #putExtra(String, CharSequence[])
7531 */
7532 public CharSequence[] getCharSequenceArrayExtra(String name) {
7533 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7534 }
7535
7536 /**
7537 * Retrieve extended data from the intent.
7538 *
7539 * @param name The name of the desired item.
7540 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007541 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007542 * or null if no Bundle value was found.
7543 *
7544 * @see #putExtra(String, Bundle)
7545 */
7546 public Bundle getBundleExtra(String name) {
7547 return mExtras == null ? null : mExtras.getBundle(name);
7548 }
7549
7550 /**
7551 * Retrieve extended data from the intent.
7552 *
7553 * @param name The name of the desired item.
7554 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007555 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007556 * or null if no IBinder value was found.
7557 *
7558 * @see #putExtra(String, IBinder)
7559 *
7560 * @deprecated
7561 * @hide
7562 */
7563 @Deprecated
7564 public IBinder getIBinderExtra(String name) {
7565 return mExtras == null ? null : mExtras.getIBinder(name);
7566 }
7567
7568 /**
7569 * Retrieve extended data from the intent.
7570 *
7571 * @param name The name of the desired item.
7572 * @param defaultValue The default value to return in case no item is
7573 * associated with the key 'name'
7574 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007575 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007576 * or defaultValue if none was found.
7577 *
7578 * @see #putExtra
7579 *
7580 * @deprecated
7581 * @hide
7582 */
7583 @Deprecated
7584 public Object getExtra(String name, Object defaultValue) {
7585 Object result = defaultValue;
7586 if (mExtras != null) {
7587 Object result2 = mExtras.get(name);
7588 if (result2 != null) {
7589 result = result2;
7590 }
7591 }
7592
7593 return result;
7594 }
7595
7596 /**
7597 * Retrieves a map of extended data from the intent.
7598 *
7599 * @return the map of all extras previously added with putExtra(),
7600 * or null if none have been added.
7601 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007602 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007603 return (mExtras != null)
7604 ? new Bundle(mExtras)
7605 : null;
7606 }
7607
7608 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007609 * Filter extras to only basic types.
7610 * @hide
7611 */
7612 public void removeUnsafeExtras() {
7613 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007614 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007615 }
7616 }
7617
7618 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007619 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7620 * return itself as-is.
7621 * @hide
7622 */
7623 public boolean canStripForHistory() {
7624 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7625 }
7626
7627 /**
7628 * Call it when the system needs to keep an intent for logging purposes to remove fields
7629 * that are not needed for logging.
7630 * @hide
7631 */
7632 public Intent maybeStripForHistory() {
7633 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7634
7635 if (!canStripForHistory()) {
7636 return this;
7637 }
7638 return new Intent(this, COPY_MODE_HISTORY);
7639 }
7640
7641 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007642 * Retrieve any special flags associated with this intent. You will
7643 * normally just set them with {@link #setFlags} and let the system
7644 * take the appropriate action with them.
7645 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007646 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007647 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007648 * @see #addFlags
7649 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007650 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007651 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007652 return mFlags;
7653 }
7654
Dianne Hackborne7f97212011-02-24 14:40:20 -08007655 /** @hide */
7656 public boolean isExcludingStopped() {
7657 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7658 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7659 }
7660
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007661 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007662 * Retrieve the application package name this Intent is limited to. When
7663 * resolving an Intent, if non-null this limits the resolution to only
7664 * components in the given application package.
7665 *
7666 * @return The name of the application package for the Intent.
7667 *
7668 * @see #resolveActivity
7669 * @see #setPackage
7670 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007671 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007672 return mPackage;
7673 }
7674
7675 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007676 * Retrieve the concrete component associated with the intent. When receiving
7677 * an intent, this is the component that was found to best handle it (that is,
7678 * yourself) and will always be non-null; in all other cases it will be
7679 * null unless explicitly set.
7680 *
7681 * @return The name of the application component to handle the intent.
7682 *
7683 * @see #resolveActivity
7684 * @see #setComponent
7685 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007686 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007687 return mComponent;
7688 }
7689
7690 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007691 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7692 * used as a hint to the receiver for animations and the like. Null means that there
7693 * is no source bounds.
7694 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007695 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007696 return mSourceBounds;
7697 }
7698
7699 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007700 * Return the Activity component that should be used to handle this intent.
7701 * The appropriate component is determined based on the information in the
7702 * intent, evaluated as follows:
7703 *
7704 * <p>If {@link #getComponent} returns an explicit class, that is returned
7705 * without any further consideration.
7706 *
7707 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7708 * category to be considered.
7709 *
7710 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7711 * action.
7712 *
7713 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7714 * this type.
7715 *
7716 * <p>If {@link #addCategory} has added any categories, the activity must
7717 * handle ALL of the categories specified.
7718 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007719 * <p>If {@link #getPackage} is non-NULL, only activity components in
7720 * that application package will be considered.
7721 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007722 * <p>If there are no activities that satisfy all of these conditions, a
7723 * null string is returned.
7724 *
7725 * <p>If multiple activities are found to satisfy the intent, the one with
7726 * the highest priority will be used. If there are multiple activities
7727 * with the same priority, the system will either pick the best activity
7728 * based on user preference, or resolve to a system class that will allow
7729 * the user to pick an activity and forward from there.
7730 *
7731 * <p>This method is implemented simply by calling
7732 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7733 * true.</p>
7734 * <p> This API is called for you as part of starting an activity from an
7735 * intent. You do not normally need to call it yourself.</p>
7736 *
7737 * @param pm The package manager with which to resolve the Intent.
7738 *
7739 * @return Name of the component implementing an activity that can
7740 * display the intent.
7741 *
7742 * @see #setComponent
7743 * @see #getComponent
7744 * @see #resolveActivityInfo
7745 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007746 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007747 if (mComponent != null) {
7748 return mComponent;
7749 }
7750
7751 ResolveInfo info = pm.resolveActivity(
7752 this, PackageManager.MATCH_DEFAULT_ONLY);
7753 if (info != null) {
7754 return new ComponentName(
7755 info.activityInfo.applicationInfo.packageName,
7756 info.activityInfo.name);
7757 }
7758
7759 return null;
7760 }
7761
7762 /**
7763 * Resolve the Intent into an {@link ActivityInfo}
7764 * describing the activity that should execute the intent. Resolution
7765 * follows the same rules as described for {@link #resolveActivity}, but
7766 * you get back the completely information about the resolved activity
7767 * instead of just its class name.
7768 *
7769 * @param pm The package manager with which to resolve the Intent.
7770 * @param flags Addition information to retrieve as per
7771 * {@link PackageManager#getActivityInfo(ComponentName, int)
7772 * PackageManager.getActivityInfo()}.
7773 *
7774 * @return PackageManager.ActivityInfo
7775 *
7776 * @see #resolveActivity
7777 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007778 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7779 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007780 ActivityInfo ai = null;
7781 if (mComponent != null) {
7782 try {
7783 ai = pm.getActivityInfo(mComponent, flags);
7784 } catch (PackageManager.NameNotFoundException e) {
7785 // ignore
7786 }
7787 } else {
7788 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007789 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007790 if (info != null) {
7791 ai = info.activityInfo;
7792 }
7793 }
7794
7795 return ai;
7796 }
7797
7798 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007799 * Special function for use by the system to resolve service
7800 * intents to system apps. Throws an exception if there are
7801 * multiple potential matches to the Intent. Returns null if
7802 * there are no matches.
7803 * @hide
7804 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007805 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7806 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007807 if (mComponent != null) {
7808 return mComponent;
7809 }
7810
7811 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7812 if (results == null) {
7813 return null;
7814 }
7815 ComponentName comp = null;
7816 for (int i=0; i<results.size(); i++) {
7817 ResolveInfo ri = results.get(i);
7818 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7819 continue;
7820 }
7821 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7822 ri.serviceInfo.name);
7823 if (comp != null) {
7824 throw new IllegalStateException("Multiple system services handle " + this
7825 + ": " + comp + ", " + foundComp);
7826 }
7827 comp = foundComp;
7828 }
7829 return comp;
7830 }
7831
7832 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007833 * Set the general action to be performed.
7834 *
7835 * @param action An action name, such as ACTION_VIEW. Application-specific
7836 * actions should be prefixed with the vendor's package name.
7837 *
7838 * @return Returns the same Intent object, for chaining multiple calls
7839 * into a single statement.
7840 *
7841 * @see #getAction
7842 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007843 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007844 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007845 return this;
7846 }
7847
7848 /**
7849 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007850 * clears any type that was previously set by {@link #setType} or
7851 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 *
Nick Pellyccae4122012-01-09 14:12:58 -08007853 * <p><em>Note: scheme matching in the Android framework is
7854 * case-sensitive, unlike the formal RFC. As a result,
7855 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007856 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007857 * {@link #setDataAndNormalize}
7858 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007859 *
Nick Pellyccae4122012-01-09 14:12:58 -08007860 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007861 *
7862 * @return Returns the same Intent object, for chaining multiple calls
7863 * into a single statement.
7864 *
7865 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007866 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007867 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007868 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007869 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007870 mData = data;
7871 mType = null;
7872 return this;
7873 }
7874
7875 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007876 * Normalize and set the data this intent is operating on.
7877 *
7878 * <p>This method automatically clears any type that was
7879 * previously set (for example, by {@link #setType}).
7880 *
7881 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007882 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007883 * so really this is just a convenience method for
7884 * <pre>
7885 * setData(data.normalize())
7886 * </pre>
7887 *
7888 * @param data The Uri of the data this intent is now targeting.
7889 *
7890 * @return Returns the same Intent object, for chaining multiple calls
7891 * into a single statement.
7892 *
7893 * @see #getData
7894 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007895 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007896 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007897 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007898 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007899 }
7900
7901 /**
7902 * Set an explicit MIME data type.
7903 *
7904 * <p>This is used to create intents that only specify a type and not data,
7905 * for example to indicate the type of data to return.
7906 *
7907 * <p>This method automatically clears any data that was
7908 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007909 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007910 * <p><em>Note: MIME type matching in the Android framework is
7911 * case-sensitive, unlike formal RFC MIME types. As a result,
7912 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007913 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7914 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007915 *
7916 * @param type The MIME type of the data being handled by this intent.
7917 *
7918 * @return Returns the same Intent object, for chaining multiple calls
7919 * into a single statement.
7920 *
7921 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007922 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007923 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007924 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007925 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007926 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007927 mData = null;
7928 mType = type;
7929 return this;
7930 }
7931
7932 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007933 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007934 *
Nick Pellyccae4122012-01-09 14:12:58 -08007935 * <p>This is used to create intents that only specify a type and not data,
7936 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007937 *
Nick Pellyccae4122012-01-09 14:12:58 -08007938 * <p>This method automatically clears any data that was
7939 * previously set (for example by {@link #setData}).
7940 *
7941 * <p>The MIME type is normalized using
7942 * {@link #normalizeMimeType} before it is set,
7943 * so really this is just a convenience method for
7944 * <pre>
7945 * setType(Intent.normalizeMimeType(type))
7946 * </pre>
7947 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007948 * @param type The MIME type of the data being handled by this intent.
7949 *
7950 * @return Returns the same Intent object, for chaining multiple calls
7951 * into a single statement.
7952 *
Nick Pellyccae4122012-01-09 14:12:58 -08007953 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007954 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007955 * @see #normalizeMimeType
7956 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007957 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007958 return setType(normalizeMimeType(type));
7959 }
7960
7961 /**
7962 * (Usually optional) Set the data for the intent along with an explicit
7963 * MIME data type. This method should very rarely be used -- it allows you
7964 * to override the MIME type that would ordinarily be inferred from the
7965 * data with your own type given here.
7966 *
7967 * <p><em>Note: MIME type and Uri scheme matching in the
7968 * Android framework is case-sensitive, unlike the formal RFC definitions.
7969 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007970 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007971 * {@link #setDataAndTypeAndNormalize}
7972 * to ensure that they are converted to lower case.</em>
7973 *
7974 * @param data The Uri of the data this intent is now targeting.
7975 * @param type The MIME type of the data being handled by this intent.
7976 *
7977 * @return Returns the same Intent object, for chaining multiple calls
7978 * into a single statement.
7979 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007980 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007981 * @see #setData
7982 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007983 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007984 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007985 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007986 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007987 mData = data;
7988 mType = type;
7989 return this;
7990 }
7991
7992 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007993 * (Usually optional) Normalize and set both the data Uri and an explicit
7994 * MIME data type. This method should very rarely be used -- it allows you
7995 * to override the MIME type that would ordinarily be inferred from the
7996 * data with your own type given here.
7997 *
7998 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007999 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008000 * before they are set, so really this is just a convenience method for
8001 * <pre>
8002 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8003 * </pre>
8004 *
8005 * @param data The Uri of the data this intent is now targeting.
8006 * @param type The MIME type of the data being handled by this intent.
8007 *
8008 * @return Returns the same Intent object, for chaining multiple calls
8009 * into a single statement.
8010 *
8011 * @see #setType
8012 * @see #setData
8013 * @see #setDataAndType
8014 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008015 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008016 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008017 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008018 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008019 }
8020
8021 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008022 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008023 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008024 * activities that provide <em>all</em> of the requested categories will be
8025 * used.
8026 *
8027 * @param category The desired category. This can be either one of the
8028 * predefined Intent categories, or a custom category in your own
8029 * namespace.
8030 *
8031 * @return Returns the same Intent object, for chaining multiple calls
8032 * into a single statement.
8033 *
8034 * @see #hasCategory
8035 * @see #removeCategory
8036 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008037 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008038 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008039 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008040 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008041 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008042 return this;
8043 }
8044
8045 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008046 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008047 *
8048 * @param category The category to remove.
8049 *
8050 * @see #addCategory
8051 */
8052 public void removeCategory(String category) {
8053 if (mCategories != null) {
8054 mCategories.remove(category);
8055 if (mCategories.size() == 0) {
8056 mCategories = null;
8057 }
8058 }
8059 }
8060
8061 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008062 * Set a selector for this Intent. This is a modification to the kinds of
8063 * things the Intent will match. If the selector is set, it will be used
8064 * when trying to find entities that can handle the Intent, instead of the
8065 * main contents of the Intent. This allows you build an Intent containing
8066 * a generic protocol while targeting it more specifically.
8067 *
8068 * <p>An example of where this may be used is with things like
8069 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8070 * Intent that will launch the Browser application. However, the correct
8071 * main entry point of an application is actually {@link #ACTION_MAIN}
8072 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8073 * used to specify the actual Activity to launch. If you launch the browser
8074 * with something different, undesired behavior may happen if the user has
8075 * previously or later launches it the normal way, since they do not match.
8076 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8077 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8078 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8079 *
8080 * <p>Setting a selector does not impact the behavior of
8081 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8082 * desired behavior of a selector -- it does not impact the base meaning
8083 * of the Intent, just what kinds of things will be matched against it
8084 * when determining who can handle it.</p>
8085 *
8086 * <p>You can not use both a selector and {@link #setPackage(String)} on
8087 * the same base Intent.</p>
8088 *
8089 * @param selector The desired selector Intent; set to null to not use
8090 * a special selector.
8091 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008092 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008093 if (selector == this) {
8094 throw new IllegalArgumentException(
8095 "Intent being set as a selector of itself");
8096 }
8097 if (selector != null && mPackage != null) {
8098 throw new IllegalArgumentException(
8099 "Can't set selector when package name is already set");
8100 }
8101 mSelector = selector;
8102 }
8103
8104 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008105 * Set a {@link ClipData} associated with this Intent. This replaces any
8106 * previously set ClipData.
8107 *
8108 * <p>The ClipData in an intent is not used for Intent matching or other
8109 * such operations. Semantically it is like extras, used to transmit
8110 * additional data with the Intent. The main feature of using this over
8111 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8112 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8113 * items included in the clip data. This is useful, in particular, if
8114 * you want to transmit an Intent containing multiple <code>content:</code>
8115 * URIs for which the recipient may not have global permission to access the
8116 * content provider.
8117 *
8118 * <p>If the ClipData contains items that are themselves Intents, any
8119 * grant flags in those Intents will be ignored. Only the top-level flags
8120 * of the main Intent are respected, and will be applied to all Uri or
8121 * Intent items in the clip (or sub-items of the clip).
8122 *
8123 * <p>The MIME type, label, and icon in the ClipData object are not
8124 * directly used by Intent. Applications should generally rely on the
8125 * MIME type of the Intent itself, not what it may find in the ClipData.
8126 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008127 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008128 *
8129 * @param clip The new clip to set. May be null to clear the current clip.
8130 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008131 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008132 mClipData = clip;
8133 }
8134
8135 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008136 * This is NOT a secure mechanism to identify the user who sent the intent.
8137 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8138 * who sent the intent.
8139 * @hide
8140 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008141 public void prepareToLeaveUser(int userId) {
8142 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8143 // We want mContentUserHint to refer to the original user, so don't do anything.
8144 if (mContentUserHint == UserHandle.USER_CURRENT) {
8145 mContentUserHint = userId;
8146 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008147 }
8148
8149 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008150 * Add extended data to the intent. The name must include a package
8151 * prefix, for example the app com.android.contacts would use names
8152 * like "com.android.contacts.ShowAll".
8153 *
8154 * @param name The name of the extra data, with package prefix.
8155 * @param value The boolean data value.
8156 *
8157 * @return Returns the same Intent object, for chaining multiple calls
8158 * into a single statement.
8159 *
8160 * @see #putExtras
8161 * @see #removeExtra
8162 * @see #getBooleanExtra(String, boolean)
8163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008164 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008165 if (mExtras == null) {
8166 mExtras = new Bundle();
8167 }
8168 mExtras.putBoolean(name, value);
8169 return this;
8170 }
8171
8172 /**
8173 * Add extended data to the intent. The name must include a package
8174 * prefix, for example the app com.android.contacts would use names
8175 * like "com.android.contacts.ShowAll".
8176 *
8177 * @param name The name of the extra data, with package prefix.
8178 * @param value The byte data value.
8179 *
8180 * @return Returns the same Intent object, for chaining multiple calls
8181 * into a single statement.
8182 *
8183 * @see #putExtras
8184 * @see #removeExtra
8185 * @see #getByteExtra(String, byte)
8186 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008187 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 if (mExtras == null) {
8189 mExtras = new Bundle();
8190 }
8191 mExtras.putByte(name, value);
8192 return this;
8193 }
8194
8195 /**
8196 * Add extended data to the intent. The name must include a package
8197 * prefix, for example the app com.android.contacts would use names
8198 * like "com.android.contacts.ShowAll".
8199 *
8200 * @param name The name of the extra data, with package prefix.
8201 * @param value The char data value.
8202 *
8203 * @return Returns the same Intent object, for chaining multiple calls
8204 * into a single statement.
8205 *
8206 * @see #putExtras
8207 * @see #removeExtra
8208 * @see #getCharExtra(String, char)
8209 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008210 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008211 if (mExtras == null) {
8212 mExtras = new Bundle();
8213 }
8214 mExtras.putChar(name, value);
8215 return this;
8216 }
8217
8218 /**
8219 * Add extended data to the intent. The name must include a package
8220 * prefix, for example the app com.android.contacts would use names
8221 * like "com.android.contacts.ShowAll".
8222 *
8223 * @param name The name of the extra data, with package prefix.
8224 * @param value The short data value.
8225 *
8226 * @return Returns the same Intent object, for chaining multiple calls
8227 * into a single statement.
8228 *
8229 * @see #putExtras
8230 * @see #removeExtra
8231 * @see #getShortExtra(String, short)
8232 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008233 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008234 if (mExtras == null) {
8235 mExtras = new Bundle();
8236 }
8237 mExtras.putShort(name, value);
8238 return this;
8239 }
8240
8241 /**
8242 * Add extended data to the intent. The name must include a package
8243 * prefix, for example the app com.android.contacts would use names
8244 * like "com.android.contacts.ShowAll".
8245 *
8246 * @param name The name of the extra data, with package prefix.
8247 * @param value The integer data value.
8248 *
8249 * @return Returns the same Intent object, for chaining multiple calls
8250 * into a single statement.
8251 *
8252 * @see #putExtras
8253 * @see #removeExtra
8254 * @see #getIntExtra(String, int)
8255 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008256 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008257 if (mExtras == null) {
8258 mExtras = new Bundle();
8259 }
8260 mExtras.putInt(name, value);
8261 return this;
8262 }
8263
8264 /**
8265 * Add extended data to the intent. The name must include a package
8266 * prefix, for example the app com.android.contacts would use names
8267 * like "com.android.contacts.ShowAll".
8268 *
8269 * @param name The name of the extra data, with package prefix.
8270 * @param value The long data value.
8271 *
8272 * @return Returns the same Intent object, for chaining multiple calls
8273 * into a single statement.
8274 *
8275 * @see #putExtras
8276 * @see #removeExtra
8277 * @see #getLongExtra(String, long)
8278 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008279 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 if (mExtras == null) {
8281 mExtras = new Bundle();
8282 }
8283 mExtras.putLong(name, value);
8284 return this;
8285 }
8286
8287 /**
8288 * Add extended data to the intent. The name must include a package
8289 * prefix, for example the app com.android.contacts would use names
8290 * like "com.android.contacts.ShowAll".
8291 *
8292 * @param name The name of the extra data, with package prefix.
8293 * @param value The float data value.
8294 *
8295 * @return Returns the same Intent object, for chaining multiple calls
8296 * into a single statement.
8297 *
8298 * @see #putExtras
8299 * @see #removeExtra
8300 * @see #getFloatExtra(String, float)
8301 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008302 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008303 if (mExtras == null) {
8304 mExtras = new Bundle();
8305 }
8306 mExtras.putFloat(name, value);
8307 return this;
8308 }
8309
8310 /**
8311 * Add extended data to the intent. The name must include a package
8312 * prefix, for example the app com.android.contacts would use names
8313 * like "com.android.contacts.ShowAll".
8314 *
8315 * @param name The name of the extra data, with package prefix.
8316 * @param value The double data value.
8317 *
8318 * @return Returns the same Intent object, for chaining multiple calls
8319 * into a single statement.
8320 *
8321 * @see #putExtras
8322 * @see #removeExtra
8323 * @see #getDoubleExtra(String, double)
8324 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008325 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008326 if (mExtras == null) {
8327 mExtras = new Bundle();
8328 }
8329 mExtras.putDouble(name, value);
8330 return this;
8331 }
8332
8333 /**
8334 * Add extended data to the intent. The name must include a package
8335 * prefix, for example the app com.android.contacts would use names
8336 * like "com.android.contacts.ShowAll".
8337 *
8338 * @param name The name of the extra data, with package prefix.
8339 * @param value The String data value.
8340 *
8341 * @return Returns the same Intent object, for chaining multiple calls
8342 * into a single statement.
8343 *
8344 * @see #putExtras
8345 * @see #removeExtra
8346 * @see #getStringExtra(String)
8347 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008348 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008349 if (mExtras == null) {
8350 mExtras = new Bundle();
8351 }
8352 mExtras.putString(name, value);
8353 return this;
8354 }
8355
8356 /**
8357 * Add extended data to the intent. The name must include a package
8358 * prefix, for example the app com.android.contacts would use names
8359 * like "com.android.contacts.ShowAll".
8360 *
8361 * @param name The name of the extra data, with package prefix.
8362 * @param value The CharSequence data value.
8363 *
8364 * @return Returns the same Intent object, for chaining multiple calls
8365 * into a single statement.
8366 *
8367 * @see #putExtras
8368 * @see #removeExtra
8369 * @see #getCharSequenceExtra(String)
8370 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008371 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008372 if (mExtras == null) {
8373 mExtras = new Bundle();
8374 }
8375 mExtras.putCharSequence(name, value);
8376 return this;
8377 }
8378
8379 /**
8380 * Add extended data to the intent. The name must include a package
8381 * prefix, for example the app com.android.contacts would use names
8382 * like "com.android.contacts.ShowAll".
8383 *
8384 * @param name The name of the extra data, with package prefix.
8385 * @param value The Parcelable data value.
8386 *
8387 * @return Returns the same Intent object, for chaining multiple calls
8388 * into a single statement.
8389 *
8390 * @see #putExtras
8391 * @see #removeExtra
8392 * @see #getParcelableExtra(String)
8393 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008394 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008395 if (mExtras == null) {
8396 mExtras = new Bundle();
8397 }
8398 mExtras.putParcelable(name, value);
8399 return this;
8400 }
8401
8402 /**
8403 * Add extended data to the intent. The name must include a package
8404 * prefix, for example the app com.android.contacts would use names
8405 * like "com.android.contacts.ShowAll".
8406 *
8407 * @param name The name of the extra data, with package prefix.
8408 * @param value The Parcelable[] data value.
8409 *
8410 * @return Returns the same Intent object, for chaining multiple calls
8411 * into a single statement.
8412 *
8413 * @see #putExtras
8414 * @see #removeExtra
8415 * @see #getParcelableArrayExtra(String)
8416 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008417 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008418 if (mExtras == null) {
8419 mExtras = new Bundle();
8420 }
8421 mExtras.putParcelableArray(name, value);
8422 return this;
8423 }
8424
8425 /**
8426 * Add extended data to the intent. The name must include a package
8427 * prefix, for example the app com.android.contacts would use names
8428 * like "com.android.contacts.ShowAll".
8429 *
8430 * @param name The name of the extra data, with package prefix.
8431 * @param value The ArrayList<Parcelable> data value.
8432 *
8433 * @return Returns the same Intent object, for chaining multiple calls
8434 * into a single statement.
8435 *
8436 * @see #putExtras
8437 * @see #removeExtra
8438 * @see #getParcelableArrayListExtra(String)
8439 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008440 public @NonNull Intent putParcelableArrayListExtra(String name,
8441 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008442 if (mExtras == null) {
8443 mExtras = new Bundle();
8444 }
8445 mExtras.putParcelableArrayList(name, value);
8446 return this;
8447 }
8448
8449 /**
8450 * Add extended data to the intent. The name must include a package
8451 * prefix, for example the app com.android.contacts would use names
8452 * like "com.android.contacts.ShowAll".
8453 *
8454 * @param name The name of the extra data, with package prefix.
8455 * @param value The ArrayList<Integer> data value.
8456 *
8457 * @return Returns the same Intent object, for chaining multiple calls
8458 * into a single statement.
8459 *
8460 * @see #putExtras
8461 * @see #removeExtra
8462 * @see #getIntegerArrayListExtra(String)
8463 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008464 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008465 if (mExtras == null) {
8466 mExtras = new Bundle();
8467 }
8468 mExtras.putIntegerArrayList(name, value);
8469 return this;
8470 }
8471
8472 /**
8473 * Add extended data to the intent. The name must include a package
8474 * prefix, for example the app com.android.contacts would use names
8475 * like "com.android.contacts.ShowAll".
8476 *
8477 * @param name The name of the extra data, with package prefix.
8478 * @param value The ArrayList<String> data value.
8479 *
8480 * @return Returns the same Intent object, for chaining multiple calls
8481 * into a single statement.
8482 *
8483 * @see #putExtras
8484 * @see #removeExtra
8485 * @see #getStringArrayListExtra(String)
8486 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008487 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008488 if (mExtras == null) {
8489 mExtras = new Bundle();
8490 }
8491 mExtras.putStringArrayList(name, value);
8492 return this;
8493 }
8494
8495 /**
8496 * Add extended data to the intent. The name must include a package
8497 * prefix, for example the app com.android.contacts would use names
8498 * like "com.android.contacts.ShowAll".
8499 *
8500 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008501 * @param value The ArrayList<CharSequence> data value.
8502 *
8503 * @return Returns the same Intent object, for chaining multiple calls
8504 * into a single statement.
8505 *
8506 * @see #putExtras
8507 * @see #removeExtra
8508 * @see #getCharSequenceArrayListExtra(String)
8509 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008510 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8511 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008512 if (mExtras == null) {
8513 mExtras = new Bundle();
8514 }
8515 mExtras.putCharSequenceArrayList(name, value);
8516 return this;
8517 }
8518
8519 /**
8520 * Add extended data to the intent. The name must include a package
8521 * prefix, for example the app com.android.contacts would use names
8522 * like "com.android.contacts.ShowAll".
8523 *
8524 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008525 * @param value The Serializable data value.
8526 *
8527 * @return Returns the same Intent object, for chaining multiple calls
8528 * into a single statement.
8529 *
8530 * @see #putExtras
8531 * @see #removeExtra
8532 * @see #getSerializableExtra(String)
8533 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008534 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008535 if (mExtras == null) {
8536 mExtras = new Bundle();
8537 }
8538 mExtras.putSerializable(name, value);
8539 return this;
8540 }
8541
8542 /**
8543 * Add extended data to the intent. The name must include a package
8544 * prefix, for example the app com.android.contacts would use names
8545 * like "com.android.contacts.ShowAll".
8546 *
8547 * @param name The name of the extra data, with package prefix.
8548 * @param value The boolean array data value.
8549 *
8550 * @return Returns the same Intent object, for chaining multiple calls
8551 * into a single statement.
8552 *
8553 * @see #putExtras
8554 * @see #removeExtra
8555 * @see #getBooleanArrayExtra(String)
8556 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008557 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 if (mExtras == null) {
8559 mExtras = new Bundle();
8560 }
8561 mExtras.putBooleanArray(name, value);
8562 return this;
8563 }
8564
8565 /**
8566 * Add extended data to the intent. The name must include a package
8567 * prefix, for example the app com.android.contacts would use names
8568 * like "com.android.contacts.ShowAll".
8569 *
8570 * @param name The name of the extra data, with package prefix.
8571 * @param value The byte array data value.
8572 *
8573 * @return Returns the same Intent object, for chaining multiple calls
8574 * into a single statement.
8575 *
8576 * @see #putExtras
8577 * @see #removeExtra
8578 * @see #getByteArrayExtra(String)
8579 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008580 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 if (mExtras == null) {
8582 mExtras = new Bundle();
8583 }
8584 mExtras.putByteArray(name, value);
8585 return this;
8586 }
8587
8588 /**
8589 * Add extended data to the intent. The name must include a package
8590 * prefix, for example the app com.android.contacts would use names
8591 * like "com.android.contacts.ShowAll".
8592 *
8593 * @param name The name of the extra data, with package prefix.
8594 * @param value The short array data value.
8595 *
8596 * @return Returns the same Intent object, for chaining multiple calls
8597 * into a single statement.
8598 *
8599 * @see #putExtras
8600 * @see #removeExtra
8601 * @see #getShortArrayExtra(String)
8602 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008603 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 if (mExtras == null) {
8605 mExtras = new Bundle();
8606 }
8607 mExtras.putShortArray(name, value);
8608 return this;
8609 }
8610
8611 /**
8612 * Add extended data to the intent. The name must include a package
8613 * prefix, for example the app com.android.contacts would use names
8614 * like "com.android.contacts.ShowAll".
8615 *
8616 * @param name The name of the extra data, with package prefix.
8617 * @param value The char array data value.
8618 *
8619 * @return Returns the same Intent object, for chaining multiple calls
8620 * into a single statement.
8621 *
8622 * @see #putExtras
8623 * @see #removeExtra
8624 * @see #getCharArrayExtra(String)
8625 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008626 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008627 if (mExtras == null) {
8628 mExtras = new Bundle();
8629 }
8630 mExtras.putCharArray(name, value);
8631 return this;
8632 }
8633
8634 /**
8635 * Add extended data to the intent. The name must include a package
8636 * prefix, for example the app com.android.contacts would use names
8637 * like "com.android.contacts.ShowAll".
8638 *
8639 * @param name The name of the extra data, with package prefix.
8640 * @param value The int array data value.
8641 *
8642 * @return Returns the same Intent object, for chaining multiple calls
8643 * into a single statement.
8644 *
8645 * @see #putExtras
8646 * @see #removeExtra
8647 * @see #getIntArrayExtra(String)
8648 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008649 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650 if (mExtras == null) {
8651 mExtras = new Bundle();
8652 }
8653 mExtras.putIntArray(name, value);
8654 return this;
8655 }
8656
8657 /**
8658 * Add extended data to the intent. The name must include a package
8659 * prefix, for example the app com.android.contacts would use names
8660 * like "com.android.contacts.ShowAll".
8661 *
8662 * @param name The name of the extra data, with package prefix.
8663 * @param value The byte array data value.
8664 *
8665 * @return Returns the same Intent object, for chaining multiple calls
8666 * into a single statement.
8667 *
8668 * @see #putExtras
8669 * @see #removeExtra
8670 * @see #getLongArrayExtra(String)
8671 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008672 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008673 if (mExtras == null) {
8674 mExtras = new Bundle();
8675 }
8676 mExtras.putLongArray(name, value);
8677 return this;
8678 }
8679
8680 /**
8681 * Add extended data to the intent. The name must include a package
8682 * prefix, for example the app com.android.contacts would use names
8683 * like "com.android.contacts.ShowAll".
8684 *
8685 * @param name The name of the extra data, with package prefix.
8686 * @param value The float array data value.
8687 *
8688 * @return Returns the same Intent object, for chaining multiple calls
8689 * into a single statement.
8690 *
8691 * @see #putExtras
8692 * @see #removeExtra
8693 * @see #getFloatArrayExtra(String)
8694 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008695 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008696 if (mExtras == null) {
8697 mExtras = new Bundle();
8698 }
8699 mExtras.putFloatArray(name, value);
8700 return this;
8701 }
8702
8703 /**
8704 * Add extended data to the intent. The name must include a package
8705 * prefix, for example the app com.android.contacts would use names
8706 * like "com.android.contacts.ShowAll".
8707 *
8708 * @param name The name of the extra data, with package prefix.
8709 * @param value The double array data value.
8710 *
8711 * @return Returns the same Intent object, for chaining multiple calls
8712 * into a single statement.
8713 *
8714 * @see #putExtras
8715 * @see #removeExtra
8716 * @see #getDoubleArrayExtra(String)
8717 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008718 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008719 if (mExtras == null) {
8720 mExtras = new Bundle();
8721 }
8722 mExtras.putDoubleArray(name, value);
8723 return this;
8724 }
8725
8726 /**
8727 * Add extended data to the intent. The name must include a package
8728 * prefix, for example the app com.android.contacts would use names
8729 * like "com.android.contacts.ShowAll".
8730 *
8731 * @param name The name of the extra data, with package prefix.
8732 * @param value The String array data value.
8733 *
8734 * @return Returns the same Intent object, for chaining multiple calls
8735 * into a single statement.
8736 *
8737 * @see #putExtras
8738 * @see #removeExtra
8739 * @see #getStringArrayExtra(String)
8740 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008741 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008742 if (mExtras == null) {
8743 mExtras = new Bundle();
8744 }
8745 mExtras.putStringArray(name, value);
8746 return this;
8747 }
8748
8749 /**
8750 * Add extended data to the intent. The name must include a package
8751 * prefix, for example the app com.android.contacts would use names
8752 * like "com.android.contacts.ShowAll".
8753 *
8754 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008755 * @param value The CharSequence array data value.
8756 *
8757 * @return Returns the same Intent object, for chaining multiple calls
8758 * into a single statement.
8759 *
8760 * @see #putExtras
8761 * @see #removeExtra
8762 * @see #getCharSequenceArrayExtra(String)
8763 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008764 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008765 if (mExtras == null) {
8766 mExtras = new Bundle();
8767 }
8768 mExtras.putCharSequenceArray(name, value);
8769 return this;
8770 }
8771
8772 /**
8773 * Add extended data to the intent. The name must include a package
8774 * prefix, for example the app com.android.contacts would use names
8775 * like "com.android.contacts.ShowAll".
8776 *
8777 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008778 * @param value The Bundle data value.
8779 *
8780 * @return Returns the same Intent object, for chaining multiple calls
8781 * into a single statement.
8782 *
8783 * @see #putExtras
8784 * @see #removeExtra
8785 * @see #getBundleExtra(String)
8786 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008787 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008788 if (mExtras == null) {
8789 mExtras = new Bundle();
8790 }
8791 mExtras.putBundle(name, value);
8792 return this;
8793 }
8794
8795 /**
8796 * Add extended data to the intent. The name must include a package
8797 * prefix, for example the app com.android.contacts would use names
8798 * like "com.android.contacts.ShowAll".
8799 *
8800 * @param name The name of the extra data, with package prefix.
8801 * @param value The IBinder data value.
8802 *
8803 * @return Returns the same Intent object, for chaining multiple calls
8804 * into a single statement.
8805 *
8806 * @see #putExtras
8807 * @see #removeExtra
8808 * @see #getIBinderExtra(String)
8809 *
8810 * @deprecated
8811 * @hide
8812 */
8813 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008814 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008815 if (mExtras == null) {
8816 mExtras = new Bundle();
8817 }
8818 mExtras.putIBinder(name, value);
8819 return this;
8820 }
8821
8822 /**
8823 * Copy all extras in 'src' in to this intent.
8824 *
8825 * @param src Contains the extras to copy.
8826 *
8827 * @see #putExtra
8828 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008829 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008830 if (src.mExtras != null) {
8831 if (mExtras == null) {
8832 mExtras = new Bundle(src.mExtras);
8833 } else {
8834 mExtras.putAll(src.mExtras);
8835 }
8836 }
8837 return this;
8838 }
8839
8840 /**
8841 * Add a set of extended data to the intent. The keys must include a package
8842 * prefix, for example the app com.android.contacts would use names
8843 * like "com.android.contacts.ShowAll".
8844 *
8845 * @param extras The Bundle of extras to add to this intent.
8846 *
8847 * @see #putExtra
8848 * @see #removeExtra
8849 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008850 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008851 if (mExtras == null) {
8852 mExtras = new Bundle();
8853 }
8854 mExtras.putAll(extras);
8855 return this;
8856 }
8857
8858 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008859 * Completely replace the extras in the Intent with the extras in the
8860 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008861 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008862 * @param src The exact extras contained in this Intent are copied
8863 * into the target intent, replacing any that were previously there.
8864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008865 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008866 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8867 return this;
8868 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008869
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008870 /**
8871 * Completely replace the extras in the Intent with the given Bundle of
8872 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008873 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008874 * @param extras The new set of extras in the Intent, or null to erase
8875 * all extras.
8876 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008877 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008878 mExtras = extras != null ? new Bundle(extras) : null;
8879 return this;
8880 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008881
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008882 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008883 * Remove extended data from the intent.
8884 *
8885 * @see #putExtra
8886 */
8887 public void removeExtra(String name) {
8888 if (mExtras != null) {
8889 mExtras.remove(name);
8890 if (mExtras.size() == 0) {
8891 mExtras = null;
8892 }
8893 }
8894 }
8895
8896 /**
8897 * Set special flags controlling how this intent is handled. Most values
8898 * here depend on the type of component being executed by the Intent,
8899 * specifically the FLAG_ACTIVITY_* flags are all for use with
8900 * {@link Context#startActivity Context.startActivity()} and the
8901 * FLAG_RECEIVER_* flags are all for use with
8902 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8903 *
Scott Main7aee61f2011-02-08 11:25:01 -08008904 * <p>See the
8905 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8906 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008907 * the behavior of your application.
8908 *
8909 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008910 * @return Returns the same Intent object, for chaining multiple calls
8911 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008912 * @see #getFlags
8913 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008914 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008915 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008916 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008917 mFlags = flags;
8918 return this;
8919 }
8920
8921 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008922 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008923 *
8924 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008925 * @return Returns the same Intent object, for chaining multiple calls into
8926 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008927 * @see #setFlags
8928 * @see #getFlags
8929 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008930 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008931 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008932 mFlags |= flags;
8933 return this;
8934 }
8935
8936 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008937 * Remove these flags from the intent.
8938 *
8939 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008940 * @see #setFlags
8941 * @see #getFlags
8942 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008943 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008944 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008945 mFlags &= ~flags;
8946 }
8947
8948 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008949 * (Usually optional) Set an explicit application package name that limits
8950 * the components this Intent will resolve to. If left to the default
8951 * value of null, all components in all applications will considered.
8952 * If non-null, the Intent can only match the components in the given
8953 * application package.
8954 *
8955 * @param packageName The name of the application package to handle the
8956 * intent, or null to allow any application package.
8957 *
8958 * @return Returns the same Intent object, for chaining multiple calls
8959 * into a single statement.
8960 *
8961 * @see #getPackage
8962 * @see #resolveActivity
8963 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008964 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008965 if (packageName != null && mSelector != null) {
8966 throw new IllegalArgumentException(
8967 "Can't set package name when selector is already set");
8968 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008969 mPackage = packageName;
8970 return this;
8971 }
8972
8973 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008974 * (Usually optional) Explicitly set the component to handle the intent.
8975 * If left with the default value of null, the system will determine the
8976 * appropriate class to use based on the other fields (action, data,
8977 * type, categories) in the Intent. If this class is defined, the
8978 * specified class will always be used regardless of the other fields. You
8979 * should only set this value when you know you absolutely want a specific
8980 * class to be used; otherwise it is better to let the system find the
8981 * appropriate class so that you will respect the installed applications
8982 * and user preferences.
8983 *
8984 * @param component The name of the application component to handle the
8985 * intent, or null to let the system find one for you.
8986 *
8987 * @return Returns the same Intent object, for chaining multiple calls
8988 * into a single statement.
8989 *
8990 * @see #setClass
8991 * @see #setClassName(Context, String)
8992 * @see #setClassName(String, String)
8993 * @see #getComponent
8994 * @see #resolveActivity
8995 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008996 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008997 mComponent = component;
8998 return this;
8999 }
9000
9001 /**
9002 * Convenience for calling {@link #setComponent} with an
9003 * explicit class name.
9004 *
9005 * @param packageContext A Context of the application package implementing
9006 * this class.
9007 * @param className The name of a class inside of the application package
9008 * that will be used as the component for this Intent.
9009 *
9010 * @return Returns the same Intent object, for chaining multiple calls
9011 * into a single statement.
9012 *
9013 * @see #setComponent
9014 * @see #setClass
9015 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009016 public @NonNull Intent setClassName(@NonNull Context packageContext,
9017 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009018 mComponent = new ComponentName(packageContext, className);
9019 return this;
9020 }
9021
9022 /**
9023 * Convenience for calling {@link #setComponent} with an
9024 * explicit application package name and class name.
9025 *
9026 * @param packageName The name of the package implementing the desired
9027 * component.
9028 * @param className The name of a class inside of the application package
9029 * that will be used as the component for this Intent.
9030 *
9031 * @return Returns the same Intent object, for chaining multiple calls
9032 * into a single statement.
9033 *
9034 * @see #setComponent
9035 * @see #setClass
9036 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009037 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009038 mComponent = new ComponentName(packageName, className);
9039 return this;
9040 }
9041
9042 /**
9043 * Convenience for calling {@link #setComponent(ComponentName)} with the
9044 * name returned by a {@link Class} object.
9045 *
9046 * @param packageContext A Context of the application package implementing
9047 * this class.
9048 * @param cls The class name to set, equivalent to
9049 * <code>setClassName(context, cls.getName())</code>.
9050 *
9051 * @return Returns the same Intent object, for chaining multiple calls
9052 * into a single statement.
9053 *
9054 * @see #setComponent
9055 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009056 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009057 mComponent = new ComponentName(packageContext, cls);
9058 return this;
9059 }
9060
9061 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009062 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9063 * used as a hint to the receiver for animations and the like. Null means that there
9064 * is no source bounds.
9065 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009066 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009067 if (r != null) {
9068 mSourceBounds = new Rect(r);
9069 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009070 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009071 }
9072 }
9073
Tor Norbyed9273d62013-05-30 15:59:53 -07009074 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009075 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9076 FILL_IN_ACTION,
9077 FILL_IN_DATA,
9078 FILL_IN_CATEGORIES,
9079 FILL_IN_COMPONENT,
9080 FILL_IN_PACKAGE,
9081 FILL_IN_SOURCE_BOUNDS,
9082 FILL_IN_SELECTOR,
9083 FILL_IN_CLIP_DATA
9084 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009085 @Retention(RetentionPolicy.SOURCE)
9086 public @interface FillInFlags {}
9087
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009088 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009089 * Use with {@link #fillIn} to allow the current action value to be
9090 * overwritten, even if it is already set.
9091 */
9092 public static final int FILL_IN_ACTION = 1<<0;
9093
9094 /**
9095 * Use with {@link #fillIn} to allow the current data or type value
9096 * overwritten, even if it is already set.
9097 */
9098 public static final int FILL_IN_DATA = 1<<1;
9099
9100 /**
9101 * Use with {@link #fillIn} to allow the current categories to be
9102 * overwritten, even if they are already set.
9103 */
9104 public static final int FILL_IN_CATEGORIES = 1<<2;
9105
9106 /**
9107 * Use with {@link #fillIn} to allow the current component value to be
9108 * overwritten, even if it is already set.
9109 */
9110 public static final int FILL_IN_COMPONENT = 1<<3;
9111
9112 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009113 * Use with {@link #fillIn} to allow the current package value to be
9114 * overwritten, even if it is already set.
9115 */
9116 public static final int FILL_IN_PACKAGE = 1<<4;
9117
9118 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009119 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009120 * overwritten, even if it is already set.
9121 */
9122 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9123
9124 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009125 * Use with {@link #fillIn} to allow the current selector to be
9126 * overwritten, even if it is already set.
9127 */
9128 public static final int FILL_IN_SELECTOR = 1<<6;
9129
9130 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009131 * Use with {@link #fillIn} to allow the current ClipData to be
9132 * overwritten, even if it is already set.
9133 */
9134 public static final int FILL_IN_CLIP_DATA = 1<<7;
9135
9136 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009137 * Copy the contents of <var>other</var> in to this object, but only
9138 * where fields are not defined by this object. For purposes of a field
9139 * being defined, the following pieces of data in the Intent are
9140 * considered to be separate fields:
9141 *
9142 * <ul>
9143 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009144 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009145 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9146 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009147 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009148 * <li> component, as set by {@link #setComponent(ComponentName)} or
9149 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009150 * <li> source bounds, as set by {@link #setSourceBounds}.
9151 * <li> selector, as set by {@link #setSelector(Intent)}.
9152 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009153 * <li> each top-level name in the associated extras.
9154 * </ul>
9155 *
9156 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009157 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009158 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9159 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9160 * the restriction where the corresponding field will not be replaced if
9161 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009162 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009163 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9164 * is explicitly specified. The selector will only be copied if
9165 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009166 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009167 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9168 * and Intent B with {action="gotit", data-type="some/thing",
9169 * categories="one","two"}.
9170 *
9171 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9172 * containing: {action="gotit", data-type="some/thing",
9173 * categories="bar"}.
9174 *
9175 * @param other Another Intent whose values are to be used to fill in
9176 * the current one.
9177 * @param flags Options to control which fields can be filled in.
9178 *
9179 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009180 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009181 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009182 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009183 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009184 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009185 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009186 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009187 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009188 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009189 if (other.mAction != null
9190 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009191 mAction = other.mAction;
9192 changes |= FILL_IN_ACTION;
9193 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009194 if ((other.mData != null || other.mType != null)
9195 && ((mData == null && mType == null)
9196 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009197 mData = other.mData;
9198 mType = other.mType;
9199 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009200 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009201 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009202 if (other.mCategories != null
9203 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009204 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009205 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009206 }
9207 changes |= FILL_IN_CATEGORIES;
9208 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009209 if (other.mPackage != null
9210 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009211 // Only do this if mSelector is not set.
9212 if (mSelector == null) {
9213 mPackage = other.mPackage;
9214 changes |= FILL_IN_PACKAGE;
9215 }
9216 }
9217 // Selector is special: it can only be set if explicitly allowed,
9218 // for the same reason as the component name.
9219 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9220 if (mPackage == null) {
9221 mSelector = new Intent(other.mSelector);
9222 mPackage = null;
9223 changes |= FILL_IN_SELECTOR;
9224 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009225 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009226 if (other.mClipData != null
9227 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9228 mClipData = other.mClipData;
9229 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009230 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009231 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009232 // Component is special: it can -only- be set if explicitly allowed,
9233 // since otherwise the sender could force the intent somewhere the
9234 // originator didn't intend.
9235 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009236 mComponent = other.mComponent;
9237 changes |= FILL_IN_COMPONENT;
9238 }
9239 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009240 if (other.mSourceBounds != null
9241 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9242 mSourceBounds = new Rect(other.mSourceBounds);
9243 changes |= FILL_IN_SOURCE_BOUNDS;
9244 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009245 if (mExtras == null) {
9246 if (other.mExtras != null) {
9247 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009248 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009249 }
9250 } else if (other.mExtras != null) {
9251 try {
9252 Bundle newb = new Bundle(other.mExtras);
9253 newb.putAll(mExtras);
9254 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009255 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009256 } catch (RuntimeException e) {
9257 // Modifying the extras can cause us to unparcel the contents
9258 // of the bundle, and if we do this in the system process that
9259 // may fail. We really should handle this (i.e., the Bundle
9260 // impl shouldn't be on top of a plain map), but for now just
9261 // ignore it and keep the original contents. :(
9262 Log.w("Intent", "Failure filling in extras", e);
9263 }
9264 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009265 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9266 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9267 mContentUserHint = other.mContentUserHint;
9268 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009269 return changes;
9270 }
9271
9272 /**
9273 * Wrapper class holding an Intent and implementing comparisons on it for
9274 * the purpose of filtering. The class implements its
9275 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9276 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9277 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9278 * on the wrapped Intent.
9279 */
9280 public static final class FilterComparison {
9281 private final Intent mIntent;
9282 private final int mHashCode;
9283
9284 public FilterComparison(Intent intent) {
9285 mIntent = intent;
9286 mHashCode = intent.filterHashCode();
9287 }
9288
9289 /**
9290 * Return the Intent that this FilterComparison represents.
9291 * @return Returns the Intent held by the FilterComparison. Do
9292 * not modify!
9293 */
9294 public Intent getIntent() {
9295 return mIntent;
9296 }
9297
9298 @Override
9299 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009300 if (obj instanceof FilterComparison) {
9301 Intent other = ((FilterComparison)obj).mIntent;
9302 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009303 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009304 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009305 }
9306
9307 @Override
9308 public int hashCode() {
9309 return mHashCode;
9310 }
9311 }
9312
9313 /**
9314 * Determine if two intents are the same for the purposes of intent
9315 * resolution (filtering). That is, if their action, data, type,
9316 * class, and categories are the same. This does <em>not</em> compare
9317 * any extra data included in the intents.
9318 *
9319 * @param other The other Intent to compare against.
9320 *
9321 * @return Returns true if action, data, type, class, and categories
9322 * are the same.
9323 */
9324 public boolean filterEquals(Intent other) {
9325 if (other == null) {
9326 return false;
9327 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009328 if (!Objects.equals(this.mAction, other.mAction)) return false;
9329 if (!Objects.equals(this.mData, other.mData)) return false;
9330 if (!Objects.equals(this.mType, other.mType)) return false;
9331 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9332 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9333 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009334
9335 return true;
9336 }
9337
9338 /**
9339 * Generate hash code that matches semantics of filterEquals().
9340 *
9341 * @return Returns the hash value of the action, data, type, class, and
9342 * categories.
9343 *
9344 * @see #filterEquals
9345 */
9346 public int filterHashCode() {
9347 int code = 0;
9348 if (mAction != null) {
9349 code += mAction.hashCode();
9350 }
9351 if (mData != null) {
9352 code += mData.hashCode();
9353 }
9354 if (mType != null) {
9355 code += mType.hashCode();
9356 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009357 if (mPackage != null) {
9358 code += mPackage.hashCode();
9359 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009360 if (mComponent != null) {
9361 code += mComponent.hashCode();
9362 }
9363 if (mCategories != null) {
9364 code += mCategories.hashCode();
9365 }
9366 return code;
9367 }
9368
9369 @Override
9370 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009371 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009372
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009373 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009374 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009375 b.append(" }");
9376
9377 return b.toString();
9378 }
9379
9380 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009381 public String toInsecureString() {
9382 StringBuilder b = new StringBuilder(128);
9383
9384 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009385 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009386 b.append(" }");
9387
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009388 return b.toString();
9389 }
Romain Guy4969af72009-06-17 10:53:19 -07009390
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009391 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009392 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009393 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009394
9395 b.append("Intent { ");
9396 toShortString(b, false, true, true, true);
9397 b.append(" }");
9398
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009399 return b.toString();
9400 }
9401
9402 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009403 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9404 StringBuilder b = new StringBuilder(128);
9405 toShortString(b, secure, comp, extras, clip);
9406 return b.toString();
9407 }
9408
9409 /** @hide */
9410 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9411 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009412 boolean first = true;
9413 if (mAction != null) {
9414 b.append("act=").append(mAction);
9415 first = false;
9416 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009417 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009418 if (!first) {
9419 b.append(' ');
9420 }
9421 first = false;
9422 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009423 for (int i=0; i<mCategories.size(); i++) {
9424 if (i > 0) b.append(',');
9425 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009426 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009427 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009428 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009429 if (mData != null) {
9430 if (!first) {
9431 b.append(' ');
9432 }
9433 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009434 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009435 if (secure) {
9436 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009437 } else {
9438 b.append(mData);
9439 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009440 }
9441 if (mType != null) {
9442 if (!first) {
9443 b.append(' ');
9444 }
9445 first = false;
9446 b.append("typ=").append(mType);
9447 }
9448 if (mFlags != 0) {
9449 if (!first) {
9450 b.append(' ');
9451 }
9452 first = false;
9453 b.append("flg=0x").append(Integer.toHexString(mFlags));
9454 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009455 if (mPackage != null) {
9456 if (!first) {
9457 b.append(' ');
9458 }
9459 first = false;
9460 b.append("pkg=").append(mPackage);
9461 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009462 if (comp && mComponent != null) {
9463 if (!first) {
9464 b.append(' ');
9465 }
9466 first = false;
9467 b.append("cmp=").append(mComponent.flattenToShortString());
9468 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009469 if (mSourceBounds != null) {
9470 if (!first) {
9471 b.append(' ');
9472 }
9473 first = false;
9474 b.append("bnds=").append(mSourceBounds.toShortString());
9475 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009476 if (mClipData != null) {
9477 if (!first) {
9478 b.append(' ');
9479 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009480 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009481 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009482 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009483 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009484 if (mClipData.getDescription() != null) {
9485 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9486 } else {
9487 first = true;
9488 }
9489 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009490 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009491 first = false;
9492 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009493 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009494 if (extras && mExtras != null) {
9495 if (!first) {
9496 b.append(' ');
9497 }
9498 first = false;
9499 b.append("(has extras)");
9500 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009501 if (mContentUserHint != UserHandle.USER_CURRENT) {
9502 if (!first) {
9503 b.append(' ');
9504 }
9505 first = false;
9506 b.append("u=").append(mContentUserHint);
9507 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009508 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009509 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009510 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009511 b.append("}");
9512 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009513 }
9514
Yi Jin129fc6c2017-09-28 15:48:38 -07009515 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009516 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9517 // Same input parameters that toString() gives to toShortString().
9518 writeToProto(proto, fieldId, true, true, true, false);
9519 }
9520
9521 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009522 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9523 boolean extras, boolean clip) {
9524 long token = proto.start(fieldId);
9525 if (mAction != null) {
9526 proto.write(IntentProto.ACTION, mAction);
9527 }
9528 if (mCategories != null) {
9529 for (String category : mCategories) {
9530 proto.write(IntentProto.CATEGORIES, category);
9531 }
9532 }
9533 if (mData != null) {
9534 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9535 }
9536 if (mType != null) {
9537 proto.write(IntentProto.TYPE, mType);
9538 }
9539 if (mFlags != 0) {
9540 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9541 }
9542 if (mPackage != null) {
9543 proto.write(IntentProto.PACKAGE, mPackage);
9544 }
9545 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009546 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009547 }
9548 if (mSourceBounds != null) {
9549 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9550 }
9551 if (mClipData != null) {
9552 StringBuilder b = new StringBuilder();
9553 if (clip) {
9554 mClipData.toShortString(b);
9555 } else {
9556 mClipData.toShortStringShortItems(b, false);
9557 }
9558 proto.write(IntentProto.CLIP_DATA, b.toString());
9559 }
9560 if (extras && mExtras != null) {
9561 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9562 }
9563 if (mContentUserHint != 0) {
9564 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9565 }
9566 if (mSelector != null) {
9567 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9568 }
9569 proto.end(token);
9570 }
9571
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009572 /**
9573 * Call {@link #toUri} with 0 flags.
9574 * @deprecated Use {@link #toUri} instead.
9575 */
9576 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009577 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009578 return toUri(0);
9579 }
9580
9581 /**
9582 * Convert this Intent into a String holding a URI representation of it.
9583 * The returned URI string has been properly URI encoded, so it can be
9584 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9585 * Intent's data as the base URI, with an additional fragment describing
9586 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009587 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009588 * <p>You can convert the returned string back to an Intent with
9589 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009590 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009591 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009592 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009593 * @return Returns a URI encoding URI string describing the entire contents
9594 * of the Intent.
9595 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009596 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009597 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009598 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9599 if (mPackage == null) {
9600 throw new IllegalArgumentException(
9601 "Intent must include an explicit package name to build an android-app: "
9602 + this);
9603 }
9604 uri.append("android-app://");
9605 uri.append(mPackage);
9606 String scheme = null;
9607 if (mData != null) {
9608 scheme = mData.getScheme();
9609 if (scheme != null) {
9610 uri.append('/');
9611 uri.append(scheme);
9612 String authority = mData.getEncodedAuthority();
9613 if (authority != null) {
9614 uri.append('/');
9615 uri.append(authority);
9616 String path = mData.getEncodedPath();
9617 if (path != null) {
9618 uri.append(path);
9619 }
9620 String queryParams = mData.getEncodedQuery();
9621 if (queryParams != null) {
9622 uri.append('?');
9623 uri.append(queryParams);
9624 }
9625 String fragment = mData.getEncodedFragment();
9626 if (fragment != null) {
9627 uri.append('#');
9628 uri.append(fragment);
9629 }
9630 }
9631 }
9632 }
9633 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9634 mPackage, flags);
9635 return uri.toString();
9636 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009637 String scheme = null;
9638 if (mData != null) {
9639 String data = mData.toString();
9640 if ((flags&URI_INTENT_SCHEME) != 0) {
9641 final int N = data.length();
9642 for (int i=0; i<N; i++) {
9643 char c = data.charAt(i);
9644 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009645 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009646 continue;
9647 }
9648 if (c == ':' && i > 0) {
9649 // Valid scheme.
9650 scheme = data.substring(0, i);
9651 uri.append("intent:");
9652 data = data.substring(i+1);
9653 break;
9654 }
Tom Taylord4a47292009-12-21 13:59:18 -08009655
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009656 // No scheme.
9657 break;
9658 }
9659 }
9660 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009661
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009662 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9663 uri.append("intent:");
9664 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009665
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009666 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009667
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009668 return uri.toString();
9669 }
9670
9671 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9672 String defPackage, int flags) {
9673 StringBuilder frag = new StringBuilder(128);
9674
9675 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009676 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009677 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009678 // Note that for now we are not going to try to handle the
9679 // data part; not clear how to represent this as a URI, and
9680 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009681 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9682 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009683 }
9684
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009685 if (frag.length() > 0) {
9686 uri.append("#Intent;");
9687 uri.append(frag);
9688 uri.append("end");
9689 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009690 }
9691
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009692 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9693 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009694 if (scheme != null) {
9695 uri.append("scheme=").append(scheme).append(';');
9696 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009697 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009698 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009699 }
9700 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009701 for (int i=0; i<mCategories.size(); i++) {
9702 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009703 }
9704 }
9705 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009706 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009707 }
9708 if (mFlags != 0) {
9709 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9710 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009711 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009712 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9713 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009714 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009715 uri.append("component=").append(Uri.encode(
9716 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009717 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009718 if (mSourceBounds != null) {
9719 uri.append("sourceBounds=")
9720 .append(Uri.encode(mSourceBounds.flattenToString()))
9721 .append(';');
9722 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009723 if (mExtras != null) {
9724 for (String key : mExtras.keySet()) {
9725 final Object value = mExtras.get(key);
9726 char entryType =
9727 value instanceof String ? 'S' :
9728 value instanceof Boolean ? 'B' :
9729 value instanceof Byte ? 'b' :
9730 value instanceof Character ? 'c' :
9731 value instanceof Double ? 'd' :
9732 value instanceof Float ? 'f' :
9733 value instanceof Integer ? 'i' :
9734 value instanceof Long ? 'l' :
9735 value instanceof Short ? 's' :
9736 '\0';
9737
9738 if (entryType != '\0') {
9739 uri.append(entryType);
9740 uri.append('.');
9741 uri.append(Uri.encode(key));
9742 uri.append('=');
9743 uri.append(Uri.encode(value.toString()));
9744 uri.append(';');
9745 }
9746 }
9747 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009748 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009749
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009750 public int describeContents() {
9751 return (mExtras != null) ? mExtras.describeContents() : 0;
9752 }
9753
9754 public void writeToParcel(Parcel out, int flags) {
9755 out.writeString(mAction);
9756 Uri.writeToParcel(out, mData);
9757 out.writeString(mType);
9758 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009759 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009760 ComponentName.writeToParcel(mComponent, out);
9761
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009762 if (mSourceBounds != null) {
9763 out.writeInt(1);
9764 mSourceBounds.writeToParcel(out, flags);
9765 } else {
9766 out.writeInt(0);
9767 }
9768
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009769 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009770 final int N = mCategories.size();
9771 out.writeInt(N);
9772 for (int i=0; i<N; i++) {
9773 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009774 }
9775 } else {
9776 out.writeInt(0);
9777 }
9778
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009779 if (mSelector != null) {
9780 out.writeInt(1);
9781 mSelector.writeToParcel(out, flags);
9782 } else {
9783 out.writeInt(0);
9784 }
9785
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009786 if (mClipData != null) {
9787 out.writeInt(1);
9788 mClipData.writeToParcel(out, flags);
9789 } else {
9790 out.writeInt(0);
9791 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009792 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009793 out.writeBundle(mExtras);
9794 }
9795
9796 public static final Parcelable.Creator<Intent> CREATOR
9797 = new Parcelable.Creator<Intent>() {
9798 public Intent createFromParcel(Parcel in) {
9799 return new Intent(in);
9800 }
9801 public Intent[] newArray(int size) {
9802 return new Intent[size];
9803 }
9804 };
9805
Dianne Hackborneb034652009-09-07 00:49:58 -07009806 /** @hide */
9807 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009808 readFromParcel(in);
9809 }
9810
9811 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009812 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009813 mData = Uri.CREATOR.createFromParcel(in);
9814 mType = in.readString();
9815 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009816 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009817 mComponent = ComponentName.readFromParcel(in);
9818
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009819 if (in.readInt() != 0) {
9820 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9821 }
9822
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009823 int N = in.readInt();
9824 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009825 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009826 int i;
9827 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009828 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009829 }
9830 } else {
9831 mCategories = null;
9832 }
9833
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009834 if (in.readInt() != 0) {
9835 mSelector = new Intent(in);
9836 }
9837
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009838 if (in.readInt() != 0) {
9839 mClipData = new ClipData(in);
9840 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009841 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009842 mExtras = in.readBundle();
9843 }
9844
9845 /**
9846 * Parses the "intent" element (and its children) from XML and instantiates
9847 * an Intent object. The given XML parser should be located at the tag
9848 * where parsing should start (often named "intent"), from which the
9849 * basic action, data, type, and package and class name will be
9850 * retrieved. The function will then parse in to any child elements,
9851 * looking for <category android:name="xxx"> tags to add categories and
9852 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9853 * to the intent.
9854 *
9855 * @param resources The Resources to use when inflating resources.
9856 * @param parser The XML parser pointing at an "intent" tag.
9857 * @param attrs The AttributeSet interface for retrieving extended
9858 * attribute data at the current <var>parser</var> location.
9859 * @return An Intent object matching the XML data.
9860 * @throws XmlPullParserException If there was an XML parsing error.
9861 * @throws IOException If there was an I/O error.
9862 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009863 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9864 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009865 throws XmlPullParserException, IOException {
9866 Intent intent = new Intent();
9867
9868 TypedArray sa = resources.obtainAttributes(attrs,
9869 com.android.internal.R.styleable.Intent);
9870
9871 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9872
9873 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9874 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9875 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9876
9877 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9878 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9879 if (packageName != null && className != null) {
9880 intent.setComponent(new ComponentName(packageName, className));
9881 }
9882
9883 sa.recycle();
9884
9885 int outerDepth = parser.getDepth();
9886 int type;
9887 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9888 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9889 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9890 continue;
9891 }
9892
9893 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009894 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009895 sa = resources.obtainAttributes(attrs,
9896 com.android.internal.R.styleable.IntentCategory);
9897 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9898 sa.recycle();
9899
9900 if (cat != null) {
9901 intent.addCategory(cat);
9902 }
9903 XmlUtils.skipCurrentTag(parser);
9904
Craig Mautner21d24a22014-04-23 11:45:37 -07009905 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009906 if (intent.mExtras == null) {
9907 intent.mExtras = new Bundle();
9908 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009909 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009910 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009911
9912 } else {
9913 XmlUtils.skipCurrentTag(parser);
9914 }
9915 }
9916
9917 return intent;
9918 }
Nick Pellyccae4122012-01-09 14:12:58 -08009919
Craig Mautner21d24a22014-04-23 11:45:37 -07009920 /** @hide */
9921 public void saveToXml(XmlSerializer out) throws IOException {
9922 if (mAction != null) {
9923 out.attribute(null, ATTR_ACTION, mAction);
9924 }
9925 if (mData != null) {
9926 out.attribute(null, ATTR_DATA, mData.toString());
9927 }
9928 if (mType != null) {
9929 out.attribute(null, ATTR_TYPE, mType);
9930 }
9931 if (mComponent != null) {
9932 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9933 }
9934 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9935
9936 if (mCategories != null) {
9937 out.startTag(null, TAG_CATEGORIES);
9938 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9939 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9940 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009941 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009942 }
9943 }
9944
9945 /** @hide */
9946 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9947 XmlPullParserException {
9948 Intent intent = new Intent();
9949 final int outerDepth = in.getDepth();
9950
9951 int attrCount = in.getAttributeCount();
9952 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9953 final String attrName = in.getAttributeName(attrNdx);
9954 final String attrValue = in.getAttributeValue(attrNdx);
9955 if (ATTR_ACTION.equals(attrName)) {
9956 intent.setAction(attrValue);
9957 } else if (ATTR_DATA.equals(attrName)) {
9958 intent.setData(Uri.parse(attrValue));
9959 } else if (ATTR_TYPE.equals(attrName)) {
9960 intent.setType(attrValue);
9961 } else if (ATTR_COMPONENT.equals(attrName)) {
9962 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9963 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009964 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009965 } else {
9966 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9967 }
9968 }
9969
9970 int event;
9971 String name;
9972 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9973 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9974 if (event == XmlPullParser.START_TAG) {
9975 name = in.getName();
9976 if (TAG_CATEGORIES.equals(name)) {
9977 attrCount = in.getAttributeCount();
9978 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9979 intent.addCategory(in.getAttributeValue(attrNdx));
9980 }
9981 } else {
9982 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9983 XmlUtils.skipCurrentTag(in);
9984 }
9985 }
9986 }
9987
9988 return intent;
9989 }
9990
Nick Pellyccae4122012-01-09 14:12:58 -08009991 /**
9992 * Normalize a MIME data type.
9993 *
9994 * <p>A normalized MIME type has white-space trimmed,
9995 * content-type parameters removed, and is lower-case.
9996 * This aligns the type with Android best practices for
9997 * intent filtering.
9998 *
9999 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10000 * "text/x-vCard" becomes "text/x-vcard".
10001 *
10002 * <p>All MIME types received from outside Android (such as user input,
10003 * or external sources like Bluetooth, NFC, or the Internet) should
10004 * be normalized before they are used to create an Intent.
10005 *
10006 * @param type MIME data type to normalize
10007 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010008 * @see #setType
10009 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010010 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010011 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010012 if (type == null) {
10013 return null;
10014 }
10015
Elliott Hughescb64d432013-08-02 10:00:44 -070010016 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010017
10018 final int semicolonIndex = type.indexOf(';');
10019 if (semicolonIndex != -1) {
10020 type = type.substring(0, semicolonIndex);
10021 }
10022 return type;
10023 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010024
10025 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010026 * Prepare this {@link Intent} to leave an app process.
10027 *
10028 * @hide
10029 */
Jeff Sharkey344744b2016-01-28 19:03:30 -070010030 public void prepareToLeaveProcess(Context context) {
10031 final boolean leavingPackage = (mComponent == null)
10032 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10033 prepareToLeaveProcess(leavingPackage);
10034 }
10035
10036 /**
10037 * Prepare this {@link Intent} to leave an app process.
10038 *
10039 * @hide
10040 */
10041 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010042 setAllowFds(false);
10043
10044 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010045 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010046 }
10047 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010048 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010049 }
10050
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010051 if (mExtras != null && !mExtras.isParcelled()) {
10052 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10053 if (intent instanceof Intent) {
10054 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10055 }
10056 }
10057
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010058 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10059 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010060 switch (mAction) {
10061 case ACTION_MEDIA_REMOVED:
10062 case ACTION_MEDIA_UNMOUNTED:
10063 case ACTION_MEDIA_CHECKING:
10064 case ACTION_MEDIA_NOFS:
10065 case ACTION_MEDIA_MOUNTED:
10066 case ACTION_MEDIA_SHARED:
10067 case ACTION_MEDIA_UNSHARED:
10068 case ACTION_MEDIA_BAD_REMOVAL:
10069 case ACTION_MEDIA_UNMOUNTABLE:
10070 case ACTION_MEDIA_EJECT:
10071 case ACTION_MEDIA_SCANNER_STARTED:
10072 case ACTION_MEDIA_SCANNER_FINISHED:
10073 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010074 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10075 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010076 // Ignore legacy actions
10077 break;
10078 default:
10079 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010080 }
10081 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010082
10083 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10084 && leavingPackage) {
10085 switch (mAction) {
10086 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010087 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010088 // Ignore actions that don't need to grant
10089 break;
10090 default:
10091 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10092 }
10093 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010094 }
10095
10096 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010097 * @hide
10098 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010099 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010100 // We just entered destination process, so we should be able to read all
10101 // parcelables inside.
10102 setDefusable(true);
10103
10104 if (mSelector != null) {
10105 mSelector.prepareToEnterProcess();
10106 }
10107 if (mClipData != null) {
10108 mClipData.prepareToEnterProcess();
10109 }
10110
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010111 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010112 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10113 fixUris(mContentUserHint);
10114 mContentUserHint = UserHandle.USER_CURRENT;
10115 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010116 }
10117 }
10118
Patrick Baumann577d4022018-01-31 16:55:10 +000010119 /** @hide */
10120 public boolean hasWebURI() {
10121 if (getData() == null) {
10122 return false;
10123 }
10124 final String scheme = getScheme();
10125 if (TextUtils.isEmpty(scheme)) {
10126 return false;
10127 }
10128 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10129 }
10130
10131 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010132 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010133 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010134 && hasWebURI();
10135 }
10136
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010137 /**
10138 * @hide
10139 */
10140 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010141 Uri data = getData();
10142 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010143 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010144 }
10145 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010146 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010147 }
10148 String action = getAction();
10149 if (ACTION_SEND.equals(action)) {
10150 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10151 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010152 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010153 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010154 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010155 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10156 if (streams != null) {
10157 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10158 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010159 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010160 }
10161 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10162 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010163 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10164 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10165 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10166 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10167 if (output != null) {
10168 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10169 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010170 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010171 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010172
10173 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010174 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010175 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10176 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010177 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010178 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010179 * @hide
10180 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010181 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010182 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010183 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010184
10185 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010186 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010187
10188 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010189 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010190 // Inspect contained intents to see if we need to migrate extras. We
10191 // don't promote ClipData to the parent, since ChooserActivity will
10192 // already start the picked item as the caller, and we can't combine
10193 // the flags in a safe way.
10194
10195 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010196 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010197 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10198 if (intent != null) {
10199 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010200 }
10201 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010202 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010203 try {
10204 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10205 if (intents != null) {
10206 for (int i = 0; i < intents.length; i++) {
10207 final Intent intent = (Intent) intents[i];
10208 if (intent != null) {
10209 migrated |= intent.migrateExtraStreamToClipData();
10210 }
10211 }
10212 }
10213 } catch (ClassCastException e) {
10214 }
10215 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010216
10217 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010218 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010219 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10220 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10221 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10222 if (stream != null || text != null || htmlText != null) {
10223 final ClipData clipData = new ClipData(
10224 null, new String[] { getType() },
10225 new ClipData.Item(text, htmlText, null, stream));
10226 setClipData(clipData);
10227 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010228 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010229 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010230 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010231 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010232
10233 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010234 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010235 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10236 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10237 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10238 int num = -1;
10239 if (streams != null) {
10240 num = streams.size();
10241 }
10242 if (texts != null) {
10243 if (num >= 0 && num != texts.size()) {
10244 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010245 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010246 }
10247 num = texts.size();
10248 }
10249 if (htmlTexts != null) {
10250 if (num >= 0 && num != htmlTexts.size()) {
10251 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010252 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010253 }
10254 num = htmlTexts.size();
10255 }
10256 if (num > 0) {
10257 final ClipData clipData = new ClipData(
10258 null, new String[] { getType() },
10259 makeClipItem(streams, texts, htmlTexts, 0));
10260
10261 for (int i = 1; i < num; i++) {
10262 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10263 }
10264
10265 setClipData(clipData);
10266 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010267 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010268 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010269 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010270 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010271 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10272 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10273 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10274 final Uri output;
10275 try {
10276 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10277 } catch (ClassCastException e) {
10278 return false;
10279 }
10280 if (output != null) {
10281 setClipData(ClipData.newRawUri("", output));
10282 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10283 return true;
10284 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010285 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010286
10287 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010288 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010289
Michael Wright19859762017-09-18 20:57:58 +010010290 /**
10291 * Convert the dock state to a human readable format.
10292 * @hide
10293 */
10294 public static String dockStateToString(int dock) {
10295 switch (dock) {
10296 case EXTRA_DOCK_STATE_HE_DESK:
10297 return "EXTRA_DOCK_STATE_HE_DESK";
10298 case EXTRA_DOCK_STATE_LE_DESK:
10299 return "EXTRA_DOCK_STATE_LE_DESK";
10300 case EXTRA_DOCK_STATE_CAR:
10301 return "EXTRA_DOCK_STATE_CAR";
10302 case EXTRA_DOCK_STATE_DESK:
10303 return "EXTRA_DOCK_STATE_DESK";
10304 case EXTRA_DOCK_STATE_UNDOCKED:
10305 return "EXTRA_DOCK_STATE_UNDOCKED";
10306 default:
10307 return Integer.toString(dock);
10308 }
10309 }
10310
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010311 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10312 ArrayList<String> htmlTexts, int which) {
10313 Uri uri = streams != null ? streams.get(which) : null;
10314 CharSequence text = texts != null ? texts.get(which) : null;
10315 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10316 return new ClipData.Item(text, htmlText, null, uri);
10317 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010318
10319 /** @hide */
10320 public boolean isDocument() {
10321 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10322 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010323}