blob: 02f0ded3fa927efa44ad2dc76ce92090259f3fab [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 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001817 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent with
1818 * {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1819 *
1820 * @see #ACTION_MY_PACKAGE_SUSPENDED
1821 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1822 * @see PackageManager#isPackageSuspended()
1823 * @see PackageManager#getSuspendedPackageAppExtras()
1824 */
1825 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1826
1827 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001828 * Intent extra: An app split name.
1829 * <p>
1830 * Type: String
1831 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001832 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001833 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1834
1835 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001836 * Intent extra: A {@link ComponentName} value.
1837 * <p>
1838 * Type: String
1839 * </p>
1840 */
1841 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1842
1843 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001844 * Intent extra: An extra for specifying whether a result is needed.
1845 * <p>
1846 * Type: boolean
1847 * </p>
1848 *
1849 * @hide
1850 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001851 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001852 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1853
1854 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001855 * Activity action: Launch UI to manage which apps have a given permission.
1856 * <p>
1857 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1858 * to which will be managed by the launched UI.
1859 * </p>
1860 * <p>
1861 * Output: Nothing.
1862 * </p>
1863 *
1864 * @see #EXTRA_PERMISSION_NAME
1865 *
1866 * @hide
1867 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001868 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001869 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1870 public static final String ACTION_MANAGE_PERMISSION_APPS =
1871 "android.intent.action.MANAGE_PERMISSION_APPS";
1872
1873 /**
1874 * Intent extra: The name of a permission.
1875 * <p>
1876 * Type: String
1877 * </p>
1878 *
1879 * @hide
1880 */
1881 @SystemApi
1882 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1883
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001884 // ---------------------------------------------------------------------
1885 // ---------------------------------------------------------------------
1886 // Standard intent broadcast actions (see action variable).
1887
1888 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001889 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1890 * <p>
1891 * For historical reasons, the name of this broadcast action refers to the power
1892 * state of the screen but it is actually sent in response to changes in the
1893 * overall interactive state of the device.
1894 * </p><p>
1895 * This broadcast is sent when the device becomes non-interactive which may have
1896 * nothing to do with the screen turning off. To determine the
1897 * actual state of the screen, use {@link android.view.Display#getState}.
1898 * </p><p>
1899 * See {@link android.os.PowerManager#isInteractive} for details.
1900 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001901 * You <em>cannot</em> receive this through components declared in
1902 * manifests, only by explicitly registering for it with
1903 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1904 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001905 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001906 * <p class="note">This is a protected intent that can only be sent
1907 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001908 */
1909 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1910 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001911
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001912 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001913 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1914 * <p>
1915 * For historical reasons, the name of this broadcast action refers to the power
1916 * state of the screen but it is actually sent in response to changes in the
1917 * overall interactive state of the device.
1918 * </p><p>
1919 * This broadcast is sent when the device becomes interactive which may have
1920 * nothing to do with the screen turning on. To determine the
1921 * actual state of the screen, use {@link android.view.Display#getState}.
1922 * </p><p>
1923 * See {@link android.os.PowerManager#isInteractive} for details.
1924 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001925 * You <em>cannot</em> receive this through components declared in
1926 * manifests, only by explicitly registering for it with
1927 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1928 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001929 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001930 * <p class="note">This is a protected intent that can only be sent
1931 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001932 */
1933 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1934 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001935
1936 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001937 * Broadcast Action: Sent after the system stops dreaming.
1938 *
1939 * <p class="note">This is a protected intent that can only be sent by the system.
1940 * It is only sent to registered receivers.</p>
1941 */
1942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1943 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1944
1945 /**
1946 * Broadcast Action: Sent after the system starts dreaming.
1947 *
1948 * <p class="note">This is a protected intent that can only be sent by the system.
1949 * It is only sent to registered receivers.</p>
1950 */
1951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1952 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1953
1954 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001955 * 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 -07001956 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001957 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001958 * <p class="note">This is a protected intent that can only be sent
1959 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001960 */
1961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001962 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001963
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 /**
1965 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001966 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001967 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001968 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1969 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001970 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001971 * <p class="note">This is a protected intent that can only be sent
1972 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001973 */
1974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1975 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1976 /**
1977 * Broadcast Action: The time was set.
1978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1981 /**
1982 * Broadcast Action: The date has changed.
1983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1985 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1986 /**
1987 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1988 * <ul>
1989 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1990 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001991 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001992 * <p class="note">This is a protected intent that can only be sent
1993 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1997 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001998 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1999 * DNS entries should be tossed.
2000 * @hide
2001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2003 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2004 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002005 * Alarm Changed Action: This is broadcast when the AlarmClock
2006 * application's alarm is set or unset. It is used by the
2007 * AlarmClock application and the StatusBar service.
2008 * @hide
2009 */
2010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2011 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002012
2013 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002014 * Broadcast Action: This is broadcast once, after the user has finished
2015 * booting, but while still in the "locked" state. It can be used to perform
2016 * application-specific initialization, such as installing alarms. You must
2017 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2018 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002019 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002020 * This broadcast is sent immediately at boot by all devices (regardless of
2021 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2022 * higher. Upon receipt of this broadcast, the user is still locked and only
2023 * device-protected storage can be accessed safely. If you want to access
2024 * credential-protected storage, you need to wait for the user to be
2025 * unlocked (typically by entering their lock pattern or PIN for the first
2026 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2027 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2028 * <p>
2029 * To receive this broadcast, your receiver component must be marked as
2030 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002031 * <p class="note">
2032 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002033 *
2034 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2038
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002039 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002040 * Broadcast Action: This is broadcast once, after the user has finished
2041 * booting. It can be used to perform application-specific initialization,
2042 * such as installing alarms. You must hold the
2043 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2044 * order to receive this broadcast.
2045 * <p>
2046 * This broadcast is sent at boot by all devices (both with and without
2047 * direct boot support). Upon receipt of this broadcast, the user is
2048 * unlocked and both device-protected and credential-protected storage can
2049 * accessed safely.
2050 * <p>
2051 * If you need to run while the user is still locked (before they've entered
2052 * their lock pattern or PIN for the first time), you can listen for the
2053 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2054 * <p class="note">
2055 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002056 */
2057 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002058 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002059 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002060
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 /**
2062 * Broadcast Action: This is broadcast when a user action should request a
2063 * temporary system dialog to dismiss. Some examples of temporary system
2064 * dialogs are the notification window-shade and the recent tasks dialog.
2065 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002067 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2068 /**
2069 * Broadcast Action: Trigger the download and eventual installation
2070 * of a package.
2071 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002072 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002073 * <p class="note">This is a protected intent that can only be sent
2074 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002075 *
2076 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002078 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2080 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2081 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002082 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002083 * device. The data contains the name of the package. Note that the
2084 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002085 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002086 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002087 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2088 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002089 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2090 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002091 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002092 * <p class="note">This is a protected intent that can only be sent
2093 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 */
2095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2096 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2097 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002098 * Broadcast Action: A new version of an application package has been
2099 * installed, replacing an existing version that was previously installed.
2100 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002101 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002102 * <ul>
2103 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2104 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002105 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002106 * <p class="note">This is a protected intent that can only be sent
2107 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002108 */
2109 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2110 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2111 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002112 * Broadcast Action: A new version of your application has been installed
2113 * over an existing one. This is only sent to the application that was
2114 * replaced. It does not contain any additional data; to receive it, just
2115 * use an intent filter for this action.
2116 *
2117 * <p class="note">This is a protected intent that can only be sent
2118 * by the system.
2119 */
2120 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2121 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2122 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002123 * Broadcast Action: An existing application package has been removed from
2124 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002125 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002126 * <ul>
2127 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2128 * to the package.
2129 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2130 * application -- data and code -- is being removed.
2131 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2132 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2133 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002134 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2140 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002141 * Broadcast Action: An existing application package has been completely
2142 * removed from the device. The data contains the name of the package.
2143 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2144 * {@link #EXTRA_DATA_REMOVED} is true and
2145 * {@link #EXTRA_REPLACING} is false of that broadcast.
2146 *
2147 * <ul>
2148 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2149 * to the package.
2150 * </ul>
2151 *
2152 * <p class="note">This is a protected intent that can only be sent
2153 * by the system.
2154 */
2155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2156 public static final String ACTION_PACKAGE_FULLY_REMOVED
2157 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2158 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002159 * Broadcast Action: An existing application package has been changed (for
2160 * example, a component has been enabled or disabled). The data contains
2161 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002162 * <ul>
2163 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002164 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002165 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002166 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2167 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002168 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002169 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002170 * <p class="note">This is a protected intent that can only be sent
2171 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002172 */
2173 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2174 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2175 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002176 * @hide
2177 * Broadcast Action: Ask system services if there is any reason to
2178 * restart the given package. The data contains the name of the
2179 * package.
2180 * <ul>
2181 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2182 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2183 * </ul>
2184 *
2185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
2187 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002188 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002189 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2190 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2191 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002192 * Broadcast Action: The user has restarted a package, and all of its
2193 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002194 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002195 * be removed. Note that the restarted package does <em>not</em>
2196 * receive this broadcast.
2197 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002198 * <ul>
2199 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2200 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002201 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002202 * <p class="note">This is a protected intent that can only be sent
2203 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2207 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002208 * Broadcast Action: The user has cleared the data of a package. This should
2209 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002210 * its persistent data is erased and this broadcast sent.
2211 * Note that the cleared package does <em>not</em>
2212 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002213 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002214 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2215 * package whose data was cleared is an uninstalled instant app, then the UID
2216 * will be -1. The platform keeps some meta-data associated with instant apps
2217 * after they are uninstalled.
2218 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2219 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002220 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002221 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002222 * <p class="note">This is a protected intent that can only be sent
2223 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2227 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002228 * Broadcast Action: Packages have been suspended.
2229 * <p>Includes the following extras:
2230 * <ul>
2231 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2232 * </ul>
2233 *
2234 * <p class="note">This is a protected intent that can only be sent
2235 * by the system. It is only sent to registered receivers.
2236 */
2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2238 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2239 /**
2240 * Broadcast Action: Packages have been unsuspended.
2241 * <p>Includes the following extras:
2242 * <ul>
2243 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2244 * </ul>
2245 *
2246 * <p class="note">This is a protected intent that can only be sent
2247 * by the system. It is only sent to registered receivers.
2248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2250 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002251
2252 /**
2253 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2254 * whenever a package is put into a suspended state or any of it's app extras change while
2255 * in the suspended state.
2256 * <p> Optionally includes the following extras:
2257 * <ul>
2258 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2259 * useful information for the app being suspended.
2260 * </ul>
2261 * <p class="note">This is a protected intent that can only be sent
2262 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2263 * the manifest.</em>
2264 *
2265 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2266 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2267 * @see PackageManager#isPackageSuspended()
2268 * @see PackageManager#getSuspendedPackageAppExtras()
2269 */
2270 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2271 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2272
2273 /**
2274 * Broadcast Action: Sent to a package that has been unsuspended.
2275 *
2276 * <p class="note">This is a protected intent that can only be sent
2277 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2278 * the manifest.</em>
2279 *
2280 * @see #ACTION_MY_PACKAGE_SUSPENDED
2281 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2282 * @see PackageManager#isPackageSuspended()
2283 * @see PackageManager#getSuspendedPackageAppExtras()
2284 */
2285 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2286 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2287
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002288 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002289 * Broadcast Action: A user ID has been removed from the system. The user
2290 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002291 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002292 * <p class="note">This is a protected intent that can only be sent
2293 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002294 */
2295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2296 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002297
2298 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002299 * Broadcast Action: Sent to the installer package of an application when
2300 * that application is first launched (that is the first time it is moved
2301 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002302 *
2303 * <p class="note">This is a protected intent that can only be sent
2304 * by the system.
2305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2308
2309 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002310 * Broadcast Action: Sent to the system package verifier when a package
2311 * needs to be verified. The data contains the package URI.
2312 * <p class="note">
2313 * This is a protected intent that can only be sent by the system.
2314 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002315 */
2316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2317 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2318
2319 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002320 * Broadcast Action: Sent to the system package verifier when a package is
2321 * verified. The data contains the package URI.
2322 * <p class="note">
2323 * This is a protected intent that can only be sent by the system.
2324 */
2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2327
2328 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002329 * Broadcast Action: Sent to the system intent filter verifier when an
2330 * intent filter needs to be verified. The data contains the filter data
2331 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002332 * <p class="note">
2333 * This is a protected intent that can only be sent by the system.
2334 * </p>
2335 *
2336 * @hide
2337 */
2338 @SystemApi
2339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2340 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2341
2342 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002343 * Broadcast Action: Resources for a set of packages (which were
2344 * previously unavailable) are currently
2345 * available since the media on which they exist is available.
2346 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2347 * list of packages whose availability changed.
2348 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2349 * list of uids of packages whose availability changed.
2350 * Note that the
2351 * packages in this list do <em>not</em> receive this broadcast.
2352 * The specified set of packages are now available on the system.
2353 * <p>Includes the following extras:
2354 * <ul>
2355 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2356 * whose resources(were previously unavailable) are currently available.
2357 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2358 * packages whose resources(were previously unavailable)
2359 * are currently available.
2360 * </ul>
2361 *
2362 * <p class="note">This is a protected intent that can only be sent
2363 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002364 */
2365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002366 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2367 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002368
2369 /**
2370 * Broadcast Action: Resources for a set of packages are currently
2371 * unavailable since the media on which they exist is unavailable.
2372 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2373 * list of packages whose availability changed.
2374 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2375 * list of uids of packages whose availability changed.
2376 * The specified set of packages can no longer be
2377 * launched and are practically unavailable on the system.
2378 * <p>Inclues the following extras:
2379 * <ul>
2380 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2381 * whose resources are no longer available.
2382 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2383 * whose resources are no longer available.
2384 * </ul>
2385 *
2386 * <p class="note">This is a protected intent that can only be sent
2387 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002388 */
2389 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002390 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002391 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002392
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002393 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002394 * Broadcast Action: preferred activities have changed *explicitly*.
2395 *
2396 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2397 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2398 * be sent.
2399 *
2400 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2401 *
2402 * @hide
2403 */
2404 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2405 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2406 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2407
2408
2409 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002410 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002411 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002412 * This should <em>only</em> be used to determine when the wallpaper
2413 * has changed to show the new wallpaper to the user. You should certainly
2414 * never, in response to this, change the wallpaper or other attributes of
2415 * it such as the suggested size. That would be crazy, right? You'd cause
2416 * all kinds of loops, especially if other apps are doing similar things,
2417 * right? Of course. So please don't do this.
2418 *
2419 * @deprecated Modern applications should use
2420 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2421 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2422 * shown behind their UI, rather than watching for this broadcast and
2423 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002424 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002425 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002426 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2427 /**
2428 * Broadcast Action: The current device {@link android.content.res.Configuration}
2429 * (orientation, locale, etc) has changed. When such a change happens, the
2430 * UIs (view hierarchy) will need to be rebuilt based on this new
2431 * information; for the most part, applications don't need to worry about
2432 * this, because the system will take care of stopping and restarting the
2433 * application to make sure it sees the new changes. Some system code that
2434 * can not be restarted will need to watch for this action and handle it
2435 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002436 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002437 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002438 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002439 * in manifests, only by explicitly registering for it with
2440 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2441 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002442 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002443 * <p class="note">This is a protected intent that can only be sent
2444 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 *
2446 * @see android.content.res.Configuration
2447 */
2448 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2449 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002450
2451 /**
2452 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2453 * such that the device may be eligible for the installation of additional configuration splits.
2454 * Configuration properties that can trigger this broadcast include locale and display density.
2455 *
2456 * <p class="note">
2457 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2458 * components declared in manifests. However, the receiver <em>must</em> hold the
2459 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2460 *
2461 * <p class="note">
2462 * This is a protected intent that can only be sent by the system.
2463 *
2464 * @hide
2465 */
2466 @SystemApi
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2469 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002470 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002471 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002472 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002473 * <p class="note">This is a protected intent that can only be sent
2474 * by the system.
2475 */
2476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2477 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2478 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002479 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2480 * charging state, level, and other information about the battery.
2481 * See {@link android.os.BatteryManager} for documentation on the
2482 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002483 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002484 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002485 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002486 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002487 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002488 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2489 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2490 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2491 * broadcasts that are sent and can be received through manifest
2492 * receivers.
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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002499
2500
2501 /**
2502 * Broadcast Action: Sent when the current battery level changes.
2503 *
2504 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2505 * instances representing individual battery level changes with associated
2506 * extras from {@link #ACTION_BATTERY_CHANGED}.
2507 *
2508 * <p class="note">
2509 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2510 *
2511 * @hide
2512 */
2513 @SystemApi
2514 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2515 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002516 /**
2517 * Broadcast Action: Indicates low battery condition on the device.
2518 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002519 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002520 * <p class="note">This is a protected intent that can only be sent
2521 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002522 */
2523 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2524 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2525 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002526 * Broadcast Action: Indicates the battery is now okay after being low.
2527 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2528 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002529 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002530 * <p class="note">This is a protected intent that can only be sent
2531 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002532 */
2533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2534 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2535 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002536 * Broadcast Action: External power has been connected to the device.
2537 * This is intended for applications that wish to register specifically to this notification.
2538 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2539 * stay active to receive this notification. This action can be used to implement actions
2540 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002541 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002542 * <p class="note">This is a protected intent that can only be sent
2543 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002546 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002547 /**
2548 * Broadcast Action: External power has been removed from the device.
2549 * This is intended for applications that wish to register specifically to this notification.
2550 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2551 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002552 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002553 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002554 * <p class="note">This is a protected intent that can only be sent
2555 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002556 */
2557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002558 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002559 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002560 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002561 * Broadcast Action: Device is shutting down.
2562 * This is broadcast when the device is being shut down (completely turned
2563 * off, not sleeping). Once the broadcast is complete, the final shutdown
2564 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002565 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002566 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2567 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2568 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002569 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002570 * <p class="note">This is a protected intent that can only be sent
2571 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002572 * <p>May include the following extras:
2573 * <ul>
2574 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2575 * shutdown is only for userspace processes. If not set, assumed to be false.
2576 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002577 */
2578 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002579 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002580 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002581 * Activity Action: Start this activity to request system shutdown.
2582 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002583 * to request confirmation from the user before shutting down. The optional boolean
2584 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2585 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002586 *
2587 * <p class="note">This is a protected intent that can only be sent
2588 * by the system.
2589 *
2590 * {@hide}
2591 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002592 public static final String ACTION_REQUEST_SHUTDOWN
2593 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002594 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002595 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002596 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002597 * <p class="note">
2598 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002599 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002600 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2601 * or above, this broadcast will no longer be delivered to any
2602 * {@link BroadcastReceiver} defined in your manifest. Instead,
2603 * apps are strongly encouraged to use the improved
2604 * {@link Context#getCacheDir()} behavior so the system can
2605 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002606 */
2607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002608 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002609 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2610 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002611 * Broadcast Action: Indicates low storage space condition on the device no
2612 * longer exists
2613 * <p class="note">
2614 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002615 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002616 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2617 * or above, this broadcast will no longer be delivered to any
2618 * {@link BroadcastReceiver} defined in your manifest. Instead,
2619 * apps are strongly encouraged to use the improved
2620 * {@link Context#getCacheDir()} behavior so the system can
2621 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002622 */
2623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002624 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002625 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2626 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002627 * Broadcast Action: A sticky broadcast that indicates a storage space full
2628 * condition on the device. This is intended for activities that want to be
2629 * able to fill the data partition completely, leaving only enough free
2630 * space to prevent system-wide SQLite failures.
2631 * <p class="note">
2632 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002633 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002634 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2635 * or above, this broadcast will no longer be delivered to any
2636 * {@link BroadcastReceiver} defined in your manifest. Instead,
2637 * apps are strongly encouraged to use the improved
2638 * {@link Context#getCacheDir()} behavior so the system can
2639 * automatically free up storage when needed.
2640 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002643 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002644 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2645 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002646 * Broadcast Action: Indicates storage space full condition on the device no
2647 * longer exists.
2648 * <p class="note">
2649 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002650 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002651 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2652 * or above, this broadcast will no longer be delivered to any
2653 * {@link BroadcastReceiver} defined in your manifest. Instead,
2654 * apps are strongly encouraged to use the improved
2655 * {@link Context#getCacheDir()} behavior so the system can
2656 * automatically free up storage when needed.
2657 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002658 */
2659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002660 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002661 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2662 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002663 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2664 * and package management should be started.
2665 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2666 * notification.
2667 */
2668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2669 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2670 /**
2671 * Broadcast Action: The device has entered USB Mass Storage mode.
2672 * This is used mainly for the USB Settings panel.
2673 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2674 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002675 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002676 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002677 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2680
2681 /**
2682 * Broadcast Action: The device has exited USB Mass Storage mode.
2683 * This is used mainly for the USB Settings panel.
2684 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2685 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002686 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002687 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002688 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002690 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2691
2692 /**
2693 * Broadcast Action: External media has been removed.
2694 * The path to the mount point for the removed media is contained in the Intent.mData field.
2695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2697 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2698
2699 /**
2700 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002701 * 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 -07002702 */
2703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2704 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2705
2706 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002707 * Broadcast Action: External media is present, and being disk-checked
2708 * 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 -08002709 */
2710 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2711 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2712
2713 /**
2714 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2715 * 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 -08002716 */
2717 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2718 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2719
2720 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002721 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002722 * 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 -07002723 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2724 * media was mounted read only.
2725 */
2726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2727 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2728
2729 /**
2730 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002731 * 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 -07002732 */
2733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2734 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2735
2736 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002737 * Broadcast Action: External media is no longer being shared via USB mass storage.
2738 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2739 *
2740 * @hide
2741 */
2742 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2743
2744 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002745 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2746 * The path to the mount point for the removed media is contained in the Intent.mData field.
2747 */
2748 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2749 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2750
2751 /**
2752 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002753 * 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 -07002754 */
2755 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2756 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2757
2758 /**
2759 * Broadcast Action: User has expressed the desire to remove the external storage media.
2760 * Applications should close all files they have open within the mount point when they receive this intent.
2761 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2762 */
2763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2764 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2765
2766 /**
2767 * Broadcast Action: The media scanner has started scanning a directory.
2768 * The path to the directory being scanned is contained in the Intent.mData field.
2769 */
2770 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2771 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2772
2773 /**
2774 * Broadcast Action: The media scanner has finished scanning a directory.
2775 * The path to the scanned directory is contained in the Intent.mData field.
2776 */
2777 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2778 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2779
2780 /**
2781 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2782 * The path to the file is contained in the Intent.mData field.
2783 */
2784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2785 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2786
2787 /**
2788 * Broadcast Action: The "Media Button" was pressed. Includes a single
2789 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2790 * caused the broadcast.
2791 */
2792 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2793 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2794
2795 /**
2796 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2797 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2798 * caused the broadcast.
2799 */
2800 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2801 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2802
2803 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2804 // location; they are not general-purpose actions.
2805
2806 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002807 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002808 */
2809 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2810 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2811 "android.intent.action.GTALK_CONNECTED";
2812
2813 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002814 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002815 */
2816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2817 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2818 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002819
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002820 /**
2821 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002822 */
2823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2824 public static final String ACTION_INPUT_METHOD_CHANGED =
2825 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002826
2827 /**
2828 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2829 * more radios have been turned off or on. The intent will have the following extra value:</p>
2830 * <ul>
2831 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2832 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2833 * turned off</li>
2834 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002835 *
Peng Xua35b5532016-01-20 00:05:45 -08002836 * <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 -07002837 */
2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2840
2841 /**
2842 * Broadcast Action: Some content providers have parts of their namespace
2843 * where they publish new events or items that the user may be especially
2844 * interested in. For these things, they may broadcast this action when the
2845 * set of interesting items change.
2846 *
2847 * For example, GmailProvider sends this notification when the set of unread
2848 * mail in the inbox changes.
2849 *
2850 * <p>The data of the intent identifies which part of which provider
2851 * changed. When queried through the content resolver, the data URI will
2852 * return the data set in question.
2853 *
2854 * <p>The intent will have the following extra values:
2855 * <ul>
2856 * <li><em>count</em> - The number of items in the data set. This is the
2857 * same as the number of items in the cursor returned by querying the
2858 * data URI. </li>
2859 * </ul>
2860 *
2861 * This intent will be sent at boot (if the count is non-zero) and when the
2862 * data set changes. It is possible for the data set to change without the
2863 * count changing (for example, if a new unread message arrives in the same
2864 * sync operation in which a message is archived). The phone should still
2865 * ring/vibrate/etc as normal in this case.
2866 */
2867 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2868 public static final String ACTION_PROVIDER_CHANGED =
2869 "android.intent.action.PROVIDER_CHANGED";
2870
2871 /**
2872 * Broadcast Action: Wired Headset plugged in or unplugged.
2873 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002874 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2875 * and documentation.
2876 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002877 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002878 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002879 */
2880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002881 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002882
2883 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002884 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2885 * <ul>
2886 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2887 * </ul>
2888 *
2889 * <p class="note">This is a protected intent that can only be sent
2890 * by the system.
2891 *
2892 * @hide
2893 */
2894 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2895 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2896 = "android.intent.action.ADVANCED_SETTINGS";
2897
2898 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002899 * Broadcast Action: Sent after application restrictions are changed.
2900 *
2901 * <p class="note">This is a protected intent that can only be sent
2902 * by the system.</p>
2903 */
2904 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2905 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2906 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2907
2908 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002909 * Broadcast Action: An outgoing call is about to be placed.
2910 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002911 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002912 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002913 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002914 * the phone number originally intended to be dialed.</li>
2915 * </ul>
2916 * <p>Once the broadcast is finished, the resultData is used as the actual
2917 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002918 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002919 * outgoing call in turn: for example, a parental control application
2920 * might verify that the user is authorized to place the call at that
2921 * time, then a number-rewriting application might add an area code if
2922 * one was not specified.</p>
2923 * <p>For consistency, any receiver whose purpose is to prohibit phone
2924 * calls should have a priority of 0, to ensure it will see the final
2925 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002926 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002927 * should have a positive priority.
2928 * Negative priorities are reserved for the system for this broadcast;
2929 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002930 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2931 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002932 * <p>Emergency calls cannot be intercepted using this mechanism, and
2933 * other calls cannot be modified to call emergency numbers using this
2934 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002935 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2936 * call to use their own service instead. Those apps should first prevent
2937 * the call from being placed by setting resultData to <code>null</code>
2938 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002939 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002940 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2941 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002942 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002943 * <p class="note">This is a protected intent that can only be sent
2944 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002945 */
2946 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2947 public static final String ACTION_NEW_OUTGOING_CALL =
2948 "android.intent.action.NEW_OUTGOING_CALL";
2949
2950 /**
2951 * Broadcast Action: Have the device reboot. This is only for use by
2952 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002953 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002954 * <p class="note">This is a protected intent that can only be sent
2955 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002956 */
2957 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2958 public static final String ACTION_REBOOT =
2959 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002960
Wei Huang97ecc9c2009-05-11 17:44:20 -07002961 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002962 * Broadcast Action: A sticky broadcast for changes in the physical
2963 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002964 *
2965 * <p>The intent will have the following extra values:
2966 * <ul>
2967 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002968 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002969 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002970 * <p>This is intended for monitoring the current physical dock state.
2971 * See {@link android.app.UiModeManager} for the normal API dealing with
2972 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002973 */
2974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2975 public static final String ACTION_DOCK_EVENT =
2976 "android.intent.action.DOCK_EVENT";
2977
2978 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002979 * Broadcast Action: A broadcast when idle maintenance can be started.
2980 * This means that the user is not interacting with the device and is
2981 * not expected to do so soon. Typical use of the idle maintenance is
2982 * to perform somehow expensive tasks that can be postponed at a moment
2983 * when they will not degrade user experience.
2984 * <p>
2985 * <p class="note">In order to keep the device responsive in case of an
2986 * unexpected user interaction, implementations of a maintenance task
2987 * should be interruptible. In such a scenario a broadcast with action
2988 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2989 * should not do the maintenance work in
2990 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2991 * maintenance service by {@link Context#startService(Intent)}. Also
2992 * you should hold a wake lock while your maintenance service is running
2993 * to prevent the device going to sleep.
2994 * </p>
2995 * <p>
2996 * <p class="note">This is a protected intent that can only be sent by
2997 * the system.
2998 * </p>
2999 *
3000 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003001 *
3002 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003003 */
3004 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3005 public static final String ACTION_IDLE_MAINTENANCE_START =
3006 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3007
3008 /**
3009 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3010 * This means that the user was not interacting with the device as a result
3011 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3012 * was sent and now the user started interacting with the device. Typical
3013 * use of the idle maintenance is to perform somehow expensive tasks that
3014 * can be postponed at a moment when they will not degrade user experience.
3015 * <p>
3016 * <p class="note">In order to keep the device responsive in case of an
3017 * unexpected user interaction, implementations of a maintenance task
3018 * should be interruptible. Hence, on receiving a broadcast with this
3019 * action, the maintenance task should be interrupted as soon as possible.
3020 * In other words, you should not do the maintenance work in
3021 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3022 * maintenance service that was started on receiving of
3023 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3024 * lock you acquired when your maintenance service started.
3025 * </p>
3026 * <p class="note">This is a protected intent that can only be sent
3027 * by the system.
3028 *
3029 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003030 *
3031 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003032 */
3033 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3034 public static final String ACTION_IDLE_MAINTENANCE_END =
3035 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3036
3037 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003038 * Broadcast Action: a remote intent is to be broadcasted.
3039 *
3040 * A remote intent is used for remote RPC between devices. The remote intent
3041 * is serialized and sent from one device to another device. The receiving
3042 * device parses the remote intent and broadcasts it. Note that anyone can
3043 * broadcast a remote intent. However, if the intent receiver of the remote intent
3044 * does not trust intent broadcasts from arbitrary intent senders, it should require
3045 * the sender to hold certain permissions so only trusted sender's broadcast will be
3046 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003047 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003048 */
3049 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003050 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003051
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003052 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003053 * Broadcast Action: This is broadcast once when the user is booting after a
3054 * system update. It can be used to perform cleanup or upgrades after a
3055 * system update.
3056 * <p>
3057 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3058 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3059 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3060 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003061 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003062 * @hide
3063 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003064 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003065 public static final String ACTION_PRE_BOOT_COMPLETED =
3066 "android.intent.action.PRE_BOOT_COMPLETED";
3067
Amith Yamasani13593602012-03-22 16:16:17 -07003068 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003069 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003070 * on restricted users. The broadcast intent contains an extra
3071 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3072 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3073 * String[] depending on the restriction type.<p/>
3074 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003075 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3076 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3077 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003078 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3079 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003080 * @see RestrictionEntry
3081 */
3082 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3083 "android.intent.action.GET_RESTRICTION_ENTRIES";
3084
3085 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003086 * Sent the first time a user is starting, to allow system apps to
3087 * perform one time initialization. (This will not be seen by third
3088 * party applications because a newly initialized user does not have any
3089 * third party applications installed for it.) This is sent early in
3090 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003091 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3092 * broadcast, since it is part of a visible user interaction; be as quick
3093 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003094 */
3095 public static final String ACTION_USER_INITIALIZE =
3096 "android.intent.action.USER_INITIALIZE";
3097
3098 /**
3099 * Sent when a user switch is happening, causing the process's user to be
3100 * brought to the foreground. This is only sent to receivers registered
3101 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3102 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003103 * foreground. This is sent as a foreground
3104 * broadcast, since it is part of a visible user interaction; be as quick
3105 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003106 */
3107 public static final String ACTION_USER_FOREGROUND =
3108 "android.intent.action.USER_FOREGROUND";
3109
3110 /**
3111 * Sent when a user switch is happening, causing the process's user to be
3112 * sent to the background. This is only sent to receivers registered
3113 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3114 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003115 * background. This is sent as a foreground
3116 * broadcast, since it is part of a visible user interaction; be as quick
3117 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003118 */
3119 public static final String ACTION_USER_BACKGROUND =
3120 "android.intent.action.USER_BACKGROUND";
3121
3122 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003123 * Broadcast sent to the system when a user is added. Carries an extra
3124 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3125 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003126 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003127 * @hide
3128 */
3129 public static final String ACTION_USER_ADDED =
3130 "android.intent.action.USER_ADDED";
3131
3132 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003133 * Broadcast sent by the system when a user is started. Carries an extra
3134 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003135 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003136 * that has been started. This is sent as a foreground
3137 * broadcast, since it is part of a visible user interaction; be as quick
3138 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003139 * @hide
3140 */
3141 public static final String ACTION_USER_STARTED =
3142 "android.intent.action.USER_STARTED";
3143
3144 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003145 * Broadcast sent when a user is in the process of starting. Carries an extra
3146 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3147 * sent to registered receivers, not manifest receivers. It is sent to all
3148 * users (including the one that is being started). You must hold
3149 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3150 * this broadcast. This is sent as a background broadcast, since
3151 * its result is not part of the primary UX flow; to safely keep track of
3152 * started/stopped state of a user you can use this in conjunction with
3153 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3154 * other user state broadcasts since those are foreground broadcasts so can
3155 * execute in a different order.
3156 * @hide
3157 */
3158 public static final String ACTION_USER_STARTING =
3159 "android.intent.action.USER_STARTING";
3160
3161 /**
3162 * Broadcast sent when a user is going to be stopped. Carries an extra
3163 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3164 * sent to registered receivers, not manifest receivers. It is sent to all
3165 * users (including the one that is being stopped). You must hold
3166 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3167 * this broadcast. The user will not stop until all receivers have
3168 * handled the broadcast. This is sent as a background broadcast, since
3169 * its result is not part of the primary UX flow; to safely keep track of
3170 * started/stopped state of a user you can use this in conjunction with
3171 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3172 * other user state broadcasts since those are foreground broadcasts so can
3173 * execute in a different order.
3174 * @hide
3175 */
3176 public static final String ACTION_USER_STOPPING =
3177 "android.intent.action.USER_STOPPING";
3178
3179 /**
3180 * Broadcast sent to the system when a user is stopped. Carries an extra
3181 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3182 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3183 * specific package. This is only sent to registered receivers, not manifest
3184 * receivers. It is sent to all running users <em>except</em> the one that
3185 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003186 * @hide
3187 */
3188 public static final String ACTION_USER_STOPPED =
3189 "android.intent.action.USER_STOPPED";
3190
3191 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003192 * 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 -07003193 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003194 * one that has been removed. The user will not be completely removed until all receivers have
3195 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003196 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003197 * @hide
3198 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003199 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003200 public static final String ACTION_USER_REMOVED =
3201 "android.intent.action.USER_REMOVED";
3202
3203 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003204 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003205 * the userHandle of the user to become the current one. This is only sent to
3206 * registered receivers, not manifest receivers. It is sent to all running users.
3207 * You must hold
3208 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003209 * @hide
3210 */
3211 public static final String ACTION_USER_SWITCHED =
3212 "android.intent.action.USER_SWITCHED";
3213
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003214 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003215 * Broadcast Action: Sent when the credential-encrypted private storage has
3216 * become unlocked for the target user. This is only sent to registered
3217 * receivers, not manifest receivers.
3218 */
3219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3220 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3221
3222 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003223 * Broadcast sent to the system when a user's information changes. Carries an extra
3224 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003225 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003226 * @hide
3227 */
3228 public static final String ACTION_USER_INFO_CHANGED =
3229 "android.intent.action.USER_INFO_CHANGED";
3230
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003231 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003232 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3233 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003234 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3235 * that need to display merged content across both primary and managed profiles need to
3236 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003237 * not manifest receivers.
3238 */
3239 public static final String ACTION_MANAGED_PROFILE_ADDED =
3240 "android.intent.action.MANAGED_PROFILE_ADDED";
3241
3242 /**
3243 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003244 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3245 * Only applications (for example Launchers) that need to display merged content across both
3246 * primary and managed profiles need to worry about this broadcast. This is only sent to
3247 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003248 */
3249 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3250 "android.intent.action.MANAGED_PROFILE_REMOVED";
3251
3252 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003253 * Broadcast sent to the primary user when the credential-encrypted private storage for
3254 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3255 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3256 * Launchers) that need to display merged content across both primary and managed profiles
3257 * need to worry about this broadcast. This is only sent to registered receivers,
3258 * not manifest receivers.
3259 */
3260 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3261 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3262
3263 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003264 * Broadcast sent to the primary user when an associated managed profile has become available.
3265 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003266 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3267 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3268 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003269 */
Rubin Xue95057a2016-04-01 16:49:25 +01003270 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3271 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3272
3273 /**
3274 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3275 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3276 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3277 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3278 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3279 */
3280 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3281 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003282
3283 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003284 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3285 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3286 * the device was locked or unlocked.
3287 *
3288 * This is only sent to registered receivers.
3289 *
3290 * @hide
3291 */
3292 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3293 "android.intent.action.DEVICE_LOCKED_CHANGED";
3294
3295 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003296 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3297 */
3298 public static final String ACTION_QUICK_CLOCK =
3299 "android.intent.action.QUICK_CLOCK";
3300
Michael Wright0087a142013-02-05 16:29:39 -08003301 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003302 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003303 * @hide
3304 */
3305 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003306 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003307
Justin Kohd378ad72013-04-01 12:18:26 -07003308 /**
3309 * Broadcast Action: A global button was pressed. Includes a single
3310 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3311 * caused the broadcast.
3312 * @hide
3313 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003314 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003315 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3316
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003317 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003318 * Broadcast Action: Sent when media resource is granted.
3319 * <p>
3320 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3321 * granted.
3322 * </p>
3323 * <p class="note">
3324 * This is a protected intent that can only be sent by the system.
3325 * </p>
3326 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003327 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003328 * </p>
3329 *
3330 * @hide
3331 */
3332 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3333 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3334
3335 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003336 * Broadcast Action: An overlay package has changed. The data contains the
3337 * name of the overlay package which has changed. This is broadcast on all
3338 * changes to the OverlayInfo returned by {@link
3339 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3340 * most common change is a state change that will change whether the
3341 * overlay is enabled or not.
3342 * @hide
3343 */
3344 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3345
3346 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003347 * Activity Action: Allow the user to select and return one or more existing
3348 * documents. When invoked, the system will display the various
3349 * {@link DocumentsProvider} instances installed on the device, letting the
3350 * user interactively navigate through them. These documents include local
3351 * media, such as photos and video, and documents provided by installed
3352 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003353 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003354 * Each document is represented as a {@code content://} URI backed by a
3355 * {@link DocumentsProvider}, which can be opened as a stream with
3356 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3357 * {@link android.provider.DocumentsContract.Document} metadata.
3358 * <p>
3359 * All selected documents are returned to the calling application with
3360 * persistable read and write permission grants. If you want to maintain
3361 * access to the documents across device reboots, you need to explicitly
3362 * take the persistable permissions using
3363 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3364 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003365 * Callers must indicate the acceptable document MIME types through
3366 * {@link #setType(String)}. For example, to select photos, use
3367 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3368 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3369 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003370 * <p>
3371 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003372 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3373 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003374 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003375 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3376 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003377 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003378 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003379 * Callers can set a document URI through
3380 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3381 * location of documents navigator. System will do its best to launch the
3382 * navigator in the specified document if it's a folder, or the folder that
3383 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003384 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003385 * Output: The URI of the item that was picked, returned in
3386 * {@link #getData()}. This must be a {@code content://} URI so that any
3387 * receiver can access it. If multiple documents were selected, they are
3388 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003389 *
3390 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003391 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003392 * @see #ACTION_CREATE_DOCUMENT
3393 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003394 */
3395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3396 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3397
3398 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003399 * Activity Action: Allow the user to create a new document. When invoked,
3400 * the system will display the various {@link DocumentsProvider} instances
3401 * installed on the device, letting the user navigate through them. The
3402 * returned document may be a newly created document with no content, or it
3403 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003404 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003405 * Each document is represented as a {@code content://} URI backed by a
3406 * {@link DocumentsProvider}, which can be opened as a stream with
3407 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3408 * {@link android.provider.DocumentsContract.Document} metadata.
3409 * <p>
3410 * Callers must indicate the concrete MIME type of the document being
3411 * created by setting {@link #setType(String)}. This MIME type cannot be
3412 * changed after the document is created.
3413 * <p>
3414 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3415 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003416 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003417 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3418 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003419 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003420 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003421 * Callers can set a document URI through
3422 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3423 * location of documents navigator. System will do its best to launch the
3424 * navigator in the specified document if it's a folder, or the folder that
3425 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003426 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003427 * Output: The URI of the item that was created. This must be a
3428 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003429 *
3430 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003431 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003432 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003433 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003434 */
3435 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3436 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3437
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003438 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003439 * Activity Action: Allow the user to pick a directory subtree. When
3440 * invoked, the system will display the various {@link DocumentsProvider}
3441 * instances installed on the device, letting the user navigate through
3442 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003443 * <p>
3444 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003445 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3446 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3447 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003448 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003449 * Callers can set a document URI through
3450 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3451 * location of documents navigator. System will do its best to launch the
3452 * navigator in the specified document if it's a folder, or the folder that
3453 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003454 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003455 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003456 *
3457 * @see DocumentsContract
3458 */
3459 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003460 public static final String
3461 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003462
Felipe Lemec7b1f892016-01-15 15:02:31 -08003463 /**
Peng Xua35b5532016-01-20 00:05:45 -08003464 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3465 * exisiting sensor being disconnected.
3466 *
3467 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3468 *
3469 * {@hide}
3470 */
3471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3472 public static final String
3473 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3474
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003475 /**
Sam Line707f832017-04-13 17:00:55 -07003476 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003477 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003478 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003479 */
3480 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003481 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003482 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3483
Christopher Tate6597e342015-02-17 12:15:25 -08003484 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003485 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3486 * is about to be performed.
3487 * @hide
3488 */
3489 @SystemApi
3490 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3491 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3492 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3493
3494 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003495 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3496 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3497 *
3498 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3499 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003500 * @hide
3501 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003502 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003503 public static final String EXTRA_FORCE_MASTER_CLEAR =
3504 "android.intent.extra.FORCE_MASTER_CLEAR";
3505
3506 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003507 * A broadcast action to trigger a factory reset.
3508 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003509 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3510 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003511 *
3512 * <p>Not for use by third-party applications.
3513 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003514 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003515 *
3516 * {@hide}
3517 */
3518 @SystemApi
3519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3520 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3521
3522 /**
3523 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3524 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3525 *
3526 * <p>Not for use by third-party applications.
3527 *
3528 * @hide
3529 */
3530 @SystemApi
3531 public static final String EXTRA_FORCE_FACTORY_RESET =
3532 "android.intent.extra.FORCE_FACTORY_RESET";
3533
3534 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003535 * Broadcast action: report that a settings element is being restored from backup. The intent
3536 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3537 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3538 * is the value of that settings entry prior to the restore operation, and
3539 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3540 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3541 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003542 *
3543 * <p>This broadcast is sent only for settings provider entries known to require special handling
3544 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3545 * the provider's backup agent implementation.
3546 *
3547 * @see #EXTRA_SETTING_NAME
3548 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3549 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003550 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003551 * {@hide}
3552 */
3553 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3554
3555 /** {@hide} */
3556 public static final String EXTRA_SETTING_NAME = "setting_name";
3557 /** {@hide} */
3558 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3559 /** {@hide} */
3560 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003561 /** {@hide} */
3562 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003563
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003564 /**
3565 * Activity Action: Process a piece of text.
3566 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3567 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3568 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3569 */
3570 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3571 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003572
3573 /**
3574 * Broadcast Action: The sim card state has changed.
3575 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3576 * because TelephonyIntents is an internal class.
3577 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003578 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3579 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003580 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003581 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003582 @SystemApi
3583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3584 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3585
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003586 /**
fionaxu90fee272017-03-31 12:45:12 -07003587 * Broadcast Action: indicate that the phone service state has changed.
3588 * The intent will have the following extra values:</p>
3589 * <p>
3590 * @see #EXTRA_VOICE_REG_STATE
3591 * @see #EXTRA_DATA_REG_STATE
3592 * @see #EXTRA_VOICE_ROAMING_TYPE
3593 * @see #EXTRA_DATA_ROAMING_TYPE
3594 * @see #EXTRA_OPERATOR_ALPHA_LONG
3595 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3596 * @see #EXTRA_OPERATOR_NUMERIC
3597 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3598 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3599 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3600 * @see #EXTRA_MANUAL
3601 * @see #EXTRA_VOICE_RADIO_TECH
3602 * @see #EXTRA_DATA_RADIO_TECH
3603 * @see #EXTRA_CSS_INDICATOR
3604 * @see #EXTRA_NETWORK_ID
3605 * @see #EXTRA_SYSTEM_ID
3606 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3607 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3608 * @see #EXTRA_EMERGENCY_ONLY
3609 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3610 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3611 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3612 *
3613 * <p class="note">
3614 * Requires the READ_PHONE_STATE permission.
3615 *
3616 * <p class="note">This is a protected intent that can only be sent by the system.
3617 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003618 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003619 */
3620 @Deprecated
3621 @SystemApi
3622 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3623 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3624
3625 /**
3626 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3627 * state.
3628 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3629 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3630 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3631 * @see android.telephony.ServiceState#STATE_POWER_OFF
3632 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003633 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003634 */
3635 @Deprecated
3636 @SystemApi
3637 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3638
3639 /**
3640 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3641 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3642 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3643 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3644 * @see android.telephony.ServiceState#STATE_POWER_OFF
3645 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003646 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003647 */
3648 @Deprecated
3649 @SystemApi
3650 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3651
3652 /**
3653 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3654 * type.
3655 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003656 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003657 */
3658 @Deprecated
3659 @SystemApi
3660 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3661
3662 /**
3663 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3664 * type.
3665 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003666 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003667 */
3668 @Deprecated
3669 @SystemApi
3670 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3671
3672 /**
3673 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3674 * registered voice operator name in long alphanumeric format.
3675 * {@code null} if the operator name is not known or unregistered.
3676 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003677 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003678 */
3679 @Deprecated
3680 @SystemApi
3681 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3682
3683 /**
3684 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3685 * registered voice operator name in short alphanumeric format.
3686 * {@code null} if the operator name is not known or unregistered.
3687 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003688 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003689 */
3690 @Deprecated
3691 @SystemApi
3692 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3693
3694 /**
3695 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3696 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3697 * network.
3698 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003699 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003700 */
3701 @Deprecated
3702 @SystemApi
3703 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3704
3705 /**
3706 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3707 * registered data operator name in long alphanumeric format.
3708 * {@code null} if the operator name is not known or unregistered.
3709 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003710 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003711 */
3712 @Deprecated
3713 @SystemApi
3714 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3715
3716 /**
3717 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3718 * registered data operator name in short alphanumeric format.
3719 * {@code null} if the operator name is not known or unregistered.
3720 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003721 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003722 */
3723 @Deprecated
3724 @SystemApi
3725 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3726
3727 /**
3728 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3729 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3730 * data operator.
3731 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003732 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003733 */
3734 @Deprecated
3735 @SystemApi
3736 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3737
3738 /**
3739 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3740 * network selection mode is manual.
3741 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3742 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003743 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003744 */
3745 @Deprecated
3746 @SystemApi
3747 public static final String EXTRA_MANUAL = "manual";
3748
3749 /**
3750 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3751 * radio technology.
3752 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003753 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003754 */
3755 @Deprecated
3756 @SystemApi
3757 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3758
3759 /**
3760 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3761 * radio technology.
3762 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003763 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003764 */
3765 @Deprecated
3766 @SystemApi
3767 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3768
3769 /**
3770 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3771 * support on CDMA network.
3772 * Will be {@code true} if support, {@code false} otherwise.
3773 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003774 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003775 */
3776 @Deprecated
3777 @SystemApi
3778 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3779
3780 /**
3781 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3782 * id. {@code Integer.MAX_VALUE} if unknown.
3783 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003784 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003785 */
3786 @Deprecated
3787 @SystemApi
3788 public static final String EXTRA_NETWORK_ID = "networkId";
3789
3790 /**
3791 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3792 * {@code Integer.MAX_VALUE} if unknown.
3793 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003794 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003795 */
3796 @Deprecated
3797 @SystemApi
3798 public static final String EXTRA_SYSTEM_ID = "systemId";
3799
3800 /**
3801 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3802 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3803 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003804 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003805 */
3806 @Deprecated
3807 @SystemApi
3808 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3809
3810 /**
3811 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3812 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3813 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003814 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003815 */
3816 @Deprecated
3817 @SystemApi
3818 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3819
3820 /**
3821 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3822 * only mode.
3823 * {@code true} if in emergency only mode, {@code false} otherwise.
3824 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003825 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003826 */
3827 @Deprecated
3828 @SystemApi
3829 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3830
3831 /**
3832 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3833 * registration state is roaming.
3834 * {@code true} if registration indicates roaming, {@code false} otherwise
3835 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003836 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003837 */
3838 @Deprecated
3839 @SystemApi
3840 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3841 "isDataRoamingFromRegistration";
3842
3843 /**
3844 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3845 * aggregation is in use.
3846 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3847 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003848 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003849 */
3850 @Deprecated
3851 @SystemApi
3852 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3853
3854 /**
3855 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3856 * is reduced from the rsrp threshold while calculating signal strength level.
3857 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003858 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003859 */
3860 @Deprecated
3861 @SystemApi
3862 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3863
3864 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003865 * The name of the extra used to define the text to be processed, as a
3866 * CharSequence. Note that this may be a styled CharSequence, so you must use
3867 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003868 */
3869 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3870 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003871 * 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 +00003872 */
3873 public static final String EXTRA_PROCESS_TEXT_READONLY =
3874 "android.intent.extra.PROCESS_TEXT_READONLY";
3875
Bryce Leebc58f592015-09-25 16:43:01 -07003876 /**
3877 * Broadcast action: reports when a new thermal event has been reached. When the device
3878 * is reaching its maximum temperatue, the thermal level reported
3879 * {@hide}
3880 */
3881 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3882 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3883
3884 /** {@hide} */
3885 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3886
3887 /**
3888 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003889 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003890 * {@hide}
3891 */
3892 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3893
3894 /**
3895 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003896 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003897 * {@hide}
3898 */
3899 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3900
3901 /**
3902 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003903 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003904 * {@hide}
3905 */
3906 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3907
3908
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003909 // ---------------------------------------------------------------------
3910 // ---------------------------------------------------------------------
3911 // Standard intent categories (see addCategory()).
3912
3913 /**
3914 * Set if the activity should be an option for the default action
3915 * (center press) to perform on a piece of data. Setting this will
3916 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003917 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003918 * Intent when initiating an action -- it is for use in intent filters
3919 * specified in packages.
3920 */
3921 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3922 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3923 /**
3924 * Activities that can be safely invoked from a browser must support this
3925 * category. For example, if the user is viewing a web page or an e-mail
3926 * and clicks on a link in the text, the Intent generated execute that
3927 * link will require the BROWSABLE category, so that only activities
3928 * supporting this category will be considered as possible actions. By
3929 * supporting this category, you are promising that there is nothing
3930 * damaging (without user intervention) that can happen by invoking any
3931 * matching Intent.
3932 */
3933 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3934 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3935 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003936 * Categories for activities that can participate in voice interaction.
3937 * An activity that supports this category must be prepared to run with
3938 * no UI shown at all (though in some case it may have a UI shown), and
3939 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3940 */
3941 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3942 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3943 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003944 * Set if the activity should be considered as an alternative action to
3945 * the data the user is currently viewing. See also
3946 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3947 * applies to the selection in a list of items.
3948 *
3949 * <p>Supporting this category means that you would like your activity to be
3950 * displayed in the set of alternative things the user can do, usually as
3951 * part of the current activity's options menu. You will usually want to
3952 * include a specific label in the &lt;intent-filter&gt; of this action
3953 * describing to the user what it does.
3954 *
3955 * <p>The action of IntentFilter with this category is important in that it
3956 * describes the specific action the target will perform. This generally
3957 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3958 * a specific name such as "com.android.camera.action.CROP. Only one
3959 * alternative of any particular action will be shown to the user, so using
3960 * a specific action like this makes sure that your alternative will be
3961 * displayed while also allowing other applications to provide their own
3962 * overrides of that particular action.
3963 */
3964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3965 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3966 /**
3967 * Set if the activity should be considered as an alternative selection
3968 * action to the data the user has currently selected. This is like
3969 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3970 * of items from which the user can select, giving them alternatives to the
3971 * default action that will be performed on it.
3972 */
3973 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3974 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3975 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003976 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003977 */
3978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3979 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3980 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003981 * Should be displayed in the top-level launcher.
3982 */
3983 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3984 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3985 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003986 * Indicates an activity optimized for Leanback mode, and that should
3987 * be displayed in the Leanback launcher.
3988 */
3989 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3990 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3991 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08003992 * Indicates the preferred entry-point activity when an application is launched from a Car
3993 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
3994 * fallback, or exclude the application entirely.
3995 * @hide
3996 */
3997 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3998 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
3999 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004000 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4001 * @hide
4002 */
4003 @SystemApi
4004 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4005 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004006 * Provides information about the package it is in; typically used if
4007 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4008 * a front-door to the user without having to be shown in the all apps list.
4009 */
4010 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4011 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4012 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004013 * This is the home activity, that is the first activity that is displayed
4014 * when the device boots.
4015 */
4016 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4017 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4018 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004019 * This is the home activity that is displayed when the device is finished setting up and ready
4020 * for use.
4021 * @hide
4022 */
4023 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4024 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4025 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004026 * This is the setup wizard activity, that is the first activity that is displayed
4027 * when the user sets up the device for the first time.
4028 * @hide
4029 */
4030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4031 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4032 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004033 * This is the home activity, that is the activity that serves as the launcher app
4034 * from there the user can start other apps. Often components with lower/higher
4035 * priority intent filters handle the home intent, for example SetupWizard, to
4036 * setup the device and we need to be able to distinguish the home app from these
4037 * setup helpers.
4038 * @hide
4039 */
4040 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4041 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004043 * This activity is a preference panel.
4044 */
4045 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4046 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4047 /**
4048 * This activity is a development preference panel.
4049 */
4050 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4051 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4052 /**
4053 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004054 */
4055 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4056 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4057 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004058 * This activity allows the user to browse and download new applications.
4059 */
4060 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4061 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4062 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004063 * This activity may be exercised by the monkey or other automated test tools.
4064 */
4065 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4066 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4067 /**
4068 * To be used as a test (not part of the normal user experience).
4069 */
4070 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4071 /**
4072 * To be used as a unit test (run through the Test Harness).
4073 */
4074 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4075 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004076 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004077 * experience).
4078 */
4079 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004080
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004081 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004082 * Used to indicate that an intent only wants URIs that can be opened with
4083 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4084 * must support at least the columns defined in {@link OpenableColumns} when
4085 * queried.
4086 *
4087 * @see #ACTION_GET_CONTENT
4088 * @see #ACTION_OPEN_DOCUMENT
4089 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004090 */
4091 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4092 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4093
4094 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004095 * Used to indicate that an intent filter can accept files which are not necessarily
4096 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4097 * at least streamable via
4098 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4099 * using one of the stream types exposed via
4100 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4101 *
4102 * @see #ACTION_SEND
4103 * @see #ACTION_SEND_MULTIPLE
4104 */
4105 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4106 public static final String CATEGORY_TYPED_OPENABLE =
4107 "android.intent.category.TYPED_OPENABLE";
4108
4109 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004110 * To be used as code under test for framework instrumentation tests.
4111 */
4112 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4113 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004114 /**
4115 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004116 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4117 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004118 */
4119 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4120 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4121 /**
4122 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004123 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4124 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004125 */
4126 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4127 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004128 /**
4129 * An activity to run when device is inserted into a analog (low end) dock.
4130 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4131 * information, see {@link android.app.UiModeManager}.
4132 */
4133 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4134 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4135
4136 /**
4137 * An activity to run when device is inserted into a digital (high end) dock.
4138 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4139 * information, see {@link android.app.UiModeManager}.
4140 */
4141 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4142 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004143
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004144 /**
4145 * Used to indicate that the activity can be used in a car environment.
4146 */
4147 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4148 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4149
Zak Cohendb6ca492017-01-26 14:09:00 -08004150 /**
4151 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4152 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4153 * information, see {@link android.app.UiModeManager}.
4154 */
4155 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4156 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004157 // ---------------------------------------------------------------------
4158 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004159 // Application launch intent categories (see addCategory()).
4160
4161 /**
4162 * Used with {@link #ACTION_MAIN} to launch the browser application.
4163 * The activity should be able to browse the Internet.
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_BROWSER = "android.intent.category.APP_BROWSER";
4172
4173 /**
4174 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4175 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004176 * <p>NOTE: This should not be used as the primary key of an Intent,
4177 * since it will not result in the app launching with the correct
4178 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004179 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004180 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004181 */
4182 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4183 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4184
4185 /**
4186 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4187 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004188 * <p>NOTE: This should not be used as the primary key of an Intent,
4189 * since it will not result in the app launching with the correct
4190 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004191 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004192 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004193 */
4194 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4195 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4196
4197 /**
4198 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4199 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004200 * <p>NOTE: This should not be used as the primary key of an Intent,
4201 * since it will not result in the app launching with the correct
4202 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004203 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004204 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004205 */
4206 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4207 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4208
4209 /**
4210 * Used with {@link #ACTION_MAIN} to launch the email application.
4211 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004212 * <p>NOTE: This should not be used as the primary key of an Intent,
4213 * since it will not result in the app launching with the correct
4214 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004215 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004216 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004217 */
4218 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4219 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4220
4221 /**
4222 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4223 * The activity should be able to view and manipulate image and video files
4224 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004225 * <p>NOTE: This should not be used as the primary key of an Intent,
4226 * since it will not result in the app launching with the correct
4227 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004228 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004229 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004230 */
4231 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4232 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4233
4234 /**
4235 * Used with {@link #ACTION_MAIN} to launch the maps application.
4236 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004237 * <p>NOTE: This should not be used as the primary key of an Intent,
4238 * since it will not result in the app launching with the correct
4239 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004240 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004241 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004242 */
4243 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4244 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4245
4246 /**
4247 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4248 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004249 * <p>NOTE: This should not be used as the primary key of an Intent,
4250 * since it will not result in the app launching with the correct
4251 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004252 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004253 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004254 */
4255 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4256 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4257
4258 /**
4259 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004260 * The activity should be able to play, browse, or manipulate music files
4261 * stored on the device.
4262 * <p>NOTE: This should not be used as the primary key of an Intent,
4263 * since it will not result in the app launching with the correct
4264 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004265 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004266 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004267 */
4268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4269 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4270
4271 // ---------------------------------------------------------------------
4272 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004273 // Standard extra data keys.
4274
4275 /**
4276 * The initial data to place in a newly created record. Use with
4277 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4278 * fields as would be given to the underlying ContentProvider.insert()
4279 * call.
4280 */
4281 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4282
4283 /**
4284 * A constant CharSequence that is associated with the Intent, used with
4285 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4286 * this may be a styled CharSequence, so you must use
4287 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4288 * retrieve it.
4289 */
4290 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4291
4292 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004293 * A constant String that is associated with the Intent, used with
4294 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4295 * as HTML formatted text. Note that you <em>must</em> also supply
4296 * {@link #EXTRA_TEXT}.
4297 */
4298 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4299
4300 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004301 * A content: URI holding a stream of data associated with the Intent,
4302 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004303 */
4304 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4305
4306 /**
4307 * A String[] holding e-mail addresses that should be delivered to.
4308 */
4309 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4310
4311 /**
4312 * A String[] holding e-mail addresses that should be carbon copied.
4313 */
4314 public static final String EXTRA_CC = "android.intent.extra.CC";
4315
4316 /**
4317 * A String[] holding e-mail addresses that should be blind carbon copied.
4318 */
4319 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4320
4321 /**
4322 * A constant string holding the desired subject line of a message.
4323 */
4324 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4325
4326 /**
4327 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004328 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004329 */
4330 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4331
4332 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004333 * An int representing the user id to be used.
4334 *
4335 * @hide
4336 */
4337 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4338
4339 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004340 * An int representing the task id to be retrieved. This is used when a launch from recents is
4341 * intercepted by another action such as credentials confirmation to remember which task should
4342 * be resumed when complete.
4343 *
4344 * @hide
4345 */
4346 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4347
4348 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004349 * An Intent[] describing additional, alternate choices you would like shown with
4350 * {@link #ACTION_CHOOSER}.
4351 *
4352 * <p>An app may be capable of providing several different payload types to complete a
4353 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4354 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4355 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4356 * photo data or a hosted link where the photos can be viewed.</p>
4357 *
4358 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4359 * first/primary/preferred intent in the set. Additional intents specified in
4360 * this extra are ordered; by default intents that appear earlier in the array will be
4361 * preferred over intents that appear later in the array as matches for the same
4362 * target component. To alter this preference, a calling app may also supply
4363 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4364 */
4365 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4366
4367 /**
Adam Powell52c39212016-04-07 15:14:18 -07004368 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4369 * and omitted from a list of components presented to the user.
4370 *
4371 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4372 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4373 * from your own package or other apps from your organization if the idea of sending to those
4374 * targets would be redundant with other app functionality. Filtered components will not
4375 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4376 */
4377 public static final String EXTRA_EXCLUDE_COMPONENTS
4378 = "android.intent.extra.EXCLUDE_COMPONENTS";
4379
4380 /**
4381 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4382 * describing additional high-priority deep-link targets for the chooser to present to the user.
4383 *
4384 * <p>Targets provided in this way will be presented inline with all other targets provided
4385 * by services from other apps. They will be prioritized before other service targets, but
4386 * after those targets provided by sources that the user has manually pinned to the front.</p>
4387 *
4388 * @see #ACTION_CHOOSER
4389 */
4390 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4391
4392 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004393 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4394 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4395 *
4396 * <p>An app preparing an action for another app to complete may wish to allow the user to
4397 * disambiguate between several options for completing the action based on the chosen target
4398 * or otherwise refine the action before it is invoked.
4399 * </p>
4400 *
4401 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4402 * <ul>
4403 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4404 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4405 * chosen target beyond the first</li>
4406 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4407 * should fill in and send once the disambiguation is complete</li>
4408 * </ul>
4409 */
4410 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4411 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4412
4413 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004414 * An {@code ArrayList} of {@code String} annotations describing content for
4415 * {@link #ACTION_CHOOSER}.
4416 *
4417 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4418 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4419 *
4420 * <p>Annotations should describe the major components or topics of the content. It is up to
4421 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4422 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004423 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4424 * character. Performance on customized annotations can suffer, if they are rarely used for
4425 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4426 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004427 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004428 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004429 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004430 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004431 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004432 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004433 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004434 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004435 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004436 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4437 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4438 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4439 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4440 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004441 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004442 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4443 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004444 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004445 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004446 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004447 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004448 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004449 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004450 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004451 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004452 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004453 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004454 * Christmas and Thanksgiving.</li>
4455 * </ul>
4456 */
4457 public static final String EXTRA_CONTENT_ANNOTATIONS
4458 = "android.intent.extra.CONTENT_ANNOTATIONS";
4459
4460 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004461 * A {@link ResultReceiver} used to return data back to the sender.
4462 *
4463 * <p>Used to complete an app-specific
4464 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4465 *
4466 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4467 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4468 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4469 * when the user selects a target component from the chooser. It is up to the recipient
4470 * to send a result to this ResultReceiver to signal that disambiguation is complete
4471 * and that the chooser should invoke the user's choice.</p>
4472 *
4473 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4474 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4475 * to match and fill in the final Intent or ChooserTarget before starting it.
4476 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4477 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4478 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4479 *
4480 * <p>The result code passed to the ResultReceiver should be
4481 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4482 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4483 * the chooser should finish without starting a target.</p>
4484 */
4485 public static final String EXTRA_RESULT_RECEIVER
4486 = "android.intent.extra.RESULT_RECEIVER";
4487
4488 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004489 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004490 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004491 */
4492 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4493
4494 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004495 * A Parcelable[] of {@link Intent} or
4496 * {@link android.content.pm.LabeledIntent} objects as set with
4497 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4498 * a the front of the list of choices, when shown to the user with a
4499 * {@link #ACTION_CHOOSER}.
4500 */
4501 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4502
4503 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004504 * A {@link IntentSender} to start after ephemeral installation success.
Patrick Baumann159cd022018-01-11 13:25:05 -08004505 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
4506 * @removed
Todd Kennedy7440f172015-12-09 14:31:22 -08004507 * @hide
4508 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004509 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004510 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4511
4512 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004513 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004514 * @hide
4515 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004516 @SystemApi
4517 public static final String EXTRA_INSTANT_APP_SUCCESS =
4518 "android.intent.extra.INSTANT_APP_SUCCESS";
4519
4520 /**
4521 * A {@link IntentSender} to start after ephemeral installation failure.
4522 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
4523 * @removed
4524 * @hide
4525 */
4526 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004527 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4528
4529 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004530 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004531 * @hide
4532 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004533 @SystemApi
4534 public static final String EXTRA_INSTANT_APP_FAILURE =
4535 "android.intent.extra.INSTANT_APP_FAILURE";
4536
4537 /**
4538 * The host name that triggered an ephemeral resolution.
4539 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
4540 * @removed
4541 * @hide
4542 */
4543 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004544 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4545
4546 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004547 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004548 * @hide
4549 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004550 @SystemApi
4551 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4552 "android.intent.extra.INSTANT_APP_HOSTNAME";
4553
4554 /**
4555 * An opaque token to track ephemeral resolution.
4556 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
4557 * @removed
4558 * @hide
4559 */
4560 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004561 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4562
4563 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004564 * An opaque token to track instant app resolution.
4565 * @hide
4566 */
4567 @SystemApi
4568 public static final String EXTRA_INSTANT_APP_TOKEN =
4569 "android.intent.extra.INSTANT_APP_TOKEN";
4570
4571 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004572 * The action that triggered an instant application resolution.
4573 * @hide
4574 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004575 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004576 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4577
4578 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004579 * An array of {@link Bundle}s containing details about resolved instant apps..
4580 * @hide
4581 */
4582 @SystemApi
4583 public static final String EXTRA_INSTANT_APP_BUNDLES =
4584 "android.intent.extra.INSTANT_APP_BUNDLES";
4585
4586 /**
4587 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004588 * installed. This data is populated from the response to
4589 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4590 * instant application resolver.
4591 * @hide
4592 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004593 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004594 public static final String EXTRA_INSTANT_APP_EXTRAS =
4595 "android.intent.extra.INSTANT_APP_EXTRAS";
4596
4597 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004598 * A boolean value indicating that the instant app resolver was unable to state with certainty
4599 * that it did or did not have an app for the sanitized {@link Intent} defined at
4600 * {@link #EXTRA_INTENT}.
4601 * @hide
4602 */
4603 @SystemApi
4604 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4605 "android.intent.extra.UNKNOWN_INSTANT_APP";
4606
4607 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004608 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004609 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004610 * @hide
4611 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004612 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004613 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4614
4615 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004616 * The version code of the app to install components from.
4617 * @hide
4618 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004619 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004620 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4621
4622 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004623 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004624 * @hide
4625 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004626 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004627 public static final String EXTRA_CALLING_PACKAGE
4628 = "android.intent.extra.CALLING_PACKAGE";
4629
4630 /**
4631 * Optional calling app provided bundle containing additional launch information the
4632 * installer may use.
4633 * @hide
4634 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004635 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004636 public static final String EXTRA_VERIFICATION_BUNDLE
4637 = "android.intent.extra.VERIFICATION_BUNDLE";
4638
4639 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004640 * A Bundle forming a mapping of potential target package names to different extras Bundles
4641 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4642 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4643 * be currently installed on the device.
4644 *
4645 * <p>An application may choose to provide alternate extras for the case where a user
4646 * selects an activity from a predetermined set of target packages. If the activity
4647 * the user selects from the chooser belongs to a package with its package name as
4648 * a key in this bundle, the corresponding extras for that package will be merged with
4649 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4650 * extra has the same key as an extra already present in the intent it will overwrite
4651 * the extra from the intent.</p>
4652 *
4653 * <p><em>Examples:</em>
4654 * <ul>
4655 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4656 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4657 * parameters for that target.</li>
4658 * <li>An application may offer additional metadata for known targets of a given intent
4659 * to pass along information only relevant to that target such as account or content
4660 * identifiers already known to that application.</li>
4661 * </ul></p>
4662 */
4663 public static final String EXTRA_REPLACEMENT_EXTRAS =
4664 "android.intent.extra.REPLACEMENT_EXTRAS";
4665
4666 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004667 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4668 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4669 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4670 * {@link ComponentName} of the chosen component.
4671 *
4672 * <p>In some situations this callback may never come, for example if the user abandons
4673 * the chooser, switches to another task or any number of other reasons. Apps should not
4674 * be written assuming that this callback will always occur.</p>
4675 */
4676 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4677 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4678
4679 /**
4680 * The {@link ComponentName} chosen by the user to complete an action.
4681 *
4682 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4683 */
4684 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4685
4686 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004687 * A {@link android.view.KeyEvent} object containing the event that
4688 * triggered the creation of the Intent it is in.
4689 */
4690 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4691
4692 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004693 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4694 * before shutting down.
4695 *
4696 * {@hide}
4697 */
4698 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4699
4700 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004701 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4702 * requested by the user.
4703 *
4704 * {@hide}
4705 */
4706 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4707 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4708
4709 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004710 * 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 -07004711 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4712 * of restarting the application.
4713 */
4714 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4715
4716 /**
4717 * A String holding the phone number originally entered in
4718 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4719 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4720 */
4721 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004722
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004723 /**
4724 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4725 * intents to supply the uid the package had been assigned. Also an optional
4726 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4727 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4728 * purpose.
4729 */
4730 public static final String EXTRA_UID = "android.intent.extra.UID";
4731
4732 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004733 * @hide String array of package names.
4734 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004735 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004736 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4737
4738 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004739 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4740 * intents to indicate whether this represents a full uninstall (removing
4741 * both the code and its data) or a partial uninstall (leaving its data,
4742 * implying that this is an update).
4743 */
4744 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004745
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004746 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004747 * @hide
4748 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4749 * intents to indicate that at this point the package has been removed for
4750 * all users on the device.
4751 */
4752 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4753 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4754
4755 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004756 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4757 * intents to indicate that this is a replacement of the package, so this
4758 * broadcast will immediately be followed by an add broadcast for a
4759 * different version of the same package.
4760 */
4761 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004762
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004763 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004764 * Used as an int extra field in {@link android.app.AlarmManager} intents
4765 * to tell the application being invoked how many pending alarms are being
4766 * delievered with the intent. For one-shot alarms this will always be 1.
4767 * For recurring alarms, this might be greater than 1 if the device was
4768 * asleep or powered off at the time an earlier alarm would have been
4769 * delivered.
4770 */
4771 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004772
Jacek Surazski86b6c532009-05-13 14:38:28 +02004773 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004774 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4775 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004776 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4777 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004778 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4779 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4780 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004781 */
4782 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4783
4784 /**
4785 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4786 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004787 */
4788 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4789
4790 /**
4791 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4792 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004793 */
4794 public static final int EXTRA_DOCK_STATE_DESK = 1;
4795
4796 /**
4797 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4798 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004799 */
4800 public static final int EXTRA_DOCK_STATE_CAR = 2;
4801
4802 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004803 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4804 * to represent that the phone is in a analog (low end) dock.
4805 */
4806 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4807
4808 /**
4809 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4810 * to represent that the phone is in a digital (high end) dock.
4811 */
4812 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4813
4814 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004815 * Boolean that can be supplied as meta-data with a dock activity, to
4816 * indicate that the dock should take over the home key when it is active.
4817 */
4818 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004819
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004820 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004821 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4822 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004823 */
4824 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4825
4826 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004827 * Used in the extra field in the remote intent. It's astring token passed with the
4828 * remote intent.
4829 */
4830 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4831 "android.intent.extra.remote_intent_token";
4832
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004833 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004834 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004835 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004836 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004837 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004838 "android.intent.extra.changed_component_name";
4839
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004840 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004841 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004842 * and contains a string array of all of the components that have changed. If
4843 * the state of the overall package has changed, then it will contain an entry
4844 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004845 */
4846 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4847 "android.intent.extra.changed_component_name_list";
4848
4849 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004850 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004851 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004852 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4853 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4854 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004855 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004856 */
4857 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4858 "android.intent.extra.changed_package_list";
4859
4860 /**
4861 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004862 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4863 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004864 * and contains an integer array of uids of all of the components
4865 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004866 */
4867 public static final String EXTRA_CHANGED_UID_LIST =
4868 "android.intent.extra.changed_uid_list";
4869
4870 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004871 * @hide
4872 * Magic extra system code can use when binding, to give a label for
4873 * who it is that has bound to a service. This is an integer giving
4874 * a framework string resource that can be displayed to the user.
4875 */
4876 public static final String EXTRA_CLIENT_LABEL =
4877 "android.intent.extra.client_label";
4878
4879 /**
4880 * @hide
4881 * Magic extra system code can use when binding, to give a PendingIntent object
4882 * that can be launched for the user to disable the system's use of this
4883 * service.
4884 */
4885 public static final String EXTRA_CLIENT_INTENT =
4886 "android.intent.extra.client_intent";
4887
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004888 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004889 * Extra used to indicate that an intent should only return data that is on
4890 * the local device. This is a boolean extra; the default is false. If true,
4891 * an implementation should only allow the user to select data that is
4892 * already on the device, not requiring it be downloaded from a remote
4893 * service when opened.
4894 *
4895 * @see #ACTION_GET_CONTENT
4896 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004897 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004898 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004899 */
4900 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004901 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004902
Amith Yamasani13593602012-03-22 16:16:17 -07004903 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004904 * Extra used to indicate that an intent can allow the user to select and
4905 * return multiple items. This is a boolean extra; the default is false. If
4906 * true, an implementation is allowed to present the user with a UI where
4907 * they can pick multiple items that are all returned to the caller. When
4908 * this happens, they should be returned as the {@link #getClipData()} part
4909 * of the result Intent.
4910 *
4911 * @see #ACTION_GET_CONTENT
4912 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004913 */
4914 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004915 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004916
4917 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004918 * The integer userHandle carried with broadcast intents related to addition, removal and
4919 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4920 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4921 *
Amith Yamasani13593602012-03-22 16:16:17 -07004922 * @hide
4923 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004924 public static final String EXTRA_USER_HANDLE =
4925 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004926
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004927 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004928 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4929 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4930 */
4931 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004932 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004933
4934 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004935 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004936 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4937 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004938 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004939 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4940
4941 /**
4942 * Extra sent in the intent to the BroadcastReceiver that handles
4943 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4944 * the restrictions as key/value pairs.
4945 */
4946 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4947 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004948
Amith Yamasani86118ba2013-03-28 14:33:16 -07004949 /**
4950 * Extra used in the response from a BroadcastReceiver that handles
4951 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4952 */
4953 public static final String EXTRA_RESTRICTIONS_INTENT =
4954 "android.intent.extra.restrictions_intent";
4955
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004956 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004957 * Extra used to communicate a set of acceptable MIME types. The type of the
4958 * extra is {@code String[]}. Values may be a combination of concrete MIME
4959 * types (such as "image/png") and/or partial MIME types (such as
4960 * "audio/*").
4961 *
4962 * @see #ACTION_GET_CONTENT
4963 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004964 */
4965 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4966
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004967 /**
4968 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4969 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004970 * When this is true, hardware devices can use this information to determine that
4971 * they shouldn't do a complete shutdown of their device since this is not a
4972 * complete shutdown down to the kernel, but only user space restarting.
4973 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004974 */
4975 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4976 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4977
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004978 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004979 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4980 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4981 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4982 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004983 *
4984 * @hide for internal use only.
4985 */
4986 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4987 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004988 /** @hide */
4989 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4990 /** @hide */
4991 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4992 /** @hide */
4993 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004994
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07004995 /**
4996 * Intent extra: the reason that the operation associated with this intent is being performed.
4997 *
4998 * <p>Type: String
4999 * @hide
5000 */
5001 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005002 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5003
qingxi240c2bb2017-04-12 17:31:18 -07005004 /**
5005 * {@hide}
5006 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5007 */
Rubin Xue8490f12015-06-25 12:17:48 +01005008 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5009
Santos Cordon15a13782015-03-31 18:32:31 -07005010 /**
qingxi240c2bb2017-04-12 17:31:18 -07005011 * {@hide}
5012 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5013 * reset for the device with eSIM. This extra will be sent together with
5014 * {@link #ACTION_FACTORY_RESET}
5015 */
5016 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5017
5018 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005019 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5020 * activation request.
5021 * TODO: Add information about the structure and response data used with the pending intent.
5022 * @hide
5023 */
5024 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5025 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5026
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005027 /**
5028 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005029 *
5030 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005031 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005032 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005033 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5034
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005035 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005036 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5037 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5038 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005039 *
5040 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005041 * @see #ACTION_QUICK_VIEW
5042 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005043 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005044 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005045 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5046 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005047
5048 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005049 * An optional extra of {@code String[]} indicating which quick view features should be made
5050 * available to the user in the quick view UI while handing a
5051 * {@link Intent#ACTION_QUICK_VIEW} intent.
5052 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5053 * Quick viewer can implement features not listed below.
5054 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005055 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5056 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5057 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005058 * <p>
5059 * Requirements:
5060 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5061 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5062 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5063 * internal policies.
5064 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5065 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5066 * disable or hide features.
5067 *
5068 * @see #ACTION_QUICK_VIEW
5069 */
5070 public static final String EXTRA_QUICK_VIEW_FEATURES =
5071 "android.intent.extra.QUICK_VIEW_FEATURES";
5072
5073 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005074 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005075 * When a profile goes into quiet mode, all apps in the profile are killed and the
5076 * profile user is stopped. Widgets originating from the profile are masked, and app
5077 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005078 */
5079 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005080
5081 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005082 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005083 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005084 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5085 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005086 *
5087 * @hide
5088 */
5089 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5090 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5091
5092 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005093 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5094 * whether to show the chooser or not when there is only one application available
5095 * to choose from.
5096 *
5097 * @hide
5098 */
5099 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5100 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5101
5102 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005103 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005104 * to represent that a video codec is allowed to use.
5105 *
5106 * @hide
5107 */
5108 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5109
5110 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005111 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005112 * to represent that a audio codec is allowed to use.
5113 *
5114 * @hide
5115 */
5116 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5117
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005118 // ---------------------------------------------------------------------
5119 // ---------------------------------------------------------------------
5120 // Intent flags (see mFlags variable).
5121
Tor Norbyed9273d62013-05-30 15:59:53 -07005122 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005123 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005124 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5125 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005126 @Retention(RetentionPolicy.SOURCE)
5127 public @interface GrantUriMode {}
5128
Jeff Sharkey846318a2014-04-04 12:12:41 -07005129 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005130 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005131 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5132 @Retention(RetentionPolicy.SOURCE)
5133 public @interface AccessUriMode {}
5134
5135 /**
5136 * Test if given mode flags specify an access mode, which must be at least
5137 * read and/or write.
5138 *
5139 * @hide
5140 */
5141 public static boolean isAccessUriMode(int modeFlags) {
5142 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5143 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5144 }
5145
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005146 /** @hide */
5147 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5148 FLAG_GRANT_READ_URI_PERMISSION,
5149 FLAG_GRANT_WRITE_URI_PERMISSION,
5150 FLAG_FROM_BACKGROUND,
5151 FLAG_DEBUG_LOG_RESOLUTION,
5152 FLAG_EXCLUDE_STOPPED_PACKAGES,
5153 FLAG_INCLUDE_STOPPED_PACKAGES,
5154 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5155 FLAG_GRANT_PREFIX_URI_PERMISSION,
5156 FLAG_DEBUG_TRIAGED_MISSING,
5157 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005158 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005159 FLAG_ACTIVITY_NO_HISTORY,
5160 FLAG_ACTIVITY_SINGLE_TOP,
5161 FLAG_ACTIVITY_NEW_TASK,
5162 FLAG_ACTIVITY_MULTIPLE_TASK,
5163 FLAG_ACTIVITY_CLEAR_TOP,
5164 FLAG_ACTIVITY_FORWARD_RESULT,
5165 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5166 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5167 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5168 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5169 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5170 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5171 FLAG_ACTIVITY_NEW_DOCUMENT,
5172 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5173 FLAG_ACTIVITY_NO_USER_ACTION,
5174 FLAG_ACTIVITY_REORDER_TO_FRONT,
5175 FLAG_ACTIVITY_NO_ANIMATION,
5176 FLAG_ACTIVITY_CLEAR_TASK,
5177 FLAG_ACTIVITY_TASK_ON_HOME,
5178 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5179 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5180 FLAG_RECEIVER_REGISTERED_ONLY,
5181 FLAG_RECEIVER_REPLACE_PENDING,
5182 FLAG_RECEIVER_FOREGROUND,
5183 FLAG_RECEIVER_NO_ABORT,
5184 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5185 FLAG_RECEIVER_BOOT_UPGRADE,
5186 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5187 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5188 FLAG_RECEIVER_FROM_SHELL,
5189 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5190 })
5191 @Retention(RetentionPolicy.SOURCE)
5192 public @interface Flags {}
5193
5194 /** @hide */
5195 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5196 FLAG_FROM_BACKGROUND,
5197 FLAG_DEBUG_LOG_RESOLUTION,
5198 FLAG_EXCLUDE_STOPPED_PACKAGES,
5199 FLAG_INCLUDE_STOPPED_PACKAGES,
5200 FLAG_DEBUG_TRIAGED_MISSING,
5201 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005202 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005203 FLAG_ACTIVITY_NO_HISTORY,
5204 FLAG_ACTIVITY_SINGLE_TOP,
5205 FLAG_ACTIVITY_NEW_TASK,
5206 FLAG_ACTIVITY_MULTIPLE_TASK,
5207 FLAG_ACTIVITY_CLEAR_TOP,
5208 FLAG_ACTIVITY_FORWARD_RESULT,
5209 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5210 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5211 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5212 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5213 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5214 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5215 FLAG_ACTIVITY_NEW_DOCUMENT,
5216 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5217 FLAG_ACTIVITY_NO_USER_ACTION,
5218 FLAG_ACTIVITY_REORDER_TO_FRONT,
5219 FLAG_ACTIVITY_NO_ANIMATION,
5220 FLAG_ACTIVITY_CLEAR_TASK,
5221 FLAG_ACTIVITY_TASK_ON_HOME,
5222 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5223 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5224 FLAG_RECEIVER_REGISTERED_ONLY,
5225 FLAG_RECEIVER_REPLACE_PENDING,
5226 FLAG_RECEIVER_FOREGROUND,
5227 FLAG_RECEIVER_NO_ABORT,
5228 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5229 FLAG_RECEIVER_BOOT_UPGRADE,
5230 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5231 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5232 FLAG_RECEIVER_FROM_SHELL,
5233 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5234 })
5235 @Retention(RetentionPolicy.SOURCE)
5236 public @interface MutableFlags {}
5237
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005238 /**
5239 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005240 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005241 * specified in its ClipData. When applying to an Intent's ClipData,
5242 * all URIs as well as recursive traversals through data or other ClipData
5243 * in Intent items will be granted; only the grant flags of the top-level
5244 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005245 */
5246 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5247 /**
5248 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005249 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005250 * specified in its ClipData. When applying to an Intent's ClipData,
5251 * all URIs as well as recursive traversals through data or other ClipData
5252 * in Intent items will be granted; only the grant flags of the top-level
5253 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005254 */
5255 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5256 /**
5257 * Can be set by the caller to indicate that this Intent is coming from
5258 * a background operation, not from direct user interaction.
5259 */
5260 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5261 /**
5262 * A flag you can enable for debugging: when set, log messages will be
5263 * printed during the resolution of this intent to show you what has
5264 * been found to create the final resolved list.
5265 */
5266 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005267 /**
5268 * If set, this intent will not match any components in packages that
5269 * are currently stopped. If this is not set, then the default behavior
5270 * is to include such applications in the result.
5271 */
5272 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5273 /**
5274 * If set, this intent will always match any components in packages that
5275 * are currently stopped. This is the default behavior when
5276 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5277 * flags are set, this one wins (it allows overriding of exclude for
5278 * places where the framework may automatically set the exclude flag).
5279 */
5280 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005281
5282 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005283 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005284 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005285 * persisted across device reboots until explicitly revoked with
5286 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5287 * grant for possible persisting; the receiving application must call
5288 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5289 * actually persist.
5290 *
5291 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5292 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5293 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005294 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005295 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005296 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005297
5298 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005299 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5300 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5301 * applies to any URI that is a prefix match against the original granted
5302 * URI. (Without this flag, the URI must match exactly for access to be
5303 * granted.) Another URI is considered a prefix match only when scheme,
5304 * authority, and all path segments defined by the prefix are an exact
5305 * match.
5306 */
5307 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5308
5309 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005310 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005311 * homework and verified that they correctly handle packages and components
5312 * that come and go over time. In particular:
5313 * <ul>
5314 * <li>Apps installed on external storage, which will appear to be
5315 * uninstalled while the the device is ejected.
5316 * <li>Apps with encryption unaware components, which will appear to not
5317 * exist while the device is locked.
5318 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005319 *
5320 * @hide
5321 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005322 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005323
5324 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005325 * Internal flag used to indicate ephemeral applications should not be
5326 * considered when resolving the intent.
5327 *
5328 * @hide
5329 */
5330 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5331
5332 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005333 * If set, the new activity is not kept in the history stack. As soon as
5334 * the user navigates away from it, the activity is finished. This may also
5335 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5336 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005337 *
5338 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5339 * is never invoked when the current activity starts a new activity which
5340 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005341 */
5342 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5343 /**
5344 * If set, the activity will not be launched if it is already running
5345 * at the top of the history stack.
5346 */
5347 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5348 /**
5349 * If set, this activity will become the start of a new task on this
5350 * history stack. A task (from the activity that started it to the
5351 * next task activity) defines an atomic group of activities that the
5352 * user can move to. Tasks can be moved to the foreground and background;
5353 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005354 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005355 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5356 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005357 *
5358 * <p>This flag is generally used by activities that want
5359 * to present a "launcher" style behavior: they give the user a list of
5360 * separate things that can be done, which otherwise run completely
5361 * independently of the activity launching them.
5362 *
5363 * <p>When using this flag, if a task is already running for the activity
5364 * you are now starting, then a new activity will not be started; instead,
5365 * the current task will simply be brought to the front of the screen with
5366 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5367 * to disable this behavior.
5368 *
5369 * <p>This flag can not be used when the caller is requesting a result from
5370 * the activity being launched.
5371 */
5372 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5373 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005374 * This flag is used to create a new task and launch an activity into it.
5375 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5376 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5377 * search through existing tasks for ones matching this Intent. Only if no such
5378 * task is found would a new task be created. When paired with
5379 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5380 * the search for a matching task and unconditionally start a new task.
5381 *
5382 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5383 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005384 * top-level application launcher.</strong> Used in conjunction with
5385 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5386 * behavior of bringing an existing task to the foreground. When set,
5387 * a new task is <em>always</em> started to host the Activity for the
5388 * Intent, regardless of whether there is already an existing task running
5389 * the same thing.
5390 *
5391 * <p><strong>Because the default system does not include graphical task management,
5392 * you should not use this flag unless you provide some way for a user to
5393 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005394 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005395 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5396 * creating new document tasks.
5397 *
5398 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005399 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005400 *
Scott Main7aee61f2011-02-08 11:25:01 -08005401 * <p>See
5402 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5403 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005404 *
5405 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5406 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005407 */
5408 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5409 /**
5410 * If set, and the activity being launched is already running in the
5411 * current task, then instead of launching a new instance of that activity,
5412 * all of the other activities on top of it will be closed and this Intent
5413 * will be delivered to the (now on top) old activity as a new Intent.
5414 *
5415 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5416 * If D calls startActivity() with an Intent that resolves to the component
5417 * of activity B, then C and D will be finished and B receive the given
5418 * Intent, resulting in the stack now being: A, B.
5419 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005420 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005421 * either receive the new intent you are starting here in its
5422 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005423 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005424 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5425 * the same intent, then it will be finished and re-created; for all other
5426 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5427 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005428 *
5429 * <p>This launch mode can also be used to good effect in conjunction with
5430 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5431 * of a task, it will bring any currently running instance of that task
5432 * to the foreground, and then clear it to its root state. This is
5433 * especially useful, for example, when launching an activity from the
5434 * notification manager.
5435 *
Scott Main7aee61f2011-02-08 11:25:01 -08005436 * <p>See
5437 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5438 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 */
5440 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5441 /**
5442 * If set and this intent is being used to launch a new activity from an
5443 * existing one, then the reply target of the existing activity will be
5444 * transfered to the new activity. This way the new activity can call
5445 * {@link android.app.Activity#setResult} and have that result sent back to
5446 * the reply target of the original activity.
5447 */
5448 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5449 /**
5450 * If set and this intent is being used to launch a new activity from an
5451 * existing one, the current activity will not be counted as the top
5452 * activity for deciding whether the new intent should be delivered to
5453 * the top instead of starting a new one. The previous activity will
5454 * be used as the top, with the assumption being that the current activity
5455 * will finish itself immediately.
5456 */
5457 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5458 /**
5459 * If set, the new activity is not kept in the list of recently launched
5460 * activities.
5461 */
5462 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5463 /**
5464 * This flag is not normally set by application code, but set for you by
5465 * the system as described in the
5466 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5467 * launchMode} documentation for the singleTask mode.
5468 */
5469 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5470 /**
5471 * If set, and this activity is either being started in a new task or
5472 * bringing to the top an existing task, then it will be launched as
5473 * the front door of the task. This will result in the application of
5474 * any affinities needed to have that task in the proper state (either
5475 * moving activities to or from it), or simply resetting that task to
5476 * its initial state if needed.
5477 */
5478 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5479 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005480 * This flag is not normally set by application code, but set for you by
5481 * the system if this activity is being launched from history
5482 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005483 */
5484 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005485 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005486 * @deprecated As of API 21 this performs identically to
5487 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005488 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005489 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005490 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005491 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005492 * This flag is used to open a document into a new task rooted at the activity launched
5493 * by this Intent. Through the use of this flag, or its equivalent attribute,
5494 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005495 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005496 *
Craig Mautner026596b2014-05-21 15:35:44 -07005497 * <p>The use of the activity attribute form of this,
5498 * {@link android.R.attr#documentLaunchMode}, is
5499 * preferred over the Intent flag described here. The attribute form allows the
5500 * Activity to specify multiple document behavior for all launchers of the Activity
5501 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005502 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005503 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5504 * it is kept after the activity is finished is different than the use of
5505 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5506 * this flag is being used to create a new recents entry, then by default that entry
5507 * will be removed once the activity is finished. You can modify this behavior with
5508 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5509 *
Craig Mautner026596b2014-05-21 15:35:44 -07005510 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5511 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5512 * equivalent of the Activity manifest specifying {@link
5513 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5514 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5515 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005516 *
Craig Mautner026596b2014-05-21 15:35:44 -07005517 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005518 *
Craig Mautner026596b2014-05-21 15:35:44 -07005519 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005520 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5521 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005522 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005523 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005524 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005525 * callback from occurring on the current frontmost activity before it is
5526 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005527 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005528 * <p>Typically, an activity can rely on that callback to indicate that an
5529 * explicit user action has caused their activity to be moved out of the
5530 * foreground. The callback marks an appropriate point in the activity's
5531 * lifecycle for it to dismiss any notifications that it intends to display
5532 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005533 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005534 * <p>If an activity is ever started via any non-user-driven events such as
5535 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5536 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005537 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005538 */
5539 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005540 /**
5541 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5542 * this flag will cause the launched activity to be brought to the front of its
5543 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005544 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005545 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5546 * If D calls startActivity() with an Intent that resolves to the component
5547 * of activity B, then B will be brought to the front of the history stack,
5548 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005549 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005550 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005551 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005552 */
5553 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005554 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005555 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5556 * this flag will prevent the system from applying an activity transition
5557 * animation to go to the next activity state. This doesn't mean an
5558 * animation will never run -- if another activity change happens that doesn't
5559 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005560 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005561 * when you are going to do a series of activity operations but the
5562 * animation seen by the user shouldn't be driven by the first activity
5563 * change but rather a later one.
5564 */
5565 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5566 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005567 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5568 * this flag will cause any existing task that would be associated with the
5569 * activity to be cleared before the activity is started. That is, the activity
5570 * becomes the new root of an otherwise empty task, and any old activities
5571 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5572 */
5573 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5574 /**
5575 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5576 * this flag will cause a newly launching task to be placed on top of the current
5577 * home activity task (if there is one). That is, pressing back from the task
5578 * will always return the user to home even if that was not the last activity they
5579 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5580 */
5581 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5582 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005583 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5584 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005585 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005586 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005587 * this flag. When set and the task's activity is finished, the recents
5588 * entry will remain in the interface for the user to re-launch it, like a
5589 * recents entry for a top-level application.
5590 * <p>
5591 * The receiving activity can override this request with
5592 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5593 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005594 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005595 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005596 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005597
5598 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005599 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5600 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005601 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5602 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005603 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005604 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005605
Patrick Baumann577d4022018-01-31 16:55:10 +00005606
5607 /**
5608 * If set, resolution of this intent may take place via an instant app not
5609 * yet on the device if there does not yet exist an app on device to
5610 * resolve it.
5611 */
5612 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5613
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005614 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005615 * If set, when sending a broadcast only registered receivers will be
5616 * called -- no BroadcastReceiver components will be launched.
5617 */
5618 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005619 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005620 * If set, when sending a broadcast the new broadcast will replace
5621 * any existing pending broadcast that matches it. Matching is defined
5622 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5623 * true for the intents of the two broadcasts. When a match is found,
5624 * the new broadcast (and receivers associated with it) will replace the
5625 * existing one in the pending broadcast list, remaining at the same
5626 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005627 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005628 * <p>This flag is most typically used with sticky broadcasts, which
5629 * only care about delivering the most recent values of the broadcast
5630 * to their receivers.
5631 */
5632 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5633 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005634 * If set, when sending a broadcast the recipient is allowed to run at
5635 * foreground priority, with a shorter timeout interval. During normal
5636 * broadcasts the receivers are not automatically hoisted out of the
5637 * background priority class.
5638 */
5639 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5640 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005641 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5642 * They can still propagate results through to later receivers, but they can not prevent
5643 * later receivers from seeing the broadcast.
5644 */
5645 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5646 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005647 * If set, when sending a broadcast <i>before boot has completed</i> only
5648 * registered receivers will be called -- no BroadcastReceiver components
5649 * will be launched. Sticky intent state will be recorded properly even
5650 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5651 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005652 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005653 * <p>This flag is only for use by system sevices as a convenience to
5654 * avoid having to implement a more complex mechanism around detection
5655 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005656 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005657 * @hide
5658 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005659 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005660 /**
5661 * Set when this broadcast is for a boot upgrade, a special mode that
5662 * allows the broadcast to be sent before the system is ready and launches
5663 * the app process with no providers running in it.
5664 * @hide
5665 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005666 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005667 /**
5668 * If set, the broadcast will always go to manifest receivers in background (cached
5669 * or not running) apps, regardless of whether that would be done by default. By
5670 * default they will only receive broadcasts if the broadcast has specified an
5671 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005672 *
5673 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5674 * the broadcast code there must also be changed to match.
5675 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005676 * @hide
5677 */
5678 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5679 /**
5680 * If set, the broadcast will never go to manifest receivers in background (cached
5681 * or not running) apps, regardless of whether that would be done by default. By
5682 * default they will receive broadcasts if the broadcast has specified an
5683 * explicit component or package name.
5684 * @hide
5685 */
5686 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005687 /**
5688 * If set, this broadcast is being sent from the shell.
5689 * @hide
5690 */
5691 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005692
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005693 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005694 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5695 * will not receive broadcasts.
5696 *
5697 * <em>This flag has no effect when used by an Instant App.</em>
5698 */
5699 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5700
5701 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005702 * @hide Flags that can't be changed with PendingIntent.
5703 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005704 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5705 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5706 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005707
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005708 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005709 // ---------------------------------------------------------------------
5710 // toUri() and parseUri() options.
5711
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005712 /** @hide */
5713 @IntDef(flag = true, prefix = { "URI_" }, value = {
5714 URI_ALLOW_UNSAFE,
5715 URI_ANDROID_APP_SCHEME,
5716 URI_INTENT_SCHEME,
5717 })
5718 @Retention(RetentionPolicy.SOURCE)
5719 public @interface UriFlags {}
5720
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005721 /**
5722 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5723 * always has the "intent:" scheme. This syntax can be used when you want
5724 * to later disambiguate between URIs that are intended to describe an
5725 * Intent vs. all others that should be treated as raw URIs. When used
5726 * with {@link #parseUri}, any other scheme will result in a generic
5727 * VIEW action for that raw URI.
5728 */
5729 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005730
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005731 /**
5732 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5733 * always has the "android-app:" scheme. This is a variation of
5734 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5735 * http/https URI being delivered to a specific package name. The format
5736 * is:
5737 *
5738 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005739 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005740 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005741 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5742 * you must also include a scheme; including a path also requires both a host and a scheme.
5743 * The final #Intent; fragment can be used without a scheme, host, or path.
5744 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005745 * used with intents that have a {@link #setSelector}, since the base intent
5746 * will always have an explicit package name.</p>
5747 *
5748 * <p>Some examples of how this scheme maps to Intent objects:</p>
5749 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5750 * <colgroup align="left" />
5751 * <colgroup align="left" />
5752 * <thead>
5753 * <tr><th>URI</th> <th>Intent</th></tr>
5754 * </thead>
5755 *
5756 * <tbody>
5757 * <tr><td><code>android-app://com.example.app</code></td>
5758 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5759 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5760 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5761 * </table></td>
5762 * </tr>
5763 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5764 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5765 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5766 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5767 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5768 * </table></td>
5769 * </tr>
5770 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5771 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5772 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5773 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5774 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5775 * </table></td>
5776 * </tr>
5777 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5778 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5779 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5780 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5781 * </table></td>
5782 * </tr>
5783 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5784 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5785 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5786 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5787 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5788 * </table></td>
5789 * </tr>
5790 * <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>
5791 * <td><table border="" style="margin:0" >
5792 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5793 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5794 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5795 * </table></td>
5796 * </tr>
5797 * </tbody>
5798 * </table>
5799 */
5800 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5801
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005802 /**
5803 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5804 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5805 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5806 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5807 * generated Intent can not cause unexpected data access to happen.
5808 *
5809 * <p>If you do not trust the source of the URI being parsed, you should still do further
5810 * processing to protect yourself from it. In particular, when using it to start an
5811 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5812 * that can handle it.</p>
5813 */
5814 public static final int URI_ALLOW_UNSAFE = 1<<2;
5815
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005816 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005817
5818 private String mAction;
5819 private Uri mData;
5820 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005821 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 private ComponentName mComponent;
5823 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005824 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005825 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005826 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005827 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005828 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005829 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005830 /** Token to track instant app launches. Local only; do not copy cross-process. */
5831 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005832
5833 // ---------------------------------------------------------------------
5834
Makoto Onuki97f82f22017-05-31 16:20:21 -07005835 private static final int COPY_MODE_ALL = 0;
5836 private static final int COPY_MODE_FILTER = 1;
5837 private static final int COPY_MODE_HISTORY = 2;
5838
5839 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005840 @IntDef(prefix = { "COPY_MODE_" }, value = {
5841 COPY_MODE_ALL,
5842 COPY_MODE_FILTER,
5843 COPY_MODE_HISTORY
5844 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005845 @Retention(RetentionPolicy.SOURCE)
5846 public @interface CopyMode {}
5847
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005848 /**
5849 * Create an empty intent.
5850 */
5851 public Intent() {
5852 }
5853
5854 /**
5855 * Copy constructor.
5856 */
5857 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005858 this(o, COPY_MODE_ALL);
5859 }
5860
5861 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005862 this.mAction = o.mAction;
5863 this.mData = o.mData;
5864 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005865 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005866 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005867
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005868 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005869 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005870 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005871
5872 if (copyMode != COPY_MODE_FILTER) {
5873 this.mFlags = o.mFlags;
5874 this.mContentUserHint = o.mContentUserHint;
5875 this.mLaunchToken = o.mLaunchToken;
5876 if (o.mSourceBounds != null) {
5877 this.mSourceBounds = new Rect(o.mSourceBounds);
5878 }
5879 if (o.mSelector != null) {
5880 this.mSelector = new Intent(o.mSelector);
5881 }
5882
5883 if (copyMode != COPY_MODE_HISTORY) {
5884 if (o.mExtras != null) {
5885 this.mExtras = new Bundle(o.mExtras);
5886 }
5887 if (o.mClipData != null) {
5888 this.mClipData = new ClipData(o.mClipData);
5889 }
5890 } else {
5891 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5892 this.mExtras = Bundle.STRIPPED;
5893 }
5894
5895 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5896 // history.
5897 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005898 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899 }
5900
5901 @Override
5902 public Object clone() {
5903 return new Intent(this);
5904 }
5905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005906 /**
5907 * Make a clone of only the parts of the Intent that are relevant for
5908 * filter matching: the action, data, type, component, and categories.
5909 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005910 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005911 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005912 }
5913
5914 /**
5915 * Create an intent with a given action. All other fields (data, type,
5916 * class) are null. Note that the action <em>must</em> be in a
5917 * namespace because Intents are used globally in the system -- for
5918 * example the system VIEW action is android.intent.action.VIEW; an
5919 * application's custom action would be something like
5920 * com.google.app.myapp.CUSTOM_ACTION.
5921 *
5922 * @param action The Intent action, such as ACTION_VIEW.
5923 */
5924 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005925 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005926 }
5927
5928 /**
5929 * Create an intent with a given action and for a given data url. Note
5930 * that the action <em>must</em> be in a namespace because Intents are
5931 * used globally in the system -- for example the system VIEW action is
5932 * android.intent.action.VIEW; an application's custom action would be
5933 * something like com.google.app.myapp.CUSTOM_ACTION.
5934 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005935 * <p><em>Note: scheme and host name matching in the Android framework is
5936 * case-sensitive, unlike the formal RFC. As a result,
5937 * you should always ensure that you write your Uri with these elements
5938 * using lower case letters, and normalize any Uris you receive from
5939 * outside of Android to ensure the scheme and host is lower case.</em></p>
5940 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005941 * @param action The Intent action, such as ACTION_VIEW.
5942 * @param uri The Intent data URI.
5943 */
5944 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005945 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005946 mData = uri;
5947 }
5948
5949 /**
5950 * Create an intent for a specific component. All other fields (action, data,
5951 * type, class) are null, though they can be modified later with explicit
5952 * calls. This provides a convenient way to create an intent that is
5953 * intended to execute a hard-coded class name, rather than relying on the
5954 * system to find an appropriate class for you; see {@link #setComponent}
5955 * for more information on the repercussions of this.
5956 *
5957 * @param packageContext A Context of the application package implementing
5958 * this class.
5959 * @param cls The component class that is to be used for the intent.
5960 *
5961 * @see #setClass
5962 * @see #setComponent
5963 * @see #Intent(String, android.net.Uri , Context, Class)
5964 */
5965 public Intent(Context packageContext, Class<?> cls) {
5966 mComponent = new ComponentName(packageContext, cls);
5967 }
5968
5969 /**
5970 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005971 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005972 * construct the Intent and then calling {@link #setClass} to set its
5973 * class.
5974 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005975 * <p><em>Note: scheme and host name matching in the Android framework is
5976 * case-sensitive, unlike the formal RFC. As a result,
5977 * you should always ensure that you write your Uri with these elements
5978 * using lower case letters, and normalize any Uris you receive from
5979 * outside of Android to ensure the scheme and host is lower case.</em></p>
5980 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005981 * @param action The Intent action, such as ACTION_VIEW.
5982 * @param uri The Intent data URI.
5983 * @param packageContext A Context of the application package implementing
5984 * this class.
5985 * @param cls The component class that is to be used for the intent.
5986 *
5987 * @see #Intent(String, android.net.Uri)
5988 * @see #Intent(Context, Class)
5989 * @see #setClass
5990 * @see #setComponent
5991 */
5992 public Intent(String action, Uri uri,
5993 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005994 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005995 mData = uri;
5996 mComponent = new ComponentName(packageContext, cls);
5997 }
5998
5999 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006000 * Create an intent to launch the main (root) activity of a task. This
6001 * is the Intent that is started when the application's is launched from
6002 * Home. For anything else that wants to launch an application in the
6003 * same way, it is important that they use an Intent structured the same
6004 * way, and can use this function to ensure this is the case.
6005 *
6006 * <p>The returned Intent has the given Activity component as its explicit
6007 * component, {@link #ACTION_MAIN} as its action, and includes the
6008 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6009 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6010 * to do that through {@link #addFlags(int)} on the returned Intent.
6011 *
6012 * @param mainActivity The main activity component that this Intent will
6013 * launch.
6014 * @return Returns a newly created Intent that can be used to launch the
6015 * activity as a main application entry.
6016 *
6017 * @see #setClass
6018 * @see #setComponent
6019 */
6020 public static Intent makeMainActivity(ComponentName mainActivity) {
6021 Intent intent = new Intent(ACTION_MAIN);
6022 intent.setComponent(mainActivity);
6023 intent.addCategory(CATEGORY_LAUNCHER);
6024 return intent;
6025 }
6026
6027 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006028 * Make an Intent for the main activity of an application, without
6029 * specifying a specific activity to run but giving a selector to find
6030 * the activity. This results in a final Intent that is structured
6031 * the same as when the application is launched from
6032 * Home. For anything else that wants to launch an application in the
6033 * same way, it is important that they use an Intent structured the same
6034 * way, and can use this function to ensure this is the case.
6035 *
6036 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6037 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6038 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6039 * to do that through {@link #addFlags(int)} on the returned Intent.
6040 *
6041 * @param selectorAction The action name of the Intent's selector.
6042 * @param selectorCategory The name of a category to add to the Intent's
6043 * selector.
6044 * @return Returns a newly created Intent that can be used to launch the
6045 * activity as a main application entry.
6046 *
6047 * @see #setSelector(Intent)
6048 */
6049 public static Intent makeMainSelectorActivity(String selectorAction,
6050 String selectorCategory) {
6051 Intent intent = new Intent(ACTION_MAIN);
6052 intent.addCategory(CATEGORY_LAUNCHER);
6053 Intent selector = new Intent();
6054 selector.setAction(selectorAction);
6055 selector.addCategory(selectorCategory);
6056 intent.setSelector(selector);
6057 return intent;
6058 }
6059
6060 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006061 * Make an Intent that can be used to re-launch an application's task
6062 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6063 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6064 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6065 *
6066 * @param mainActivity The activity component that is the root of the
6067 * task; this is the activity that has been published in the application's
6068 * manifest as the main launcher icon.
6069 *
6070 * @return Returns a newly created Intent that can be used to relaunch the
6071 * activity's task in its root state.
6072 */
6073 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6074 Intent intent = makeMainActivity(mainActivity);
6075 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6076 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6077 return intent;
6078 }
6079
6080 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006081 * Call {@link #parseUri} with 0 flags.
6082 * @deprecated Use {@link #parseUri} instead.
6083 */
6084 @Deprecated
6085 public static Intent getIntent(String uri) throws URISyntaxException {
6086 return parseUri(uri, 0);
6087 }
Tom Taylord4a47292009-12-21 13:59:18 -08006088
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006089 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006090 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006091 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006092 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006093 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006094 *
6095 * <p>The URI given here must not be relative -- that is, it must include
6096 * the scheme and full path.
6097 *
6098 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006099 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006100 *
6101 * @return Intent The newly created Intent object.
6102 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006103 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6104 * it bad (as parsed by the Uri class) or the Intent data within the
6105 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006106 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006107 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006108 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006109 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006110 int i = 0;
6111 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006112 final boolean androidApp = uri.startsWith("android-app:");
6113
6114 // Validate intent scheme if requested.
6115 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6116 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006117 Intent intent = new Intent(ACTION_VIEW);
6118 try {
6119 intent.setData(Uri.parse(uri));
6120 } catch (IllegalArgumentException e) {
6121 throw new URISyntaxException(uri, e.getMessage());
6122 }
6123 return intent;
6124 }
6125 }
Tom Taylord4a47292009-12-21 13:59:18 -08006126
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006127 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006128 // simple case
6129 if (i == -1) {
6130 if (!androidApp) {
6131 return new Intent(ACTION_VIEW, Uri.parse(uri));
6132 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006133
6134 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006135 } else if (!uri.startsWith("#Intent;", i)) {
6136 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006137 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006138 } else {
6139 i = -1;
6140 }
6141 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006142
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006143 // new format
6144 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006145 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006146 boolean explicitAction = false;
6147 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006148
6149 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006150 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006151 String data;
6152 if (i >= 0) {
6153 data = uri.substring(0, i);
6154 i += 8; // length of "#Intent;"
6155 } else {
6156 data = uri;
6157 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006158
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006159 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006160 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006161 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006162 if (eq < 0) eq = i-1;
6163 int semi = uri.indexOf(';', i);
6164 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006165
6166 // action
6167 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006168 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006169 if (!inSelector) {
6170 explicitAction = true;
6171 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006172 }
6173
6174 // categories
6175 else if (uri.startsWith("category=", i)) {
6176 intent.addCategory(value);
6177 }
6178
6179 // type
6180 else if (uri.startsWith("type=", i)) {
6181 intent.mType = value;
6182 }
6183
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006184 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006185 else if (uri.startsWith("launchFlags=", i)) {
6186 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006187 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6188 intent.mFlags &= ~IMMUTABLE_FLAGS;
6189 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006190 }
6191
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006192 // package
6193 else if (uri.startsWith("package=", i)) {
6194 intent.mPackage = value;
6195 }
6196
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006197 // component
6198 else if (uri.startsWith("component=", i)) {
6199 intent.mComponent = ComponentName.unflattenFromString(value);
6200 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006201
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006202 // scheme
6203 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006204 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006205 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006206 } else {
6207 scheme = value;
6208 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006209 }
6210
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006211 // source bounds
6212 else if (uri.startsWith("sourceBounds=", i)) {
6213 intent.mSourceBounds = Rect.unflattenFromString(value);
6214 }
6215
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006216 // selector
6217 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6218 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006219 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006220 }
6221
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006222 // extra
6223 else {
6224 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006225 // create Bundle if it doesn't already exist
6226 if (intent.mExtras == null) intent.mExtras = new Bundle();
6227 Bundle b = intent.mExtras;
6228 // add EXTRA
6229 if (uri.startsWith("S.", i)) b.putString(key, value);
6230 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6231 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6232 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6233 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6234 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6235 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6236 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6237 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6238 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6239 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006240
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006241 // move to the next item
6242 i = semi + 1;
6243 }
6244
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006245 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006246 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006247 if (baseIntent.mPackage == null) {
6248 baseIntent.setSelector(intent);
6249 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006250 intent = baseIntent;
6251 }
6252
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006253 if (data != null) {
6254 if (data.startsWith("intent:")) {
6255 data = data.substring(7);
6256 if (scheme != null) {
6257 data = scheme + ':' + data;
6258 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006259 } else if (data.startsWith("android-app:")) {
6260 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6261 // Correctly formed android-app, first part is package name.
6262 int end = data.indexOf('/', 14);
6263 if (end < 0) {
6264 // All we have is a package name.
6265 intent.mPackage = data.substring(14);
6266 if (!explicitAction) {
6267 intent.setAction(ACTION_MAIN);
6268 }
6269 data = "";
6270 } else {
6271 // Target the Intent at the given package name always.
6272 String authority = null;
6273 intent.mPackage = data.substring(14, end);
6274 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006275 if ((end+1) < data.length()) {
6276 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6277 // Found a scheme, remember it.
6278 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006279 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006280 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6281 // Found a authority, remember it.
6282 authority = data.substring(end+1, newEnd);
6283 end = newEnd;
6284 }
6285 } else {
6286 // All we have is a scheme.
6287 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006288 }
6289 }
6290 if (scheme == null) {
6291 // If there was no scheme, then this just targets the package.
6292 if (!explicitAction) {
6293 intent.setAction(ACTION_MAIN);
6294 }
6295 data = "";
6296 } else if (authority == null) {
6297 data = scheme + ":";
6298 } else {
6299 data = scheme + "://" + authority + data.substring(end);
6300 }
6301 }
6302 } else {
6303 data = "";
6304 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006305 }
Tom Taylord4a47292009-12-21 13:59:18 -08006306
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006307 if (data.length() > 0) {
6308 try {
6309 intent.mData = Uri.parse(data);
6310 } catch (IllegalArgumentException e) {
6311 throw new URISyntaxException(uri, e.getMessage());
6312 }
6313 }
6314 }
Tom Taylord4a47292009-12-21 13:59:18 -08006315
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006316 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006317
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006318 } catch (IndexOutOfBoundsException e) {
6319 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6320 }
6321 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006322
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006323 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006324 return getIntentOld(uri, 0);
6325 }
6326
6327 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006328 Intent intent;
6329
6330 int i = uri.lastIndexOf('#');
6331 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006332 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006333 final int intentFragmentStart = i;
6334 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006335
6336 i++;
6337
6338 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006339 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006340 i += 7;
6341 int j = uri.indexOf(')', i);
6342 action = uri.substring(i, j);
6343 i = j + 1;
6344 }
6345
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006346 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006347
6348 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006349 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006350 i += 11;
6351 int j = uri.indexOf(')', i);
6352 while (i < j) {
6353 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006354 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006355 if (i < sep) {
6356 intent.addCategory(uri.substring(i, sep));
6357 }
6358 i = sep + 1;
6359 }
6360 i = j + 1;
6361 }
6362
6363 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006364 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006365 i += 5;
6366 int j = uri.indexOf(')', i);
6367 intent.mType = uri.substring(i, j);
6368 i = j + 1;
6369 }
6370
6371 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006372 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006373 i += 12;
6374 int j = uri.indexOf(')', i);
6375 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006376 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6377 intent.mFlags &= ~IMMUTABLE_FLAGS;
6378 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006379 i = j + 1;
6380 }
6381
6382 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006383 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006384 i += 10;
6385 int j = uri.indexOf(')', i);
6386 int sep = uri.indexOf('!', i);
6387 if (sep >= 0 && sep < j) {
6388 String pkg = uri.substring(i, sep);
6389 String cls = uri.substring(sep + 1, j);
6390 intent.mComponent = new ComponentName(pkg, cls);
6391 }
6392 i = j + 1;
6393 }
6394
6395 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006396 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006397 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006398
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006399 final int closeParen = uri.indexOf(')', i);
6400 if (closeParen == -1) throw new URISyntaxException(uri,
6401 "EXTRA missing trailing ')'", i);
6402
6403 while (i < closeParen) {
6404 // fetch the key value
6405 int j = uri.indexOf('=', i);
6406 if (j <= i + 1 || i >= closeParen) {
6407 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6408 }
6409 char type = uri.charAt(i);
6410 i++;
6411 String key = uri.substring(i, j);
6412 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006414 // get type-value
6415 j = uri.indexOf('!', i);
6416 if (j == -1 || j >= closeParen) j = closeParen;
6417 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6418 String value = uri.substring(i, j);
6419 i = j;
6420
6421 // create Bundle if it doesn't already exist
6422 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006423
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006424 // add item to bundle
6425 try {
6426 switch (type) {
6427 case 'S':
6428 intent.mExtras.putString(key, Uri.decode(value));
6429 break;
6430 case 'B':
6431 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6432 break;
6433 case 'b':
6434 intent.mExtras.putByte(key, Byte.parseByte(value));
6435 break;
6436 case 'c':
6437 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6438 break;
6439 case 'd':
6440 intent.mExtras.putDouble(key, Double.parseDouble(value));
6441 break;
6442 case 'f':
6443 intent.mExtras.putFloat(key, Float.parseFloat(value));
6444 break;
6445 case 'i':
6446 intent.mExtras.putInt(key, Integer.parseInt(value));
6447 break;
6448 case 'l':
6449 intent.mExtras.putLong(key, Long.parseLong(value));
6450 break;
6451 case 's':
6452 intent.mExtras.putShort(key, Short.parseShort(value));
6453 break;
6454 default:
6455 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6456 }
6457 } catch (NumberFormatException e) {
6458 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6459 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006460
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006461 char ch = uri.charAt(i);
6462 if (ch == ')') break;
6463 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6464 i++;
6465 }
6466 }
6467
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006468 if (isIntentFragment) {
6469 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6470 } else {
6471 intent.mData = Uri.parse(uri);
6472 }
Tom Taylord4a47292009-12-21 13:59:18 -08006473
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006474 if (intent.mAction == null) {
6475 // By default, if no action is specified, then use VIEW.
6476 intent.mAction = ACTION_VIEW;
6477 }
6478
6479 } else {
6480 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6481 }
6482
6483 return intent;
6484 }
6485
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006486 /** @hide */
6487 public interface CommandOptionHandler {
6488 boolean handleOption(String opt, ShellCommand cmd);
6489 }
6490
6491 /** @hide */
6492 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6493 throws URISyntaxException {
6494 Intent intent = new Intent();
6495 Intent baseIntent = intent;
6496 boolean hasIntentInfo = false;
6497
6498 Uri data = null;
6499 String type = null;
6500
6501 String opt;
6502 while ((opt=cmd.getNextOption()) != null) {
6503 switch (opt) {
6504 case "-a":
6505 intent.setAction(cmd.getNextArgRequired());
6506 if (intent == baseIntent) {
6507 hasIntentInfo = true;
6508 }
6509 break;
6510 case "-d":
6511 data = Uri.parse(cmd.getNextArgRequired());
6512 if (intent == baseIntent) {
6513 hasIntentInfo = true;
6514 }
6515 break;
6516 case "-t":
6517 type = cmd.getNextArgRequired();
6518 if (intent == baseIntent) {
6519 hasIntentInfo = true;
6520 }
6521 break;
6522 case "-c":
6523 intent.addCategory(cmd.getNextArgRequired());
6524 if (intent == baseIntent) {
6525 hasIntentInfo = true;
6526 }
6527 break;
6528 case "-e":
6529 case "--es": {
6530 String key = cmd.getNextArgRequired();
6531 String value = cmd.getNextArgRequired();
6532 intent.putExtra(key, value);
6533 }
6534 break;
6535 case "--esn": {
6536 String key = cmd.getNextArgRequired();
6537 intent.putExtra(key, (String) null);
6538 }
6539 break;
6540 case "--ei": {
6541 String key = cmd.getNextArgRequired();
6542 String value = cmd.getNextArgRequired();
6543 intent.putExtra(key, Integer.decode(value));
6544 }
6545 break;
6546 case "--eu": {
6547 String key = cmd.getNextArgRequired();
6548 String value = cmd.getNextArgRequired();
6549 intent.putExtra(key, Uri.parse(value));
6550 }
6551 break;
6552 case "--ecn": {
6553 String key = cmd.getNextArgRequired();
6554 String value = cmd.getNextArgRequired();
6555 ComponentName cn = ComponentName.unflattenFromString(value);
6556 if (cn == null)
6557 throw new IllegalArgumentException("Bad component name: " + value);
6558 intent.putExtra(key, cn);
6559 }
6560 break;
6561 case "--eia": {
6562 String key = cmd.getNextArgRequired();
6563 String value = cmd.getNextArgRequired();
6564 String[] strings = value.split(",");
6565 int[] list = new int[strings.length];
6566 for (int i = 0; i < strings.length; i++) {
6567 list[i] = Integer.decode(strings[i]);
6568 }
6569 intent.putExtra(key, list);
6570 }
6571 break;
6572 case "--eial": {
6573 String key = cmd.getNextArgRequired();
6574 String value = cmd.getNextArgRequired();
6575 String[] strings = value.split(",");
6576 ArrayList<Integer> list = new ArrayList<>(strings.length);
6577 for (int i = 0; i < strings.length; i++) {
6578 list.add(Integer.decode(strings[i]));
6579 }
6580 intent.putExtra(key, list);
6581 }
6582 break;
6583 case "--el": {
6584 String key = cmd.getNextArgRequired();
6585 String value = cmd.getNextArgRequired();
6586 intent.putExtra(key, Long.valueOf(value));
6587 }
6588 break;
6589 case "--ela": {
6590 String key = cmd.getNextArgRequired();
6591 String value = cmd.getNextArgRequired();
6592 String[] strings = value.split(",");
6593 long[] list = new long[strings.length];
6594 for (int i = 0; i < strings.length; i++) {
6595 list[i] = Long.valueOf(strings[i]);
6596 }
6597 intent.putExtra(key, list);
6598 hasIntentInfo = true;
6599 }
6600 break;
6601 case "--elal": {
6602 String key = cmd.getNextArgRequired();
6603 String value = cmd.getNextArgRequired();
6604 String[] strings = value.split(",");
6605 ArrayList<Long> list = new ArrayList<>(strings.length);
6606 for (int i = 0; i < strings.length; i++) {
6607 list.add(Long.valueOf(strings[i]));
6608 }
6609 intent.putExtra(key, list);
6610 hasIntentInfo = true;
6611 }
6612 break;
6613 case "--ef": {
6614 String key = cmd.getNextArgRequired();
6615 String value = cmd.getNextArgRequired();
6616 intent.putExtra(key, Float.valueOf(value));
6617 hasIntentInfo = true;
6618 }
6619 break;
6620 case "--efa": {
6621 String key = cmd.getNextArgRequired();
6622 String value = cmd.getNextArgRequired();
6623 String[] strings = value.split(",");
6624 float[] list = new float[strings.length];
6625 for (int i = 0; i < strings.length; i++) {
6626 list[i] = Float.valueOf(strings[i]);
6627 }
6628 intent.putExtra(key, list);
6629 hasIntentInfo = true;
6630 }
6631 break;
6632 case "--efal": {
6633 String key = cmd.getNextArgRequired();
6634 String value = cmd.getNextArgRequired();
6635 String[] strings = value.split(",");
6636 ArrayList<Float> list = new ArrayList<>(strings.length);
6637 for (int i = 0; i < strings.length; i++) {
6638 list.add(Float.valueOf(strings[i]));
6639 }
6640 intent.putExtra(key, list);
6641 hasIntentInfo = true;
6642 }
6643 break;
6644 case "--esa": {
6645 String key = cmd.getNextArgRequired();
6646 String value = cmd.getNextArgRequired();
6647 // Split on commas unless they are preceeded by an escape.
6648 // The escape character must be escaped for the string and
6649 // again for the regex, thus four escape characters become one.
6650 String[] strings = value.split("(?<!\\\\),");
6651 intent.putExtra(key, strings);
6652 hasIntentInfo = true;
6653 }
6654 break;
6655 case "--esal": {
6656 String key = cmd.getNextArgRequired();
6657 String value = cmd.getNextArgRequired();
6658 // Split on commas unless they are preceeded by an escape.
6659 // The escape character must be escaped for the string and
6660 // again for the regex, thus four escape characters become one.
6661 String[] strings = value.split("(?<!\\\\),");
6662 ArrayList<String> list = new ArrayList<>(strings.length);
6663 for (int i = 0; i < strings.length; i++) {
6664 list.add(strings[i]);
6665 }
6666 intent.putExtra(key, list);
6667 hasIntentInfo = true;
6668 }
6669 break;
6670 case "--ez": {
6671 String key = cmd.getNextArgRequired();
6672 String value = cmd.getNextArgRequired().toLowerCase();
6673 // Boolean.valueOf() results in false for anything that is not "true", which is
6674 // error-prone in shell commands
6675 boolean arg;
6676 if ("true".equals(value) || "t".equals(value)) {
6677 arg = true;
6678 } else if ("false".equals(value) || "f".equals(value)) {
6679 arg = false;
6680 } else {
6681 try {
6682 arg = Integer.decode(value) != 0;
6683 } catch (NumberFormatException ex) {
6684 throw new IllegalArgumentException("Invalid boolean value: " + value);
6685 }
6686 }
6687
6688 intent.putExtra(key, arg);
6689 }
6690 break;
6691 case "-n": {
6692 String str = cmd.getNextArgRequired();
6693 ComponentName cn = ComponentName.unflattenFromString(str);
6694 if (cn == null)
6695 throw new IllegalArgumentException("Bad component name: " + str);
6696 intent.setComponent(cn);
6697 if (intent == baseIntent) {
6698 hasIntentInfo = true;
6699 }
6700 }
6701 break;
6702 case "-p": {
6703 String str = cmd.getNextArgRequired();
6704 intent.setPackage(str);
6705 if (intent == baseIntent) {
6706 hasIntentInfo = true;
6707 }
6708 }
6709 break;
6710 case "-f":
6711 String str = cmd.getNextArgRequired();
6712 intent.setFlags(Integer.decode(str).intValue());
6713 break;
6714 case "--grant-read-uri-permission":
6715 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6716 break;
6717 case "--grant-write-uri-permission":
6718 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6719 break;
6720 case "--grant-persistable-uri-permission":
6721 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6722 break;
6723 case "--grant-prefix-uri-permission":
6724 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6725 break;
6726 case "--exclude-stopped-packages":
6727 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6728 break;
6729 case "--include-stopped-packages":
6730 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6731 break;
6732 case "--debug-log-resolution":
6733 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6734 break;
6735 case "--activity-brought-to-front":
6736 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6737 break;
6738 case "--activity-clear-top":
6739 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6740 break;
6741 case "--activity-clear-when-task-reset":
6742 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6743 break;
6744 case "--activity-exclude-from-recents":
6745 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6746 break;
6747 case "--activity-launched-from-history":
6748 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6749 break;
6750 case "--activity-multiple-task":
6751 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6752 break;
6753 case "--activity-no-animation":
6754 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6755 break;
6756 case "--activity-no-history":
6757 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6758 break;
6759 case "--activity-no-user-action":
6760 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6761 break;
6762 case "--activity-previous-is-top":
6763 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6764 break;
6765 case "--activity-reorder-to-front":
6766 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6767 break;
6768 case "--activity-reset-task-if-needed":
6769 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6770 break;
6771 case "--activity-single-top":
6772 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6773 break;
6774 case "--activity-clear-task":
6775 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6776 break;
6777 case "--activity-task-on-home":
6778 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6779 break;
6780 case "--receiver-registered-only":
6781 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6782 break;
6783 case "--receiver-replace-pending":
6784 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6785 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006786 case "--receiver-foreground":
6787 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6788 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006789 case "--receiver-no-abort":
6790 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6791 break;
6792 case "--receiver-include-background":
6793 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6794 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006795 case "--selector":
6796 intent.setDataAndType(data, type);
6797 intent = new Intent();
6798 break;
6799 default:
6800 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6801 // Okay, caller handled this option.
6802 } else {
6803 throw new IllegalArgumentException("Unknown option: " + opt);
6804 }
6805 break;
6806 }
6807 }
6808 intent.setDataAndType(data, type);
6809
6810 final boolean hasSelector = intent != baseIntent;
6811 if (hasSelector) {
6812 // A selector was specified; fix up.
6813 baseIntent.setSelector(intent);
6814 intent = baseIntent;
6815 }
6816
6817 String arg = cmd.getNextArg();
6818 baseIntent = null;
6819 if (arg == null) {
6820 if (hasSelector) {
6821 // If a selector has been specified, and no arguments
6822 // have been supplied for the main Intent, then we can
6823 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6824 // need to have a component name specified yet, the
6825 // selector will take care of that.
6826 baseIntent = new Intent(Intent.ACTION_MAIN);
6827 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6828 }
6829 } else if (arg.indexOf(':') >= 0) {
6830 // The argument is a URI. Fully parse it, and use that result
6831 // to fill in any data not specified so far.
6832 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6833 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6834 } else if (arg.indexOf('/') >= 0) {
6835 // The argument is a component name. Build an Intent to launch
6836 // it.
6837 baseIntent = new Intent(Intent.ACTION_MAIN);
6838 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6839 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6840 } else {
6841 // Assume the argument is a package name.
6842 baseIntent = new Intent(Intent.ACTION_MAIN);
6843 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6844 baseIntent.setPackage(arg);
6845 }
6846 if (baseIntent != null) {
6847 Bundle extras = intent.getExtras();
6848 intent.replaceExtras((Bundle)null);
6849 Bundle uriExtras = baseIntent.getExtras();
6850 baseIntent.replaceExtras((Bundle)null);
6851 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6852 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6853 for (String c : cats) {
6854 baseIntent.removeCategory(c);
6855 }
6856 }
6857 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6858 if (extras == null) {
6859 extras = uriExtras;
6860 } else if (uriExtras != null) {
6861 uriExtras.putAll(extras);
6862 extras = uriExtras;
6863 }
6864 intent.replaceExtras(extras);
6865 hasIntentInfo = true;
6866 }
6867
6868 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6869 return intent;
6870 }
6871
6872 /** @hide */
6873 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6874 final String[] lines = new String[] {
6875 "<INTENT> specifications include these flags and arguments:",
6876 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6877 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6878 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6879 " [--esn <EXTRA_KEY> ...]",
6880 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6881 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6882 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6883 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6884 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6885 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6886 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6887 " (mutiple extras passed as Integer[])",
6888 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6889 " (mutiple extras passed as List<Integer>)",
6890 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6891 " (mutiple extras passed as Long[])",
6892 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6893 " (mutiple extras passed as List<Long>)",
6894 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6895 " (mutiple extras passed as Float[])",
6896 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6897 " (mutiple extras passed as List<Float>)",
6898 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6899 " (mutiple extras passed as String[]; to embed a comma into a string,",
6900 " escape it using \"\\,\")",
6901 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6902 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6903 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006904 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006905 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6906 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6907 " [--debug-log-resolution] [--exclude-stopped-packages]",
6908 " [--include-stopped-packages]",
6909 " [--activity-brought-to-front] [--activity-clear-top]",
6910 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6911 " [--activity-launched-from-history] [--activity-multiple-task]",
6912 " [--activity-no-animation] [--activity-no-history]",
6913 " [--activity-no-user-action] [--activity-previous-is-top]",
6914 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6915 " [--activity-single-top] [--activity-clear-task]",
6916 " [--activity-task-on-home]",
6917 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006918 " [--receiver-foreground] [--receiver-no-abort]",
6919 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006920 " [--selector]",
6921 " [<URI> | <PACKAGE> | <COMPONENT>]"
6922 };
6923 for (String line : lines) {
6924 pw.print(prefix);
6925 pw.println(line);
6926 }
6927 }
6928
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006929 /**
6930 * Retrieve the general action to be performed, such as
6931 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6932 * the information in the intent should be interpreted -- most importantly,
6933 * what to do with the data returned by {@link #getData}.
6934 *
6935 * @return The action of this intent or null if none is specified.
6936 *
6937 * @see #setAction
6938 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006939 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 return mAction;
6941 }
6942
6943 /**
6944 * Retrieve data this intent is operating on. This URI specifies the name
6945 * of the data; often it uses the content: scheme, specifying data in a
6946 * content provider. Other schemes may be handled by specific activities,
6947 * such as http: by the web browser.
6948 *
6949 * @return The URI of the data this intent is targeting or null.
6950 *
6951 * @see #getScheme
6952 * @see #setData
6953 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006954 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006955 return mData;
6956 }
6957
6958 /**
6959 * The same as {@link #getData()}, but returns the URI as an encoded
6960 * String.
6961 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006962 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006963 return mData != null ? mData.toString() : null;
6964 }
6965
6966 /**
6967 * Return the scheme portion of the intent's data. If the data is null or
6968 * does not include a scheme, null is returned. Otherwise, the scheme
6969 * prefix without the final ':' is returned, i.e. "http".
6970 *
6971 * <p>This is the same as calling getData().getScheme() (and checking for
6972 * null data).
6973 *
6974 * @return The scheme of this intent.
6975 *
6976 * @see #getData
6977 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006978 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006979 return mData != null ? mData.getScheme() : null;
6980 }
6981
6982 /**
6983 * Retrieve any explicit MIME type included in the intent. This is usually
6984 * null, as the type is determined by the intent data.
6985 *
6986 * @return If a type was manually set, it is returned; else null is
6987 * returned.
6988 *
6989 * @see #resolveType(ContentResolver)
6990 * @see #setType
6991 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006992 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006993 return mType;
6994 }
6995
6996 /**
6997 * Return the MIME data type of this intent. If the type field is
6998 * explicitly set, that is simply returned. Otherwise, if the data is set,
6999 * the type of that data is returned. If neither fields are set, a null is
7000 * returned.
7001 *
7002 * @return The MIME type of this intent.
7003 *
7004 * @see #getType
7005 * @see #resolveType(ContentResolver)
7006 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007007 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007008 return resolveType(context.getContentResolver());
7009 }
7010
7011 /**
7012 * Return the MIME data type of this intent. If the type field is
7013 * explicitly set, that is simply returned. Otherwise, if the data is set,
7014 * the type of that data is returned. If neither fields are set, a null is
7015 * returned.
7016 *
7017 * @param resolver A ContentResolver that can be used to determine the MIME
7018 * type of the intent's data.
7019 *
7020 * @return The MIME type of this intent.
7021 *
7022 * @see #getType
7023 * @see #resolveType(Context)
7024 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007025 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007026 if (mType != null) {
7027 return mType;
7028 }
7029 if (mData != null) {
7030 if ("content".equals(mData.getScheme())) {
7031 return resolver.getType(mData);
7032 }
7033 }
7034 return null;
7035 }
7036
7037 /**
7038 * Return the MIME data type of this intent, only if it will be needed for
7039 * intent resolution. This is not generally useful for application code;
7040 * it is used by the frameworks for communicating with back-end system
7041 * services.
7042 *
7043 * @param resolver A ContentResolver that can be used to determine the MIME
7044 * type of the intent's data.
7045 *
7046 * @return The MIME type of this intent, or null if it is unknown or not
7047 * needed.
7048 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007049 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007050 if (mComponent != null) {
7051 return mType;
7052 }
7053 return resolveType(resolver);
7054 }
7055
7056 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007057 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007058 *
7059 * @param category The category to check.
7060 *
7061 * @return boolean True if the intent contains the category, else false.
7062 *
7063 * @see #getCategories
7064 * @see #addCategory
7065 */
7066 public boolean hasCategory(String category) {
7067 return mCategories != null && mCategories.contains(category);
7068 }
7069
7070 /**
7071 * Return the set of all categories in the intent. If there are no categories,
7072 * returns NULL.
7073 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007074 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007075 *
7076 * @see #hasCategory
7077 * @see #addCategory
7078 */
7079 public Set<String> getCategories() {
7080 return mCategories;
7081 }
7082
7083 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007084 * Return the specific selector associated with this Intent. If there is
7085 * none, returns null. See {@link #setSelector} for more information.
7086 *
7087 * @see #setSelector
7088 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007089 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007090 return mSelector;
7091 }
7092
7093 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007094 * Return the {@link ClipData} associated with this Intent. If there is
7095 * none, returns null. See {@link #setClipData} for more information.
7096 *
John Spurlock125d1332013-11-25 11:58:37 -05007097 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007098 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007099 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007100 return mClipData;
7101 }
7102
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007103 /** @hide */
7104 public int getContentUserHint() {
7105 return mContentUserHint;
7106 }
7107
Todd Kennedyb3b431302017-03-20 16:05:48 -07007108 /** @hide */
7109 public String getLaunchToken() {
7110 return mLaunchToken;
7111 }
7112
7113 /** @hide */
7114 public void setLaunchToken(String launchToken) {
7115 mLaunchToken = launchToken;
7116 }
7117
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007118 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007119 * Sets the ClassLoader that will be used when unmarshalling
7120 * any Parcelable values from the extras of this Intent.
7121 *
7122 * @param loader a ClassLoader, or null to use the default loader
7123 * at the time of unmarshalling.
7124 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007125 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007126 if (mExtras != null) {
7127 mExtras.setClassLoader(loader);
7128 }
7129 }
7130
7131 /**
7132 * Returns true if an extra value is associated with the given name.
7133 * @param name the extra's name
7134 * @return true if the given extra is present.
7135 */
7136 public boolean hasExtra(String name) {
7137 return mExtras != null && mExtras.containsKey(name);
7138 }
7139
7140 /**
7141 * Returns true if the Intent's extras contain a parcelled file descriptor.
7142 * @return true if the Intent contains a parcelled file descriptor.
7143 */
7144 public boolean hasFileDescriptors() {
7145 return mExtras != null && mExtras.hasFileDescriptors();
7146 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007147
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007148 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007149 public void setAllowFds(boolean allowFds) {
7150 if (mExtras != null) {
7151 mExtras.setAllowFds(allowFds);
7152 }
7153 }
7154
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007155 /** {@hide} */
7156 public void setDefusable(boolean defusable) {
7157 if (mExtras != null) {
7158 mExtras.setDefusable(defusable);
7159 }
7160 }
7161
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007162 /**
7163 * Retrieve extended data from the intent.
7164 *
7165 * @param name The name of the desired item.
7166 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007167 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007168 * or null if none was found.
7169 *
7170 * @deprecated
7171 * @hide
7172 */
7173 @Deprecated
7174 public Object getExtra(String name) {
7175 return getExtra(name, null);
7176 }
7177
7178 /**
7179 * Retrieve extended data from the intent.
7180 *
7181 * @param name The name of the desired item.
7182 * @param defaultValue the value to be returned if no value of the desired
7183 * type is stored with the given name.
7184 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007185 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007186 * or the default value if none was found.
7187 *
7188 * @see #putExtra(String, boolean)
7189 */
7190 public boolean getBooleanExtra(String name, boolean defaultValue) {
7191 return mExtras == null ? defaultValue :
7192 mExtras.getBoolean(name, defaultValue);
7193 }
7194
7195 /**
7196 * Retrieve extended data from the intent.
7197 *
7198 * @param name The name of the desired item.
7199 * @param defaultValue the value to be returned if no value of the desired
7200 * type is stored with the given name.
7201 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007202 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007203 * or the default value if none was found.
7204 *
7205 * @see #putExtra(String, byte)
7206 */
7207 public byte getByteExtra(String name, byte defaultValue) {
7208 return mExtras == null ? defaultValue :
7209 mExtras.getByte(name, defaultValue);
7210 }
7211
7212 /**
7213 * Retrieve extended data from the intent.
7214 *
7215 * @param name The name of the desired item.
7216 * @param defaultValue the value to be returned if no value of the desired
7217 * type is stored with the given name.
7218 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007219 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007220 * or the default value if none was found.
7221 *
7222 * @see #putExtra(String, short)
7223 */
7224 public short getShortExtra(String name, short defaultValue) {
7225 return mExtras == null ? defaultValue :
7226 mExtras.getShort(name, defaultValue);
7227 }
7228
7229 /**
7230 * Retrieve extended data from the intent.
7231 *
7232 * @param name The name of the desired item.
7233 * @param defaultValue the value to be returned if no value of the desired
7234 * type is stored with the given name.
7235 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007236 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007237 * or the default value if none was found.
7238 *
7239 * @see #putExtra(String, char)
7240 */
7241 public char getCharExtra(String name, char defaultValue) {
7242 return mExtras == null ? defaultValue :
7243 mExtras.getChar(name, defaultValue);
7244 }
7245
7246 /**
7247 * Retrieve extended data from the intent.
7248 *
7249 * @param name The name of the desired item.
7250 * @param defaultValue the value to be returned if no value of the desired
7251 * type is stored with the given name.
7252 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007253 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007254 * or the default value if none was found.
7255 *
7256 * @see #putExtra(String, int)
7257 */
7258 public int getIntExtra(String name, int defaultValue) {
7259 return mExtras == null ? defaultValue :
7260 mExtras.getInt(name, defaultValue);
7261 }
7262
7263 /**
7264 * Retrieve extended data from the intent.
7265 *
7266 * @param name The name of the desired item.
7267 * @param defaultValue the value to be returned if no value of the desired
7268 * type is stored with the given name.
7269 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007270 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007271 * or the default value if none was found.
7272 *
7273 * @see #putExtra(String, long)
7274 */
7275 public long getLongExtra(String name, long defaultValue) {
7276 return mExtras == null ? defaultValue :
7277 mExtras.getLong(name, defaultValue);
7278 }
7279
7280 /**
7281 * Retrieve extended data from the intent.
7282 *
7283 * @param name The name of the desired item.
7284 * @param defaultValue the value to be returned if no value of the desired
7285 * type is stored with the given name.
7286 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007287 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007288 * or the default value if no such item is present
7289 *
7290 * @see #putExtra(String, float)
7291 */
7292 public float getFloatExtra(String name, float defaultValue) {
7293 return mExtras == null ? defaultValue :
7294 mExtras.getFloat(name, defaultValue);
7295 }
7296
7297 /**
7298 * Retrieve extended data from the intent.
7299 *
7300 * @param name The name of the desired item.
7301 * @param defaultValue the value to be returned if no value of the desired
7302 * type is stored with the given name.
7303 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007304 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007305 * or the default value if none was found.
7306 *
7307 * @see #putExtra(String, double)
7308 */
7309 public double getDoubleExtra(String name, double defaultValue) {
7310 return mExtras == null ? defaultValue :
7311 mExtras.getDouble(name, defaultValue);
7312 }
7313
7314 /**
7315 * Retrieve extended data from the intent.
7316 *
7317 * @param name The name of the desired item.
7318 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007319 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007320 * or null if no String value was found.
7321 *
7322 * @see #putExtra(String, String)
7323 */
7324 public String getStringExtra(String name) {
7325 return mExtras == null ? null : mExtras.getString(name);
7326 }
7327
7328 /**
7329 * Retrieve extended data from the intent.
7330 *
7331 * @param name The name of the desired item.
7332 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007333 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007334 * or null if no CharSequence value was found.
7335 *
7336 * @see #putExtra(String, CharSequence)
7337 */
7338 public CharSequence getCharSequenceExtra(String name) {
7339 return mExtras == null ? null : mExtras.getCharSequence(name);
7340 }
7341
7342 /**
7343 * Retrieve extended data from the intent.
7344 *
7345 * @param name The name of the desired item.
7346 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007347 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007348 * or null if no Parcelable value was found.
7349 *
7350 * @see #putExtra(String, Parcelable)
7351 */
7352 public <T extends Parcelable> T getParcelableExtra(String name) {
7353 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7354 }
7355
7356 /**
7357 * Retrieve extended data from the intent.
7358 *
7359 * @param name The name of the desired item.
7360 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007361 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007362 * or null if no Parcelable[] value was found.
7363 *
7364 * @see #putExtra(String, Parcelable[])
7365 */
7366 public Parcelable[] getParcelableArrayExtra(String name) {
7367 return mExtras == null ? null : mExtras.getParcelableArray(name);
7368 }
7369
7370 /**
7371 * Retrieve extended data from the intent.
7372 *
7373 * @param name The name of the desired item.
7374 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007375 * @return the value of an item previously added with
7376 * putParcelableArrayListExtra(), or null if no
7377 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007378 *
7379 * @see #putParcelableArrayListExtra(String, ArrayList)
7380 */
7381 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7382 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7383 }
7384
7385 /**
7386 * Retrieve extended data from the intent.
7387 *
7388 * @param name The name of the desired item.
7389 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007390 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007391 * or null if no Serializable value was found.
7392 *
7393 * @see #putExtra(String, Serializable)
7394 */
7395 public Serializable getSerializableExtra(String name) {
7396 return mExtras == null ? null : mExtras.getSerializable(name);
7397 }
7398
7399 /**
7400 * Retrieve extended data from the intent.
7401 *
7402 * @param name The name of the desired item.
7403 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007404 * @return the value of an item previously added with
7405 * putIntegerArrayListExtra(), or null if no
7406 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007407 *
7408 * @see #putIntegerArrayListExtra(String, ArrayList)
7409 */
7410 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7411 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7412 }
7413
7414 /**
7415 * Retrieve extended data from the intent.
7416 *
7417 * @param name The name of the desired item.
7418 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007419 * @return the value of an item previously added with
7420 * putStringArrayListExtra(), or null if no
7421 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007422 *
7423 * @see #putStringArrayListExtra(String, ArrayList)
7424 */
7425 public ArrayList<String> getStringArrayListExtra(String name) {
7426 return mExtras == null ? null : mExtras.getStringArrayList(name);
7427 }
7428
7429 /**
7430 * Retrieve extended data from the intent.
7431 *
7432 * @param name The name of the desired item.
7433 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007434 * @return the value of an item previously added with
7435 * putCharSequenceArrayListExtra, or null if no
7436 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007437 *
7438 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7439 */
7440 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7441 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7442 }
7443
7444 /**
7445 * Retrieve extended data from the intent.
7446 *
7447 * @param name The name of the desired item.
7448 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007449 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007450 * or null if no boolean array value was found.
7451 *
7452 * @see #putExtra(String, boolean[])
7453 */
7454 public boolean[] getBooleanArrayExtra(String name) {
7455 return mExtras == null ? null : mExtras.getBooleanArray(name);
7456 }
7457
7458 /**
7459 * Retrieve extended data from the intent.
7460 *
7461 * @param name The name of the desired item.
7462 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007463 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007464 * or null if no byte array value was found.
7465 *
7466 * @see #putExtra(String, byte[])
7467 */
7468 public byte[] getByteArrayExtra(String name) {
7469 return mExtras == null ? null : mExtras.getByteArray(name);
7470 }
7471
7472 /**
7473 * Retrieve extended data from the intent.
7474 *
7475 * @param name The name of the desired item.
7476 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007477 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007478 * or null if no short array value was found.
7479 *
7480 * @see #putExtra(String, short[])
7481 */
7482 public short[] getShortArrayExtra(String name) {
7483 return mExtras == null ? null : mExtras.getShortArray(name);
7484 }
7485
7486 /**
7487 * Retrieve extended data from the intent.
7488 *
7489 * @param name The name of the desired item.
7490 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007491 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007492 * or null if no char array value was found.
7493 *
7494 * @see #putExtra(String, char[])
7495 */
7496 public char[] getCharArrayExtra(String name) {
7497 return mExtras == null ? null : mExtras.getCharArray(name);
7498 }
7499
7500 /**
7501 * Retrieve extended data from the intent.
7502 *
7503 * @param name The name of the desired item.
7504 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007505 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007506 * or null if no int array value was found.
7507 *
7508 * @see #putExtra(String, int[])
7509 */
7510 public int[] getIntArrayExtra(String name) {
7511 return mExtras == null ? null : mExtras.getIntArray(name);
7512 }
7513
7514 /**
7515 * Retrieve extended data from the intent.
7516 *
7517 * @param name The name of the desired item.
7518 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007519 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007520 * or null if no long array value was found.
7521 *
7522 * @see #putExtra(String, long[])
7523 */
7524 public long[] getLongArrayExtra(String name) {
7525 return mExtras == null ? null : mExtras.getLongArray(name);
7526 }
7527
7528 /**
7529 * Retrieve extended data from the intent.
7530 *
7531 * @param name The name of the desired item.
7532 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007533 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007534 * or null if no float array value was found.
7535 *
7536 * @see #putExtra(String, float[])
7537 */
7538 public float[] getFloatArrayExtra(String name) {
7539 return mExtras == null ? null : mExtras.getFloatArray(name);
7540 }
7541
7542 /**
7543 * Retrieve extended data from the intent.
7544 *
7545 * @param name The name of the desired item.
7546 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007547 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007548 * or null if no double array value was found.
7549 *
7550 * @see #putExtra(String, double[])
7551 */
7552 public double[] getDoubleArrayExtra(String name) {
7553 return mExtras == null ? null : mExtras.getDoubleArray(name);
7554 }
7555
7556 /**
7557 * Retrieve extended data from the intent.
7558 *
7559 * @param name The name of the desired item.
7560 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007561 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007562 * or null if no String array value was found.
7563 *
7564 * @see #putExtra(String, String[])
7565 */
7566 public String[] getStringArrayExtra(String name) {
7567 return mExtras == null ? null : mExtras.getStringArray(name);
7568 }
7569
7570 /**
7571 * Retrieve extended data from the intent.
7572 *
7573 * @param name The name of the desired item.
7574 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007575 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007576 * or null if no CharSequence array value was found.
7577 *
7578 * @see #putExtra(String, CharSequence[])
7579 */
7580 public CharSequence[] getCharSequenceArrayExtra(String name) {
7581 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7582 }
7583
7584 /**
7585 * Retrieve extended data from the intent.
7586 *
7587 * @param name The name of the desired item.
7588 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007589 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007590 * or null if no Bundle value was found.
7591 *
7592 * @see #putExtra(String, Bundle)
7593 */
7594 public Bundle getBundleExtra(String name) {
7595 return mExtras == null ? null : mExtras.getBundle(name);
7596 }
7597
7598 /**
7599 * Retrieve extended data from the intent.
7600 *
7601 * @param name The name of the desired item.
7602 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007603 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007604 * or null if no IBinder value was found.
7605 *
7606 * @see #putExtra(String, IBinder)
7607 *
7608 * @deprecated
7609 * @hide
7610 */
7611 @Deprecated
7612 public IBinder getIBinderExtra(String name) {
7613 return mExtras == null ? null : mExtras.getIBinder(name);
7614 }
7615
7616 /**
7617 * Retrieve extended data from the intent.
7618 *
7619 * @param name The name of the desired item.
7620 * @param defaultValue The default value to return in case no item is
7621 * associated with the key 'name'
7622 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007623 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007624 * or defaultValue if none was found.
7625 *
7626 * @see #putExtra
7627 *
7628 * @deprecated
7629 * @hide
7630 */
7631 @Deprecated
7632 public Object getExtra(String name, Object defaultValue) {
7633 Object result = defaultValue;
7634 if (mExtras != null) {
7635 Object result2 = mExtras.get(name);
7636 if (result2 != null) {
7637 result = result2;
7638 }
7639 }
7640
7641 return result;
7642 }
7643
7644 /**
7645 * Retrieves a map of extended data from the intent.
7646 *
7647 * @return the map of all extras previously added with putExtra(),
7648 * or null if none have been added.
7649 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007650 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007651 return (mExtras != null)
7652 ? new Bundle(mExtras)
7653 : null;
7654 }
7655
7656 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007657 * Filter extras to only basic types.
7658 * @hide
7659 */
7660 public void removeUnsafeExtras() {
7661 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007662 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007663 }
7664 }
7665
7666 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007667 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7668 * return itself as-is.
7669 * @hide
7670 */
7671 public boolean canStripForHistory() {
7672 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7673 }
7674
7675 /**
7676 * Call it when the system needs to keep an intent for logging purposes to remove fields
7677 * that are not needed for logging.
7678 * @hide
7679 */
7680 public Intent maybeStripForHistory() {
7681 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7682
7683 if (!canStripForHistory()) {
7684 return this;
7685 }
7686 return new Intent(this, COPY_MODE_HISTORY);
7687 }
7688
7689 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007690 * Retrieve any special flags associated with this intent. You will
7691 * normally just set them with {@link #setFlags} and let the system
7692 * take the appropriate action with them.
7693 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007694 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007696 * @see #addFlags
7697 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007698 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007699 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007700 return mFlags;
7701 }
7702
Dianne Hackborne7f97212011-02-24 14:40:20 -08007703 /** @hide */
7704 public boolean isExcludingStopped() {
7705 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7706 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7707 }
7708
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007709 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007710 * Retrieve the application package name this Intent is limited to. When
7711 * resolving an Intent, if non-null this limits the resolution to only
7712 * components in the given application package.
7713 *
7714 * @return The name of the application package for the Intent.
7715 *
7716 * @see #resolveActivity
7717 * @see #setPackage
7718 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007719 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007720 return mPackage;
7721 }
7722
7723 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007724 * Retrieve the concrete component associated with the intent. When receiving
7725 * an intent, this is the component that was found to best handle it (that is,
7726 * yourself) and will always be non-null; in all other cases it will be
7727 * null unless explicitly set.
7728 *
7729 * @return The name of the application component to handle the intent.
7730 *
7731 * @see #resolveActivity
7732 * @see #setComponent
7733 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007734 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007735 return mComponent;
7736 }
7737
7738 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007739 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7740 * used as a hint to the receiver for animations and the like. Null means that there
7741 * is no source bounds.
7742 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007743 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007744 return mSourceBounds;
7745 }
7746
7747 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007748 * Return the Activity component that should be used to handle this intent.
7749 * The appropriate component is determined based on the information in the
7750 * intent, evaluated as follows:
7751 *
7752 * <p>If {@link #getComponent} returns an explicit class, that is returned
7753 * without any further consideration.
7754 *
7755 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7756 * category to be considered.
7757 *
7758 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7759 * action.
7760 *
7761 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7762 * this type.
7763 *
7764 * <p>If {@link #addCategory} has added any categories, the activity must
7765 * handle ALL of the categories specified.
7766 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007767 * <p>If {@link #getPackage} is non-NULL, only activity components in
7768 * that application package will be considered.
7769 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007770 * <p>If there are no activities that satisfy all of these conditions, a
7771 * null string is returned.
7772 *
7773 * <p>If multiple activities are found to satisfy the intent, the one with
7774 * the highest priority will be used. If there are multiple activities
7775 * with the same priority, the system will either pick the best activity
7776 * based on user preference, or resolve to a system class that will allow
7777 * the user to pick an activity and forward from there.
7778 *
7779 * <p>This method is implemented simply by calling
7780 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7781 * true.</p>
7782 * <p> This API is called for you as part of starting an activity from an
7783 * intent. You do not normally need to call it yourself.</p>
7784 *
7785 * @param pm The package manager with which to resolve the Intent.
7786 *
7787 * @return Name of the component implementing an activity that can
7788 * display the intent.
7789 *
7790 * @see #setComponent
7791 * @see #getComponent
7792 * @see #resolveActivityInfo
7793 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007794 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 if (mComponent != null) {
7796 return mComponent;
7797 }
7798
7799 ResolveInfo info = pm.resolveActivity(
7800 this, PackageManager.MATCH_DEFAULT_ONLY);
7801 if (info != null) {
7802 return new ComponentName(
7803 info.activityInfo.applicationInfo.packageName,
7804 info.activityInfo.name);
7805 }
7806
7807 return null;
7808 }
7809
7810 /**
7811 * Resolve the Intent into an {@link ActivityInfo}
7812 * describing the activity that should execute the intent. Resolution
7813 * follows the same rules as described for {@link #resolveActivity}, but
7814 * you get back the completely information about the resolved activity
7815 * instead of just its class name.
7816 *
7817 * @param pm The package manager with which to resolve the Intent.
7818 * @param flags Addition information to retrieve as per
7819 * {@link PackageManager#getActivityInfo(ComponentName, int)
7820 * PackageManager.getActivityInfo()}.
7821 *
7822 * @return PackageManager.ActivityInfo
7823 *
7824 * @see #resolveActivity
7825 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007826 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7827 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007828 ActivityInfo ai = null;
7829 if (mComponent != null) {
7830 try {
7831 ai = pm.getActivityInfo(mComponent, flags);
7832 } catch (PackageManager.NameNotFoundException e) {
7833 // ignore
7834 }
7835 } else {
7836 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007837 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 if (info != null) {
7839 ai = info.activityInfo;
7840 }
7841 }
7842
7843 return ai;
7844 }
7845
7846 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007847 * Special function for use by the system to resolve service
7848 * intents to system apps. Throws an exception if there are
7849 * multiple potential matches to the Intent. Returns null if
7850 * there are no matches.
7851 * @hide
7852 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007853 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7854 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007855 if (mComponent != null) {
7856 return mComponent;
7857 }
7858
7859 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7860 if (results == null) {
7861 return null;
7862 }
7863 ComponentName comp = null;
7864 for (int i=0; i<results.size(); i++) {
7865 ResolveInfo ri = results.get(i);
7866 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7867 continue;
7868 }
7869 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7870 ri.serviceInfo.name);
7871 if (comp != null) {
7872 throw new IllegalStateException("Multiple system services handle " + this
7873 + ": " + comp + ", " + foundComp);
7874 }
7875 comp = foundComp;
7876 }
7877 return comp;
7878 }
7879
7880 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007881 * Set the general action to be performed.
7882 *
7883 * @param action An action name, such as ACTION_VIEW. Application-specific
7884 * actions should be prefixed with the vendor's package name.
7885 *
7886 * @return Returns the same Intent object, for chaining multiple calls
7887 * into a single statement.
7888 *
7889 * @see #getAction
7890 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007891 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007892 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007893 return this;
7894 }
7895
7896 /**
7897 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007898 * clears any type that was previously set by {@link #setType} or
7899 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007900 *
Nick Pellyccae4122012-01-09 14:12:58 -08007901 * <p><em>Note: scheme matching in the Android framework is
7902 * case-sensitive, unlike the formal RFC. As a result,
7903 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007904 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007905 * {@link #setDataAndNormalize}
7906 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007907 *
Nick Pellyccae4122012-01-09 14:12:58 -08007908 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007909 *
7910 * @return Returns the same Intent object, for chaining multiple calls
7911 * into a single statement.
7912 *
7913 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007914 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007915 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007916 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007917 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007918 mData = data;
7919 mType = null;
7920 return this;
7921 }
7922
7923 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007924 * Normalize and set the data this intent is operating on.
7925 *
7926 * <p>This method automatically clears any type that was
7927 * previously set (for example, by {@link #setType}).
7928 *
7929 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007930 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007931 * so really this is just a convenience method for
7932 * <pre>
7933 * setData(data.normalize())
7934 * </pre>
7935 *
7936 * @param data The Uri of the data this intent is now targeting.
7937 *
7938 * @return Returns the same Intent object, for chaining multiple calls
7939 * into a single statement.
7940 *
7941 * @see #getData
7942 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007943 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007944 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007945 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007946 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007947 }
7948
7949 /**
7950 * Set an explicit MIME data type.
7951 *
7952 * <p>This is used to create intents that only specify a type and not data,
7953 * for example to indicate the type of data to return.
7954 *
7955 * <p>This method automatically clears any data that was
7956 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007957 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007958 * <p><em>Note: MIME type matching in the Android framework is
7959 * case-sensitive, unlike formal RFC MIME types. As a result,
7960 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007961 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7962 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007963 *
7964 * @param type The MIME type of the data being handled by this intent.
7965 *
7966 * @return Returns the same Intent object, for chaining multiple calls
7967 * into a single statement.
7968 *
7969 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007970 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007971 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007972 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007973 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007974 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007975 mData = null;
7976 mType = type;
7977 return this;
7978 }
7979
7980 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007981 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007982 *
Nick Pellyccae4122012-01-09 14:12:58 -08007983 * <p>This is used to create intents that only specify a type and not data,
7984 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007985 *
Nick Pellyccae4122012-01-09 14:12:58 -08007986 * <p>This method automatically clears any data that was
7987 * previously set (for example by {@link #setData}).
7988 *
7989 * <p>The MIME type is normalized using
7990 * {@link #normalizeMimeType} before it is set,
7991 * so really this is just a convenience method for
7992 * <pre>
7993 * setType(Intent.normalizeMimeType(type))
7994 * </pre>
7995 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007996 * @param type The MIME type of the data being handled by this intent.
7997 *
7998 * @return Returns the same Intent object, for chaining multiple calls
7999 * into a single statement.
8000 *
Nick Pellyccae4122012-01-09 14:12:58 -08008001 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008002 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008003 * @see #normalizeMimeType
8004 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008005 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008006 return setType(normalizeMimeType(type));
8007 }
8008
8009 /**
8010 * (Usually optional) Set the data for the intent along with an explicit
8011 * MIME data type. This method should very rarely be used -- it allows you
8012 * to override the MIME type that would ordinarily be inferred from the
8013 * data with your own type given here.
8014 *
8015 * <p><em>Note: MIME type and Uri scheme matching in the
8016 * Android framework is case-sensitive, unlike the formal RFC definitions.
8017 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008018 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008019 * {@link #setDataAndTypeAndNormalize}
8020 * to ensure that they are converted to lower case.</em>
8021 *
8022 * @param data The Uri of the data this intent is now targeting.
8023 * @param type The MIME type of the data being handled by this intent.
8024 *
8025 * @return Returns the same Intent object, for chaining multiple calls
8026 * into a single statement.
8027 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008028 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008029 * @see #setData
8030 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008031 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008032 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008033 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008034 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008035 mData = data;
8036 mType = type;
8037 return this;
8038 }
8039
8040 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008041 * (Usually optional) Normalize and set both the data Uri and an explicit
8042 * MIME data type. This method should very rarely be used -- it allows you
8043 * to override the MIME type that would ordinarily be inferred from the
8044 * data with your own type given here.
8045 *
8046 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008047 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008048 * before they are set, so really this is just a convenience method for
8049 * <pre>
8050 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8051 * </pre>
8052 *
8053 * @param data The Uri of the data this intent is now targeting.
8054 * @param type The MIME type of the data being handled by this intent.
8055 *
8056 * @return Returns the same Intent object, for chaining multiple calls
8057 * into a single statement.
8058 *
8059 * @see #setType
8060 * @see #setData
8061 * @see #setDataAndType
8062 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008063 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008064 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008065 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008066 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008067 }
8068
8069 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008071 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008072 * activities that provide <em>all</em> of the requested categories will be
8073 * used.
8074 *
8075 * @param category The desired category. This can be either one of the
8076 * predefined Intent categories, or a custom category in your own
8077 * namespace.
8078 *
8079 * @return Returns the same Intent object, for chaining multiple calls
8080 * into a single statement.
8081 *
8082 * @see #hasCategory
8083 * @see #removeCategory
8084 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008085 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008086 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008087 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008088 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008089 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008090 return this;
8091 }
8092
8093 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008094 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008095 *
8096 * @param category The category to remove.
8097 *
8098 * @see #addCategory
8099 */
8100 public void removeCategory(String category) {
8101 if (mCategories != null) {
8102 mCategories.remove(category);
8103 if (mCategories.size() == 0) {
8104 mCategories = null;
8105 }
8106 }
8107 }
8108
8109 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008110 * Set a selector for this Intent. This is a modification to the kinds of
8111 * things the Intent will match. If the selector is set, it will be used
8112 * when trying to find entities that can handle the Intent, instead of the
8113 * main contents of the Intent. This allows you build an Intent containing
8114 * a generic protocol while targeting it more specifically.
8115 *
8116 * <p>An example of where this may be used is with things like
8117 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8118 * Intent that will launch the Browser application. However, the correct
8119 * main entry point of an application is actually {@link #ACTION_MAIN}
8120 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8121 * used to specify the actual Activity to launch. If you launch the browser
8122 * with something different, undesired behavior may happen if the user has
8123 * previously or later launches it the normal way, since they do not match.
8124 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8125 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8126 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8127 *
8128 * <p>Setting a selector does not impact the behavior of
8129 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8130 * desired behavior of a selector -- it does not impact the base meaning
8131 * of the Intent, just what kinds of things will be matched against it
8132 * when determining who can handle it.</p>
8133 *
8134 * <p>You can not use both a selector and {@link #setPackage(String)} on
8135 * the same base Intent.</p>
8136 *
8137 * @param selector The desired selector Intent; set to null to not use
8138 * a special selector.
8139 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008140 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008141 if (selector == this) {
8142 throw new IllegalArgumentException(
8143 "Intent being set as a selector of itself");
8144 }
8145 if (selector != null && mPackage != null) {
8146 throw new IllegalArgumentException(
8147 "Can't set selector when package name is already set");
8148 }
8149 mSelector = selector;
8150 }
8151
8152 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008153 * Set a {@link ClipData} associated with this Intent. This replaces any
8154 * previously set ClipData.
8155 *
8156 * <p>The ClipData in an intent is not used for Intent matching or other
8157 * such operations. Semantically it is like extras, used to transmit
8158 * additional data with the Intent. The main feature of using this over
8159 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8160 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8161 * items included in the clip data. This is useful, in particular, if
8162 * you want to transmit an Intent containing multiple <code>content:</code>
8163 * URIs for which the recipient may not have global permission to access the
8164 * content provider.
8165 *
8166 * <p>If the ClipData contains items that are themselves Intents, any
8167 * grant flags in those Intents will be ignored. Only the top-level flags
8168 * of the main Intent are respected, and will be applied to all Uri or
8169 * Intent items in the clip (or sub-items of the clip).
8170 *
8171 * <p>The MIME type, label, and icon in the ClipData object are not
8172 * directly used by Intent. Applications should generally rely on the
8173 * MIME type of the Intent itself, not what it may find in the ClipData.
8174 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008175 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008176 *
8177 * @param clip The new clip to set. May be null to clear the current clip.
8178 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008179 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008180 mClipData = clip;
8181 }
8182
8183 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008184 * This is NOT a secure mechanism to identify the user who sent the intent.
8185 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8186 * who sent the intent.
8187 * @hide
8188 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008189 public void prepareToLeaveUser(int userId) {
8190 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8191 // We want mContentUserHint to refer to the original user, so don't do anything.
8192 if (mContentUserHint == UserHandle.USER_CURRENT) {
8193 mContentUserHint = userId;
8194 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008195 }
8196
8197 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008198 * Add extended data to the intent. The name must include a package
8199 * prefix, for example the app com.android.contacts would use names
8200 * like "com.android.contacts.ShowAll".
8201 *
8202 * @param name The name of the extra data, with package prefix.
8203 * @param value The boolean data value.
8204 *
8205 * @return Returns the same Intent object, for chaining multiple calls
8206 * into a single statement.
8207 *
8208 * @see #putExtras
8209 * @see #removeExtra
8210 * @see #getBooleanExtra(String, boolean)
8211 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008212 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008213 if (mExtras == null) {
8214 mExtras = new Bundle();
8215 }
8216 mExtras.putBoolean(name, value);
8217 return this;
8218 }
8219
8220 /**
8221 * Add extended data to the intent. The name must include a package
8222 * prefix, for example the app com.android.contacts would use names
8223 * like "com.android.contacts.ShowAll".
8224 *
8225 * @param name The name of the extra data, with package prefix.
8226 * @param value The byte data value.
8227 *
8228 * @return Returns the same Intent object, for chaining multiple calls
8229 * into a single statement.
8230 *
8231 * @see #putExtras
8232 * @see #removeExtra
8233 * @see #getByteExtra(String, byte)
8234 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008235 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008236 if (mExtras == null) {
8237 mExtras = new Bundle();
8238 }
8239 mExtras.putByte(name, value);
8240 return this;
8241 }
8242
8243 /**
8244 * Add extended data to the intent. The name must include a package
8245 * prefix, for example the app com.android.contacts would use names
8246 * like "com.android.contacts.ShowAll".
8247 *
8248 * @param name The name of the extra data, with package prefix.
8249 * @param value The char data value.
8250 *
8251 * @return Returns the same Intent object, for chaining multiple calls
8252 * into a single statement.
8253 *
8254 * @see #putExtras
8255 * @see #removeExtra
8256 * @see #getCharExtra(String, char)
8257 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008258 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008259 if (mExtras == null) {
8260 mExtras = new Bundle();
8261 }
8262 mExtras.putChar(name, value);
8263 return this;
8264 }
8265
8266 /**
8267 * Add extended data to the intent. The name must include a package
8268 * prefix, for example the app com.android.contacts would use names
8269 * like "com.android.contacts.ShowAll".
8270 *
8271 * @param name The name of the extra data, with package prefix.
8272 * @param value The short data value.
8273 *
8274 * @return Returns the same Intent object, for chaining multiple calls
8275 * into a single statement.
8276 *
8277 * @see #putExtras
8278 * @see #removeExtra
8279 * @see #getShortExtra(String, short)
8280 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008281 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008282 if (mExtras == null) {
8283 mExtras = new Bundle();
8284 }
8285 mExtras.putShort(name, value);
8286 return this;
8287 }
8288
8289 /**
8290 * Add extended data to the intent. The name must include a package
8291 * prefix, for example the app com.android.contacts would use names
8292 * like "com.android.contacts.ShowAll".
8293 *
8294 * @param name The name of the extra data, with package prefix.
8295 * @param value The integer data value.
8296 *
8297 * @return Returns the same Intent object, for chaining multiple calls
8298 * into a single statement.
8299 *
8300 * @see #putExtras
8301 * @see #removeExtra
8302 * @see #getIntExtra(String, int)
8303 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008304 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305 if (mExtras == null) {
8306 mExtras = new Bundle();
8307 }
8308 mExtras.putInt(name, value);
8309 return this;
8310 }
8311
8312 /**
8313 * Add extended data to the intent. The name must include a package
8314 * prefix, for example the app com.android.contacts would use names
8315 * like "com.android.contacts.ShowAll".
8316 *
8317 * @param name The name of the extra data, with package prefix.
8318 * @param value The long data value.
8319 *
8320 * @return Returns the same Intent object, for chaining multiple calls
8321 * into a single statement.
8322 *
8323 * @see #putExtras
8324 * @see #removeExtra
8325 * @see #getLongExtra(String, long)
8326 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008327 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008328 if (mExtras == null) {
8329 mExtras = new Bundle();
8330 }
8331 mExtras.putLong(name, value);
8332 return this;
8333 }
8334
8335 /**
8336 * Add extended data to the intent. The name must include a package
8337 * prefix, for example the app com.android.contacts would use names
8338 * like "com.android.contacts.ShowAll".
8339 *
8340 * @param name The name of the extra data, with package prefix.
8341 * @param value The float data value.
8342 *
8343 * @return Returns the same Intent object, for chaining multiple calls
8344 * into a single statement.
8345 *
8346 * @see #putExtras
8347 * @see #removeExtra
8348 * @see #getFloatExtra(String, float)
8349 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008350 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008351 if (mExtras == null) {
8352 mExtras = new Bundle();
8353 }
8354 mExtras.putFloat(name, value);
8355 return this;
8356 }
8357
8358 /**
8359 * Add extended data to the intent. The name must include a package
8360 * prefix, for example the app com.android.contacts would use names
8361 * like "com.android.contacts.ShowAll".
8362 *
8363 * @param name The name of the extra data, with package prefix.
8364 * @param value The double data value.
8365 *
8366 * @return Returns the same Intent object, for chaining multiple calls
8367 * into a single statement.
8368 *
8369 * @see #putExtras
8370 * @see #removeExtra
8371 * @see #getDoubleExtra(String, double)
8372 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008373 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008374 if (mExtras == null) {
8375 mExtras = new Bundle();
8376 }
8377 mExtras.putDouble(name, value);
8378 return this;
8379 }
8380
8381 /**
8382 * Add extended data to the intent. The name must include a package
8383 * prefix, for example the app com.android.contacts would use names
8384 * like "com.android.contacts.ShowAll".
8385 *
8386 * @param name The name of the extra data, with package prefix.
8387 * @param value The String data value.
8388 *
8389 * @return Returns the same Intent object, for chaining multiple calls
8390 * into a single statement.
8391 *
8392 * @see #putExtras
8393 * @see #removeExtra
8394 * @see #getStringExtra(String)
8395 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008396 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008397 if (mExtras == null) {
8398 mExtras = new Bundle();
8399 }
8400 mExtras.putString(name, value);
8401 return this;
8402 }
8403
8404 /**
8405 * Add extended data to the intent. The name must include a package
8406 * prefix, for example the app com.android.contacts would use names
8407 * like "com.android.contacts.ShowAll".
8408 *
8409 * @param name The name of the extra data, with package prefix.
8410 * @param value The CharSequence data value.
8411 *
8412 * @return Returns the same Intent object, for chaining multiple calls
8413 * into a single statement.
8414 *
8415 * @see #putExtras
8416 * @see #removeExtra
8417 * @see #getCharSequenceExtra(String)
8418 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008419 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008420 if (mExtras == null) {
8421 mExtras = new Bundle();
8422 }
8423 mExtras.putCharSequence(name, value);
8424 return this;
8425 }
8426
8427 /**
8428 * Add extended data to the intent. The name must include a package
8429 * prefix, for example the app com.android.contacts would use names
8430 * like "com.android.contacts.ShowAll".
8431 *
8432 * @param name The name of the extra data, with package prefix.
8433 * @param value The Parcelable data value.
8434 *
8435 * @return Returns the same Intent object, for chaining multiple calls
8436 * into a single statement.
8437 *
8438 * @see #putExtras
8439 * @see #removeExtra
8440 * @see #getParcelableExtra(String)
8441 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008442 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008443 if (mExtras == null) {
8444 mExtras = new Bundle();
8445 }
8446 mExtras.putParcelable(name, value);
8447 return this;
8448 }
8449
8450 /**
8451 * Add extended data to the intent. The name must include a package
8452 * prefix, for example the app com.android.contacts would use names
8453 * like "com.android.contacts.ShowAll".
8454 *
8455 * @param name The name of the extra data, with package prefix.
8456 * @param value The Parcelable[] data value.
8457 *
8458 * @return Returns the same Intent object, for chaining multiple calls
8459 * into a single statement.
8460 *
8461 * @see #putExtras
8462 * @see #removeExtra
8463 * @see #getParcelableArrayExtra(String)
8464 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008465 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 if (mExtras == null) {
8467 mExtras = new Bundle();
8468 }
8469 mExtras.putParcelableArray(name, value);
8470 return this;
8471 }
8472
8473 /**
8474 * Add extended data to the intent. The name must include a package
8475 * prefix, for example the app com.android.contacts would use names
8476 * like "com.android.contacts.ShowAll".
8477 *
8478 * @param name The name of the extra data, with package prefix.
8479 * @param value The ArrayList<Parcelable> data value.
8480 *
8481 * @return Returns the same Intent object, for chaining multiple calls
8482 * into a single statement.
8483 *
8484 * @see #putExtras
8485 * @see #removeExtra
8486 * @see #getParcelableArrayListExtra(String)
8487 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008488 public @NonNull Intent putParcelableArrayListExtra(String name,
8489 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008490 if (mExtras == null) {
8491 mExtras = new Bundle();
8492 }
8493 mExtras.putParcelableArrayList(name, value);
8494 return this;
8495 }
8496
8497 /**
8498 * Add extended data to the intent. The name must include a package
8499 * prefix, for example the app com.android.contacts would use names
8500 * like "com.android.contacts.ShowAll".
8501 *
8502 * @param name The name of the extra data, with package prefix.
8503 * @param value The ArrayList<Integer> data value.
8504 *
8505 * @return Returns the same Intent object, for chaining multiple calls
8506 * into a single statement.
8507 *
8508 * @see #putExtras
8509 * @see #removeExtra
8510 * @see #getIntegerArrayListExtra(String)
8511 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008512 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008513 if (mExtras == null) {
8514 mExtras = new Bundle();
8515 }
8516 mExtras.putIntegerArrayList(name, value);
8517 return this;
8518 }
8519
8520 /**
8521 * Add extended data to the intent. The name must include a package
8522 * prefix, for example the app com.android.contacts would use names
8523 * like "com.android.contacts.ShowAll".
8524 *
8525 * @param name The name of the extra data, with package prefix.
8526 * @param value The ArrayList<String> data value.
8527 *
8528 * @return Returns the same Intent object, for chaining multiple calls
8529 * into a single statement.
8530 *
8531 * @see #putExtras
8532 * @see #removeExtra
8533 * @see #getStringArrayListExtra(String)
8534 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008535 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008536 if (mExtras == null) {
8537 mExtras = new Bundle();
8538 }
8539 mExtras.putStringArrayList(name, value);
8540 return this;
8541 }
8542
8543 /**
8544 * Add extended data to the intent. The name must include a package
8545 * prefix, for example the app com.android.contacts would use names
8546 * like "com.android.contacts.ShowAll".
8547 *
8548 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008549 * @param value The ArrayList<CharSequence> data value.
8550 *
8551 * @return Returns the same Intent object, for chaining multiple calls
8552 * into a single statement.
8553 *
8554 * @see #putExtras
8555 * @see #removeExtra
8556 * @see #getCharSequenceArrayListExtra(String)
8557 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008558 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8559 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008560 if (mExtras == null) {
8561 mExtras = new Bundle();
8562 }
8563 mExtras.putCharSequenceArrayList(name, value);
8564 return this;
8565 }
8566
8567 /**
8568 * Add extended data to the intent. The name must include a package
8569 * prefix, for example the app com.android.contacts would use names
8570 * like "com.android.contacts.ShowAll".
8571 *
8572 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008573 * @param value The Serializable data value.
8574 *
8575 * @return Returns the same Intent object, for chaining multiple calls
8576 * into a single statement.
8577 *
8578 * @see #putExtras
8579 * @see #removeExtra
8580 * @see #getSerializableExtra(String)
8581 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008582 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 if (mExtras == null) {
8584 mExtras = new Bundle();
8585 }
8586 mExtras.putSerializable(name, value);
8587 return this;
8588 }
8589
8590 /**
8591 * Add extended data to the intent. The name must include a package
8592 * prefix, for example the app com.android.contacts would use names
8593 * like "com.android.contacts.ShowAll".
8594 *
8595 * @param name The name of the extra data, with package prefix.
8596 * @param value The boolean array data value.
8597 *
8598 * @return Returns the same Intent object, for chaining multiple calls
8599 * into a single statement.
8600 *
8601 * @see #putExtras
8602 * @see #removeExtra
8603 * @see #getBooleanArrayExtra(String)
8604 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008605 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008606 if (mExtras == null) {
8607 mExtras = new Bundle();
8608 }
8609 mExtras.putBooleanArray(name, value);
8610 return this;
8611 }
8612
8613 /**
8614 * Add extended data to the intent. The name must include a package
8615 * prefix, for example the app com.android.contacts would use names
8616 * like "com.android.contacts.ShowAll".
8617 *
8618 * @param name The name of the extra data, with package prefix.
8619 * @param value The byte array data value.
8620 *
8621 * @return Returns the same Intent object, for chaining multiple calls
8622 * into a single statement.
8623 *
8624 * @see #putExtras
8625 * @see #removeExtra
8626 * @see #getByteArrayExtra(String)
8627 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008628 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008629 if (mExtras == null) {
8630 mExtras = new Bundle();
8631 }
8632 mExtras.putByteArray(name, value);
8633 return this;
8634 }
8635
8636 /**
8637 * Add extended data to the intent. The name must include a package
8638 * prefix, for example the app com.android.contacts would use names
8639 * like "com.android.contacts.ShowAll".
8640 *
8641 * @param name The name of the extra data, with package prefix.
8642 * @param value The short array data value.
8643 *
8644 * @return Returns the same Intent object, for chaining multiple calls
8645 * into a single statement.
8646 *
8647 * @see #putExtras
8648 * @see #removeExtra
8649 * @see #getShortArrayExtra(String)
8650 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008651 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 if (mExtras == null) {
8653 mExtras = new Bundle();
8654 }
8655 mExtras.putShortArray(name, value);
8656 return this;
8657 }
8658
8659 /**
8660 * Add extended data to the intent. The name must include a package
8661 * prefix, for example the app com.android.contacts would use names
8662 * like "com.android.contacts.ShowAll".
8663 *
8664 * @param name The name of the extra data, with package prefix.
8665 * @param value The char array data value.
8666 *
8667 * @return Returns the same Intent object, for chaining multiple calls
8668 * into a single statement.
8669 *
8670 * @see #putExtras
8671 * @see #removeExtra
8672 * @see #getCharArrayExtra(String)
8673 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008674 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008675 if (mExtras == null) {
8676 mExtras = new Bundle();
8677 }
8678 mExtras.putCharArray(name, value);
8679 return this;
8680 }
8681
8682 /**
8683 * Add extended data to the intent. The name must include a package
8684 * prefix, for example the app com.android.contacts would use names
8685 * like "com.android.contacts.ShowAll".
8686 *
8687 * @param name The name of the extra data, with package prefix.
8688 * @param value The int array data value.
8689 *
8690 * @return Returns the same Intent object, for chaining multiple calls
8691 * into a single statement.
8692 *
8693 * @see #putExtras
8694 * @see #removeExtra
8695 * @see #getIntArrayExtra(String)
8696 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008697 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008698 if (mExtras == null) {
8699 mExtras = new Bundle();
8700 }
8701 mExtras.putIntArray(name, value);
8702 return this;
8703 }
8704
8705 /**
8706 * Add extended data to the intent. The name must include a package
8707 * prefix, for example the app com.android.contacts would use names
8708 * like "com.android.contacts.ShowAll".
8709 *
8710 * @param name The name of the extra data, with package prefix.
8711 * @param value The byte array data value.
8712 *
8713 * @return Returns the same Intent object, for chaining multiple calls
8714 * into a single statement.
8715 *
8716 * @see #putExtras
8717 * @see #removeExtra
8718 * @see #getLongArrayExtra(String)
8719 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008720 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008721 if (mExtras == null) {
8722 mExtras = new Bundle();
8723 }
8724 mExtras.putLongArray(name, value);
8725 return this;
8726 }
8727
8728 /**
8729 * Add extended data to the intent. The name must include a package
8730 * prefix, for example the app com.android.contacts would use names
8731 * like "com.android.contacts.ShowAll".
8732 *
8733 * @param name The name of the extra data, with package prefix.
8734 * @param value The float array data value.
8735 *
8736 * @return Returns the same Intent object, for chaining multiple calls
8737 * into a single statement.
8738 *
8739 * @see #putExtras
8740 * @see #removeExtra
8741 * @see #getFloatArrayExtra(String)
8742 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008743 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008744 if (mExtras == null) {
8745 mExtras = new Bundle();
8746 }
8747 mExtras.putFloatArray(name, value);
8748 return this;
8749 }
8750
8751 /**
8752 * Add extended data to the intent. The name must include a package
8753 * prefix, for example the app com.android.contacts would use names
8754 * like "com.android.contacts.ShowAll".
8755 *
8756 * @param name The name of the extra data, with package prefix.
8757 * @param value The double array data value.
8758 *
8759 * @return Returns the same Intent object, for chaining multiple calls
8760 * into a single statement.
8761 *
8762 * @see #putExtras
8763 * @see #removeExtra
8764 * @see #getDoubleArrayExtra(String)
8765 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008766 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008767 if (mExtras == null) {
8768 mExtras = new Bundle();
8769 }
8770 mExtras.putDoubleArray(name, value);
8771 return this;
8772 }
8773
8774 /**
8775 * Add extended data to the intent. The name must include a package
8776 * prefix, for example the app com.android.contacts would use names
8777 * like "com.android.contacts.ShowAll".
8778 *
8779 * @param name The name of the extra data, with package prefix.
8780 * @param value The String array data value.
8781 *
8782 * @return Returns the same Intent object, for chaining multiple calls
8783 * into a single statement.
8784 *
8785 * @see #putExtras
8786 * @see #removeExtra
8787 * @see #getStringArrayExtra(String)
8788 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008789 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008790 if (mExtras == null) {
8791 mExtras = new Bundle();
8792 }
8793 mExtras.putStringArray(name, value);
8794 return this;
8795 }
8796
8797 /**
8798 * Add extended data to the intent. The name must include a package
8799 * prefix, for example the app com.android.contacts would use names
8800 * like "com.android.contacts.ShowAll".
8801 *
8802 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008803 * @param value The CharSequence array data value.
8804 *
8805 * @return Returns the same Intent object, for chaining multiple calls
8806 * into a single statement.
8807 *
8808 * @see #putExtras
8809 * @see #removeExtra
8810 * @see #getCharSequenceArrayExtra(String)
8811 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008812 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008813 if (mExtras == null) {
8814 mExtras = new Bundle();
8815 }
8816 mExtras.putCharSequenceArray(name, value);
8817 return this;
8818 }
8819
8820 /**
8821 * Add extended data to the intent. The name must include a package
8822 * prefix, for example the app com.android.contacts would use names
8823 * like "com.android.contacts.ShowAll".
8824 *
8825 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008826 * @param value The Bundle data value.
8827 *
8828 * @return Returns the same Intent object, for chaining multiple calls
8829 * into a single statement.
8830 *
8831 * @see #putExtras
8832 * @see #removeExtra
8833 * @see #getBundleExtra(String)
8834 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008835 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008836 if (mExtras == null) {
8837 mExtras = new Bundle();
8838 }
8839 mExtras.putBundle(name, value);
8840 return this;
8841 }
8842
8843 /**
8844 * Add extended data to the intent. The name must include a package
8845 * prefix, for example the app com.android.contacts would use names
8846 * like "com.android.contacts.ShowAll".
8847 *
8848 * @param name The name of the extra data, with package prefix.
8849 * @param value The IBinder data value.
8850 *
8851 * @return Returns the same Intent object, for chaining multiple calls
8852 * into a single statement.
8853 *
8854 * @see #putExtras
8855 * @see #removeExtra
8856 * @see #getIBinderExtra(String)
8857 *
8858 * @deprecated
8859 * @hide
8860 */
8861 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008862 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008863 if (mExtras == null) {
8864 mExtras = new Bundle();
8865 }
8866 mExtras.putIBinder(name, value);
8867 return this;
8868 }
8869
8870 /**
8871 * Copy all extras in 'src' in to this intent.
8872 *
8873 * @param src Contains the extras to copy.
8874 *
8875 * @see #putExtra
8876 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008877 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008878 if (src.mExtras != null) {
8879 if (mExtras == null) {
8880 mExtras = new Bundle(src.mExtras);
8881 } else {
8882 mExtras.putAll(src.mExtras);
8883 }
8884 }
8885 return this;
8886 }
8887
8888 /**
8889 * Add a set of extended data to the intent. The keys must include a package
8890 * prefix, for example the app com.android.contacts would use names
8891 * like "com.android.contacts.ShowAll".
8892 *
8893 * @param extras The Bundle of extras to add to this intent.
8894 *
8895 * @see #putExtra
8896 * @see #removeExtra
8897 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008898 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008899 if (mExtras == null) {
8900 mExtras = new Bundle();
8901 }
8902 mExtras.putAll(extras);
8903 return this;
8904 }
8905
8906 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008907 * Completely replace the extras in the Intent with the extras in the
8908 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008909 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008910 * @param src The exact extras contained in this Intent are copied
8911 * into the target intent, replacing any that were previously there.
8912 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008913 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008914 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8915 return this;
8916 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008917
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008918 /**
8919 * Completely replace the extras in the Intent with the given Bundle of
8920 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008921 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008922 * @param extras The new set of extras in the Intent, or null to erase
8923 * all extras.
8924 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008925 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008926 mExtras = extras != null ? new Bundle(extras) : null;
8927 return this;
8928 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008929
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008930 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008931 * Remove extended data from the intent.
8932 *
8933 * @see #putExtra
8934 */
8935 public void removeExtra(String name) {
8936 if (mExtras != null) {
8937 mExtras.remove(name);
8938 if (mExtras.size() == 0) {
8939 mExtras = null;
8940 }
8941 }
8942 }
8943
8944 /**
8945 * Set special flags controlling how this intent is handled. Most values
8946 * here depend on the type of component being executed by the Intent,
8947 * specifically the FLAG_ACTIVITY_* flags are all for use with
8948 * {@link Context#startActivity Context.startActivity()} and the
8949 * FLAG_RECEIVER_* flags are all for use with
8950 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8951 *
Scott Main7aee61f2011-02-08 11:25:01 -08008952 * <p>See the
8953 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8954 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008955 * the behavior of your application.
8956 *
8957 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008958 * @return Returns the same Intent object, for chaining multiple calls
8959 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008960 * @see #getFlags
8961 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008962 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008963 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008964 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008965 mFlags = flags;
8966 return this;
8967 }
8968
8969 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008970 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008971 *
8972 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008973 * @return Returns the same Intent object, for chaining multiple calls into
8974 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008975 * @see #setFlags
8976 * @see #getFlags
8977 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008978 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008979 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008980 mFlags |= flags;
8981 return this;
8982 }
8983
8984 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008985 * Remove these flags from the intent.
8986 *
8987 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008988 * @see #setFlags
8989 * @see #getFlags
8990 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008991 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008992 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008993 mFlags &= ~flags;
8994 }
8995
8996 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008997 * (Usually optional) Set an explicit application package name that limits
8998 * the components this Intent will resolve to. If left to the default
8999 * value of null, all components in all applications will considered.
9000 * If non-null, the Intent can only match the components in the given
9001 * application package.
9002 *
9003 * @param packageName The name of the application package to handle the
9004 * intent, or null to allow any application package.
9005 *
9006 * @return Returns the same Intent object, for chaining multiple calls
9007 * into a single statement.
9008 *
9009 * @see #getPackage
9010 * @see #resolveActivity
9011 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009012 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009013 if (packageName != null && mSelector != null) {
9014 throw new IllegalArgumentException(
9015 "Can't set package name when selector is already set");
9016 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009017 mPackage = packageName;
9018 return this;
9019 }
9020
9021 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009022 * (Usually optional) Explicitly set the component to handle the intent.
9023 * If left with the default value of null, the system will determine the
9024 * appropriate class to use based on the other fields (action, data,
9025 * type, categories) in the Intent. If this class is defined, the
9026 * specified class will always be used regardless of the other fields. You
9027 * should only set this value when you know you absolutely want a specific
9028 * class to be used; otherwise it is better to let the system find the
9029 * appropriate class so that you will respect the installed applications
9030 * and user preferences.
9031 *
9032 * @param component The name of the application component to handle the
9033 * intent, or null to let the system find one for you.
9034 *
9035 * @return Returns the same Intent object, for chaining multiple calls
9036 * into a single statement.
9037 *
9038 * @see #setClass
9039 * @see #setClassName(Context, String)
9040 * @see #setClassName(String, String)
9041 * @see #getComponent
9042 * @see #resolveActivity
9043 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009044 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009045 mComponent = component;
9046 return this;
9047 }
9048
9049 /**
9050 * Convenience for calling {@link #setComponent} with an
9051 * explicit class name.
9052 *
9053 * @param packageContext A Context of the application package implementing
9054 * this class.
9055 * @param className The name of a class inside of the application package
9056 * that will be used as the component for this Intent.
9057 *
9058 * @return Returns the same Intent object, for chaining multiple calls
9059 * into a single statement.
9060 *
9061 * @see #setComponent
9062 * @see #setClass
9063 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009064 public @NonNull Intent setClassName(@NonNull Context packageContext,
9065 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009066 mComponent = new ComponentName(packageContext, className);
9067 return this;
9068 }
9069
9070 /**
9071 * Convenience for calling {@link #setComponent} with an
9072 * explicit application package name and class name.
9073 *
9074 * @param packageName The name of the package implementing the desired
9075 * component.
9076 * @param className The name of a class inside of the application package
9077 * that will be used as the component for this Intent.
9078 *
9079 * @return Returns the same Intent object, for chaining multiple calls
9080 * into a single statement.
9081 *
9082 * @see #setComponent
9083 * @see #setClass
9084 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009085 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009086 mComponent = new ComponentName(packageName, className);
9087 return this;
9088 }
9089
9090 /**
9091 * Convenience for calling {@link #setComponent(ComponentName)} with the
9092 * name returned by a {@link Class} object.
9093 *
9094 * @param packageContext A Context of the application package implementing
9095 * this class.
9096 * @param cls The class name to set, equivalent to
9097 * <code>setClassName(context, cls.getName())</code>.
9098 *
9099 * @return Returns the same Intent object, for chaining multiple calls
9100 * into a single statement.
9101 *
9102 * @see #setComponent
9103 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009104 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009105 mComponent = new ComponentName(packageContext, cls);
9106 return this;
9107 }
9108
9109 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009110 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9111 * used as a hint to the receiver for animations and the like. Null means that there
9112 * is no source bounds.
9113 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009114 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009115 if (r != null) {
9116 mSourceBounds = new Rect(r);
9117 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009118 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009119 }
9120 }
9121
Tor Norbyed9273d62013-05-30 15:59:53 -07009122 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009123 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9124 FILL_IN_ACTION,
9125 FILL_IN_DATA,
9126 FILL_IN_CATEGORIES,
9127 FILL_IN_COMPONENT,
9128 FILL_IN_PACKAGE,
9129 FILL_IN_SOURCE_BOUNDS,
9130 FILL_IN_SELECTOR,
9131 FILL_IN_CLIP_DATA
9132 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009133 @Retention(RetentionPolicy.SOURCE)
9134 public @interface FillInFlags {}
9135
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009136 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009137 * Use with {@link #fillIn} to allow the current action value to be
9138 * overwritten, even if it is already set.
9139 */
9140 public static final int FILL_IN_ACTION = 1<<0;
9141
9142 /**
9143 * Use with {@link #fillIn} to allow the current data or type value
9144 * overwritten, even if it is already set.
9145 */
9146 public static final int FILL_IN_DATA = 1<<1;
9147
9148 /**
9149 * Use with {@link #fillIn} to allow the current categories to be
9150 * overwritten, even if they are already set.
9151 */
9152 public static final int FILL_IN_CATEGORIES = 1<<2;
9153
9154 /**
9155 * Use with {@link #fillIn} to allow the current component value to be
9156 * overwritten, even if it is already set.
9157 */
9158 public static final int FILL_IN_COMPONENT = 1<<3;
9159
9160 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009161 * Use with {@link #fillIn} to allow the current package value to be
9162 * overwritten, even if it is already set.
9163 */
9164 public static final int FILL_IN_PACKAGE = 1<<4;
9165
9166 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009167 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009168 * overwritten, even if it is already set.
9169 */
9170 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9171
9172 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009173 * Use with {@link #fillIn} to allow the current selector to be
9174 * overwritten, even if it is already set.
9175 */
9176 public static final int FILL_IN_SELECTOR = 1<<6;
9177
9178 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009179 * Use with {@link #fillIn} to allow the current ClipData to be
9180 * overwritten, even if it is already set.
9181 */
9182 public static final int FILL_IN_CLIP_DATA = 1<<7;
9183
9184 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009185 * Copy the contents of <var>other</var> in to this object, but only
9186 * where fields are not defined by this object. For purposes of a field
9187 * being defined, the following pieces of data in the Intent are
9188 * considered to be separate fields:
9189 *
9190 * <ul>
9191 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009192 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009193 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9194 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009195 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009196 * <li> component, as set by {@link #setComponent(ComponentName)} or
9197 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009198 * <li> source bounds, as set by {@link #setSourceBounds}.
9199 * <li> selector, as set by {@link #setSelector(Intent)}.
9200 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009201 * <li> each top-level name in the associated extras.
9202 * </ul>
9203 *
9204 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009205 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009206 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9207 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9208 * the restriction where the corresponding field will not be replaced if
9209 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009210 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009211 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9212 * is explicitly specified. The selector will only be copied if
9213 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009214 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009215 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9216 * and Intent B with {action="gotit", data-type="some/thing",
9217 * categories="one","two"}.
9218 *
9219 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9220 * containing: {action="gotit", data-type="some/thing",
9221 * categories="bar"}.
9222 *
9223 * @param other Another Intent whose values are to be used to fill in
9224 * the current one.
9225 * @param flags Options to control which fields can be filled in.
9226 *
9227 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009228 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009229 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009230 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009231 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009232 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009233 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009234 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009235 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009236 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009237 if (other.mAction != null
9238 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009239 mAction = other.mAction;
9240 changes |= FILL_IN_ACTION;
9241 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009242 if ((other.mData != null || other.mType != null)
9243 && ((mData == null && mType == null)
9244 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009245 mData = other.mData;
9246 mType = other.mType;
9247 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009248 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009249 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009250 if (other.mCategories != null
9251 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009252 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009253 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009254 }
9255 changes |= FILL_IN_CATEGORIES;
9256 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009257 if (other.mPackage != null
9258 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009259 // Only do this if mSelector is not set.
9260 if (mSelector == null) {
9261 mPackage = other.mPackage;
9262 changes |= FILL_IN_PACKAGE;
9263 }
9264 }
9265 // Selector is special: it can only be set if explicitly allowed,
9266 // for the same reason as the component name.
9267 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9268 if (mPackage == null) {
9269 mSelector = new Intent(other.mSelector);
9270 mPackage = null;
9271 changes |= FILL_IN_SELECTOR;
9272 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009273 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009274 if (other.mClipData != null
9275 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9276 mClipData = other.mClipData;
9277 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009278 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009279 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009280 // Component is special: it can -only- be set if explicitly allowed,
9281 // since otherwise the sender could force the intent somewhere the
9282 // originator didn't intend.
9283 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009284 mComponent = other.mComponent;
9285 changes |= FILL_IN_COMPONENT;
9286 }
9287 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009288 if (other.mSourceBounds != null
9289 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9290 mSourceBounds = new Rect(other.mSourceBounds);
9291 changes |= FILL_IN_SOURCE_BOUNDS;
9292 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009293 if (mExtras == null) {
9294 if (other.mExtras != null) {
9295 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009296 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009297 }
9298 } else if (other.mExtras != null) {
9299 try {
9300 Bundle newb = new Bundle(other.mExtras);
9301 newb.putAll(mExtras);
9302 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009303 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009304 } catch (RuntimeException e) {
9305 // Modifying the extras can cause us to unparcel the contents
9306 // of the bundle, and if we do this in the system process that
9307 // may fail. We really should handle this (i.e., the Bundle
9308 // impl shouldn't be on top of a plain map), but for now just
9309 // ignore it and keep the original contents. :(
9310 Log.w("Intent", "Failure filling in extras", e);
9311 }
9312 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009313 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9314 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9315 mContentUserHint = other.mContentUserHint;
9316 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009317 return changes;
9318 }
9319
9320 /**
9321 * Wrapper class holding an Intent and implementing comparisons on it for
9322 * the purpose of filtering. The class implements its
9323 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9324 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9325 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9326 * on the wrapped Intent.
9327 */
9328 public static final class FilterComparison {
9329 private final Intent mIntent;
9330 private final int mHashCode;
9331
9332 public FilterComparison(Intent intent) {
9333 mIntent = intent;
9334 mHashCode = intent.filterHashCode();
9335 }
9336
9337 /**
9338 * Return the Intent that this FilterComparison represents.
9339 * @return Returns the Intent held by the FilterComparison. Do
9340 * not modify!
9341 */
9342 public Intent getIntent() {
9343 return mIntent;
9344 }
9345
9346 @Override
9347 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009348 if (obj instanceof FilterComparison) {
9349 Intent other = ((FilterComparison)obj).mIntent;
9350 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009351 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009352 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009353 }
9354
9355 @Override
9356 public int hashCode() {
9357 return mHashCode;
9358 }
9359 }
9360
9361 /**
9362 * Determine if two intents are the same for the purposes of intent
9363 * resolution (filtering). That is, if their action, data, type,
9364 * class, and categories are the same. This does <em>not</em> compare
9365 * any extra data included in the intents.
9366 *
9367 * @param other The other Intent to compare against.
9368 *
9369 * @return Returns true if action, data, type, class, and categories
9370 * are the same.
9371 */
9372 public boolean filterEquals(Intent other) {
9373 if (other == null) {
9374 return false;
9375 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009376 if (!Objects.equals(this.mAction, other.mAction)) return false;
9377 if (!Objects.equals(this.mData, other.mData)) return false;
9378 if (!Objects.equals(this.mType, other.mType)) return false;
9379 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9380 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9381 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009382
9383 return true;
9384 }
9385
9386 /**
9387 * Generate hash code that matches semantics of filterEquals().
9388 *
9389 * @return Returns the hash value of the action, data, type, class, and
9390 * categories.
9391 *
9392 * @see #filterEquals
9393 */
9394 public int filterHashCode() {
9395 int code = 0;
9396 if (mAction != null) {
9397 code += mAction.hashCode();
9398 }
9399 if (mData != null) {
9400 code += mData.hashCode();
9401 }
9402 if (mType != null) {
9403 code += mType.hashCode();
9404 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009405 if (mPackage != null) {
9406 code += mPackage.hashCode();
9407 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009408 if (mComponent != null) {
9409 code += mComponent.hashCode();
9410 }
9411 if (mCategories != null) {
9412 code += mCategories.hashCode();
9413 }
9414 return code;
9415 }
9416
9417 @Override
9418 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009419 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009420
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009421 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009422 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009423 b.append(" }");
9424
9425 return b.toString();
9426 }
9427
9428 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009429 public String toInsecureString() {
9430 StringBuilder b = new StringBuilder(128);
9431
9432 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009433 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009434 b.append(" }");
9435
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009436 return b.toString();
9437 }
Romain Guy4969af72009-06-17 10:53:19 -07009438
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009439 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009440 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009441 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009442
9443 b.append("Intent { ");
9444 toShortString(b, false, true, true, true);
9445 b.append(" }");
9446
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009447 return b.toString();
9448 }
9449
9450 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009451 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9452 StringBuilder b = new StringBuilder(128);
9453 toShortString(b, secure, comp, extras, clip);
9454 return b.toString();
9455 }
9456
9457 /** @hide */
9458 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9459 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009460 boolean first = true;
9461 if (mAction != null) {
9462 b.append("act=").append(mAction);
9463 first = false;
9464 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009465 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009466 if (!first) {
9467 b.append(' ');
9468 }
9469 first = false;
9470 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009471 for (int i=0; i<mCategories.size(); i++) {
9472 if (i > 0) b.append(',');
9473 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009474 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009475 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009476 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009477 if (mData != null) {
9478 if (!first) {
9479 b.append(' ');
9480 }
9481 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009482 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009483 if (secure) {
9484 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009485 } else {
9486 b.append(mData);
9487 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009488 }
9489 if (mType != null) {
9490 if (!first) {
9491 b.append(' ');
9492 }
9493 first = false;
9494 b.append("typ=").append(mType);
9495 }
9496 if (mFlags != 0) {
9497 if (!first) {
9498 b.append(' ');
9499 }
9500 first = false;
9501 b.append("flg=0x").append(Integer.toHexString(mFlags));
9502 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009503 if (mPackage != null) {
9504 if (!first) {
9505 b.append(' ');
9506 }
9507 first = false;
9508 b.append("pkg=").append(mPackage);
9509 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009510 if (comp && mComponent != null) {
9511 if (!first) {
9512 b.append(' ');
9513 }
9514 first = false;
9515 b.append("cmp=").append(mComponent.flattenToShortString());
9516 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009517 if (mSourceBounds != null) {
9518 if (!first) {
9519 b.append(' ');
9520 }
9521 first = false;
9522 b.append("bnds=").append(mSourceBounds.toShortString());
9523 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009524 if (mClipData != null) {
9525 if (!first) {
9526 b.append(' ');
9527 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009528 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009529 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009530 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009531 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009532 if (mClipData.getDescription() != null) {
9533 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9534 } else {
9535 first = true;
9536 }
9537 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009538 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009539 first = false;
9540 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009541 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009542 if (extras && mExtras != null) {
9543 if (!first) {
9544 b.append(' ');
9545 }
9546 first = false;
9547 b.append("(has extras)");
9548 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009549 if (mContentUserHint != UserHandle.USER_CURRENT) {
9550 if (!first) {
9551 b.append(' ');
9552 }
9553 first = false;
9554 b.append("u=").append(mContentUserHint);
9555 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009556 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009557 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009558 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009559 b.append("}");
9560 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009561 }
9562
Yi Jin129fc6c2017-09-28 15:48:38 -07009563 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009564 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9565 // Same input parameters that toString() gives to toShortString().
9566 writeToProto(proto, fieldId, true, true, true, false);
9567 }
9568
9569 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009570 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9571 boolean extras, boolean clip) {
9572 long token = proto.start(fieldId);
9573 if (mAction != null) {
9574 proto.write(IntentProto.ACTION, mAction);
9575 }
9576 if (mCategories != null) {
9577 for (String category : mCategories) {
9578 proto.write(IntentProto.CATEGORIES, category);
9579 }
9580 }
9581 if (mData != null) {
9582 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9583 }
9584 if (mType != null) {
9585 proto.write(IntentProto.TYPE, mType);
9586 }
9587 if (mFlags != 0) {
9588 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9589 }
9590 if (mPackage != null) {
9591 proto.write(IntentProto.PACKAGE, mPackage);
9592 }
9593 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009594 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009595 }
9596 if (mSourceBounds != null) {
9597 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9598 }
9599 if (mClipData != null) {
9600 StringBuilder b = new StringBuilder();
9601 if (clip) {
9602 mClipData.toShortString(b);
9603 } else {
9604 mClipData.toShortStringShortItems(b, false);
9605 }
9606 proto.write(IntentProto.CLIP_DATA, b.toString());
9607 }
9608 if (extras && mExtras != null) {
9609 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9610 }
9611 if (mContentUserHint != 0) {
9612 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9613 }
9614 if (mSelector != null) {
9615 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9616 }
9617 proto.end(token);
9618 }
9619
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009620 /**
9621 * Call {@link #toUri} with 0 flags.
9622 * @deprecated Use {@link #toUri} instead.
9623 */
9624 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009625 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009626 return toUri(0);
9627 }
9628
9629 /**
9630 * Convert this Intent into a String holding a URI representation of it.
9631 * The returned URI string has been properly URI encoded, so it can be
9632 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9633 * Intent's data as the base URI, with an additional fragment describing
9634 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009635 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009636 * <p>You can convert the returned string back to an Intent with
9637 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009638 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009639 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009640 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009641 * @return Returns a URI encoding URI string describing the entire contents
9642 * of the Intent.
9643 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009644 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009645 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009646 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9647 if (mPackage == null) {
9648 throw new IllegalArgumentException(
9649 "Intent must include an explicit package name to build an android-app: "
9650 + this);
9651 }
9652 uri.append("android-app://");
9653 uri.append(mPackage);
9654 String scheme = null;
9655 if (mData != null) {
9656 scheme = mData.getScheme();
9657 if (scheme != null) {
9658 uri.append('/');
9659 uri.append(scheme);
9660 String authority = mData.getEncodedAuthority();
9661 if (authority != null) {
9662 uri.append('/');
9663 uri.append(authority);
9664 String path = mData.getEncodedPath();
9665 if (path != null) {
9666 uri.append(path);
9667 }
9668 String queryParams = mData.getEncodedQuery();
9669 if (queryParams != null) {
9670 uri.append('?');
9671 uri.append(queryParams);
9672 }
9673 String fragment = mData.getEncodedFragment();
9674 if (fragment != null) {
9675 uri.append('#');
9676 uri.append(fragment);
9677 }
9678 }
9679 }
9680 }
9681 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9682 mPackage, flags);
9683 return uri.toString();
9684 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009685 String scheme = null;
9686 if (mData != null) {
9687 String data = mData.toString();
9688 if ((flags&URI_INTENT_SCHEME) != 0) {
9689 final int N = data.length();
9690 for (int i=0; i<N; i++) {
9691 char c = data.charAt(i);
9692 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009693 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009694 continue;
9695 }
9696 if (c == ':' && i > 0) {
9697 // Valid scheme.
9698 scheme = data.substring(0, i);
9699 uri.append("intent:");
9700 data = data.substring(i+1);
9701 break;
9702 }
Tom Taylord4a47292009-12-21 13:59:18 -08009703
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009704 // No scheme.
9705 break;
9706 }
9707 }
9708 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009709
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009710 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9711 uri.append("intent:");
9712 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009713
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009714 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009715
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009716 return uri.toString();
9717 }
9718
9719 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9720 String defPackage, int flags) {
9721 StringBuilder frag = new StringBuilder(128);
9722
9723 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009724 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009725 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009726 // Note that for now we are not going to try to handle the
9727 // data part; not clear how to represent this as a URI, and
9728 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009729 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9730 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009731 }
9732
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009733 if (frag.length() > 0) {
9734 uri.append("#Intent;");
9735 uri.append(frag);
9736 uri.append("end");
9737 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009738 }
9739
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009740 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9741 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009742 if (scheme != null) {
9743 uri.append("scheme=").append(scheme).append(';');
9744 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009745 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009746 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009747 }
9748 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009749 for (int i=0; i<mCategories.size(); i++) {
9750 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009751 }
9752 }
9753 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009754 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009755 }
9756 if (mFlags != 0) {
9757 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9758 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009759 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009760 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9761 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009762 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009763 uri.append("component=").append(Uri.encode(
9764 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009765 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009766 if (mSourceBounds != null) {
9767 uri.append("sourceBounds=")
9768 .append(Uri.encode(mSourceBounds.flattenToString()))
9769 .append(';');
9770 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009771 if (mExtras != null) {
9772 for (String key : mExtras.keySet()) {
9773 final Object value = mExtras.get(key);
9774 char entryType =
9775 value instanceof String ? 'S' :
9776 value instanceof Boolean ? 'B' :
9777 value instanceof Byte ? 'b' :
9778 value instanceof Character ? 'c' :
9779 value instanceof Double ? 'd' :
9780 value instanceof Float ? 'f' :
9781 value instanceof Integer ? 'i' :
9782 value instanceof Long ? 'l' :
9783 value instanceof Short ? 's' :
9784 '\0';
9785
9786 if (entryType != '\0') {
9787 uri.append(entryType);
9788 uri.append('.');
9789 uri.append(Uri.encode(key));
9790 uri.append('=');
9791 uri.append(Uri.encode(value.toString()));
9792 uri.append(';');
9793 }
9794 }
9795 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009796 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009797
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009798 public int describeContents() {
9799 return (mExtras != null) ? mExtras.describeContents() : 0;
9800 }
9801
9802 public void writeToParcel(Parcel out, int flags) {
9803 out.writeString(mAction);
9804 Uri.writeToParcel(out, mData);
9805 out.writeString(mType);
9806 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009807 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009808 ComponentName.writeToParcel(mComponent, out);
9809
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009810 if (mSourceBounds != null) {
9811 out.writeInt(1);
9812 mSourceBounds.writeToParcel(out, flags);
9813 } else {
9814 out.writeInt(0);
9815 }
9816
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009817 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009818 final int N = mCategories.size();
9819 out.writeInt(N);
9820 for (int i=0; i<N; i++) {
9821 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009822 }
9823 } else {
9824 out.writeInt(0);
9825 }
9826
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009827 if (mSelector != null) {
9828 out.writeInt(1);
9829 mSelector.writeToParcel(out, flags);
9830 } else {
9831 out.writeInt(0);
9832 }
9833
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009834 if (mClipData != null) {
9835 out.writeInt(1);
9836 mClipData.writeToParcel(out, flags);
9837 } else {
9838 out.writeInt(0);
9839 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009840 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009841 out.writeBundle(mExtras);
9842 }
9843
9844 public static final Parcelable.Creator<Intent> CREATOR
9845 = new Parcelable.Creator<Intent>() {
9846 public Intent createFromParcel(Parcel in) {
9847 return new Intent(in);
9848 }
9849 public Intent[] newArray(int size) {
9850 return new Intent[size];
9851 }
9852 };
9853
Dianne Hackborneb034652009-09-07 00:49:58 -07009854 /** @hide */
9855 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009856 readFromParcel(in);
9857 }
9858
9859 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009860 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009861 mData = Uri.CREATOR.createFromParcel(in);
9862 mType = in.readString();
9863 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009864 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009865 mComponent = ComponentName.readFromParcel(in);
9866
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009867 if (in.readInt() != 0) {
9868 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9869 }
9870
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009871 int N = in.readInt();
9872 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009873 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009874 int i;
9875 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009876 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009877 }
9878 } else {
9879 mCategories = null;
9880 }
9881
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009882 if (in.readInt() != 0) {
9883 mSelector = new Intent(in);
9884 }
9885
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009886 if (in.readInt() != 0) {
9887 mClipData = new ClipData(in);
9888 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009889 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009890 mExtras = in.readBundle();
9891 }
9892
9893 /**
9894 * Parses the "intent" element (and its children) from XML and instantiates
9895 * an Intent object. The given XML parser should be located at the tag
9896 * where parsing should start (often named "intent"), from which the
9897 * basic action, data, type, and package and class name will be
9898 * retrieved. The function will then parse in to any child elements,
9899 * looking for <category android:name="xxx"> tags to add categories and
9900 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9901 * to the intent.
9902 *
9903 * @param resources The Resources to use when inflating resources.
9904 * @param parser The XML parser pointing at an "intent" tag.
9905 * @param attrs The AttributeSet interface for retrieving extended
9906 * attribute data at the current <var>parser</var> location.
9907 * @return An Intent object matching the XML data.
9908 * @throws XmlPullParserException If there was an XML parsing error.
9909 * @throws IOException If there was an I/O error.
9910 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009911 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9912 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009913 throws XmlPullParserException, IOException {
9914 Intent intent = new Intent();
9915
9916 TypedArray sa = resources.obtainAttributes(attrs,
9917 com.android.internal.R.styleable.Intent);
9918
9919 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9920
9921 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9922 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9923 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9924
9925 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9926 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9927 if (packageName != null && className != null) {
9928 intent.setComponent(new ComponentName(packageName, className));
9929 }
9930
9931 sa.recycle();
9932
9933 int outerDepth = parser.getDepth();
9934 int type;
9935 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9936 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9937 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9938 continue;
9939 }
9940
9941 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009942 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009943 sa = resources.obtainAttributes(attrs,
9944 com.android.internal.R.styleable.IntentCategory);
9945 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9946 sa.recycle();
9947
9948 if (cat != null) {
9949 intent.addCategory(cat);
9950 }
9951 XmlUtils.skipCurrentTag(parser);
9952
Craig Mautner21d24a22014-04-23 11:45:37 -07009953 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009954 if (intent.mExtras == null) {
9955 intent.mExtras = new Bundle();
9956 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009957 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009958 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009959
9960 } else {
9961 XmlUtils.skipCurrentTag(parser);
9962 }
9963 }
9964
9965 return intent;
9966 }
Nick Pellyccae4122012-01-09 14:12:58 -08009967
Craig Mautner21d24a22014-04-23 11:45:37 -07009968 /** @hide */
9969 public void saveToXml(XmlSerializer out) throws IOException {
9970 if (mAction != null) {
9971 out.attribute(null, ATTR_ACTION, mAction);
9972 }
9973 if (mData != null) {
9974 out.attribute(null, ATTR_DATA, mData.toString());
9975 }
9976 if (mType != null) {
9977 out.attribute(null, ATTR_TYPE, mType);
9978 }
9979 if (mComponent != null) {
9980 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9981 }
9982 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9983
9984 if (mCategories != null) {
9985 out.startTag(null, TAG_CATEGORIES);
9986 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9987 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9988 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009989 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009990 }
9991 }
9992
9993 /** @hide */
9994 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9995 XmlPullParserException {
9996 Intent intent = new Intent();
9997 final int outerDepth = in.getDepth();
9998
9999 int attrCount = in.getAttributeCount();
10000 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10001 final String attrName = in.getAttributeName(attrNdx);
10002 final String attrValue = in.getAttributeValue(attrNdx);
10003 if (ATTR_ACTION.equals(attrName)) {
10004 intent.setAction(attrValue);
10005 } else if (ATTR_DATA.equals(attrName)) {
10006 intent.setData(Uri.parse(attrValue));
10007 } else if (ATTR_TYPE.equals(attrName)) {
10008 intent.setType(attrValue);
10009 } else if (ATTR_COMPONENT.equals(attrName)) {
10010 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10011 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010012 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010013 } else {
10014 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10015 }
10016 }
10017
10018 int event;
10019 String name;
10020 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10021 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10022 if (event == XmlPullParser.START_TAG) {
10023 name = in.getName();
10024 if (TAG_CATEGORIES.equals(name)) {
10025 attrCount = in.getAttributeCount();
10026 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10027 intent.addCategory(in.getAttributeValue(attrNdx));
10028 }
10029 } else {
10030 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10031 XmlUtils.skipCurrentTag(in);
10032 }
10033 }
10034 }
10035
10036 return intent;
10037 }
10038
Nick Pellyccae4122012-01-09 14:12:58 -080010039 /**
10040 * Normalize a MIME data type.
10041 *
10042 * <p>A normalized MIME type has white-space trimmed,
10043 * content-type parameters removed, and is lower-case.
10044 * This aligns the type with Android best practices for
10045 * intent filtering.
10046 *
10047 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10048 * "text/x-vCard" becomes "text/x-vcard".
10049 *
10050 * <p>All MIME types received from outside Android (such as user input,
10051 * or external sources like Bluetooth, NFC, or the Internet) should
10052 * be normalized before they are used to create an Intent.
10053 *
10054 * @param type MIME data type to normalize
10055 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010056 * @see #setType
10057 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010058 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010059 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010060 if (type == null) {
10061 return null;
10062 }
10063
Elliott Hughescb64d432013-08-02 10:00:44 -070010064 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010065
10066 final int semicolonIndex = type.indexOf(';');
10067 if (semicolonIndex != -1) {
10068 type = type.substring(0, semicolonIndex);
10069 }
10070 return type;
10071 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010072
10073 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010074 * Prepare this {@link Intent} to leave an app process.
10075 *
10076 * @hide
10077 */
Jeff Sharkey344744b2016-01-28 19:03:30 -070010078 public void prepareToLeaveProcess(Context context) {
10079 final boolean leavingPackage = (mComponent == null)
10080 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10081 prepareToLeaveProcess(leavingPackage);
10082 }
10083
10084 /**
10085 * Prepare this {@link Intent} to leave an app process.
10086 *
10087 * @hide
10088 */
10089 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010090 setAllowFds(false);
10091
10092 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010093 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010094 }
10095 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010096 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010097 }
10098
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010099 if (mExtras != null && !mExtras.isParcelled()) {
10100 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10101 if (intent instanceof Intent) {
10102 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10103 }
10104 }
10105
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010106 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10107 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010108 switch (mAction) {
10109 case ACTION_MEDIA_REMOVED:
10110 case ACTION_MEDIA_UNMOUNTED:
10111 case ACTION_MEDIA_CHECKING:
10112 case ACTION_MEDIA_NOFS:
10113 case ACTION_MEDIA_MOUNTED:
10114 case ACTION_MEDIA_SHARED:
10115 case ACTION_MEDIA_UNSHARED:
10116 case ACTION_MEDIA_BAD_REMOVAL:
10117 case ACTION_MEDIA_UNMOUNTABLE:
10118 case ACTION_MEDIA_EJECT:
10119 case ACTION_MEDIA_SCANNER_STARTED:
10120 case ACTION_MEDIA_SCANNER_FINISHED:
10121 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010122 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10123 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010124 // Ignore legacy actions
10125 break;
10126 default:
10127 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010128 }
10129 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010130
10131 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10132 && leavingPackage) {
10133 switch (mAction) {
10134 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010135 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010136 // Ignore actions that don't need to grant
10137 break;
10138 default:
10139 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10140 }
10141 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010142 }
10143
10144 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010145 * @hide
10146 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010147 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010148 // We just entered destination process, so we should be able to read all
10149 // parcelables inside.
10150 setDefusable(true);
10151
10152 if (mSelector != null) {
10153 mSelector.prepareToEnterProcess();
10154 }
10155 if (mClipData != null) {
10156 mClipData.prepareToEnterProcess();
10157 }
10158
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010159 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010160 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10161 fixUris(mContentUserHint);
10162 mContentUserHint = UserHandle.USER_CURRENT;
10163 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010164 }
10165 }
10166
Patrick Baumann577d4022018-01-31 16:55:10 +000010167 /** @hide */
10168 public boolean hasWebURI() {
10169 if (getData() == null) {
10170 return false;
10171 }
10172 final String scheme = getScheme();
10173 if (TextUtils.isEmpty(scheme)) {
10174 return false;
10175 }
10176 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10177 }
10178
10179 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010180 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010181 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010182 && hasWebURI();
10183 }
10184
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010185 /**
10186 * @hide
10187 */
10188 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010189 Uri data = getData();
10190 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010191 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010192 }
10193 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010194 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010195 }
10196 String action = getAction();
10197 if (ACTION_SEND.equals(action)) {
10198 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10199 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010200 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010201 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010202 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010203 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10204 if (streams != null) {
10205 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10206 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010207 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010208 }
10209 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10210 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010211 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10212 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10213 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10214 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10215 if (output != null) {
10216 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10217 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010218 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010219 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010220
10221 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010222 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010223 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10224 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010225 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010226 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010227 * @hide
10228 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010229 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010230 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010231 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010232
10233 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010234 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010235
10236 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010237 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010238 // Inspect contained intents to see if we need to migrate extras. We
10239 // don't promote ClipData to the parent, since ChooserActivity will
10240 // already start the picked item as the caller, and we can't combine
10241 // the flags in a safe way.
10242
10243 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010244 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010245 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10246 if (intent != null) {
10247 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010248 }
10249 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010250 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010251 try {
10252 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10253 if (intents != null) {
10254 for (int i = 0; i < intents.length; i++) {
10255 final Intent intent = (Intent) intents[i];
10256 if (intent != null) {
10257 migrated |= intent.migrateExtraStreamToClipData();
10258 }
10259 }
10260 }
10261 } catch (ClassCastException e) {
10262 }
10263 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010264
10265 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010266 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010267 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10268 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10269 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10270 if (stream != null || text != null || htmlText != null) {
10271 final ClipData clipData = new ClipData(
10272 null, new String[] { getType() },
10273 new ClipData.Item(text, htmlText, null, stream));
10274 setClipData(clipData);
10275 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010276 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010277 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010278 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010279 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010280
10281 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010282 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010283 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10284 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10285 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10286 int num = -1;
10287 if (streams != null) {
10288 num = streams.size();
10289 }
10290 if (texts != null) {
10291 if (num >= 0 && num != texts.size()) {
10292 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010293 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010294 }
10295 num = texts.size();
10296 }
10297 if (htmlTexts != null) {
10298 if (num >= 0 && num != htmlTexts.size()) {
10299 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010300 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010301 }
10302 num = htmlTexts.size();
10303 }
10304 if (num > 0) {
10305 final ClipData clipData = new ClipData(
10306 null, new String[] { getType() },
10307 makeClipItem(streams, texts, htmlTexts, 0));
10308
10309 for (int i = 1; i < num; i++) {
10310 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10311 }
10312
10313 setClipData(clipData);
10314 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010315 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010316 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010317 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010318 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010319 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10320 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10321 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10322 final Uri output;
10323 try {
10324 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10325 } catch (ClassCastException e) {
10326 return false;
10327 }
10328 if (output != null) {
10329 setClipData(ClipData.newRawUri("", output));
10330 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10331 return true;
10332 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010333 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010334
10335 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010336 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010337
Michael Wright19859762017-09-18 20:57:58 +010010338 /**
10339 * Convert the dock state to a human readable format.
10340 * @hide
10341 */
10342 public static String dockStateToString(int dock) {
10343 switch (dock) {
10344 case EXTRA_DOCK_STATE_HE_DESK:
10345 return "EXTRA_DOCK_STATE_HE_DESK";
10346 case EXTRA_DOCK_STATE_LE_DESK:
10347 return "EXTRA_DOCK_STATE_LE_DESK";
10348 case EXTRA_DOCK_STATE_CAR:
10349 return "EXTRA_DOCK_STATE_CAR";
10350 case EXTRA_DOCK_STATE_DESK:
10351 return "EXTRA_DOCK_STATE_DESK";
10352 case EXTRA_DOCK_STATE_UNDOCKED:
10353 return "EXTRA_DOCK_STATE_UNDOCKED";
10354 default:
10355 return Integer.toString(dock);
10356 }
10357 }
10358
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010359 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10360 ArrayList<String> htmlTexts, int which) {
10361 Uri uri = streams != null ? streams.get(which) : null;
10362 CharSequence text = texts != null ? texts.get(which) : null;
10363 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10364 return new ClipData.Item(text, htmlText, null, uri);
10365 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010366
10367 /** @hide */
10368 public boolean isDocument() {
10369 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10370 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010371}