blob: f05a4d1aa9c78bb8a3ac7b5a1ed4bc68cf973c1a [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;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054import android.util.AttributeSet;
55import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070056import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070057
Dianne Hackborn2269d1572010-02-24 19:54:22 -080058import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070059
Jason Monk2f68e8a2016-02-23 17:57:28 -050060import org.xmlpull.v1.XmlPullParser;
61import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070062import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070063
64import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080065import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070067import java.lang.annotation.Retention;
68import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070069import java.net.URISyntaxException;
70import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080071import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070072import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080073import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070074import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070075import java.util.Set;
76
77/**
78 * An intent is an abstract description of an operation to be performed. It
79 * can be used with {@link Context#startActivity(Intent) startActivity} to
80 * launch an {@link android.app.Activity},
81 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
82 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
83 * and {@link android.content.Context#startService} or
84 * {@link android.content.Context#bindService} to communicate with a
85 * background {@link android.app.Service}.
86 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 * <p>An Intent provides a facility for performing late runtime binding between the code in
88 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070089 * can be thought of as the glue between activities. It is basically a passive data structure
90 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070091 *
92 * <div class="special reference">
93 * <h3>Developer Guides</h3>
94 * <p>For information about how to create and resolve intents, read the
95 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
96 * developer guide.</p>
97 * </div>
98 *
99 * <a name="IntentStructure"></a>
100 * <h3>Intent Structure</h3>
101 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700102 *
103 * <ul>
104 * <li> <p><b>action</b> -- The general action to be performed, such as
105 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
106 * etc.</p>
107 * </li>
108 * <li> <p><b>data</b> -- The data to operate on, such as a person record
109 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
110 * </li>
111 * </ul>
112 *
113 *
114 * <p>Some examples of action/data pairs are:</p>
115 *
116 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700117 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700118 * information about the person whose identifier is "1".</p>
119 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700120 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * the phone dialer with the person filled in.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700125 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * a particular URI.</p>
127 * </li>
128 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
129 * the phone dialer with the given number filled in.</p>
130 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700131 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * information about the person whose identifier is "1".</p>
133 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700134 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * a list of people, which the user can browse through. This example is a
136 * typical top-level entry into the Contacts application, showing you the
137 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700138 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700139 * being used to start an activity to display that person.</p>
140 * </li>
141 * </ul>
142 *
143 * <p>In addition to these primary attributes, there are a number of secondary
144 * attributes that you can also include with an intent:</p>
145 *
146 * <ul>
147 * <li> <p><b>category</b> -- Gives additional information about the action
148 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
149 * appear in the Launcher as a top-level application, while
150 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
151 * of alternative actions the user can perform on a piece of data.</p>
152 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
153 * intent data. Normally the type is inferred from the data itself.
154 * By setting this attribute, you disable that evaluation and force
155 * an explicit type.</p>
156 * <li> <p><b>component</b> -- Specifies an explicit name of a component
157 * class to use for the intent. Normally this is determined by looking
158 * at the other information in the intent (the action, data/type, and
159 * categories) and matching that with a component that can handle it.
160 * If this attribute is set then none of the evaluation is performed,
161 * and this component is used exactly as is. By specifying this attribute,
162 * all of the other Intent attributes become optional.</p>
163 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
164 * This can be used to provide extended information to the component.
165 * For example, if we have a action to send an e-mail message, we could
166 * also include extra pieces of data here to supply a subject, body,
167 * etc.</p>
168 * </ul>
169 *
170 * <p>Here are some examples of other operations you can specify as intents
171 * using these additional parameters:</p>
172 *
173 * <ul>
174 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
175 * Launch the home screen.</p>
176 * </li>
177 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
178 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
179 * vnd.android.cursor.item/phone}</i></b>
180 * -- Display the list of people's phone numbers, allowing the user to
181 * browse through them and pick one and return it to the parent activity.</p>
182 * </li>
183 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
184 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
185 * -- Display all pickers for data that can be opened with
186 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
187 * allowing the user to pick one of them and then some data inside of it
188 * and returning the resulting URI to the caller. This can be used,
189 * for example, in an e-mail application to allow the user to pick some
190 * data to include as an attachment.</p>
191 * </li>
192 * </ul>
193 *
194 * <p>There are a variety of standard Intent action and category constants
195 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700196 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700197 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700198 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700199 *
200 * <p>Put together, the set of actions, data types, categories, and extra data
201 * defines a language for the system allowing for the expression of phrases
202 * such as "call john smith's cell". As applications are added to the system,
203 * they can extend this language by adding new actions, types, and categories, or
204 * they can modify the behavior of existing phrases by supplying their own
205 * activities that handle them.</p>
206 *
207 * <a name="IntentResolution"></a>
208 * <h3>Intent Resolution</h3>
209 *
210 * <p>There are two primary forms of intents you will use.
211 *
212 * <ul>
213 * <li> <p><b>Explicit Intents</b> have specified a component (via
214 * {@link #setComponent} or {@link #setClass}), which provides the exact
215 * class to be run. Often these will not include any other information,
216 * simply being a way for an application to launch various internal
217 * activities it has as the user interacts with the application.
218 *
219 * <li> <p><b>Implicit Intents</b> have not specified a component;
220 * instead, they must include enough information for the system to
221 * determine which of the available components is best to run for that
222 * intent.
223 * </ul>
224 *
225 * <p>When using implicit intents, given such an arbitrary intent we need to
226 * know what to do with it. This is handled by the process of <em>Intent
227 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
228 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
229 * more activities/receivers) that can handle it.</p>
230 *
231 * <p>The intent resolution mechanism basically revolves around matching an
232 * Intent against all of the &lt;intent-filter&gt; descriptions in the
233 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
234 * objects explicitly registered with {@link Context#registerReceiver}.) More
235 * details on this can be found in the documentation on the {@link
236 * IntentFilter} class.</p>
237 *
238 * <p>There are three pieces of information in the Intent that are used for
239 * resolution: the action, type, and category. Using this information, a query
240 * is done on the {@link PackageManager} for a component that can handle the
241 * intent. The appropriate component is determined based on the intent
242 * information supplied in the <code>AndroidManifest.xml</code> file as
243 * follows:</p>
244 *
245 * <ul>
246 * <li> <p>The <b>action</b>, if given, must be listed by the component as
247 * one it handles.</p>
248 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
249 * already supplied in the Intent. Like the action, if a type is
250 * included in the intent (either explicitly or implicitly in its
251 * data), then this must be listed by the component as one it handles.</p>
252 * <li> For data that is not a <code>content:</code> URI and where no explicit
253 * type is included in the Intent, instead the <b>scheme</b> of the
254 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
255 * considered. Again like the action, if we are matching a scheme it
256 * must be listed by the component as one it can handle.
257 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
258 * by the activity as categories it handles. That is, if you include
259 * the categories {@link #CATEGORY_LAUNCHER} and
260 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
261 * with an intent that lists <em>both</em> of those categories.
262 * Activities will very often need to support the
263 * {@link #CATEGORY_DEFAULT} so that they can be found by
264 * {@link Context#startActivity Context.startActivity()}.</p>
265 * </ul>
266 *
267 * <p>For example, consider the Note Pad sample application that
268 * allows user to browse through a list of notes data and view details about
269 * individual items. Text in italics indicate places were you would replace a
270 * name with one specific to your own package.</p>
271 *
272 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
273 * package="<i>com.android.notepad</i>"&gt;
274 * &lt;application android:icon="@drawable/app_notes"
275 * android:label="@string/app_name"&gt;
276 *
277 * &lt;provider class=".NotePadProvider"
278 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
279 *
280 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.MAIN" /&gt;
283 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.VIEW" /&gt;
287 * &lt;action android:name="android.intent.action.EDIT" /&gt;
288 * &lt;action android:name="android.intent.action.PICK" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700293 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
294 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 * &lt;/activity&gt;
298 *
299 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
300 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.VIEW" /&gt;
302 * &lt;action android:name="android.intent.action.EDIT" /&gt;
303 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
304 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700305 * &lt;/intent-filter&gt;
306 *
307 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700308 * &lt;action android:name="android.intent.action.INSERT" /&gt;
309 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
310 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700311 * &lt;/intent-filter&gt;
312 *
313 * &lt;/activity&gt;
314 *
315 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
316 * android:theme="@android:style/Theme.Dialog"&gt;
317 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700318 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
319 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
320 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
321 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
322 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700323 * &lt;/intent-filter&gt;
324 * &lt;/activity&gt;
325 *
326 * &lt;/application&gt;
327 * &lt;/manifest&gt;</pre>
328 *
329 * <p>The first activity,
330 * <code>com.android.notepad.NotesList</code>, serves as our main
331 * entry into the app. It can do three things as described by its three intent
332 * templates:
333 * <ol>
334 * <li><pre>
335 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700336 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
337 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700338 * &lt;/intent-filter&gt;</pre>
339 * <p>This provides a top-level entry into the NotePad application: the standard
340 * MAIN action is a main entry point (not requiring any other information in
341 * the Intent), and the LAUNCHER category says that this entry point should be
342 * listed in the application launcher.</p>
343 * <li><pre>
344 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700345 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
346 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
347 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
348 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700349 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700350 * &lt;/intent-filter&gt;</pre>
351 * <p>This declares the things that the activity can do on a directory of
352 * notes. The type being supported is given with the &lt;type&gt; tag, where
353 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
354 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
355 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
356 * The activity allows the user to view or edit the directory of data (via
357 * the VIEW and EDIT actions), or to pick a particular note and return it
358 * to the caller (via the PICK action). Note also the DEFAULT category
359 * supplied here: this is <em>required</em> for the
360 * {@link Context#startActivity Context.startActivity} method to resolve your
361 * activity when its component name is not explicitly specified.</p>
362 * <li><pre>
363 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700364 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
365 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
366 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700367 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700368 * <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 -0700369 * the user without needing to know where it came from. The data type
370 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
371 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
372 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
373 * The GET_CONTENT action is similar to the PICK action, where the activity
374 * will return to its caller a piece of data selected by the user. Here,
375 * however, the caller specifies the type of data they desire instead of
376 * the type of data the user will be picking from.</p>
377 * </ol>
378 *
379 * <p>Given these capabilities, the following intents will resolve to the
380 * NotesList activity:</p>
381 *
382 * <ul>
383 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
384 * activities that can be used as top-level entry points into an
385 * application.</p>
386 * <li> <p><b>{ action=android.app.action.MAIN,
387 * category=android.app.category.LAUNCHER }</b> is the actual intent
388 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700389 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700390 * data=content://com.google.provider.NotePad/notes }</b>
391 * displays a list of all the notes under
392 * "content://com.google.provider.NotePad/notes", which
393 * the user can browse through and see the details on.</p>
394 * <li> <p><b>{ action=android.app.action.PICK
395 * data=content://com.google.provider.NotePad/notes }</b>
396 * provides a list of the notes under
397 * "content://com.google.provider.NotePad/notes", from which
398 * the user can pick a note whose data URL is returned back to the caller.</p>
399 * <li> <p><b>{ action=android.app.action.GET_CONTENT
400 * type=vnd.android.cursor.item/vnd.google.note }</b>
401 * is similar to the pick action, but allows the caller to specify the
402 * kind of data they want back so that the system can find the appropriate
403 * activity to pick something of that data type.</p>
404 * </ul>
405 *
406 * <p>The second activity,
407 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
408 * note entry and allows them to edit it. It can do two things as described
409 * by its two intent templates:
410 * <ol>
411 * <li><pre>
412 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700413 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
414 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
415 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
416 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700417 * &lt;/intent-filter&gt;</pre>
418 * <p>The first, primary, purpose of this activity is to let the user interact
419 * with a single note, as decribed by the MIME type
420 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
421 * either VIEW a note or allow the user to EDIT it. Again we support the
422 * DEFAULT category to allow the activity to be launched without explicitly
423 * specifying its component.</p>
424 * <li><pre>
425 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700426 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
427 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
428 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700429 * &lt;/intent-filter&gt;</pre>
430 * <p>The secondary use of this activity is to insert a new note entry into
431 * an existing directory of notes. This is used when the user creates a new
432 * note: the INSERT action is executed on the directory of notes, causing
433 * this activity to run and have the user create the new note data which
434 * it then adds to the content provider.</p>
435 * </ol>
436 *
437 * <p>Given these capabilities, the following intents will resolve to the
438 * NoteEditor activity:</p>
439 *
440 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700441 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700442 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
443 * shows the user the content of note <var>{ID}</var>.</p>
444 * <li> <p><b>{ action=android.app.action.EDIT
445 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
446 * allows the user to edit the content of note <var>{ID}</var>.</p>
447 * <li> <p><b>{ action=android.app.action.INSERT
448 * data=content://com.google.provider.NotePad/notes }</b>
449 * creates a new, empty note in the notes list at
450 * "content://com.google.provider.NotePad/notes"
451 * and allows the user to edit it. If they keep their changes, the URI
452 * of the newly created note is returned to the caller.</p>
453 * </ul>
454 *
455 * <p>The last activity,
456 * <code>com.android.notepad.TitleEditor</code>, allows the user to
457 * edit the title of a note. This could be implemented as a class that the
458 * application directly invokes (by explicitly setting its component in
459 * the Intent), but here we show a way you can publish alternative
460 * operations on existing data:</p>
461 *
462 * <pre>
463 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700464 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
465 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
466 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
467 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
468 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700469 * &lt;/intent-filter&gt;</pre>
470 *
471 * <p>In the single intent template here, we
472 * have created our own private action called
473 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
474 * edit the title of a note. It must be invoked on a specific note
475 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
476 * view and edit actions, but here displays and edits the title contained
477 * in the note data.
478 *
479 * <p>In addition to supporting the default category as usual, our title editor
480 * also supports two other standard categories: ALTERNATIVE and
481 * SELECTED_ALTERNATIVE. Implementing
482 * these categories allows others to find the special action it provides
483 * without directly knowing about it, through the
484 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
485 * more often to build dynamic menu items with
486 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
487 * template here was also supply an explicit name for the template
488 * (via <code>android:label="@string/resolve_title"</code>) to better control
489 * what the user sees when presented with this activity as an alternative
490 * action to the data they are viewing.
491 *
492 * <p>Given these capabilities, the following intent will resolve to the
493 * TitleEditor activity:</p>
494 *
495 * <ul>
496 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
497 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
498 * displays and allows the user to edit the title associated
499 * with note <var>{ID}</var>.</p>
500 * </ul>
501 *
502 * <h3>Standard Activity Actions</h3>
503 *
504 * <p>These are the current standard actions that Intent defines for launching
505 * activities (usually through {@link Context#startActivity}. The most
506 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
507 * {@link #ACTION_EDIT}.
508 *
509 * <ul>
510 * <li> {@link #ACTION_MAIN}
511 * <li> {@link #ACTION_VIEW}
512 * <li> {@link #ACTION_ATTACH_DATA}
513 * <li> {@link #ACTION_EDIT}
514 * <li> {@link #ACTION_PICK}
515 * <li> {@link #ACTION_CHOOSER}
516 * <li> {@link #ACTION_GET_CONTENT}
517 * <li> {@link #ACTION_DIAL}
518 * <li> {@link #ACTION_CALL}
519 * <li> {@link #ACTION_SEND}
520 * <li> {@link #ACTION_SENDTO}
521 * <li> {@link #ACTION_ANSWER}
522 * <li> {@link #ACTION_INSERT}
523 * <li> {@link #ACTION_DELETE}
524 * <li> {@link #ACTION_RUN}
525 * <li> {@link #ACTION_SYNC}
526 * <li> {@link #ACTION_PICK_ACTIVITY}
527 * <li> {@link #ACTION_SEARCH}
528 * <li> {@link #ACTION_WEB_SEARCH}
529 * <li> {@link #ACTION_FACTORY_TEST}
530 * </ul>
531 *
532 * <h3>Standard Broadcast Actions</h3>
533 *
534 * <p>These are the current standard actions that Intent defines for receiving
535 * broadcasts (usually through {@link Context#registerReceiver} or a
536 * &lt;receiver&gt; tag in a manifest).
537 *
538 * <ul>
539 * <li> {@link #ACTION_TIME_TICK}
540 * <li> {@link #ACTION_TIME_CHANGED}
541 * <li> {@link #ACTION_TIMEZONE_CHANGED}
542 * <li> {@link #ACTION_BOOT_COMPLETED}
543 * <li> {@link #ACTION_PACKAGE_ADDED}
544 * <li> {@link #ACTION_PACKAGE_CHANGED}
545 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546 * <li> {@link #ACTION_PACKAGE_RESTARTED}
547 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000548 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
549 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * <li> {@link #ACTION_UID_REMOVED}
551 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700552 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700553 * <li> {@link #ACTION_POWER_DISCONNECTED}
554 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700555 * </ul>
556 *
557 * <h3>Standard Categories</h3>
558 *
559 * <p>These are the current standard categories that can be used to further
560 * clarify an Intent via {@link #addCategory}.
561 *
562 * <ul>
563 * <li> {@link #CATEGORY_DEFAULT}
564 * <li> {@link #CATEGORY_BROWSABLE}
565 * <li> {@link #CATEGORY_TAB}
566 * <li> {@link #CATEGORY_ALTERNATIVE}
567 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
568 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * <li> {@link #CATEGORY_HOME}
571 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400573 * <li> {@link #CATEGORY_CAR_DOCK}
574 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500575 * <li> {@link #CATEGORY_LE_DESK_DOCK}
576 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200577 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700578 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800579 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700580 * </ul>
581 *
582 * <h3>Standard Extra Data</h3>
583 *
584 * <p>These are the current standard fields that can be used as extra data via
585 * {@link #putExtra}.
586 *
587 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800588 * <li> {@link #EXTRA_ALARM_COUNT}
589 * <li> {@link #EXTRA_BCC}
590 * <li> {@link #EXTRA_CC}
591 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
592 * <li> {@link #EXTRA_DATA_REMOVED}
593 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500594 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
595 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_DOCK_STATE_CAR}
597 * <li> {@link #EXTRA_DOCK_STATE_DESK}
598 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
599 * <li> {@link #EXTRA_DONT_KILL_APP}
600 * <li> {@link #EXTRA_EMAIL}
601 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700604 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800605 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700606 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
608 * <li> {@link #EXTRA_REPLACING}
609 * <li> {@link #EXTRA_SHORTCUT_ICON}
610 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
611 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_SHORTCUT_NAME}
614 * <li> {@link #EXTRA_SUBJECT}
615 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800617 * <li> {@link #EXTRA_TITLE}
618 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 * </ul>
620 *
621 * <h3>Flags</h3>
622 *
623 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800624 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
625 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700626 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800627public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700628 private static final String ATTR_ACTION = "action";
629 private static final String TAG_CATEGORIES = "categories";
630 private static final String ATTR_CATEGORY = "category";
631 private static final String TAG_EXTRA = "extra";
632 private static final String ATTR_TYPE = "type";
633 private static final String ATTR_COMPONENT = "component";
634 private static final String ATTR_DATA = "data";
635 private static final String ATTR_FLAGS = "flags";
636
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700637 // ---------------------------------------------------------------------
638 // ---------------------------------------------------------------------
639 // Standard intent activity actions (see action variable).
640
641 /**
642 * Activity Action: Start as a main entry point, does not expect to
643 * receive data.
644 * <p>Input: nothing
645 * <p>Output: nothing
646 */
647 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
648 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800649
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700650 /**
651 * Activity Action: Display the data to the user. This is the most common
652 * action performed on data -- it is the generic action you can use on
653 * a piece of data to get the most reasonable thing to occur. For example,
654 * when used on a contacts entry it will view the entry; when used on a
655 * mailto: URI it will bring up a compose window filled with the information
656 * supplied by the URI; when used with a tel: URI it will invoke the
657 * dialer.
658 * <p>Input: {@link #getData} is URI from which to retrieve data.
659 * <p>Output: nothing.
660 */
661 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
662 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800663
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700664 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700665 * Extra that can be included on activity intents coming from the storage UI
666 * when it launches sub-activities to manage various types of storage. For example,
667 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
668 * the images on the device, and in that case also include this extra to tell the
669 * app it is coming from the storage UI so should help the user manage storage of
670 * this type.
671 */
672 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
673
674 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
676 * performed on a piece of data.
677 */
678 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800679
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700680 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900681 * Activity Action: Quick view the data. Launches a quick viewer for
682 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900683 * <p>Activities handling this intent action should handle the vast majority of
684 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700685 * <p>Quick viewers must render the quick view image locally, and must not send
686 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900687 * <p>Input: {@link #getData} is a mandatory content URI of the item to
688 * preview. {@link #getClipData} contains an optional list of content URIs
689 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
690 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700691 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
692 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700693 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900694 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700695 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700696 */
697 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
698 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
699
700 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700701 * Used to indicate that some piece of data should be attached to some other
702 * place. For example, image data could be attached to a contact. It is up
703 * to the recipient to decide where the data should be attached; the intent
704 * does not specify the ultimate destination.
705 * <p>Input: {@link #getData} is URI of data to be attached.
706 * <p>Output: nothing.
707 */
708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
709 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800710
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700711 /**
712 * Activity Action: Provide explicit editable access to the given data.
713 * <p>Input: {@link #getData} is URI of data to be edited.
714 * <p>Output: nothing.
715 */
716 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
717 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800718
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700719 /**
720 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
721 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
722 * The extras can contain type specific data to pass through to the editing/creating
723 * activity.
724 * <p>Output: The URI of the item that was picked. This must be a content:
725 * URI so that any receiver can access it.
726 */
727 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
728 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800729
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 /**
731 * Activity Action: Pick an item from the data, returning what was selected.
732 * <p>Input: {@link #getData} is URI containing a directory of data
733 * (vnd.android.cursor.dir/*) from which to pick an item.
734 * <p>Output: The URI of the item that was picked.
735 */
736 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
737 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800738
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700739 /**
740 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800742 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
743 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
745 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800746 * (value: ShortcutIconResource).</p>
747 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 * @see #EXTRA_SHORTCUT_INTENT
750 * @see #EXTRA_SHORTCUT_NAME
751 * @see #EXTRA_SHORTCUT_ICON
752 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
753 * @see android.content.Intent.ShortcutIconResource
754 */
755 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
756 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
757
758 /**
759 * The name of the extra used to define the Intent of a shortcut.
760 *
761 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800762 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700763 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
766 /**
767 * The name of the extra used to define the name of a shortcut.
768 *
769 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800770 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700771 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
774 /**
775 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
776 *
777 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800778 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700779 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800780 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700781 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
782 /**
783 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
784 *
785 * @see #ACTION_CREATE_SHORTCUT
786 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800787 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700788 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800789 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
791 "android.intent.extra.shortcut.ICON_RESOURCE";
792
793 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500794 * An activity that provides a user interface for adjusting application preferences.
795 * Optional but recommended settings for all applications which have settings.
796 */
797 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
798 public static final String ACTION_APPLICATION_PREFERENCES
799 = "android.intent.action.APPLICATION_PREFERENCES";
800
801 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700802 * Activity Action: Launch an activity showing the app information.
803 * For applications which install other applications (such as app stores), it is recommended
804 * to handle this action for providing the app information to the user.
805 *
806 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
807 * to be displayed.
808 * <p>Output: Nothing.
809 */
810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
811 public static final String ACTION_SHOW_APP_INFO
812 = "android.intent.action.SHOW_APP_INFO";
813
814 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800815 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700816 *
817 * @see Intent#ACTION_CREATE_SHORTCUT
818 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800819 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
820 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821 */
822 public static class ShortcutIconResource implements Parcelable {
823 /**
824 * The package name of the application containing the icon.
825 */
826 public String packageName;
827
828 /**
829 * The resource name of the icon, including package, name and type.
830 */
831 public String resourceName;
832
833 /**
834 * Creates a new ShortcutIconResource for the specified context and resource
835 * identifier.
836 *
837 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700838 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700839 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700840 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700841 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700842 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 ShortcutIconResource icon = new ShortcutIconResource();
844 icon.packageName = context.getPackageName();
845 icon.resourceName = context.getResources().getResourceName(resourceId);
846 return icon;
847 }
848
849 /**
850 * Used to read a ShortcutIconResource from a Parcel.
851 */
852 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
853 new Parcelable.Creator<ShortcutIconResource>() {
854
855 public ShortcutIconResource createFromParcel(Parcel source) {
856 ShortcutIconResource icon = new ShortcutIconResource();
857 icon.packageName = source.readString();
858 icon.resourceName = source.readString();
859 return icon;
860 }
861
862 public ShortcutIconResource[] newArray(int size) {
863 return new ShortcutIconResource[size];
864 }
865 };
866
867 /**
868 * No special parcel contents.
869 */
870 public int describeContents() {
871 return 0;
872 }
873
874 public void writeToParcel(Parcel dest, int flags) {
875 dest.writeString(packageName);
876 dest.writeString(resourceName);
877 }
878
879 @Override
880 public String toString() {
881 return resourceName;
882 }
883 }
884
885 /**
886 * Activity Action: Display an activity chooser, allowing the user to pick
887 * what they want to before proceeding. This can be used as an alternative
888 * to the standard activity picker that is displayed by the system when
889 * you try to start an activity with multiple possible matches, with these
890 * differences in behavior:
891 * <ul>
892 * <li>You can specify the title that will appear in the activity chooser.
893 * <li>The user does not have the option to make one of the matching
894 * activities a preferred activity, and all possible activities will
895 * always be shown even if one of them is currently marked as the
896 * preferred activity.
897 * </ul>
898 * <p>
899 * This action should be used when the user will naturally expect to
900 * select an activity in order to proceed. An example if when not to use
901 * it is when the user clicks on a "mailto:" link. They would naturally
902 * expect to go directly to their mail app, so startActivity() should be
903 * called directly: it will
904 * either launch the current preferred app, or put up a dialog allowing the
905 * user to pick an app to use and optionally marking that as preferred.
906 * <p>
907 * In contrast, if the user is selecting a menu item to send a picture
908 * they are viewing to someone else, there are many different things they
909 * may want to do at this point: send it through e-mail, upload it to a
910 * web service, etc. In this case the CHOOSER action should be used, to
911 * always present to the user a list of the things they can do, with a
912 * nice title given by the caller such as "Send this photo with:".
913 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700914 * If you need to grant URI permissions through a chooser, you must specify
915 * the permissions to be granted on the ACTION_CHOOSER Intent
916 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
917 * {@link #setClipData} to specify the URIs to be granted as well as
918 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
919 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
920 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700921 * As a convenience, an Intent of this form can be created with the
922 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700923 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700924 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
926 * and can optionally have a {@link #EXTRA_TITLE} field containing the
927 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700928 * <p>
929 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 */
931 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
932 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
933
934 /**
935 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
936 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700937 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
938 * target intent, also optionally supplying a title. If the target
939 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
940 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
941 * set in the returned chooser intent, with its ClipData set appropriately:
942 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500943 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700944 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700945 * @param target The Intent that the user will be selecting an activity
946 * to perform.
947 * @param title Optional title that will be displayed in the chooser.
948 * @return Return a new Intent object that you can hand to
949 * {@link Context#startActivity(Intent) Context.startActivity()} and
950 * related methods.
951 */
952 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700953 return createChooser(target, title, null);
954 }
955
956 /**
957 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
958 *
959 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
960 * target intent, also optionally supplying a title. If the target
961 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
962 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
963 * set in the returned chooser intent, with its ClipData set appropriately:
964 * either a direct reflection of {@link #getClipData()} if that is non-null,
965 * or a new ClipData built from {@link #getData()}.</p>
966 *
967 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
968 * when the user makes a choice. This can be useful if the calling application wants
969 * to remember the last chosen target and surface it as a more prominent or one-touch
970 * affordance elsewhere in the UI for next time.</p>
971 *
972 * @param target The Intent that the user will be selecting an activity
973 * to perform.
974 * @param title Optional title that will be displayed in the chooser.
975 * @param sender Optional IntentSender to be called when a choice is made.
976 * @return Return a new Intent object that you can hand to
977 * {@link Context#startActivity(Intent) Context.startActivity()} and
978 * related methods.
979 */
980 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700981 Intent intent = new Intent(ACTION_CHOOSER);
982 intent.putExtra(EXTRA_INTENT, target);
983 if (title != null) {
984 intent.putExtra(EXTRA_TITLE, title);
985 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700986
Adam Powell0b3c1122014-10-09 12:50:14 -0700987 if (sender != null) {
988 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
989 }
990
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700991 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700992 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
993 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
994 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700995 if (permFlags != 0) {
996 ClipData targetClipData = target.getClipData();
997 if (targetClipData == null && target.getData() != null) {
998 ClipData.Item item = new ClipData.Item(target.getData());
999 String[] mimeTypes;
1000 if (target.getType() != null) {
1001 mimeTypes = new String[] { target.getType() };
1002 } else {
1003 mimeTypes = new String[] { };
1004 }
1005 targetClipData = new ClipData(null, mimeTypes, item);
1006 }
1007 if (targetClipData != null) {
1008 intent.setClipData(targetClipData);
1009 intent.addFlags(permFlags);
1010 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001011 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001013 return intent;
1014 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001015
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 /**
1017 * Activity Action: Allow the user to select a particular kind of data and
1018 * return it. This is different than {@link #ACTION_PICK} in that here we
1019 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001020 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001021 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001022 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001023 * etc.
1024 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001025 * 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 -07001026 * of data, such as a person contact, you set the MIME type to the kind of
1027 * data you want and launch it with {@link Context#startActivity(Intent)}.
1028 * The system will then launch the best application to select that kind
1029 * of data for you.
1030 * <p>
1031 * You may also be interested in any of a set of types of content the user
1032 * can pick. For example, an e-mail application that wants to allow the
1033 * user to add an attachment to an e-mail message can use this action to
1034 * bring up a list of all of the types of content the user can attach.
1035 * <p>
1036 * In this case, you should wrap the GET_CONTENT intent with a chooser
1037 * (through {@link #createChooser}), which will give the proper interface
1038 * for the user to pick how to send your data and allow you to specify
1039 * a prompt indicating what they are doing. You will usually specify a
1040 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1041 * broad range of content types the user can select from.
1042 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001043 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 * only pick from data that can be represented as a stream. This is
1045 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1046 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001048 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001049 * is locally available on the device. For example, if this extra is set
1050 * to true then an image picker should not show any pictures that are available
1051 * from a remote server but not already on the local device (thus requiring
1052 * they be downloaded when opened).
1053 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001054 * If the caller can handle multiple returned items (the user performing
1055 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1056 * to indicate this.
1057 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001058 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1059 * that no URI is supplied in the intent, as there are no constraints on
1060 * where the returned data originally comes from. You may also include the
1061 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001062 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001063 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1064 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001065 * <p>
1066 * Output: The URI of the item that was picked. This must be a content:
1067 * URI so that any receiver can access it.
1068 */
1069 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1070 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1071 /**
1072 * Activity Action: Dial a number as specified by the data. This shows a
1073 * UI with the number being dialed, allowing the user to explicitly
1074 * initiate the call.
1075 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1076 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1077 * number.
1078 * <p>Output: nothing.
1079 */
1080 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1081 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1082 /**
1083 * Activity Action: Perform a call to someone specified by the data.
1084 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1085 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1086 * number.
1087 * <p>Output: nothing.
1088 *
1089 * <p>Note: there will be restrictions on which applications can initiate a
1090 * call; most applications should use the {@link #ACTION_DIAL}.
1091 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1092 * numbers. Applications can <strong>dial</strong> emergency numbers using
1093 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001094 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001095 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001096 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001097 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001098 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001099 */
1100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1101 public static final String ACTION_CALL = "android.intent.action.CALL";
1102 /**
1103 * Activity Action: Perform a call to an emergency number specified by the
1104 * data.
1105 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1106 * tel: URI of an explicit phone number.
1107 * <p>Output: nothing.
1108 * @hide
1109 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001110 @SystemApi
1111 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001112 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1113 /**
1114 * Activity action: Perform a call to any number (emergency or not)
1115 * specified by the data.
1116 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1117 * tel: URI of an explicit phone number.
1118 * <p>Output: nothing.
1119 * @hide
1120 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001121 @SystemApi
1122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001123 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001124
Santos Cordon15a13782015-03-31 18:32:31 -07001125 /**
fionaxuadfe7002017-02-17 17:20:46 -08001126 * Activity Action: Main entry point for carrier setup apps.
1127 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1128 * carrier service and typically require
1129 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1130 * fulfill their duties.
1131 */
1132 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1133 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1134 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001135 * Activity Action: Send a message to someone specified by the data.
1136 * <p>Input: {@link #getData} is URI describing the target.
1137 * <p>Output: nothing.
1138 */
1139 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1140 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1141 /**
1142 * Activity Action: Deliver some data to someone else. Who the data is
1143 * being delivered to is not specified; it is up to the receiver of this
1144 * action to ask the user where the data should be sent.
1145 * <p>
1146 * When launching a SEND intent, you should usually wrap it in a chooser
1147 * (through {@link #createChooser}), which will give the proper interface
1148 * for the user to pick how to send your data and allow you to specify
1149 * a prompt indicating what they are doing.
1150 * <p>
1151 * Input: {@link #getType} is the MIME type of the data being sent.
1152 * get*Extra can have either a {@link #EXTRA_TEXT}
1153 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1154 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1155 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1156 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001157 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1158 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1159 * your text with HTML formatting.
1160 * <p>
1161 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1162 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1163 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1164 * content: URIs and other advanced features of {@link ClipData}. If
1165 * using this approach, you still must supply the same data through the
1166 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1167 * for compatibility with old applications. If you don't set a ClipData,
1168 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001169 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001170 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1171 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1172 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1173 * be openable only as asset typed files using
1174 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1175 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001176 * Optional standard extras, which may be interpreted by some recipients as
1177 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1178 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1179 * <p>
1180 * Output: nothing.
1181 */
1182 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1183 public static final String ACTION_SEND = "android.intent.action.SEND";
1184 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001185 * Activity Action: Deliver multiple data to someone else.
1186 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001187 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001188 * <p>
1189 * Input: {@link #getType} is the MIME type of the data being sent.
1190 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001191 * #EXTRA_STREAM} field, containing the data to be sent. If using
1192 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1193 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001194 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001195 * Multiple types are supported, and receivers should handle mixed types
1196 * whenever possible. The right way for the receiver to check them is to
1197 * use the content resolver on each URI. The intent sender should try to
1198 * put the most concrete mime type in the intent type, but it can fall
1199 * back to {@literal <type>/*} or {@literal *}/* as needed.
1200 * <p>
1201 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1202 * be image/jpg, but if you are sending image/jpg and image/png, then the
1203 * intent's type should be image/*.
1204 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001205 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1206 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1207 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1208 * content: URIs and other advanced features of {@link ClipData}. If
1209 * using this approach, you still must supply the same data through the
1210 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1211 * for compatibility with old applications. If you don't set a ClipData,
1212 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1213 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001214 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1215 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1216 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1217 * be openable only as asset typed files using
1218 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1219 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001220 * Optional standard extras, which may be interpreted by some recipients as
1221 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1222 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1223 * <p>
1224 * Output: nothing.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1228 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001229 * Activity Action: Handle an incoming phone call.
1230 * <p>Input: nothing.
1231 * <p>Output: nothing.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1235 /**
1236 * Activity Action: Insert an empty item into the given container.
1237 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1238 * in which to place the data.
1239 * <p>Output: URI of the new data that was created.
1240 */
1241 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1242 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1243 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001244 * Activity Action: Create a new item in the given container, initializing it
1245 * from the current contents of the clipboard.
1246 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1247 * in which to place the data.
1248 * <p>Output: URI of the new data that was created.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1252 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001253 * Activity Action: Delete the given data from its container.
1254 * <p>Input: {@link #getData} is URI of data to be deleted.
1255 * <p>Output: nothing.
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1259 /**
1260 * Activity Action: Run the data, whatever that means.
1261 * <p>Input: ? (Note: this is currently specific to the test harness.)
1262 * <p>Output: nothing.
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_RUN = "android.intent.action.RUN";
1266 /**
1267 * Activity Action: Perform a data synchronization.
1268 * <p>Input: ?
1269 * <p>Output: ?
1270 */
1271 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1272 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1273 /**
1274 * Activity Action: Pick an activity given an intent, returning the class
1275 * selected.
1276 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1277 * used with {@link PackageManager#queryIntentActivities} to determine the
1278 * set of activities from which to pick.
1279 * <p>Output: Class name of the activity that was selected.
1280 */
1281 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1282 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1283 /**
1284 * Activity Action: Perform a search.
1285 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1286 * is the text to search for. If empty, simply
1287 * enter your search results Activity with the search UI activated.
1288 * <p>Output: nothing.
1289 */
1290 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1291 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1292 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001293 * Activity Action: Start the platform-defined tutorial
1294 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1295 * is the text to search for. If empty, simply
1296 * enter your search results Activity with the search UI activated.
1297 * <p>Output: nothing.
1298 */
1299 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1300 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1301 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001302 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001303 * <p>
1304 * Input: {@link android.app.SearchManager#QUERY
1305 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1306 * a url starts with http or https, the site will be opened. If it is plain
1307 * text, Google search will be applied.
1308 * <p>
1309 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001310 */
1311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001313
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 /**
Jim Miller07994402012-05-02 14:22:27 -07001315 * Activity Action: Perform assist action.
1316 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001317 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1318 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001319 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1320 * information.
Jim Miller07994402012-05-02 14:22:27 -07001321 * Output: nothing.
1322 */
1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001325
1326 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001327 * Activity Action: Perform voice assist action.
1328 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001329 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1330 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001331 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001332 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001333 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001334 */
Amith Yamasani16452032017-03-03 10:15:57 -08001335 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001336 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1337 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1338
1339 /**
Adam Skory7140a252013-09-11 12:04:58 +01001340 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1341 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001342 */
1343 public static final String EXTRA_ASSIST_PACKAGE
1344 = "android.intent.extra.ASSIST_PACKAGE";
1345
1346 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001347 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1348 * application package at the time the assist was invoked.
1349 */
1350 public static final String EXTRA_ASSIST_UID
1351 = "android.intent.extra.ASSIST_UID";
1352
1353 /**
Adam Skory7140a252013-09-11 12:04:58 +01001354 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1355 * information supplied by the current foreground app at the time of the assist request.
1356 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001357 */
1358 public static final String EXTRA_ASSIST_CONTEXT
1359 = "android.intent.extra.ASSIST_CONTEXT";
1360
Jim Miller07994402012-05-02 14:22:27 -07001361 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001362 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1363 * keyboard as the primary input device for assistance.
1364 */
1365 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1366 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1367
1368 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001369 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1370 * that was used to invoke the assist.
1371 */
1372 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1373 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1374
1375 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001376 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001377 * <p>Input: Nothing.
1378 * <p>Output: nothing.
1379 */
1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1382 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001383 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001384 * <p>Input: Nothing.
1385 * <p>Output: Nothing.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1389
1390 /**
1391 * Activity Action: Show activity for reporting a bug.
1392 * <p>Input: Nothing.
1393 * <p>Output: Nothing.
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1397
1398 /**
1399 * Activity Action: Main entry point for factory tests. Only used when
1400 * the device is booting in factory test node. The implementing package
1401 * must be installed in the system image.
1402 * <p>Input: nothing
1403 * <p>Output: nothing
1404 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001406 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1407
1408 /**
1409 * Activity Action: The user pressed the "call" button to go to the dialer
1410 * or other appropriate UI for placing a call.
1411 * <p>Input: Nothing.
1412 * <p>Output: Nothing.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1416
1417 /**
1418 * Activity Action: Start Voice Command.
1419 * <p>Input: Nothing.
1420 * <p>Output: Nothing.
1421 */
1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001424
1425 /**
1426 * Activity Action: Start action associated with long pressing on the
1427 * search key.
1428 * <p>Input: Nothing.
1429 * <p>Output: Nothing.
1430 */
1431 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1432 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001433
Jacek Surazski86b6c532009-05-13 14:38:28 +02001434 /**
1435 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1436 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001437 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001438 * <p>Input: No data is specified. The bug report is passed in using
1439 * an {@link #EXTRA_BUG_REPORT} field.
1440 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001441 *
1442 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001443 */
1444 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1445 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001446
1447 /**
1448 * Activity Action: Show power usage information to the user.
1449 * <p>Input: Nothing.
1450 * <p>Output: Nothing.
1451 */
1452 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1453 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001454
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001455 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001456 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1457 * to run.
1458 * <p>Input: Nothing.
1459 * <p>Output: Nothing.
1460 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1461 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1462 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001463 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001464 */
1465 @Deprecated
1466 @SystemApi
1467 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1468 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1469
1470 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001471 * Activity Action: Setup wizard to launch after a platform update. This
1472 * activity should have a string meta-data field associated with it,
1473 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1474 * the platform for setup. The activity will be launched only if
1475 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1476 * same value.
1477 * <p>Input: Nothing.
1478 * <p>Output: Nothing.
1479 * @hide
1480 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001481 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001482 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1483 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001484
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001485 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001486 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1487 * <p>Input: Nothing.
1488 * <p>Output: Nothing.
1489 * @hide
1490 */
1491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1492 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001493 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001494
1495 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001496 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1497 * <p>Input: Nothing.
1498 * <p>Output: Nothing.
1499 * @hide
1500 */
1501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1502 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001503 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001504
1505 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001506 * Activity Action: Show settings for managing network data usage of a
1507 * specific application. Applications should define an activity that offers
1508 * options to control data usage.
1509 */
1510 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1511 public static final String ACTION_MANAGE_NETWORK_USAGE =
1512 "android.intent.action.MANAGE_NETWORK_USAGE";
1513
1514 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001515 * Activity Action: Launch application installer.
1516 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001517 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001518 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1519 * you can also use "package:<package-name>" to install an application for the
1520 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001521 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1522 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1523 * <p>
1524 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1525 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001526 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001527 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001528 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1529 * in order to launch the application installer.
1530 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 *
1532 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1533 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1534 * @see #EXTRA_RETURN_RESULT
1535 */
1536 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1537 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1538
1539 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001540 * Activity Action: Activity to handle split installation failures.
1541 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1542 * but the split that contains the application isn't installed. When a split is
1543 * installed in this manner, the containing package usually doesn't know this is
1544 * happening. However, if an error occurs during installation, the containing
1545 * package can define a single activity handling this action to deal with such
1546 * failures.
1547 * <p>The activity handling this action must be in the base package.
1548 * <p>
1549 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1550 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1551 */
1552 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1553 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1554
1555 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001556 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001557 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001558 * @deprecated Do not use. This will go away.
1559 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1560 */
1561 @SystemApi
1562 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1563 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1564 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1565 /**
1566 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001567 * <p class="note">
1568 * This is a protected intent that can only be sent by the system.
1569 * </p>
1570 *
1571 * @hide
1572 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001573 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001574 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1576 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001577
1578 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001579 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001580 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001581 * @deprecated Do not use. This will go away.
1582 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1583 */
1584 @SystemApi
1585 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1586 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1587 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1588 /**
1589 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001590 * <p>
1591 * The system will have a persistent connection to this service.
1592 * This is a protected intent that can only be sent by the system.
1593 * </p>
1594 *
1595 * @hide
1596 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001598 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1600 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001601
1602 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001603 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001604 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001605 * @deprecated Do not use. This will go away.
1606 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1607 */
1608 @SystemApi
1609 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1610 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1611 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1612 /**
1613 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001614 *
1615 * <p class="note">
1616 * This is a protected intent that can only be sent by the system.
1617 * </p>
1618 *
1619 * @hide
1620 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001621 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001622 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001623 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1624 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001625
1626 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001627 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1628 * package. Specifies the installer package name; this package will receive the
1629 * {@link #ACTION_APP_ERROR} intent.
1630 */
1631 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1632 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1633
1634 /**
1635 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1636 * package. Specifies that the application being installed should not be
1637 * treated as coming from an unknown source, but as coming from the app
1638 * invoking the Intent. For this to work you must start the installer with
1639 * startActivityForResult().
1640 */
1641 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1642 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1643
1644 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001645 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1646 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001647 * data field originated from.
1648 */
rich cannings706e8ba2012-08-20 13:20:14 -07001649 public static final String EXTRA_ORIGINATING_URI
1650 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001651
1652 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001653 * This extra can be used with any Intent used to launch an activity, supplying information
1654 * about who is launching that activity. This field contains a {@link android.net.Uri}
1655 * object, typically an http: or https: URI of the web site that the referral came from;
1656 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1657 * a native application that it came from.
1658 *
1659 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1660 * instead of directly retrieving the extra. It is also valid for applications to
1661 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1662 * a string, not a Uri; the field here, if supplied, will always take precedence,
1663 * however.</p>
1664 *
1665 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001666 */
1667 public static final String EXTRA_REFERRER
1668 = "android.intent.extra.REFERRER";
1669
1670 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001671 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1672 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1673 * not be created, in particular when Intent extras are supplied through the
1674 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1675 * schemes.
1676 *
1677 * @see #EXTRA_REFERRER
1678 */
1679 public static final String EXTRA_REFERRER_NAME
1680 = "android.intent.extra.REFERRER_NAME";
1681
1682 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001683 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001684 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001685 * Currently only a system app that hosts the provider authority "downloads" or holds the
1686 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001687 * @hide
1688 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001689 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001690 public static final String EXTRA_ORIGINATING_UID
1691 = "android.intent.extra.ORIGINATING_UID";
1692
1693 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001694 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1695 * package. Tells the installer UI to skip the confirmation with the user
1696 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001697 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1698 * will no longer show an interstitial message about updating existing
1699 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001700 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001701 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001702 public static final String EXTRA_ALLOW_REPLACE
1703 = "android.intent.extra.ALLOW_REPLACE";
1704
1705 /**
1706 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1707 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1708 * return to the application the result code of the install/uninstall. The returned result
1709 * code will be {@link android.app.Activity#RESULT_OK} on success or
1710 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1711 */
1712 public static final String EXTRA_RETURN_RESULT
1713 = "android.intent.extra.RETURN_RESULT";
1714
1715 /**
1716 * Package manager install result code. @hide because result codes are not
1717 * yet ready to be exposed.
1718 */
1719 public static final String EXTRA_INSTALL_RESULT
1720 = "android.intent.extra.INSTALL_RESULT";
1721
1722 /**
1723 * Activity Action: Launch application uninstaller.
1724 * <p>
1725 * Input: The data must be a package: URI whose scheme specific part is
1726 * the package name of the current installed package to be uninstalled.
1727 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1728 * <p>
1729 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1730 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001731 * <p>
1732 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1733 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001734 */
1735 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1736 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1737
1738 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001739 * Specify whether the package should be uninstalled for all users.
1740 * @hide because these should not be part of normal application flow.
1741 */
1742 public static final String EXTRA_UNINSTALL_ALL_USERS
1743 = "android.intent.extra.UNINSTALL_ALL_USERS";
1744
1745 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001746 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1747 * describing the last run version of the platform that was setup.
1748 * @hide
1749 */
1750 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1751
Svet Ganov3695b8a2015-03-24 16:30:25 -07001752 /**
1753 * Activity action: Launch UI to manage the permissions of an app.
1754 * <p>
1755 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1756 * will be managed by the launched UI.
1757 * </p>
1758 * <p>
1759 * Output: Nothing.
1760 * </p>
1761 *
1762 * @see #EXTRA_PACKAGE_NAME
1763 *
1764 * @hide
1765 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001766 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001767 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1768 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1769 "android.intent.action.MANAGE_APP_PERMISSIONS";
1770
1771 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001772 * Activity action: Launch UI to manage permissions.
1773 * <p>
1774 * Input: Nothing.
1775 * </p>
1776 * <p>
1777 * Output: Nothing.
1778 * </p>
1779 *
1780 * @hide
1781 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001782 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001783 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1784 public static final String ACTION_MANAGE_PERMISSIONS =
1785 "android.intent.action.MANAGE_PERMISSIONS";
1786
1787 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001788 * Activity action: Launch UI to review permissions for an app.
1789 * The system uses this intent if permission review for apps not
1790 * supporting the new runtime permissions model is enabled. In
1791 * this mode a permission review is required before any of the
1792 * app components can run.
1793 * <p>
1794 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1795 * permissions will be reviewed (mandatory).
1796 * </p>
1797 * <p>
1798 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1799 * be fired after the permission review (optional).
1800 * </p>
1801 * <p>
1802 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1803 * be invoked after the permission review (optional).
1804 * </p>
1805 * <p>
1806 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1807 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1808 * </p>
1809 * <p>
1810 * Output: Nothing.
1811 * </p>
1812 *
1813 * @see #EXTRA_PACKAGE_NAME
1814 * @see #EXTRA_INTENT
1815 * @see #EXTRA_REMOTE_CALLBACK
1816 * @see #EXTRA_RESULT_NEEDED
1817 *
1818 * @hide
1819 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001820 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001821 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1822 public static final String ACTION_REVIEW_PERMISSIONS =
1823 "android.intent.action.REVIEW_PERMISSIONS";
1824
1825 /**
1826 * Intent extra: A callback for reporting remote result as a bundle.
1827 * <p>
1828 * Type: IRemoteCallback
1829 * </p>
1830 *
1831 * @hide
1832 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001833 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001834 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1835
1836 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001837 * Intent extra: An app package name.
1838 * <p>
1839 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001840 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001841 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001842 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001843 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1844
1845 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001846 * Intent extra: An app split name.
1847 * <p>
1848 * Type: String
1849 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001850 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001851 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1852
1853 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001854 * Intent extra: A {@link ComponentName} value.
1855 * <p>
1856 * Type: String
1857 * </p>
1858 */
1859 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1860
1861 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001862 * Intent extra: An extra for specifying whether a result is needed.
1863 * <p>
1864 * Type: boolean
1865 * </p>
1866 *
1867 * @hide
1868 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001869 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001870 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1871
1872 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001873 * Activity action: Launch UI to manage which apps have a given permission.
1874 * <p>
1875 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1876 * to which will be managed by the launched UI.
1877 * </p>
1878 * <p>
1879 * Output: Nothing.
1880 * </p>
1881 *
1882 * @see #EXTRA_PERMISSION_NAME
1883 *
1884 * @hide
1885 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001886 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001887 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1888 public static final String ACTION_MANAGE_PERMISSION_APPS =
1889 "android.intent.action.MANAGE_PERMISSION_APPS";
1890
1891 /**
1892 * Intent extra: The name of a permission.
1893 * <p>
1894 * Type: String
1895 * </p>
1896 *
1897 * @hide
1898 */
1899 @SystemApi
1900 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1901
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001902 // ---------------------------------------------------------------------
1903 // ---------------------------------------------------------------------
1904 // Standard intent broadcast actions (see action variable).
1905
1906 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001907 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1908 * <p>
1909 * For historical reasons, the name of this broadcast action refers to the power
1910 * state of the screen but it is actually sent in response to changes in the
1911 * overall interactive state of the device.
1912 * </p><p>
1913 * This broadcast is sent when the device becomes non-interactive which may have
1914 * nothing to do with the screen turning off. To determine the
1915 * actual state of the screen, use {@link android.view.Display#getState}.
1916 * </p><p>
1917 * See {@link android.os.PowerManager#isInteractive} for details.
1918 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001919 * You <em>cannot</em> receive this through components declared in
1920 * manifests, only by explicitly registering for it with
1921 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1922 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001923 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001924 * <p class="note">This is a protected intent that can only be sent
1925 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001929
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001930 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001931 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1932 * <p>
1933 * For historical reasons, the name of this broadcast action refers to the power
1934 * state of the screen but it is actually sent in response to changes in the
1935 * overall interactive state of the device.
1936 * </p><p>
1937 * This broadcast is sent when the device becomes interactive which may have
1938 * nothing to do with the screen turning on. To determine the
1939 * actual state of the screen, use {@link android.view.Display#getState}.
1940 * </p><p>
1941 * See {@link android.os.PowerManager#isInteractive} for details.
1942 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001943 * You <em>cannot</em> receive this through components declared in
1944 * manifests, only by explicitly registering for it with
1945 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1946 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001947 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001948 * <p class="note">This is a protected intent that can only be sent
1949 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 */
1951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1952 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001953
1954 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001955 * Broadcast Action: Sent after the system stops dreaming.
1956 *
1957 * <p class="note">This is a protected intent that can only be sent by the system.
1958 * It is only sent to registered receivers.</p>
1959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1962
1963 /**
1964 * Broadcast Action: Sent after the system starts dreaming.
1965 *
1966 * <p class="note">This is a protected intent that can only be sent by the system.
1967 * It is only sent to registered receivers.</p>
1968 */
1969 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1970 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1971
1972 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001973 * 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 -07001974 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001975 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001976 * <p class="note">This is a protected intent that can only be sent
1977 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001980 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001981
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001982 /**
1983 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001984 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001985 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001986 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1987 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001989 * <p class="note">This is a protected intent that can only be sent
1990 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1993 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1994 /**
1995 * Broadcast Action: The time was set.
1996 */
1997 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1998 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1999 /**
2000 * Broadcast Action: The date has changed.
2001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2003 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2004 /**
2005 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2006 * <ul>
2007 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2008 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002009 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002010 * <p class="note">This is a protected intent that can only be sent
2011 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 */
2013 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2014 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2015 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002016 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2017 * DNS entries should be tossed.
2018 * @hide
2019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2022 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 * Alarm Changed Action: This is broadcast when the AlarmClock
2024 * application's alarm is set or unset. It is used by the
2025 * AlarmClock application and the StatusBar service.
2026 * @hide
2027 */
2028 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2029 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002030
2031 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002032 * Broadcast Action: This is broadcast once, after the user has finished
2033 * booting, but while still in the "locked" state. It can be used to perform
2034 * application-specific initialization, such as installing alarms. You must
2035 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2036 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002037 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002038 * This broadcast is sent immediately at boot by all devices (regardless of
2039 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2040 * higher. Upon receipt of this broadcast, the user is still locked and only
2041 * device-protected storage can be accessed safely. If you want to access
2042 * credential-protected storage, you need to wait for the user to be
2043 * unlocked (typically by entering their lock pattern or PIN for the first
2044 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2045 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2046 * <p>
2047 * To receive this broadcast, your receiver component must be marked as
2048 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002049 * <p class="note">
2050 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002051 *
2052 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002053 */
2054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2055 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2056
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002058 * Broadcast Action: This is broadcast once, after the user has finished
2059 * booting. It can be used to perform application-specific initialization,
2060 * such as installing alarms. You must hold the
2061 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2062 * order to receive this broadcast.
2063 * <p>
2064 * This broadcast is sent at boot by all devices (both with and without
2065 * direct boot support). Upon receipt of this broadcast, the user is
2066 * unlocked and both device-protected and credential-protected storage can
2067 * accessed safely.
2068 * <p>
2069 * If you need to run while the user is still locked (before they've entered
2070 * their lock pattern or PIN for the first time), you can listen for the
2071 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2072 * <p class="note">
2073 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 */
2075 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002076 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002078
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 /**
2080 * Broadcast Action: This is broadcast when a user action should request a
2081 * temporary system dialog to dismiss. Some examples of temporary system
2082 * dialogs are the notification window-shade and the recent tasks dialog.
2083 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002084 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002085 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2086 /**
2087 * Broadcast Action: Trigger the download and eventual installation
2088 * of a package.
2089 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002090 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002091 * <p class="note">This is a protected intent that can only be sent
2092 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002093 *
2094 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002095 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002096 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2098 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2099 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002100 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002101 * device. The data contains the name of the package. Note that the
2102 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002103 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002105 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2106 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002107 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2108 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002109 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002110 * <p class="note">This is a protected intent that can only be sent
2111 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002112 */
2113 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2114 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2115 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002116 * Broadcast Action: A new version of an application package has been
2117 * installed, replacing an existing version that was previously installed.
2118 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002119 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002120 * <ul>
2121 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2122 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002123 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2129 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002130 * Broadcast Action: A new version of your application has been installed
2131 * over an existing one. This is only sent to the application that was
2132 * replaced. It does not contain any additional data; to receive it, just
2133 * use an intent filter for this action.
2134 *
2135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
2137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2140 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002141 * Broadcast Action: An existing application package has been removed from
2142 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002143 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002144 * <ul>
2145 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2146 * to the package.
2147 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2148 * application -- data and code -- is being removed.
2149 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2150 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2151 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002152 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2158 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002159 * Broadcast Action: An existing application package has been completely
2160 * removed from the device. The data contains the name of the package.
2161 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2162 * {@link #EXTRA_DATA_REMOVED} is true and
2163 * {@link #EXTRA_REPLACING} is false of that broadcast.
2164 *
2165 * <ul>
2166 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2167 * to the package.
2168 * </ul>
2169 *
2170 * <p class="note">This is a protected intent that can only be sent
2171 * by the system.
2172 */
2173 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2174 public static final String ACTION_PACKAGE_FULLY_REMOVED
2175 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2176 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002177 * Broadcast Action: An existing application package has been changed (for
2178 * example, a component has been enabled or disabled). The data contains
2179 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002180 * <ul>
2181 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002182 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002183 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002184 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2185 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002186 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002187 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002188 * <p class="note">This is a protected intent that can only be sent
2189 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002190 */
2191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2192 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2193 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002194 * @hide
2195 * Broadcast Action: Ask system services if there is any reason to
2196 * restart the given package. The data contains the name of the
2197 * package.
2198 * <ul>
2199 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2200 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2201 * </ul>
2202 *
2203 * <p class="note">This is a protected intent that can only be sent
2204 * by the system.
2205 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002206 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2208 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2209 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002210 * Broadcast Action: The user has restarted a package, and all of its
2211 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002212 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002213 * be removed. Note that the restarted package does <em>not</em>
2214 * receive this broadcast.
2215 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002216 * <ul>
2217 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2218 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002219 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002220 * <p class="note">This is a protected intent that can only be sent
2221 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002222 */
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2225 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 * Broadcast Action: The user has cleared the data of a package. This should
2227 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002228 * its persistent data is erased and this broadcast sent.
2229 * Note that the cleared package does <em>not</em>
2230 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002231 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002232 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2233 * package whose data was cleared is an uninstalled instant app, then the UID
2234 * will be -1. The platform keeps some meta-data associated with instant apps
2235 * after they are uninstalled.
2236 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2237 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002238 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002239 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002240 * <p class="note">This is a protected intent that can only be sent
2241 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002242 */
2243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2244 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2245 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002246 * Broadcast Action: Packages have been suspended.
2247 * <p>Includes the following extras:
2248 * <ul>
2249 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2250 * </ul>
2251 *
2252 * <p class="note">This is a protected intent that can only be sent
2253 * by the system. It is only sent to registered receivers.
2254 */
2255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2256 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2257 /**
2258 * Broadcast Action: Packages have been unsuspended.
2259 * <p>Includes the following extras:
2260 * <ul>
2261 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2262 * </ul>
2263 *
2264 * <p class="note">This is a protected intent that can only be sent
2265 * by the system. It is only sent to registered receivers.
2266 */
2267 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2268 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2269 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002270 * Broadcast Action: A user ID has been removed from the system. The user
2271 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002272 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002273 * <p class="note">This is a protected intent that can only be sent
2274 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002275 */
2276 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2277 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002278
2279 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002280 * Broadcast Action: Sent to the installer package of an application when
2281 * that application is first launched (that is the first time it is moved
2282 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002283 *
2284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
2286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2289
2290 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002291 * Broadcast Action: Sent to the system package verifier when a package
2292 * needs to be verified. The data contains the package URI.
2293 * <p class="note">
2294 * This is a protected intent that can only be sent by the system.
2295 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2299
2300 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002301 * Broadcast Action: Sent to the system package verifier when a package is
2302 * verified. The data contains the package URI.
2303 * <p class="note">
2304 * This is a protected intent that can only be sent by the system.
2305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2308
2309 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002310 * Broadcast Action: Sent to the system intent filter verifier when an
2311 * intent filter needs to be verified. The data contains the filter data
2312 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002313 * <p class="note">
2314 * This is a protected intent that can only be sent by the system.
2315 * </p>
2316 *
2317 * @hide
2318 */
2319 @SystemApi
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2322
2323 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002324 * Broadcast Action: Resources for a set of packages (which were
2325 * previously unavailable) are currently
2326 * available since the media on which they exist is available.
2327 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2328 * list of packages whose availability changed.
2329 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2330 * list of uids of packages whose availability changed.
2331 * Note that the
2332 * packages in this list do <em>not</em> receive this broadcast.
2333 * The specified set of packages are now available on the system.
2334 * <p>Includes the following extras:
2335 * <ul>
2336 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2337 * whose resources(were previously unavailable) are currently available.
2338 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2339 * packages whose resources(were previously unavailable)
2340 * are currently available.
2341 * </ul>
2342 *
2343 * <p class="note">This is a protected intent that can only be sent
2344 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002347 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2348 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002349
2350 /**
2351 * Broadcast Action: Resources for a set of packages are currently
2352 * unavailable since the media on which they exist is unavailable.
2353 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2354 * list of packages whose availability changed.
2355 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2356 * list of uids of packages whose availability changed.
2357 * The specified set of packages can no longer be
2358 * launched and are practically unavailable on the system.
2359 * <p>Inclues the following extras:
2360 * <ul>
2361 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2362 * whose resources are no longer available.
2363 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2364 * whose resources are no longer available.
2365 * </ul>
2366 *
2367 * <p class="note">This is a protected intent that can only be sent
2368 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002371 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002372 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002373
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002374 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002375 * Broadcast Action: preferred activities have changed *explicitly*.
2376 *
2377 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2378 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2379 * be sent.
2380 *
2381 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2382 *
2383 * @hide
2384 */
2385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2386 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2387 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2388
2389
2390 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002391 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002392 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002393 * This should <em>only</em> be used to determine when the wallpaper
2394 * has changed to show the new wallpaper to the user. You should certainly
2395 * never, in response to this, change the wallpaper or other attributes of
2396 * it such as the suggested size. That would be crazy, right? You'd cause
2397 * all kinds of loops, especially if other apps are doing similar things,
2398 * right? Of course. So please don't do this.
2399 *
2400 * @deprecated Modern applications should use
2401 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2402 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2403 * shown behind their UI, rather than watching for this broadcast and
2404 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002406 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002407 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2408 /**
2409 * Broadcast Action: The current device {@link android.content.res.Configuration}
2410 * (orientation, locale, etc) has changed. When such a change happens, the
2411 * UIs (view hierarchy) will need to be rebuilt based on this new
2412 * information; for the most part, applications don't need to worry about
2413 * this, because the system will take care of stopping and restarting the
2414 * application to make sure it sees the new changes. Some system code that
2415 * can not be restarted will need to watch for this action and handle it
2416 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002417 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002418 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002419 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002420 * in manifests, only by explicitly registering for it with
2421 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2422 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002423 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002424 * <p class="note">This is a protected intent that can only be sent
2425 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002426 *
2427 * @see android.content.res.Configuration
2428 */
2429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2430 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2431 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002432 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002433 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
2436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2438 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2439 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002440 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2441 * charging state, level, and other information about the battery.
2442 * See {@link android.os.BatteryManager} for documentation on the
2443 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002444 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002446 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002447 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002448 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002449 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2450 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2451 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2452 * broadcasts that are sent and can be received through manifest
2453 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002454 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002455 * <p class="note">This is a protected intent that can only be sent
2456 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002457 */
2458 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2459 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2460 /**
2461 * Broadcast Action: Indicates low battery condition on the device.
2462 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002463 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002464 * <p class="note">This is a protected intent that can only be sent
2465 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2469 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002470 * Broadcast Action: Indicates the battery is now okay after being low.
2471 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2472 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002473 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002474 * <p class="note">This is a protected intent that can only be sent
2475 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002476 */
2477 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2478 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2479 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002480 * Broadcast Action: External power has been connected to the device.
2481 * This is intended for applications that wish to register specifically to this notification.
2482 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2483 * stay active to receive this notification. This action can be used to implement actions
2484 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002485 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002486 * <p class="note">This is a protected intent that can only be sent
2487 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002488 */
2489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002490 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002491 /**
2492 * Broadcast Action: External power has been removed from the device.
2493 * This is intended for applications that wish to register specifically to this notification.
2494 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2495 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002496 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002497 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002498 * <p class="note">This is a protected intent that can only be sent
2499 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002502 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002503 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002504 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002505 * Broadcast Action: Device is shutting down.
2506 * This is broadcast when the device is being shut down (completely turned
2507 * off, not sleeping). Once the broadcast is complete, the final shutdown
2508 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002509 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002510 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002511 * <p class="note">This is a protected intent that can only be sent
2512 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002513 * <p>May include the following extras:
2514 * <ul>
2515 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2516 * shutdown is only for userspace processes. If not set, assumed to be false.
2517 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002520 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002521 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002522 * Activity Action: Start this activity to request system shutdown.
2523 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002524 * to request confirmation from the user before shutting down. The optional boolean
2525 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2526 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002527 *
2528 * <p class="note">This is a protected intent that can only be sent
2529 * by the system.
2530 *
2531 * {@hide}
2532 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002533 public static final String ACTION_REQUEST_SHUTDOWN
2534 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002535 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002536 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002537 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002538 * <p class="note">
2539 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002540 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002541 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2542 * or above, this broadcast will no longer be delivered to any
2543 * {@link BroadcastReceiver} defined in your manifest. Instead,
2544 * apps are strongly encouraged to use the improved
2545 * {@link Context#getCacheDir()} behavior so the system can
2546 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002550 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2551 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 * Broadcast Action: Indicates low storage space condition on the device no
2553 * longer exists
2554 * <p class="note">
2555 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002556 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002557 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2558 * or above, this broadcast will no longer be delivered to any
2559 * {@link BroadcastReceiver} defined in your manifest. Instead,
2560 * apps are strongly encouraged to use the improved
2561 * {@link Context#getCacheDir()} behavior so the system can
2562 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002563 */
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002565 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002566 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2567 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002568 * Broadcast Action: A sticky broadcast that indicates a storage space full
2569 * condition on the device. This is intended for activities that want to be
2570 * able to fill the data partition completely, leaving only enough free
2571 * space to prevent system-wide SQLite failures.
2572 * <p class="note">
2573 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002574 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002575 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2576 * or above, this broadcast will no longer be delivered to any
2577 * {@link BroadcastReceiver} defined in your manifest. Instead,
2578 * apps are strongly encouraged to use the improved
2579 * {@link Context#getCacheDir()} behavior so the system can
2580 * automatically free up storage when needed.
2581 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002584 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002585 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2586 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002587 * Broadcast Action: Indicates storage space full condition on the device no
2588 * longer exists.
2589 * <p class="note">
2590 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002591 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002592 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2593 * or above, this broadcast will no longer be delivered to any
2594 * {@link BroadcastReceiver} defined in your manifest. Instead,
2595 * apps are strongly encouraged to use the improved
2596 * {@link Context#getCacheDir()} behavior so the system can
2597 * automatically free up storage when needed.
2598 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002599 */
2600 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002601 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002602 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2603 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002604 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2605 * and package management should be started.
2606 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2607 * notification.
2608 */
2609 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2610 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2611 /**
2612 * Broadcast Action: The device has entered USB Mass Storage mode.
2613 * This is used mainly for the USB Settings panel.
2614 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2615 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002616 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002617 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002618 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002620 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2621
2622 /**
2623 * Broadcast Action: The device has exited USB Mass Storage mode.
2624 * This is used mainly for the USB Settings panel.
2625 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2626 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002627 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002628 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002629 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002631 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2632
2633 /**
2634 * Broadcast Action: External media has been removed.
2635 * The path to the mount point for the removed media is contained in the Intent.mData field.
2636 */
2637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2638 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2639
2640 /**
2641 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002642 * 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 -07002643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2646
2647 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002648 * Broadcast Action: External media is present, and being disk-checked
2649 * 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 -08002650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2652 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2653
2654 /**
2655 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2656 * 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 -08002657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2660
2661 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002662 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002663 * 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 -07002664 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2665 * media was mounted read only.
2666 */
2667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2668 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2669
2670 /**
2671 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002672 * 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 -07002673 */
2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2676
2677 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002678 * Broadcast Action: External media is no longer being shared via USB mass storage.
2679 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2680 *
2681 * @hide
2682 */
2683 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2684
2685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002686 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2687 * The path to the mount point for the removed media is contained in the Intent.mData field.
2688 */
2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2690 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2691
2692 /**
2693 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002694 * 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 -07002695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2697 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2698
2699 /**
2700 * Broadcast Action: User has expressed the desire to remove the external storage media.
2701 * Applications should close all files they have open within the mount point when they receive this intent.
2702 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2703 */
2704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2705 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2706
2707 /**
2708 * Broadcast Action: The media scanner has started scanning a directory.
2709 * The path to the directory being scanned is contained in the Intent.mData field.
2710 */
2711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2712 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2713
2714 /**
2715 * Broadcast Action: The media scanner has finished scanning a directory.
2716 * The path to the scanned directory is contained in the Intent.mData field.
2717 */
2718 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2719 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2720
2721 /**
2722 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2723 * The path to the file is contained in the Intent.mData field.
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2727
2728 /**
2729 * Broadcast Action: The "Media Button" was pressed. Includes a single
2730 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2731 * caused the broadcast.
2732 */
2733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2734 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2735
2736 /**
2737 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2738 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2739 * caused the broadcast.
2740 */
2741 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2742 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2743
2744 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2745 // location; they are not general-purpose actions.
2746
2747 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002748 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002749 */
2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2751 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2752 "android.intent.action.GTALK_CONNECTED";
2753
2754 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002755 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002756 */
2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2759 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002760
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002761 /**
2762 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002763 */
2764 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2765 public static final String ACTION_INPUT_METHOD_CHANGED =
2766 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767
2768 /**
2769 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2770 * more radios have been turned off or on. The intent will have the following extra value:</p>
2771 * <ul>
2772 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2773 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2774 * turned off</li>
2775 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002776 *
Peng Xua35b5532016-01-20 00:05:45 -08002777 * <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 -07002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2781
2782 /**
2783 * Broadcast Action: Some content providers have parts of their namespace
2784 * where they publish new events or items that the user may be especially
2785 * interested in. For these things, they may broadcast this action when the
2786 * set of interesting items change.
2787 *
2788 * For example, GmailProvider sends this notification when the set of unread
2789 * mail in the inbox changes.
2790 *
2791 * <p>The data of the intent identifies which part of which provider
2792 * changed. When queried through the content resolver, the data URI will
2793 * return the data set in question.
2794 *
2795 * <p>The intent will have the following extra values:
2796 * <ul>
2797 * <li><em>count</em> - The number of items in the data set. This is the
2798 * same as the number of items in the cursor returned by querying the
2799 * data URI. </li>
2800 * </ul>
2801 *
2802 * This intent will be sent at boot (if the count is non-zero) and when the
2803 * data set changes. It is possible for the data set to change without the
2804 * count changing (for example, if a new unread message arrives in the same
2805 * sync operation in which a message is archived). The phone should still
2806 * ring/vibrate/etc as normal in this case.
2807 */
2808 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2809 public static final String ACTION_PROVIDER_CHANGED =
2810 "android.intent.action.PROVIDER_CHANGED";
2811
2812 /**
2813 * Broadcast Action: Wired Headset plugged in or unplugged.
2814 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002815 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2816 * and documentation.
2817 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002818 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002819 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002820 */
2821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002822 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002823
2824 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002825 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2826 * <ul>
2827 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2828 * </ul>
2829 *
2830 * <p class="note">This is a protected intent that can only be sent
2831 * by the system.
2832 *
2833 * @hide
2834 */
2835 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2836 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2837 = "android.intent.action.ADVANCED_SETTINGS";
2838
2839 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002840 * Broadcast Action: Sent after application restrictions are changed.
2841 *
2842 * <p class="note">This is a protected intent that can only be sent
2843 * by the system.</p>
2844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2847 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2848
2849 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002850 * Broadcast Action: An outgoing call is about to be placed.
2851 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002852 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002853 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002854 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002855 * the phone number originally intended to be dialed.</li>
2856 * </ul>
2857 * <p>Once the broadcast is finished, the resultData is used as the actual
2858 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002859 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002860 * outgoing call in turn: for example, a parental control application
2861 * might verify that the user is authorized to place the call at that
2862 * time, then a number-rewriting application might add an area code if
2863 * one was not specified.</p>
2864 * <p>For consistency, any receiver whose purpose is to prohibit phone
2865 * calls should have a priority of 0, to ensure it will see the final
2866 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002867 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002868 * should have a positive priority.
2869 * Negative priorities are reserved for the system for this broadcast;
2870 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002871 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2872 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 * <p>Emergency calls cannot be intercepted using this mechanism, and
2874 * other calls cannot be modified to call emergency numbers using this
2875 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002876 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2877 * call to use their own service instead. Those apps should first prevent
2878 * the call from being placed by setting resultData to <code>null</code>
2879 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002880 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002881 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2882 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002883 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002884 * <p class="note">This is a protected intent that can only be sent
2885 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002886 */
2887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2888 public static final String ACTION_NEW_OUTGOING_CALL =
2889 "android.intent.action.NEW_OUTGOING_CALL";
2890
2891 /**
2892 * Broadcast Action: Have the device reboot. This is only for use by
2893 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002895 * <p class="note">This is a protected intent that can only be sent
2896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002897 */
2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2899 public static final String ACTION_REBOOT =
2900 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002901
Wei Huang97ecc9c2009-05-11 17:44:20 -07002902 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002903 * Broadcast Action: A sticky broadcast for changes in the physical
2904 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002905 *
2906 * <p>The intent will have the following extra values:
2907 * <ul>
2908 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002909 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002910 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002911 * <p>This is intended for monitoring the current physical dock state.
2912 * See {@link android.app.UiModeManager} for the normal API dealing with
2913 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002914 */
2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2916 public static final String ACTION_DOCK_EVENT =
2917 "android.intent.action.DOCK_EVENT";
2918
2919 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002920 * Broadcast Action: A broadcast when idle maintenance can be started.
2921 * This means that the user is not interacting with the device and is
2922 * not expected to do so soon. Typical use of the idle maintenance is
2923 * to perform somehow expensive tasks that can be postponed at a moment
2924 * when they will not degrade user experience.
2925 * <p>
2926 * <p class="note">In order to keep the device responsive in case of an
2927 * unexpected user interaction, implementations of a maintenance task
2928 * should be interruptible. In such a scenario a broadcast with action
2929 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2930 * should not do the maintenance work in
2931 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2932 * maintenance service by {@link Context#startService(Intent)}. Also
2933 * you should hold a wake lock while your maintenance service is running
2934 * to prevent the device going to sleep.
2935 * </p>
2936 * <p>
2937 * <p class="note">This is a protected intent that can only be sent by
2938 * the system.
2939 * </p>
2940 *
2941 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002942 *
2943 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002944 */
2945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2946 public static final String ACTION_IDLE_MAINTENANCE_START =
2947 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2948
2949 /**
2950 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2951 * This means that the user was not interacting with the device as a result
2952 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2953 * was sent and now the user started interacting with the device. Typical
2954 * use of the idle maintenance is to perform somehow expensive tasks that
2955 * can be postponed at a moment when they will not degrade user experience.
2956 * <p>
2957 * <p class="note">In order to keep the device responsive in case of an
2958 * unexpected user interaction, implementations of a maintenance task
2959 * should be interruptible. Hence, on receiving a broadcast with this
2960 * action, the maintenance task should be interrupted as soon as possible.
2961 * In other words, you should not do the maintenance work in
2962 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2963 * maintenance service that was started on receiving of
2964 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2965 * lock you acquired when your maintenance service started.
2966 * </p>
2967 * <p class="note">This is a protected intent that can only be sent
2968 * by the system.
2969 *
2970 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002971 *
2972 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002973 */
2974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2975 public static final String ACTION_IDLE_MAINTENANCE_END =
2976 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2977
2978 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002979 * Broadcast Action: a remote intent is to be broadcasted.
2980 *
2981 * A remote intent is used for remote RPC between devices. The remote intent
2982 * is serialized and sent from one device to another device. The receiving
2983 * device parses the remote intent and broadcasts it. Note that anyone can
2984 * broadcast a remote intent. However, if the intent receiver of the remote intent
2985 * does not trust intent broadcasts from arbitrary intent senders, it should require
2986 * the sender to hold certain permissions so only trusted sender's broadcast will be
2987 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002988 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002989 */
2990 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002991 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002992
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002993 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002994 * Broadcast Action: This is broadcast once when the user is booting after a
2995 * system update. It can be used to perform cleanup or upgrades after a
2996 * system update.
2997 * <p>
2998 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2999 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3000 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3001 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003002 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003003 * @hide
3004 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003005 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003006 public static final String ACTION_PRE_BOOT_COMPLETED =
3007 "android.intent.action.PRE_BOOT_COMPLETED";
3008
Amith Yamasani13593602012-03-22 16:16:17 -07003009 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003010 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003011 * on restricted users. The broadcast intent contains an extra
3012 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3013 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3014 * String[] depending on the restriction type.<p/>
3015 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003016 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3017 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3018 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003019 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3020 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003021 * @see RestrictionEntry
3022 */
3023 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3024 "android.intent.action.GET_RESTRICTION_ENTRIES";
3025
3026 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003027 * Sent the first time a user is starting, to allow system apps to
3028 * perform one time initialization. (This will not be seen by third
3029 * party applications because a newly initialized user does not have any
3030 * third party applications installed for it.) This is sent early in
3031 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003032 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3033 * broadcast, since it is part of a visible user interaction; be as quick
3034 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003035 */
3036 public static final String ACTION_USER_INITIALIZE =
3037 "android.intent.action.USER_INITIALIZE";
3038
3039 /**
3040 * Sent when a user switch is happening, causing the process's user to be
3041 * brought to the foreground. This is only sent to receivers registered
3042 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3043 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003044 * foreground. This is sent as a foreground
3045 * broadcast, since it is part of a visible user interaction; be as quick
3046 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003047 */
3048 public static final String ACTION_USER_FOREGROUND =
3049 "android.intent.action.USER_FOREGROUND";
3050
3051 /**
3052 * Sent when a user switch is happening, causing the process's user to be
3053 * sent to the background. This is only sent to receivers registered
3054 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3055 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003056 * background. This is sent as a foreground
3057 * broadcast, since it is part of a visible user interaction; be as quick
3058 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003059 */
3060 public static final String ACTION_USER_BACKGROUND =
3061 "android.intent.action.USER_BACKGROUND";
3062
3063 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003064 * Broadcast sent to the system when a user is added. Carries an extra
3065 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3066 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003067 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003068 * @hide
3069 */
3070 public static final String ACTION_USER_ADDED =
3071 "android.intent.action.USER_ADDED";
3072
3073 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003074 * Broadcast sent by the system when a user is started. Carries an extra
3075 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003076 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003077 * that has been started. This is sent as a foreground
3078 * broadcast, since it is part of a visible user interaction; be as quick
3079 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003080 * @hide
3081 */
3082 public static final String ACTION_USER_STARTED =
3083 "android.intent.action.USER_STARTED";
3084
3085 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003086 * Broadcast sent when a user is in the process of starting. Carries an extra
3087 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3088 * sent to registered receivers, not manifest receivers. It is sent to all
3089 * users (including the one that is being started). You must hold
3090 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3091 * this broadcast. This is sent as a background broadcast, since
3092 * its result is not part of the primary UX flow; to safely keep track of
3093 * started/stopped state of a user you can use this in conjunction with
3094 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3095 * other user state broadcasts since those are foreground broadcasts so can
3096 * execute in a different order.
3097 * @hide
3098 */
3099 public static final String ACTION_USER_STARTING =
3100 "android.intent.action.USER_STARTING";
3101
3102 /**
3103 * Broadcast sent when a user is going to be stopped. Carries an extra
3104 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3105 * sent to registered receivers, not manifest receivers. It is sent to all
3106 * users (including the one that is being stopped). You must hold
3107 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3108 * this broadcast. The user will not stop until all receivers have
3109 * handled the broadcast. This is sent as a background broadcast, since
3110 * its result is not part of the primary UX flow; to safely keep track of
3111 * started/stopped state of a user you can use this in conjunction with
3112 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3113 * other user state broadcasts since those are foreground broadcasts so can
3114 * execute in a different order.
3115 * @hide
3116 */
3117 public static final String ACTION_USER_STOPPING =
3118 "android.intent.action.USER_STOPPING";
3119
3120 /**
3121 * Broadcast sent to the system when a user is stopped. Carries an extra
3122 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3123 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3124 * specific package. This is only sent to registered receivers, not manifest
3125 * receivers. It is sent to all running users <em>except</em> the one that
3126 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003127 * @hide
3128 */
3129 public static final String ACTION_USER_STOPPED =
3130 "android.intent.action.USER_STOPPED";
3131
3132 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003133 * 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 -07003134 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003135 * one that has been removed. The user will not be completely removed until all receivers have
3136 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003137 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003138 * @hide
3139 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003140 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003141 public static final String ACTION_USER_REMOVED =
3142 "android.intent.action.USER_REMOVED";
3143
3144 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003145 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003146 * the userHandle of the user to become the current one. This is only sent to
3147 * registered receivers, not manifest receivers. It is sent to all running users.
3148 * You must hold
3149 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003150 * @hide
3151 */
3152 public static final String ACTION_USER_SWITCHED =
3153 "android.intent.action.USER_SWITCHED";
3154
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003155 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003156 * Broadcast Action: Sent when the credential-encrypted private storage has
3157 * become unlocked for the target user. This is only sent to registered
3158 * receivers, not manifest receivers.
3159 */
3160 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3161 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3162
3163 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003164 * Broadcast sent to the system when a user's information changes. Carries an extra
3165 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003166 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003167 * @hide
3168 */
3169 public static final String ACTION_USER_INFO_CHANGED =
3170 "android.intent.action.USER_INFO_CHANGED";
3171
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003172 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003173 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3174 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003175 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3176 * that need to display merged content across both primary and managed profiles need to
3177 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003178 * not manifest receivers.
3179 */
3180 public static final String ACTION_MANAGED_PROFILE_ADDED =
3181 "android.intent.action.MANAGED_PROFILE_ADDED";
3182
3183 /**
3184 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003185 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3186 * Only applications (for example Launchers) that need to display merged content across both
3187 * primary and managed profiles need to worry about this broadcast. This is only sent to
3188 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003189 */
3190 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3191 "android.intent.action.MANAGED_PROFILE_REMOVED";
3192
3193 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003194 * Broadcast sent to the primary user when the credential-encrypted private storage for
3195 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3196 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3197 * Launchers) that need to display merged content across both primary and managed profiles
3198 * need to worry about this broadcast. This is only sent to registered receivers,
3199 * not manifest receivers.
3200 */
3201 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3202 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3203
3204 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003205 * Broadcast sent to the primary user when an associated managed profile has become available.
3206 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003207 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3208 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3209 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003210 */
Rubin Xue95057a2016-04-01 16:49:25 +01003211 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3212 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3213
3214 /**
3215 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3216 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3217 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3218 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3219 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3220 */
3221 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3222 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003223
3224 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003225 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3226 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3227 * the device was locked or unlocked.
3228 *
3229 * This is only sent to registered receivers.
3230 *
3231 * @hide
3232 */
3233 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3234 "android.intent.action.DEVICE_LOCKED_CHANGED";
3235
3236 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003237 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3238 */
3239 public static final String ACTION_QUICK_CLOCK =
3240 "android.intent.action.QUICK_CLOCK";
3241
Michael Wright0087a142013-02-05 16:29:39 -08003242 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003243 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003244 * @hide
3245 */
3246 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003247 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003248
Justin Kohd378ad72013-04-01 12:18:26 -07003249 /**
3250 * Broadcast Action: A global button was pressed. Includes a single
3251 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3252 * caused the broadcast.
3253 * @hide
3254 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003255 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003256 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3257
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003258 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003259 * Broadcast Action: Sent when media resource is granted.
3260 * <p>
3261 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3262 * granted.
3263 * </p>
3264 * <p class="note">
3265 * This is a protected intent that can only be sent by the system.
3266 * </p>
3267 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003268 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003269 * </p>
3270 *
3271 * @hide
3272 */
3273 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3274 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3275
3276 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003277 * Broadcast Action: An overlay package has changed. The data contains the
3278 * name of the overlay package which has changed. This is broadcast on all
3279 * changes to the OverlayInfo returned by {@link
3280 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3281 * most common change is a state change that will change whether the
3282 * overlay is enabled or not.
3283 * @hide
3284 */
3285 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3286
3287 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003288 * Activity Action: Allow the user to select and return one or more existing
3289 * documents. When invoked, the system will display the various
3290 * {@link DocumentsProvider} instances installed on the device, letting the
3291 * user interactively navigate through them. These documents include local
3292 * media, such as photos and video, and documents provided by installed
3293 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003294 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003295 * Each document is represented as a {@code content://} URI backed by a
3296 * {@link DocumentsProvider}, which can be opened as a stream with
3297 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3298 * {@link android.provider.DocumentsContract.Document} metadata.
3299 * <p>
3300 * All selected documents are returned to the calling application with
3301 * persistable read and write permission grants. If you want to maintain
3302 * access to the documents across device reboots, you need to explicitly
3303 * take the persistable permissions using
3304 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3305 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003306 * Callers must indicate the acceptable document MIME types through
3307 * {@link #setType(String)}. For example, to select photos, use
3308 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3309 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3310 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003311 * <p>
3312 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003313 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3314 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003315 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003316 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3317 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003318 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003319 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003320 * Callers can set a document URI through
3321 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3322 * location of documents navigator. System will do its best to launch the
3323 * navigator in the specified document if it's a folder, or the folder that
3324 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003325 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003326 * Output: The URI of the item that was picked, returned in
3327 * {@link #getData()}. This must be a {@code content://} URI so that any
3328 * receiver can access it. If multiple documents were selected, they are
3329 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003330 *
3331 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003332 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003333 * @see #ACTION_CREATE_DOCUMENT
3334 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003335 */
3336 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3337 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3338
3339 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003340 * Activity Action: Allow the user to create a new document. When invoked,
3341 * the system will display the various {@link DocumentsProvider} instances
3342 * installed on the device, letting the user navigate through them. The
3343 * returned document may be a newly created document with no content, or it
3344 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003345 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003346 * Each document is represented as a {@code content://} URI backed by a
3347 * {@link DocumentsProvider}, which can be opened as a stream with
3348 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3349 * {@link android.provider.DocumentsContract.Document} metadata.
3350 * <p>
3351 * Callers must indicate the concrete MIME type of the document being
3352 * created by setting {@link #setType(String)}. This MIME type cannot be
3353 * changed after the document is created.
3354 * <p>
3355 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3356 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003357 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003358 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3359 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003360 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003361 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003362 * Callers can set a document URI through
3363 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3364 * location of documents navigator. System will do its best to launch the
3365 * navigator in the specified document if it's a folder, or the folder that
3366 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003367 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003368 * Output: The URI of the item that was created. This must be a
3369 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003370 *
3371 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003372 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003373 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003374 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003375 */
3376 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3377 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3378
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003379 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003380 * Activity Action: Allow the user to pick a directory subtree. When
3381 * invoked, the system will display the various {@link DocumentsProvider}
3382 * instances installed on the device, letting the user navigate through
3383 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003384 * <p>
3385 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003386 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3387 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3388 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003389 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003390 * Callers can set a document URI through
3391 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3392 * location of documents navigator. System will do its best to launch the
3393 * navigator in the specified document if it's a folder, or the folder that
3394 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003395 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003396 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003397 *
3398 * @see DocumentsContract
3399 */
3400 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003401 public static final String
3402 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003403
Felipe Lemec7b1f892016-01-15 15:02:31 -08003404 /**
Peng Xua35b5532016-01-20 00:05:45 -08003405 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3406 * exisiting sensor being disconnected.
3407 *
3408 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3409 *
3410 * {@hide}
3411 */
3412 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3413 public static final String
3414 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3415
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003416 /**
Sam Line707f832017-04-13 17:00:55 -07003417 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003418 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003419 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003420 */
3421 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003422 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003423 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3424
Christopher Tate6597e342015-02-17 12:15:25 -08003425 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003426 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3427 * is about to be performed.
3428 * @hide
3429 */
3430 @SystemApi
3431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3432 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3433 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3434
3435 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003436 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3437 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3438 *
3439 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3440 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003441 * @hide
3442 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003443 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003444 public static final String EXTRA_FORCE_MASTER_CLEAR =
3445 "android.intent.extra.FORCE_MASTER_CLEAR";
3446
3447 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003448 * A broadcast action to trigger a factory reset.
3449 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003450 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3451 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003452 *
3453 * <p>Not for use by third-party applications.
3454 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003455 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003456 *
3457 * {@hide}
3458 */
3459 @SystemApi
3460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3461 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3462
3463 /**
3464 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3465 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3466 *
3467 * <p>Not for use by third-party applications.
3468 *
3469 * @hide
3470 */
3471 @SystemApi
3472 public static final String EXTRA_FORCE_FACTORY_RESET =
3473 "android.intent.extra.FORCE_FACTORY_RESET";
3474
3475 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003476 * Broadcast action: report that a settings element is being restored from backup. The intent
3477 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3478 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3479 * is the value of that settings entry prior to the restore operation, and
3480 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3481 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3482 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003483 *
3484 * <p>This broadcast is sent only for settings provider entries known to require special handling
3485 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3486 * the provider's backup agent implementation.
3487 *
3488 * @see #EXTRA_SETTING_NAME
3489 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3490 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003491 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003492 * {@hide}
3493 */
3494 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3495
3496 /** {@hide} */
3497 public static final String EXTRA_SETTING_NAME = "setting_name";
3498 /** {@hide} */
3499 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3500 /** {@hide} */
3501 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003502 /** {@hide} */
3503 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003504
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003505 /**
3506 * Activity Action: Process a piece of text.
3507 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3508 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3509 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3510 */
3511 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3512 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003513
3514 /**
3515 * Broadcast Action: The sim card state has changed.
3516 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3517 * because TelephonyIntents is an internal class.
3518 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003519 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3520 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003521 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003522 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003523 @SystemApi
3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3525 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3526
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003527 /**
Amit Mahajan052e1e22018-01-12 17:40:29 -08003528 * Broadcast Action: The sim card state has changed.
3529 * The intent will have the following extra values:</p>
3530 * <dl>
3531 * <dt>{@link android.telephony.TelephonyManager.EXTRA_SIM_STATE}</dt>
3532 * <dd>The sim card state. One of:
3533 * <dl>
3534 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_ABSENT}</dt>
3535 * <dd>SIM card not found</dd>
3536 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_CARD_IO_ERROR}</dt>
3537 * <dd>SIM card IO error</dd>
3538 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_CARD_RESTRICTED}</dt>
3539 * <dd>SIM card is restricted</dd>
3540 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_PRESENT}</dt>
3541 * <dd>SIM card is present</dd>
3542 * </dl>
3543 * </dd>
3544 * </dl>
3545 *
3546 * <p class="note">Requires the READ_PRIVILEGED_PHONE_STATE permission.
3547 *
3548 * <p class="note">The current state can also be queried using
3549 * {@link android.telephony.TelephonyManager.getSimCardState()}
3550 *
3551 * <p class="note">This is a protected intent that can only be sent by the system.
3552 * @hide
3553 */
3554 @SystemApi
3555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3556 public static final String ACTION_SIM_CARD_STATE_CHANGED =
3557 "android.intent.action.SIM_CARD_STATE_CHANGED";
3558
3559 /**
3560 * Broadcast Action: The sim application state has changed.
3561 * The intent will have the following extra values:</p>
3562 * <dl>
3563 * <dt>{@link android.telephony.TelephonyManager.EXTRA_SIM_STATE}</dt>
3564 * <dd>The sim application state. One of:
3565 * <dl>
3566 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_NOT_READY}</dt>
3567 * <dd>SIM card applications not ready</dd>
3568 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_PIN_REQUIRED}</dt>
3569 * <dd>SIM card PIN locked</dd>
3570 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_PUK_REQUIRED}</dt>
3571 * <dd>SIM card PUK locked</dd>
3572 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_NETWORK_LOCKED}</dt>
3573 * <dd>SIM card network locked</dd>
3574 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_PERM_DISABLED}</dt>
3575 * <dd>SIM card permanently disabled due to PUK failures</dd>
3576 * <dt>{@link android.telephony.TelephonyManager.SIM_STATE_LOADED}</dt>
3577 * <dd>SIM card data loaded</dd>
3578 * </dl>
3579 * </dd>
3580 * </dl>
3581 *
3582 * <p class="note">Requires the READ_PRIVILEGED_PHONE_STATE permission.
3583 *
3584 * <p class="note">The current state can also be queried using
3585 * {@link android.telephony.TelephonyManager.getSimApplicationState()}
3586 *
3587 * <p class="note">This is a protected intent that can only be sent by the system.
3588 * @hide
3589 */
3590 @SystemApi
3591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3592 public static final String ACTION_SIM_APPLICATION_STATE_CHANGED =
3593 "android.intent.action.SIM_APPLICATION_STATE_CHANGED";
3594
3595 /**
fionaxu90fee272017-03-31 12:45:12 -07003596 * Broadcast Action: indicate that the phone service state has changed.
3597 * The intent will have the following extra values:</p>
3598 * <p>
3599 * @see #EXTRA_VOICE_REG_STATE
3600 * @see #EXTRA_DATA_REG_STATE
3601 * @see #EXTRA_VOICE_ROAMING_TYPE
3602 * @see #EXTRA_DATA_ROAMING_TYPE
3603 * @see #EXTRA_OPERATOR_ALPHA_LONG
3604 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3605 * @see #EXTRA_OPERATOR_NUMERIC
3606 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3607 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3608 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3609 * @see #EXTRA_MANUAL
3610 * @see #EXTRA_VOICE_RADIO_TECH
3611 * @see #EXTRA_DATA_RADIO_TECH
3612 * @see #EXTRA_CSS_INDICATOR
3613 * @see #EXTRA_NETWORK_ID
3614 * @see #EXTRA_SYSTEM_ID
3615 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3616 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3617 * @see #EXTRA_EMERGENCY_ONLY
3618 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3619 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3620 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3621 *
3622 * <p class="note">
3623 * Requires the READ_PHONE_STATE permission.
3624 *
3625 * <p class="note">This is a protected intent that can only be sent by the system.
3626 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003627 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003628 */
3629 @Deprecated
3630 @SystemApi
3631 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3632 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3633
3634 /**
3635 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3636 * state.
3637 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3638 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3639 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3640 * @see android.telephony.ServiceState#STATE_POWER_OFF
3641 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003642 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003643 */
3644 @Deprecated
3645 @SystemApi
3646 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3647
3648 /**
3649 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3650 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3651 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3652 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3653 * @see android.telephony.ServiceState#STATE_POWER_OFF
3654 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003655 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003656 */
3657 @Deprecated
3658 @SystemApi
3659 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3660
3661 /**
3662 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3663 * type.
3664 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003665 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003666 */
3667 @Deprecated
3668 @SystemApi
3669 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3670
3671 /**
3672 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3673 * type.
3674 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003675 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003676 */
3677 @Deprecated
3678 @SystemApi
3679 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3680
3681 /**
3682 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3683 * registered voice operator name in long alphanumeric format.
3684 * {@code null} if the operator name is not known or unregistered.
3685 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003686 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003687 */
3688 @Deprecated
3689 @SystemApi
3690 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3691
3692 /**
3693 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3694 * registered voice operator name in short alphanumeric format.
3695 * {@code null} if the operator name is not known or unregistered.
3696 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003697 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003698 */
3699 @Deprecated
3700 @SystemApi
3701 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3702
3703 /**
3704 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3705 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3706 * network.
3707 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003708 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003709 */
3710 @Deprecated
3711 @SystemApi
3712 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3713
3714 /**
3715 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3716 * registered data operator name in long alphanumeric format.
3717 * {@code null} if the operator name is not known or unregistered.
3718 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003719 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003720 */
3721 @Deprecated
3722 @SystemApi
3723 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3724
3725 /**
3726 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3727 * registered data operator name in short alphanumeric format.
3728 * {@code null} if the operator name is not known or unregistered.
3729 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003730 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003731 */
3732 @Deprecated
3733 @SystemApi
3734 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3735
3736 /**
3737 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3738 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3739 * data operator.
3740 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003741 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003742 */
3743 @Deprecated
3744 @SystemApi
3745 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3746
3747 /**
3748 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3749 * network selection mode is manual.
3750 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3751 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003752 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003753 */
3754 @Deprecated
3755 @SystemApi
3756 public static final String EXTRA_MANUAL = "manual";
3757
3758 /**
3759 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3760 * radio technology.
3761 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003762 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003763 */
3764 @Deprecated
3765 @SystemApi
3766 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3767
3768 /**
3769 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3770 * radio technology.
3771 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003772 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003773 */
3774 @Deprecated
3775 @SystemApi
3776 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3777
3778 /**
3779 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3780 * support on CDMA network.
3781 * Will be {@code true} if support, {@code false} otherwise.
3782 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003783 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003784 */
3785 @Deprecated
3786 @SystemApi
3787 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3788
3789 /**
3790 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3791 * id. {@code Integer.MAX_VALUE} if unknown.
3792 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003793 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003794 */
3795 @Deprecated
3796 @SystemApi
3797 public static final String EXTRA_NETWORK_ID = "networkId";
3798
3799 /**
3800 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3801 * {@code Integer.MAX_VALUE} if unknown.
3802 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003803 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003804 */
3805 @Deprecated
3806 @SystemApi
3807 public static final String EXTRA_SYSTEM_ID = "systemId";
3808
3809 /**
3810 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3811 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3812 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003813 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003814 */
3815 @Deprecated
3816 @SystemApi
3817 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3818
3819 /**
3820 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3821 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3822 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003823 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003824 */
3825 @Deprecated
3826 @SystemApi
3827 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3828
3829 /**
3830 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3831 * only mode.
3832 * {@code true} if in emergency only mode, {@code false} otherwise.
3833 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003834 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003835 */
3836 @Deprecated
3837 @SystemApi
3838 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3839
3840 /**
3841 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3842 * registration state is roaming.
3843 * {@code true} if registration indicates roaming, {@code false} otherwise
3844 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003845 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003846 */
3847 @Deprecated
3848 @SystemApi
3849 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3850 "isDataRoamingFromRegistration";
3851
3852 /**
3853 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3854 * aggregation is in use.
3855 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3856 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003857 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003858 */
3859 @Deprecated
3860 @SystemApi
3861 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3862
3863 /**
3864 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3865 * is reduced from the rsrp threshold while calculating signal strength level.
3866 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003867 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003868 */
3869 @Deprecated
3870 @SystemApi
3871 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3872
3873 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003874 * The name of the extra used to define the text to be processed, as a
3875 * CharSequence. Note that this may be a styled CharSequence, so you must use
3876 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003877 */
3878 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3879 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003880 * 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 +00003881 */
3882 public static final String EXTRA_PROCESS_TEXT_READONLY =
3883 "android.intent.extra.PROCESS_TEXT_READONLY";
3884
Bryce Leebc58f592015-09-25 16:43:01 -07003885 /**
3886 * Broadcast action: reports when a new thermal event has been reached. When the device
3887 * is reaching its maximum temperatue, the thermal level reported
3888 * {@hide}
3889 */
3890 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3891 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3892
3893 /** {@hide} */
3894 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3895
3896 /**
3897 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003898 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003899 * {@hide}
3900 */
3901 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3902
3903 /**
3904 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003905 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003906 * {@hide}
3907 */
3908 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3909
3910 /**
3911 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003912 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003913 * {@hide}
3914 */
3915 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3916
3917
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003918 // ---------------------------------------------------------------------
3919 // ---------------------------------------------------------------------
3920 // Standard intent categories (see addCategory()).
3921
3922 /**
3923 * Set if the activity should be an option for the default action
3924 * (center press) to perform on a piece of data. Setting this will
3925 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003926 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003927 * Intent when initiating an action -- it is for use in intent filters
3928 * specified in packages.
3929 */
3930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3931 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3932 /**
3933 * Activities that can be safely invoked from a browser must support this
3934 * category. For example, if the user is viewing a web page or an e-mail
3935 * and clicks on a link in the text, the Intent generated execute that
3936 * link will require the BROWSABLE category, so that only activities
3937 * supporting this category will be considered as possible actions. By
3938 * supporting this category, you are promising that there is nothing
3939 * damaging (without user intervention) that can happen by invoking any
3940 * matching Intent.
3941 */
3942 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3943 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3944 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003945 * Categories for activities that can participate in voice interaction.
3946 * An activity that supports this category must be prepared to run with
3947 * no UI shown at all (though in some case it may have a UI shown), and
3948 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3949 */
3950 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3951 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3952 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003953 * Set if the activity should be considered as an alternative action to
3954 * the data the user is currently viewing. See also
3955 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3956 * applies to the selection in a list of items.
3957 *
3958 * <p>Supporting this category means that you would like your activity to be
3959 * displayed in the set of alternative things the user can do, usually as
3960 * part of the current activity's options menu. You will usually want to
3961 * include a specific label in the &lt;intent-filter&gt; of this action
3962 * describing to the user what it does.
3963 *
3964 * <p>The action of IntentFilter with this category is important in that it
3965 * describes the specific action the target will perform. This generally
3966 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3967 * a specific name such as "com.android.camera.action.CROP. Only one
3968 * alternative of any particular action will be shown to the user, so using
3969 * a specific action like this makes sure that your alternative will be
3970 * displayed while also allowing other applications to provide their own
3971 * overrides of that particular action.
3972 */
3973 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3974 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3975 /**
3976 * Set if the activity should be considered as an alternative selection
3977 * action to the data the user has currently selected. This is like
3978 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3979 * of items from which the user can select, giving them alternatives to the
3980 * default action that will be performed on it.
3981 */
3982 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3983 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3984 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003985 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003986 */
3987 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3988 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3989 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003990 * Should be displayed in the top-level launcher.
3991 */
3992 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3993 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3994 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003995 * Indicates an activity optimized for Leanback mode, and that should
3996 * be displayed in the Leanback launcher.
3997 */
3998 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3999 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4000 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004001 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4002 * @hide
4003 */
4004 @SystemApi
4005 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4006 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004007 * Provides information about the package it is in; typically used if
4008 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4009 * a front-door to the user without having to be shown in the all apps list.
4010 */
4011 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4012 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4013 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004014 * This is the home activity, that is the first activity that is displayed
4015 * when the device boots.
4016 */
4017 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4018 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4019 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004020 * This is the home activity that is displayed when the device is finished setting up and ready
4021 * for use.
4022 * @hide
4023 */
4024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4025 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4026 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004027 * This is the setup wizard activity, that is the first activity that is displayed
4028 * when the user sets up the device for the first time.
4029 * @hide
4030 */
4031 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4032 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4033 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004034 * This is the home activity, that is the activity that serves as the launcher app
4035 * from there the user can start other apps. Often components with lower/higher
4036 * priority intent filters handle the home intent, for example SetupWizard, to
4037 * setup the device and we need to be able to distinguish the home app from these
4038 * setup helpers.
4039 * @hide
4040 */
4041 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4042 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4043 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004044 * This activity is a preference panel.
4045 */
4046 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4047 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4048 /**
4049 * This activity is a development preference panel.
4050 */
4051 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4052 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4053 /**
4054 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004055 */
4056 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4057 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4058 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004059 * This activity allows the user to browse and download new applications.
4060 */
4061 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4062 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4063 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004064 * This activity may be exercised by the monkey or other automated test tools.
4065 */
4066 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4067 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4068 /**
4069 * To be used as a test (not part of the normal user experience).
4070 */
4071 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4072 /**
4073 * To be used as a unit test (run through the Test Harness).
4074 */
4075 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4076 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004077 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004078 * experience).
4079 */
4080 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004081
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004082 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004083 * Used to indicate that an intent only wants URIs that can be opened with
4084 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4085 * must support at least the columns defined in {@link OpenableColumns} when
4086 * queried.
4087 *
4088 * @see #ACTION_GET_CONTENT
4089 * @see #ACTION_OPEN_DOCUMENT
4090 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004091 */
4092 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4093 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4094
4095 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004096 * Used to indicate that an intent filter can accept files which are not necessarily
4097 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4098 * at least streamable via
4099 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4100 * using one of the stream types exposed via
4101 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4102 *
4103 * @see #ACTION_SEND
4104 * @see #ACTION_SEND_MULTIPLE
4105 */
4106 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4107 public static final String CATEGORY_TYPED_OPENABLE =
4108 "android.intent.category.TYPED_OPENABLE";
4109
4110 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004111 * To be used as code under test for framework instrumentation tests.
4112 */
4113 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4114 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004115 /**
4116 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004117 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4118 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004119 */
4120 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4121 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4122 /**
4123 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004124 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4125 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004126 */
4127 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4128 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004129 /**
4130 * An activity to run when device is inserted into a analog (low end) dock.
4131 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4132 * information, see {@link android.app.UiModeManager}.
4133 */
4134 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4135 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4136
4137 /**
4138 * An activity to run when device is inserted into a digital (high end) dock.
4139 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4140 * information, see {@link android.app.UiModeManager}.
4141 */
4142 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4143 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004144
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004145 /**
4146 * Used to indicate that the activity can be used in a car environment.
4147 */
4148 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4149 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4150
Zak Cohendb6ca492017-01-26 14:09:00 -08004151 /**
4152 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4153 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4154 * information, see {@link android.app.UiModeManager}.
4155 */
4156 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4157 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004158 // ---------------------------------------------------------------------
4159 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004160 // Application launch intent categories (see addCategory()).
4161
4162 /**
4163 * Used with {@link #ACTION_MAIN} to launch the browser application.
4164 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004165 * <p>NOTE: This should not be used as the primary key of an Intent,
4166 * since it will not result in the app launching with the correct
4167 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004168 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004169 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004170 */
4171 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4172 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4173
4174 /**
4175 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4176 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004177 * <p>NOTE: This should not be used as the primary key of an Intent,
4178 * since it will not result in the app launching with the correct
4179 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004180 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004181 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004182 */
4183 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4184 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4185
4186 /**
4187 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4188 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004189 * <p>NOTE: This should not be used as the primary key of an Intent,
4190 * since it will not result in the app launching with the correct
4191 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004192 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004193 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004194 */
4195 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4196 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4197
4198 /**
4199 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4200 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004201 * <p>NOTE: This should not be used as the primary key of an Intent,
4202 * since it will not result in the app launching with the correct
4203 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004204 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004205 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004206 */
4207 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4208 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4209
4210 /**
4211 * Used with {@link #ACTION_MAIN} to launch the email application.
4212 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004213 * <p>NOTE: This should not be used as the primary key of an Intent,
4214 * since it will not result in the app launching with the correct
4215 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004216 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004217 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004218 */
4219 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4220 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4221
4222 /**
4223 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4224 * The activity should be able to view and manipulate image and video files
4225 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004226 * <p>NOTE: This should not be used as the primary key of an Intent,
4227 * since it will not result in the app launching with the correct
4228 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004229 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004230 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004231 */
4232 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4233 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4234
4235 /**
4236 * Used with {@link #ACTION_MAIN} to launch the maps application.
4237 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004238 * <p>NOTE: This should not be used as the primary key of an Intent,
4239 * since it will not result in the app launching with the correct
4240 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004241 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004242 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004243 */
4244 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4245 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4246
4247 /**
4248 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4249 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004250 * <p>NOTE: This should not be used as the primary key of an Intent,
4251 * since it will not result in the app launching with the correct
4252 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004253 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004254 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004255 */
4256 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4257 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4258
4259 /**
4260 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004261 * The activity should be able to play, browse, or manipulate music files
4262 * stored on the device.
4263 * <p>NOTE: This should not be used as the primary key of an Intent,
4264 * since it will not result in the app launching with the correct
4265 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004266 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004267 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004268 */
4269 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4270 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4271
4272 // ---------------------------------------------------------------------
4273 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004274 // Standard extra data keys.
4275
4276 /**
4277 * The initial data to place in a newly created record. Use with
4278 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4279 * fields as would be given to the underlying ContentProvider.insert()
4280 * call.
4281 */
4282 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4283
4284 /**
4285 * A constant CharSequence that is associated with the Intent, used with
4286 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4287 * this may be a styled CharSequence, so you must use
4288 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4289 * retrieve it.
4290 */
4291 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4292
4293 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004294 * A constant String that is associated with the Intent, used with
4295 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4296 * as HTML formatted text. Note that you <em>must</em> also supply
4297 * {@link #EXTRA_TEXT}.
4298 */
4299 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4300
4301 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004302 * A content: URI holding a stream of data associated with the Intent,
4303 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004304 */
4305 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4306
4307 /**
4308 * A String[] holding e-mail addresses that should be delivered to.
4309 */
4310 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4311
4312 /**
4313 * A String[] holding e-mail addresses that should be carbon copied.
4314 */
4315 public static final String EXTRA_CC = "android.intent.extra.CC";
4316
4317 /**
4318 * A String[] holding e-mail addresses that should be blind carbon copied.
4319 */
4320 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4321
4322 /**
4323 * A constant string holding the desired subject line of a message.
4324 */
4325 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4326
4327 /**
4328 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004329 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004330 */
4331 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4332
4333 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004334 * An int representing the user id to be used.
4335 *
4336 * @hide
4337 */
4338 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4339
4340 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004341 * An int representing the task id to be retrieved. This is used when a launch from recents is
4342 * intercepted by another action such as credentials confirmation to remember which task should
4343 * be resumed when complete.
4344 *
4345 * @hide
4346 */
4347 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4348
4349 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004350 * An Intent[] describing additional, alternate choices you would like shown with
4351 * {@link #ACTION_CHOOSER}.
4352 *
4353 * <p>An app may be capable of providing several different payload types to complete a
4354 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4355 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4356 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4357 * photo data or a hosted link where the photos can be viewed.</p>
4358 *
4359 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4360 * first/primary/preferred intent in the set. Additional intents specified in
4361 * this extra are ordered; by default intents that appear earlier in the array will be
4362 * preferred over intents that appear later in the array as matches for the same
4363 * target component. To alter this preference, a calling app may also supply
4364 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4365 */
4366 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4367
4368 /**
Adam Powell52c39212016-04-07 15:14:18 -07004369 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4370 * and omitted from a list of components presented to the user.
4371 *
4372 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4373 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4374 * from your own package or other apps from your organization if the idea of sending to those
4375 * targets would be redundant with other app functionality. Filtered components will not
4376 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4377 */
4378 public static final String EXTRA_EXCLUDE_COMPONENTS
4379 = "android.intent.extra.EXCLUDE_COMPONENTS";
4380
4381 /**
4382 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4383 * describing additional high-priority deep-link targets for the chooser to present to the user.
4384 *
4385 * <p>Targets provided in this way will be presented inline with all other targets provided
4386 * by services from other apps. They will be prioritized before other service targets, but
4387 * after those targets provided by sources that the user has manually pinned to the front.</p>
4388 *
4389 * @see #ACTION_CHOOSER
4390 */
4391 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4392
4393 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004394 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4395 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4396 *
4397 * <p>An app preparing an action for another app to complete may wish to allow the user to
4398 * disambiguate between several options for completing the action based on the chosen target
4399 * or otherwise refine the action before it is invoked.
4400 * </p>
4401 *
4402 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4403 * <ul>
4404 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4405 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4406 * chosen target beyond the first</li>
4407 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4408 * should fill in and send once the disambiguation is complete</li>
4409 * </ul>
4410 */
4411 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4412 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4413
4414 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004415 * An {@code ArrayList} of {@code String} annotations describing content for
4416 * {@link #ACTION_CHOOSER}.
4417 *
4418 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4419 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4420 *
4421 * <p>Annotations should describe the major components or topics of the content. It is up to
4422 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4423 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004424 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4425 * character. Performance on customized annotations can suffer, if they are rarely used for
4426 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4427 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004428 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004429 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004430 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004431 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004432 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004433 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004434 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004435 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004436 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004437 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4438 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4439 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4440 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4441 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004442 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004443 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4444 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004445 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004446 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004447 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004448 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004449 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004450 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004451 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004452 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004453 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004454 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004455 * Christmas and Thanksgiving.</li>
4456 * </ul>
4457 */
4458 public static final String EXTRA_CONTENT_ANNOTATIONS
4459 = "android.intent.extra.CONTENT_ANNOTATIONS";
4460
4461 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004462 * A {@link ResultReceiver} used to return data back to the sender.
4463 *
4464 * <p>Used to complete an app-specific
4465 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4466 *
4467 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4468 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4469 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4470 * when the user selects a target component from the chooser. It is up to the recipient
4471 * to send a result to this ResultReceiver to signal that disambiguation is complete
4472 * and that the chooser should invoke the user's choice.</p>
4473 *
4474 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4475 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4476 * to match and fill in the final Intent or ChooserTarget before starting it.
4477 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4478 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4479 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4480 *
4481 * <p>The result code passed to the ResultReceiver should be
4482 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4483 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4484 * the chooser should finish without starting a target.</p>
4485 */
4486 public static final String EXTRA_RESULT_RECEIVER
4487 = "android.intent.extra.RESULT_RECEIVER";
4488
4489 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004490 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004491 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004492 */
4493 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4494
4495 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004496 * A Parcelable[] of {@link Intent} or
4497 * {@link android.content.pm.LabeledIntent} objects as set with
4498 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4499 * a the front of the list of choices, when shown to the user with a
4500 * {@link #ACTION_CHOOSER}.
4501 */
4502 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4503
4504 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004505 * A {@link IntentSender} to start after ephemeral installation success.
4506 * @hide
4507 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004508 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4509
4510 /**
4511 * A {@link IntentSender} to start after ephemeral installation failure.
4512 * @hide
4513 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004514 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4515
4516 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004517 * The host name that triggered an ephemeral resolution.
4518 * @hide
4519 */
4520 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4521
4522 /**
4523 * An opaque token to track ephemeral resolution.
4524 * @hide
4525 */
4526 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4527
4528 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004529 * The action that triggered an instant application resolution.
4530 * @hide
4531 */
4532 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4533
4534 /**
Patrick Baumann709ee152017-12-04 16:12:52 -08004535 * A {@link Bundle} of metadata that describes the instanta application that needs to be
4536 * installed. This data is populated from the response to
4537 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4538 * instant application resolver.
4539 * @hide
4540 */
4541 public static final String EXTRA_INSTANT_APP_EXTRAS =
4542 "android.intent.extra.INSTANT_APP_EXTRAS";
4543
4544 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004545 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004546 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004547 * @hide
4548 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004549 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004550 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4551
4552 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004553 * The version code of the app to install components from.
4554 * @hide
4555 */
4556 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4557
4558 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004559 * The app that triggered the ephemeral installation.
4560 * @hide
4561 */
4562 public static final String EXTRA_CALLING_PACKAGE
4563 = "android.intent.extra.CALLING_PACKAGE";
4564
4565 /**
4566 * Optional calling app provided bundle containing additional launch information the
4567 * installer may use.
4568 * @hide
4569 */
4570 public static final String EXTRA_VERIFICATION_BUNDLE
4571 = "android.intent.extra.VERIFICATION_BUNDLE";
4572
4573 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004574 * A Bundle forming a mapping of potential target package names to different extras Bundles
4575 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4576 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4577 * be currently installed on the device.
4578 *
4579 * <p>An application may choose to provide alternate extras for the case where a user
4580 * selects an activity from a predetermined set of target packages. If the activity
4581 * the user selects from the chooser belongs to a package with its package name as
4582 * a key in this bundle, the corresponding extras for that package will be merged with
4583 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4584 * extra has the same key as an extra already present in the intent it will overwrite
4585 * the extra from the intent.</p>
4586 *
4587 * <p><em>Examples:</em>
4588 * <ul>
4589 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4590 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4591 * parameters for that target.</li>
4592 * <li>An application may offer additional metadata for known targets of a given intent
4593 * to pass along information only relevant to that target such as account or content
4594 * identifiers already known to that application.</li>
4595 * </ul></p>
4596 */
4597 public static final String EXTRA_REPLACEMENT_EXTRAS =
4598 "android.intent.extra.REPLACEMENT_EXTRAS";
4599
4600 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004601 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4602 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4603 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4604 * {@link ComponentName} of the chosen component.
4605 *
4606 * <p>In some situations this callback may never come, for example if the user abandons
4607 * the chooser, switches to another task or any number of other reasons. Apps should not
4608 * be written assuming that this callback will always occur.</p>
4609 */
4610 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4611 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4612
4613 /**
4614 * The {@link ComponentName} chosen by the user to complete an action.
4615 *
4616 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4617 */
4618 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4619
4620 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004621 * A {@link android.view.KeyEvent} object containing the event that
4622 * triggered the creation of the Intent it is in.
4623 */
4624 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4625
4626 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004627 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4628 * before shutting down.
4629 *
4630 * {@hide}
4631 */
4632 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4633
4634 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004635 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4636 * requested by the user.
4637 *
4638 * {@hide}
4639 */
4640 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4641 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4642
4643 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004644 * 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 -07004645 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4646 * of restarting the application.
4647 */
4648 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4649
4650 /**
4651 * A String holding the phone number originally entered in
4652 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4653 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4654 */
4655 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004657 /**
4658 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4659 * intents to supply the uid the package had been assigned. Also an optional
4660 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4661 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4662 * purpose.
4663 */
4664 public static final String EXTRA_UID = "android.intent.extra.UID";
4665
4666 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004667 * @hide String array of package names.
4668 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004669 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004670 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4671
4672 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004673 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4674 * intents to indicate whether this represents a full uninstall (removing
4675 * both the code and its data) or a partial uninstall (leaving its data,
4676 * implying that this is an update).
4677 */
4678 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004679
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004680 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004681 * @hide
4682 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4683 * intents to indicate that at this point the package has been removed for
4684 * all users on the device.
4685 */
4686 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4687 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4688
4689 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004690 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4691 * intents to indicate that this is a replacement of the package, so this
4692 * broadcast will immediately be followed by an add broadcast for a
4693 * different version of the same package.
4694 */
4695 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004696
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004697 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004698 * Used as an int extra field in {@link android.app.AlarmManager} intents
4699 * to tell the application being invoked how many pending alarms are being
4700 * delievered with the intent. For one-shot alarms this will always be 1.
4701 * For recurring alarms, this might be greater than 1 if the device was
4702 * asleep or powered off at the time an earlier alarm would have been
4703 * delivered.
4704 */
4705 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004706
Jacek Surazski86b6c532009-05-13 14:38:28 +02004707 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004708 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4709 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004710 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4711 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004712 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4713 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4714 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004715 */
4716 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4717
4718 /**
4719 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4720 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004721 */
4722 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4723
4724 /**
4725 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4726 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004727 */
4728 public static final int EXTRA_DOCK_STATE_DESK = 1;
4729
4730 /**
4731 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4732 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004733 */
4734 public static final int EXTRA_DOCK_STATE_CAR = 2;
4735
4736 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004737 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4738 * to represent that the phone is in a analog (low end) dock.
4739 */
4740 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4741
4742 /**
4743 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4744 * to represent that the phone is in a digital (high end) dock.
4745 */
4746 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4747
4748 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004749 * Boolean that can be supplied as meta-data with a dock activity, to
4750 * indicate that the dock should take over the home key when it is active.
4751 */
4752 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004753
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004754 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004755 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4756 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004757 */
4758 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4759
4760 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004761 * Used in the extra field in the remote intent. It's astring token passed with the
4762 * remote intent.
4763 */
4764 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4765 "android.intent.extra.remote_intent_token";
4766
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004767 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004768 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004769 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004770 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004771 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004772 "android.intent.extra.changed_component_name";
4773
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004774 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004775 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004776 * and contains a string array of all of the components that have changed. If
4777 * the state of the overall package has changed, then it will contain an entry
4778 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004779 */
4780 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4781 "android.intent.extra.changed_component_name_list";
4782
4783 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004784 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004785 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004786 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4787 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4788 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004789 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004790 */
4791 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4792 "android.intent.extra.changed_package_list";
4793
4794 /**
4795 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004796 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4797 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004798 * and contains an integer array of uids of all of the components
4799 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004800 */
4801 public static final String EXTRA_CHANGED_UID_LIST =
4802 "android.intent.extra.changed_uid_list";
4803
4804 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004805 * @hide
4806 * Magic extra system code can use when binding, to give a label for
4807 * who it is that has bound to a service. This is an integer giving
4808 * a framework string resource that can be displayed to the user.
4809 */
4810 public static final String EXTRA_CLIENT_LABEL =
4811 "android.intent.extra.client_label";
4812
4813 /**
4814 * @hide
4815 * Magic extra system code can use when binding, to give a PendingIntent object
4816 * that can be launched for the user to disable the system's use of this
4817 * service.
4818 */
4819 public static final String EXTRA_CLIENT_INTENT =
4820 "android.intent.extra.client_intent";
4821
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004822 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004823 * Extra used to indicate that an intent should only return data that is on
4824 * the local device. This is a boolean extra; the default is false. If true,
4825 * an implementation should only allow the user to select data that is
4826 * already on the device, not requiring it be downloaded from a remote
4827 * service when opened.
4828 *
4829 * @see #ACTION_GET_CONTENT
4830 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004831 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004832 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004833 */
4834 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004835 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004836
Amith Yamasani13593602012-03-22 16:16:17 -07004837 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004838 * Extra used to indicate that an intent can allow the user to select and
4839 * return multiple items. This is a boolean extra; the default is false. If
4840 * true, an implementation is allowed to present the user with a UI where
4841 * they can pick multiple items that are all returned to the caller. When
4842 * this happens, they should be returned as the {@link #getClipData()} part
4843 * of the result Intent.
4844 *
4845 * @see #ACTION_GET_CONTENT
4846 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004847 */
4848 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004849 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004850
4851 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004852 * The integer userHandle carried with broadcast intents related to addition, removal and
4853 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4854 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4855 *
Amith Yamasani13593602012-03-22 16:16:17 -07004856 * @hide
4857 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004858 public static final String EXTRA_USER_HANDLE =
4859 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004860
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004861 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004862 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4863 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4864 */
4865 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004866 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004867
4868 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004869 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004870 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4871 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004872 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004873 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4874
4875 /**
4876 * Extra sent in the intent to the BroadcastReceiver that handles
4877 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4878 * the restrictions as key/value pairs.
4879 */
4880 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4881 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004882
Amith Yamasani86118ba2013-03-28 14:33:16 -07004883 /**
4884 * Extra used in the response from a BroadcastReceiver that handles
4885 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4886 */
4887 public static final String EXTRA_RESTRICTIONS_INTENT =
4888 "android.intent.extra.restrictions_intent";
4889
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004890 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004891 * Extra used to communicate a set of acceptable MIME types. The type of the
4892 * extra is {@code String[]}. Values may be a combination of concrete MIME
4893 * types (such as "image/png") and/or partial MIME types (such as
4894 * "audio/*").
4895 *
4896 * @see #ACTION_GET_CONTENT
4897 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004898 */
4899 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4900
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004901 /**
4902 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4903 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004904 * When this is true, hardware devices can use this information to determine that
4905 * they shouldn't do a complete shutdown of their device since this is not a
4906 * complete shutdown down to the kernel, but only user space restarting.
4907 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004908 */
4909 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4910 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4911
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004912 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004913 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4914 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4915 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4916 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004917 *
4918 * @hide for internal use only.
4919 */
4920 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4921 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004922 /** @hide */
4923 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4924 /** @hide */
4925 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4926 /** @hide */
4927 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004928
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07004929 /**
4930 * Intent extra: the reason that the operation associated with this intent is being performed.
4931 *
4932 * <p>Type: String
4933 * @hide
4934 */
4935 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004936 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4937
qingxi240c2bb2017-04-12 17:31:18 -07004938 /**
4939 * {@hide}
4940 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4941 */
Rubin Xue8490f12015-06-25 12:17:48 +01004942 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4943
Santos Cordon15a13782015-03-31 18:32:31 -07004944 /**
qingxi240c2bb2017-04-12 17:31:18 -07004945 * {@hide}
4946 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4947 * reset for the device with eSIM. This extra will be sent together with
4948 * {@link #ACTION_FACTORY_RESET}
4949 */
4950 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4951
4952 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004953 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4954 * activation request.
4955 * TODO: Add information about the structure and response data used with the pending intent.
4956 * @hide
4957 */
4958 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4959 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4960
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004961 /**
4962 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004963 *
4964 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004965 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004966 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004967 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4968
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004969 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004970 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4971 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4972 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004973 *
4974 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004975 * @see #ACTION_QUICK_VIEW
4976 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004977 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004978 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004979 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4980 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004981
4982 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004983 * An optional extra of {@code String[]} indicating which quick view features should be made
4984 * available to the user in the quick view UI while handing a
4985 * {@link Intent#ACTION_QUICK_VIEW} intent.
4986 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4987 * Quick viewer can implement features not listed below.
4988 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05004989 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
4990 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
4991 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07004992 * <p>
4993 * Requirements:
4994 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4995 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4996 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4997 * internal policies.
4998 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4999 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5000 * disable or hide features.
5001 *
5002 * @see #ACTION_QUICK_VIEW
5003 */
5004 public static final String EXTRA_QUICK_VIEW_FEATURES =
5005 "android.intent.extra.QUICK_VIEW_FEATURES";
5006
5007 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005008 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005009 * When a profile goes into quiet mode, all apps in the profile are killed and the
5010 * profile user is stopped. Widgets originating from the profile are masked, and app
5011 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005012 */
5013 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005014
5015 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005016 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005017 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005018 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5019 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005020 *
5021 * @hide
5022 */
5023 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5024 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5025
5026 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005027 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5028 * whether to show the chooser or not when there is only one application available
5029 * to choose from.
5030 *
5031 * @hide
5032 */
5033 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5034 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5035
5036 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005037 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005038 * to represent that a video codec is allowed to use.
5039 *
5040 * @hide
5041 */
5042 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5043
5044 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005045 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005046 * to represent that a audio codec is allowed to use.
5047 *
5048 * @hide
5049 */
5050 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5051
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005052 // ---------------------------------------------------------------------
5053 // ---------------------------------------------------------------------
5054 // Intent flags (see mFlags variable).
5055
Tor Norbyed9273d62013-05-30 15:59:53 -07005056 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005057 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005058 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5059 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005060 @Retention(RetentionPolicy.SOURCE)
5061 public @interface GrantUriMode {}
5062
Jeff Sharkey846318a2014-04-04 12:12:41 -07005063 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005064 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005065 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5066 @Retention(RetentionPolicy.SOURCE)
5067 public @interface AccessUriMode {}
5068
5069 /**
5070 * Test if given mode flags specify an access mode, which must be at least
5071 * read and/or write.
5072 *
5073 * @hide
5074 */
5075 public static boolean isAccessUriMode(int modeFlags) {
5076 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5077 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5078 }
5079
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005080 /** @hide */
5081 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5082 FLAG_GRANT_READ_URI_PERMISSION,
5083 FLAG_GRANT_WRITE_URI_PERMISSION,
5084 FLAG_FROM_BACKGROUND,
5085 FLAG_DEBUG_LOG_RESOLUTION,
5086 FLAG_EXCLUDE_STOPPED_PACKAGES,
5087 FLAG_INCLUDE_STOPPED_PACKAGES,
5088 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5089 FLAG_GRANT_PREFIX_URI_PERMISSION,
5090 FLAG_DEBUG_TRIAGED_MISSING,
5091 FLAG_IGNORE_EPHEMERAL,
5092 FLAG_ACTIVITY_NO_HISTORY,
5093 FLAG_ACTIVITY_SINGLE_TOP,
5094 FLAG_ACTIVITY_NEW_TASK,
5095 FLAG_ACTIVITY_MULTIPLE_TASK,
5096 FLAG_ACTIVITY_CLEAR_TOP,
5097 FLAG_ACTIVITY_FORWARD_RESULT,
5098 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5099 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5100 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5101 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5102 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5103 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5104 FLAG_ACTIVITY_NEW_DOCUMENT,
5105 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5106 FLAG_ACTIVITY_NO_USER_ACTION,
5107 FLAG_ACTIVITY_REORDER_TO_FRONT,
5108 FLAG_ACTIVITY_NO_ANIMATION,
5109 FLAG_ACTIVITY_CLEAR_TASK,
5110 FLAG_ACTIVITY_TASK_ON_HOME,
5111 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5112 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5113 FLAG_RECEIVER_REGISTERED_ONLY,
5114 FLAG_RECEIVER_REPLACE_PENDING,
5115 FLAG_RECEIVER_FOREGROUND,
5116 FLAG_RECEIVER_NO_ABORT,
5117 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5118 FLAG_RECEIVER_BOOT_UPGRADE,
5119 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5120 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5121 FLAG_RECEIVER_FROM_SHELL,
5122 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5123 })
5124 @Retention(RetentionPolicy.SOURCE)
5125 public @interface Flags {}
5126
5127 /** @hide */
5128 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5129 FLAG_FROM_BACKGROUND,
5130 FLAG_DEBUG_LOG_RESOLUTION,
5131 FLAG_EXCLUDE_STOPPED_PACKAGES,
5132 FLAG_INCLUDE_STOPPED_PACKAGES,
5133 FLAG_DEBUG_TRIAGED_MISSING,
5134 FLAG_IGNORE_EPHEMERAL,
5135 FLAG_ACTIVITY_NO_HISTORY,
5136 FLAG_ACTIVITY_SINGLE_TOP,
5137 FLAG_ACTIVITY_NEW_TASK,
5138 FLAG_ACTIVITY_MULTIPLE_TASK,
5139 FLAG_ACTIVITY_CLEAR_TOP,
5140 FLAG_ACTIVITY_FORWARD_RESULT,
5141 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5142 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5143 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5144 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5145 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5146 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5147 FLAG_ACTIVITY_NEW_DOCUMENT,
5148 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5149 FLAG_ACTIVITY_NO_USER_ACTION,
5150 FLAG_ACTIVITY_REORDER_TO_FRONT,
5151 FLAG_ACTIVITY_NO_ANIMATION,
5152 FLAG_ACTIVITY_CLEAR_TASK,
5153 FLAG_ACTIVITY_TASK_ON_HOME,
5154 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5155 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5156 FLAG_RECEIVER_REGISTERED_ONLY,
5157 FLAG_RECEIVER_REPLACE_PENDING,
5158 FLAG_RECEIVER_FOREGROUND,
5159 FLAG_RECEIVER_NO_ABORT,
5160 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5161 FLAG_RECEIVER_BOOT_UPGRADE,
5162 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5163 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5164 FLAG_RECEIVER_FROM_SHELL,
5165 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5166 })
5167 @Retention(RetentionPolicy.SOURCE)
5168 public @interface MutableFlags {}
5169
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005170 /**
5171 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005172 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005173 * specified in its ClipData. When applying to an Intent's ClipData,
5174 * all URIs as well as recursive traversals through data or other ClipData
5175 * in Intent items will be granted; only the grant flags of the top-level
5176 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 */
5178 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5179 /**
5180 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005181 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005182 * specified in its ClipData. When applying to an Intent's ClipData,
5183 * all URIs as well as recursive traversals through data or other ClipData
5184 * in Intent items will be granted; only the grant flags of the top-level
5185 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005186 */
5187 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5188 /**
5189 * Can be set by the caller to indicate that this Intent is coming from
5190 * a background operation, not from direct user interaction.
5191 */
5192 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5193 /**
5194 * A flag you can enable for debugging: when set, log messages will be
5195 * printed during the resolution of this intent to show you what has
5196 * been found to create the final resolved list.
5197 */
5198 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005199 /**
5200 * If set, this intent will not match any components in packages that
5201 * are currently stopped. If this is not set, then the default behavior
5202 * is to include such applications in the result.
5203 */
5204 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5205 /**
5206 * If set, this intent will always match any components in packages that
5207 * are currently stopped. This is the default behavior when
5208 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5209 * flags are set, this one wins (it allows overriding of exclude for
5210 * places where the framework may automatically set the exclude flag).
5211 */
5212 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005213
5214 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005215 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005216 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005217 * persisted across device reboots until explicitly revoked with
5218 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5219 * grant for possible persisting; the receiving application must call
5220 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5221 * actually persist.
5222 *
5223 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5224 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5225 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005226 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005227 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005228 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005229
5230 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005231 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5232 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5233 * applies to any URI that is a prefix match against the original granted
5234 * URI. (Without this flag, the URI must match exactly for access to be
5235 * granted.) Another URI is considered a prefix match only when scheme,
5236 * authority, and all path segments defined by the prefix are an exact
5237 * match.
5238 */
5239 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5240
5241 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005242 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005243 * homework and verified that they correctly handle packages and components
5244 * that come and go over time. In particular:
5245 * <ul>
5246 * <li>Apps installed on external storage, which will appear to be
5247 * uninstalled while the the device is ejected.
5248 * <li>Apps with encryption unaware components, which will appear to not
5249 * exist while the device is locked.
5250 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005251 *
5252 * @hide
5253 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005254 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005255
5256 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005257 * Internal flag used to indicate ephemeral applications should not be
5258 * considered when resolving the intent.
5259 *
5260 * @hide
5261 */
5262 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5263
5264 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005265 * If set, the new activity is not kept in the history stack. As soon as
5266 * the user navigates away from it, the activity is finished. This may also
5267 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5268 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005269 *
5270 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5271 * is never invoked when the current activity starts a new activity which
5272 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005273 */
5274 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5275 /**
5276 * If set, the activity will not be launched if it is already running
5277 * at the top of the history stack.
5278 */
5279 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5280 /**
5281 * If set, this activity will become the start of a new task on this
5282 * history stack. A task (from the activity that started it to the
5283 * next task activity) defines an atomic group of activities that the
5284 * user can move to. Tasks can be moved to the foreground and background;
5285 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005286 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005287 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5288 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005289 *
5290 * <p>This flag is generally used by activities that want
5291 * to present a "launcher" style behavior: they give the user a list of
5292 * separate things that can be done, which otherwise run completely
5293 * independently of the activity launching them.
5294 *
5295 * <p>When using this flag, if a task is already running for the activity
5296 * you are now starting, then a new activity will not be started; instead,
5297 * the current task will simply be brought to the front of the screen with
5298 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5299 * to disable this behavior.
5300 *
5301 * <p>This flag can not be used when the caller is requesting a result from
5302 * the activity being launched.
5303 */
5304 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5305 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005306 * This flag is used to create a new task and launch an activity into it.
5307 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5308 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5309 * search through existing tasks for ones matching this Intent. Only if no such
5310 * task is found would a new task be created. When paired with
5311 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5312 * the search for a matching task and unconditionally start a new task.
5313 *
5314 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5315 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005316 * top-level application launcher.</strong> Used in conjunction with
5317 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5318 * behavior of bringing an existing task to the foreground. When set,
5319 * a new task is <em>always</em> started to host the Activity for the
5320 * Intent, regardless of whether there is already an existing task running
5321 * the same thing.
5322 *
5323 * <p><strong>Because the default system does not include graphical task management,
5324 * you should not use this flag unless you provide some way for a user to
5325 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005326 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005327 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5328 * creating new document tasks.
5329 *
5330 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005331 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005332 *
Scott Main7aee61f2011-02-08 11:25:01 -08005333 * <p>See
5334 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5335 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005336 *
5337 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5338 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005339 */
5340 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5341 /**
5342 * If set, and the activity being launched is already running in the
5343 * current task, then instead of launching a new instance of that activity,
5344 * all of the other activities on top of it will be closed and this Intent
5345 * will be delivered to the (now on top) old activity as a new Intent.
5346 *
5347 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5348 * If D calls startActivity() with an Intent that resolves to the component
5349 * of activity B, then C and D will be finished and B receive the given
5350 * Intent, resulting in the stack now being: A, B.
5351 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005352 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005353 * either receive the new intent you are starting here in its
5354 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005355 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005356 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5357 * the same intent, then it will be finished and re-created; for all other
5358 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5359 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005360 *
5361 * <p>This launch mode can also be used to good effect in conjunction with
5362 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5363 * of a task, it will bring any currently running instance of that task
5364 * to the foreground, and then clear it to its root state. This is
5365 * especially useful, for example, when launching an activity from the
5366 * notification manager.
5367 *
Scott Main7aee61f2011-02-08 11:25:01 -08005368 * <p>See
5369 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5370 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005371 */
5372 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5373 /**
5374 * If set and this intent is being used to launch a new activity from an
5375 * existing one, then the reply target of the existing activity will be
5376 * transfered to the new activity. This way the new activity can call
5377 * {@link android.app.Activity#setResult} and have that result sent back to
5378 * the reply target of the original activity.
5379 */
5380 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5381 /**
5382 * If set and this intent is being used to launch a new activity from an
5383 * existing one, the current activity will not be counted as the top
5384 * activity for deciding whether the new intent should be delivered to
5385 * the top instead of starting a new one. The previous activity will
5386 * be used as the top, with the assumption being that the current activity
5387 * will finish itself immediately.
5388 */
5389 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5390 /**
5391 * If set, the new activity is not kept in the list of recently launched
5392 * activities.
5393 */
5394 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5395 /**
5396 * This flag is not normally set by application code, but set for you by
5397 * the system as described in the
5398 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5399 * launchMode} documentation for the singleTask mode.
5400 */
5401 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5402 /**
5403 * If set, and this activity is either being started in a new task or
5404 * bringing to the top an existing task, then it will be launched as
5405 * the front door of the task. This will result in the application of
5406 * any affinities needed to have that task in the proper state (either
5407 * moving activities to or from it), or simply resetting that task to
5408 * its initial state if needed.
5409 */
5410 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5411 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005412 * This flag is not normally set by application code, but set for you by
5413 * the system if this activity is being launched from history
5414 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 */
5416 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005417 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005418 * @deprecated As of API 21 this performs identically to
5419 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005420 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005421 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005422 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005423 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005424 * This flag is used to open a document into a new task rooted at the activity launched
5425 * by this Intent. Through the use of this flag, or its equivalent attribute,
5426 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005427 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005428 *
Craig Mautner026596b2014-05-21 15:35:44 -07005429 * <p>The use of the activity attribute form of this,
5430 * {@link android.R.attr#documentLaunchMode}, is
5431 * preferred over the Intent flag described here. The attribute form allows the
5432 * Activity to specify multiple document behavior for all launchers of the Activity
5433 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005434 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005435 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5436 * it is kept after the activity is finished is different than the use of
5437 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5438 * this flag is being used to create a new recents entry, then by default that entry
5439 * will be removed once the activity is finished. You can modify this behavior with
5440 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5441 *
Craig Mautner026596b2014-05-21 15:35:44 -07005442 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5443 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5444 * equivalent of the Activity manifest specifying {@link
5445 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5446 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5447 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005448 *
Craig Mautner026596b2014-05-21 15:35:44 -07005449 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005450 *
Craig Mautner026596b2014-05-21 15:35:44 -07005451 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005452 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5453 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005454 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005455 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005456 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005457 * callback from occurring on the current frontmost activity before it is
5458 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005459 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005460 * <p>Typically, an activity can rely on that callback to indicate that an
5461 * explicit user action has caused their activity to be moved out of the
5462 * foreground. The callback marks an appropriate point in the activity's
5463 * lifecycle for it to dismiss any notifications that it intends to display
5464 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005465 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005466 * <p>If an activity is ever started via any non-user-driven events such as
5467 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5468 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005469 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005470 */
5471 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005472 /**
5473 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5474 * this flag will cause the launched activity to be brought to the front of its
5475 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005476 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005477 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5478 * If D calls startActivity() with an Intent that resolves to the component
5479 * of activity B, then B will be brought to the front of the history stack,
5480 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005481 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005482 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005483 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005484 */
5485 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005486 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005487 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5488 * this flag will prevent the system from applying an activity transition
5489 * animation to go to the next activity state. This doesn't mean an
5490 * animation will never run -- if another activity change happens that doesn't
5491 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005492 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005493 * when you are going to do a series of activity operations but the
5494 * animation seen by the user shouldn't be driven by the first activity
5495 * change but rather a later one.
5496 */
5497 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5498 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005499 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5500 * this flag will cause any existing task that would be associated with the
5501 * activity to be cleared before the activity is started. That is, the activity
5502 * becomes the new root of an otherwise empty task, and any old activities
5503 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5504 */
5505 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5506 /**
5507 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5508 * this flag will cause a newly launching task to be placed on top of the current
5509 * home activity task (if there is one). That is, pressing back from the task
5510 * will always return the user to home even if that was not the last activity they
5511 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5512 */
5513 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5514 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005515 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5516 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005517 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005518 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005519 * this flag. When set and the task's activity is finished, the recents
5520 * entry will remain in the interface for the user to re-launch it, like a
5521 * recents entry for a top-level application.
5522 * <p>
5523 * The receiving activity can override this request with
5524 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5525 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005526 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005527 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005528 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005529
5530 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005531 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5532 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005533 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5534 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005535 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005536 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005537
5538 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005539 * If set, when sending a broadcast only registered receivers will be
5540 * called -- no BroadcastReceiver components will be launched.
5541 */
5542 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005543 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005544 * If set, when sending a broadcast the new broadcast will replace
5545 * any existing pending broadcast that matches it. Matching is defined
5546 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5547 * true for the intents of the two broadcasts. When a match is found,
5548 * the new broadcast (and receivers associated with it) will replace the
5549 * existing one in the pending broadcast list, remaining at the same
5550 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005551 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005552 * <p>This flag is most typically used with sticky broadcasts, which
5553 * only care about delivering the most recent values of the broadcast
5554 * to their receivers.
5555 */
5556 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5557 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005558 * If set, when sending a broadcast the recipient is allowed to run at
5559 * foreground priority, with a shorter timeout interval. During normal
5560 * broadcasts the receivers are not automatically hoisted out of the
5561 * background priority class.
5562 */
5563 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5564 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005565 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5566 * They can still propagate results through to later receivers, but they can not prevent
5567 * later receivers from seeing the broadcast.
5568 */
5569 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5570 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005571 * If set, when sending a broadcast <i>before boot has completed</i> only
5572 * registered receivers will be called -- no BroadcastReceiver components
5573 * will be launched. Sticky intent state will be recorded properly even
5574 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5575 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005576 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005577 * <p>This flag is only for use by system sevices as a convenience to
5578 * avoid having to implement a more complex mechanism around detection
5579 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005580 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005581 * @hide
5582 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005583 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005584 /**
5585 * Set when this broadcast is for a boot upgrade, a special mode that
5586 * allows the broadcast to be sent before the system is ready and launches
5587 * the app process with no providers running in it.
5588 * @hide
5589 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005590 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005591 /**
5592 * If set, the broadcast will always go to manifest receivers in background (cached
5593 * or not running) apps, regardless of whether that would be done by default. By
5594 * default they will only receive broadcasts if the broadcast has specified an
5595 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005596 *
5597 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5598 * the broadcast code there must also be changed to match.
5599 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005600 * @hide
5601 */
5602 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5603 /**
5604 * If set, the broadcast will never go to manifest receivers in background (cached
5605 * or not running) apps, regardless of whether that would be done by default. By
5606 * default they will receive broadcasts if the broadcast has specified an
5607 * explicit component or package name.
5608 * @hide
5609 */
5610 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005611 /**
5612 * If set, this broadcast is being sent from the shell.
5613 * @hide
5614 */
5615 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005616
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005617 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005618 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5619 * will not receive broadcasts.
5620 *
5621 * <em>This flag has no effect when used by an Instant App.</em>
5622 */
5623 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5624
5625 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005626 * @hide Flags that can't be changed with PendingIntent.
5627 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005628 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5629 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5630 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005632 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005633 // ---------------------------------------------------------------------
5634 // toUri() and parseUri() options.
5635
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005636 /** @hide */
5637 @IntDef(flag = true, prefix = { "URI_" }, value = {
5638 URI_ALLOW_UNSAFE,
5639 URI_ANDROID_APP_SCHEME,
5640 URI_INTENT_SCHEME,
5641 })
5642 @Retention(RetentionPolicy.SOURCE)
5643 public @interface UriFlags {}
5644
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005645 /**
5646 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5647 * always has the "intent:" scheme. This syntax can be used when you want
5648 * to later disambiguate between URIs that are intended to describe an
5649 * Intent vs. all others that should be treated as raw URIs. When used
5650 * with {@link #parseUri}, any other scheme will result in a generic
5651 * VIEW action for that raw URI.
5652 */
5653 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005654
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005655 /**
5656 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5657 * always has the "android-app:" scheme. This is a variation of
5658 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5659 * http/https URI being delivered to a specific package name. The format
5660 * is:
5661 *
5662 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005663 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005664 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005665 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5666 * you must also include a scheme; including a path also requires both a host and a scheme.
5667 * The final #Intent; fragment can be used without a scheme, host, or path.
5668 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005669 * used with intents that have a {@link #setSelector}, since the base intent
5670 * will always have an explicit package name.</p>
5671 *
5672 * <p>Some examples of how this scheme maps to Intent objects:</p>
5673 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5674 * <colgroup align="left" />
5675 * <colgroup align="left" />
5676 * <thead>
5677 * <tr><th>URI</th> <th>Intent</th></tr>
5678 * </thead>
5679 *
5680 * <tbody>
5681 * <tr><td><code>android-app://com.example.app</code></td>
5682 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5683 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5684 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5685 * </table></td>
5686 * </tr>
5687 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5688 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5689 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5690 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5691 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5692 * </table></td>
5693 * </tr>
5694 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5695 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5696 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5697 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5698 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5699 * </table></td>
5700 * </tr>
5701 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5702 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5703 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5704 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5705 * </table></td>
5706 * </tr>
5707 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5708 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5709 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5710 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5711 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5712 * </table></td>
5713 * </tr>
5714 * <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>
5715 * <td><table border="" style="margin:0" >
5716 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5717 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5718 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5719 * </table></td>
5720 * </tr>
5721 * </tbody>
5722 * </table>
5723 */
5724 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5725
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005726 /**
5727 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5728 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5729 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5730 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5731 * generated Intent can not cause unexpected data access to happen.
5732 *
5733 * <p>If you do not trust the source of the URI being parsed, you should still do further
5734 * processing to protect yourself from it. In particular, when using it to start an
5735 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5736 * that can handle it.</p>
5737 */
5738 public static final int URI_ALLOW_UNSAFE = 1<<2;
5739
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005740 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005741
5742 private String mAction;
5743 private Uri mData;
5744 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005745 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005746 private ComponentName mComponent;
5747 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005748 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005749 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005750 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005751 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005752 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005753 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005754 /** Token to track instant app launches. Local only; do not copy cross-process. */
5755 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756
5757 // ---------------------------------------------------------------------
5758
Makoto Onuki97f82f22017-05-31 16:20:21 -07005759 private static final int COPY_MODE_ALL = 0;
5760 private static final int COPY_MODE_FILTER = 1;
5761 private static final int COPY_MODE_HISTORY = 2;
5762
5763 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005764 @IntDef(prefix = { "COPY_MODE_" }, value = {
5765 COPY_MODE_ALL,
5766 COPY_MODE_FILTER,
5767 COPY_MODE_HISTORY
5768 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005769 @Retention(RetentionPolicy.SOURCE)
5770 public @interface CopyMode {}
5771
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005772 /**
5773 * Create an empty intent.
5774 */
5775 public Intent() {
5776 }
5777
5778 /**
5779 * Copy constructor.
5780 */
5781 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005782 this(o, COPY_MODE_ALL);
5783 }
5784
5785 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005786 this.mAction = o.mAction;
5787 this.mData = o.mData;
5788 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005789 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005791
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005792 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005793 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005794 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005795
5796 if (copyMode != COPY_MODE_FILTER) {
5797 this.mFlags = o.mFlags;
5798 this.mContentUserHint = o.mContentUserHint;
5799 this.mLaunchToken = o.mLaunchToken;
5800 if (o.mSourceBounds != null) {
5801 this.mSourceBounds = new Rect(o.mSourceBounds);
5802 }
5803 if (o.mSelector != null) {
5804 this.mSelector = new Intent(o.mSelector);
5805 }
5806
5807 if (copyMode != COPY_MODE_HISTORY) {
5808 if (o.mExtras != null) {
5809 this.mExtras = new Bundle(o.mExtras);
5810 }
5811 if (o.mClipData != null) {
5812 this.mClipData = new ClipData(o.mClipData);
5813 }
5814 } else {
5815 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5816 this.mExtras = Bundle.STRIPPED;
5817 }
5818
5819 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5820 // history.
5821 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005822 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005823 }
5824
5825 @Override
5826 public Object clone() {
5827 return new Intent(this);
5828 }
5829
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005830 /**
5831 * Make a clone of only the parts of the Intent that are relevant for
5832 * filter matching: the action, data, type, component, and categories.
5833 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005834 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005835 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005836 }
5837
5838 /**
5839 * Create an intent with a given action. All other fields (data, type,
5840 * class) are null. Note that the action <em>must</em> be in a
5841 * namespace because Intents are used globally in the system -- for
5842 * example the system VIEW action is android.intent.action.VIEW; an
5843 * application's custom action would be something like
5844 * com.google.app.myapp.CUSTOM_ACTION.
5845 *
5846 * @param action The Intent action, such as ACTION_VIEW.
5847 */
5848 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005849 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005850 }
5851
5852 /**
5853 * Create an intent with a given action and for a given data url. Note
5854 * that the action <em>must</em> be in a namespace because Intents are
5855 * used globally in the system -- for example the system VIEW action is
5856 * android.intent.action.VIEW; an application's custom action would be
5857 * something like com.google.app.myapp.CUSTOM_ACTION.
5858 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005859 * <p><em>Note: scheme and host name matching in the Android framework is
5860 * case-sensitive, unlike the formal RFC. As a result,
5861 * you should always ensure that you write your Uri with these elements
5862 * using lower case letters, and normalize any Uris you receive from
5863 * outside of Android to ensure the scheme and host is lower case.</em></p>
5864 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005865 * @param action The Intent action, such as ACTION_VIEW.
5866 * @param uri The Intent data URI.
5867 */
5868 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005869 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005870 mData = uri;
5871 }
5872
5873 /**
5874 * Create an intent for a specific component. All other fields (action, data,
5875 * type, class) are null, though they can be modified later with explicit
5876 * calls. This provides a convenient way to create an intent that is
5877 * intended to execute a hard-coded class name, rather than relying on the
5878 * system to find an appropriate class for you; see {@link #setComponent}
5879 * for more information on the repercussions of this.
5880 *
5881 * @param packageContext A Context of the application package implementing
5882 * this class.
5883 * @param cls The component class that is to be used for the intent.
5884 *
5885 * @see #setClass
5886 * @see #setComponent
5887 * @see #Intent(String, android.net.Uri , Context, Class)
5888 */
5889 public Intent(Context packageContext, Class<?> cls) {
5890 mComponent = new ComponentName(packageContext, cls);
5891 }
5892
5893 /**
5894 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005895 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005896 * construct the Intent and then calling {@link #setClass} to set its
5897 * class.
5898 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005899 * <p><em>Note: scheme and host name matching in the Android framework is
5900 * case-sensitive, unlike the formal RFC. As a result,
5901 * you should always ensure that you write your Uri with these elements
5902 * using lower case letters, and normalize any Uris you receive from
5903 * outside of Android to ensure the scheme and host is lower case.</em></p>
5904 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005905 * @param action The Intent action, such as ACTION_VIEW.
5906 * @param uri The Intent data URI.
5907 * @param packageContext A Context of the application package implementing
5908 * this class.
5909 * @param cls The component class that is to be used for the intent.
5910 *
5911 * @see #Intent(String, android.net.Uri)
5912 * @see #Intent(Context, Class)
5913 * @see #setClass
5914 * @see #setComponent
5915 */
5916 public Intent(String action, Uri uri,
5917 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005918 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005919 mData = uri;
5920 mComponent = new ComponentName(packageContext, cls);
5921 }
5922
5923 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005924 * Create an intent to launch the main (root) activity of a task. This
5925 * is the Intent that is started when the application's is launched from
5926 * Home. For anything else that wants to launch an application in the
5927 * same way, it is important that they use an Intent structured the same
5928 * way, and can use this function to ensure this is the case.
5929 *
5930 * <p>The returned Intent has the given Activity component as its explicit
5931 * component, {@link #ACTION_MAIN} as its action, and includes the
5932 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5933 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5934 * to do that through {@link #addFlags(int)} on the returned Intent.
5935 *
5936 * @param mainActivity The main activity component that this Intent will
5937 * launch.
5938 * @return Returns a newly created Intent that can be used to launch the
5939 * activity as a main application entry.
5940 *
5941 * @see #setClass
5942 * @see #setComponent
5943 */
5944 public static Intent makeMainActivity(ComponentName mainActivity) {
5945 Intent intent = new Intent(ACTION_MAIN);
5946 intent.setComponent(mainActivity);
5947 intent.addCategory(CATEGORY_LAUNCHER);
5948 return intent;
5949 }
5950
5951 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005952 * Make an Intent for the main activity of an application, without
5953 * specifying a specific activity to run but giving a selector to find
5954 * the activity. This results in a final Intent that is structured
5955 * the same as when the application is launched from
5956 * Home. For anything else that wants to launch an application in the
5957 * same way, it is important that they use an Intent structured the same
5958 * way, and can use this function to ensure this is the case.
5959 *
5960 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5961 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5962 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5963 * to do that through {@link #addFlags(int)} on the returned Intent.
5964 *
5965 * @param selectorAction The action name of the Intent's selector.
5966 * @param selectorCategory The name of a category to add to the Intent's
5967 * selector.
5968 * @return Returns a newly created Intent that can be used to launch the
5969 * activity as a main application entry.
5970 *
5971 * @see #setSelector(Intent)
5972 */
5973 public static Intent makeMainSelectorActivity(String selectorAction,
5974 String selectorCategory) {
5975 Intent intent = new Intent(ACTION_MAIN);
5976 intent.addCategory(CATEGORY_LAUNCHER);
5977 Intent selector = new Intent();
5978 selector.setAction(selectorAction);
5979 selector.addCategory(selectorCategory);
5980 intent.setSelector(selector);
5981 return intent;
5982 }
5983
5984 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005985 * Make an Intent that can be used to re-launch an application's task
5986 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5987 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5988 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5989 *
5990 * @param mainActivity The activity component that is the root of the
5991 * task; this is the activity that has been published in the application's
5992 * manifest as the main launcher icon.
5993 *
5994 * @return Returns a newly created Intent that can be used to relaunch the
5995 * activity's task in its root state.
5996 */
5997 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5998 Intent intent = makeMainActivity(mainActivity);
5999 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6000 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6001 return intent;
6002 }
6003
6004 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006005 * Call {@link #parseUri} with 0 flags.
6006 * @deprecated Use {@link #parseUri} instead.
6007 */
6008 @Deprecated
6009 public static Intent getIntent(String uri) throws URISyntaxException {
6010 return parseUri(uri, 0);
6011 }
Tom Taylord4a47292009-12-21 13:59:18 -08006012
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006013 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006014 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006015 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006016 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006017 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006018 *
6019 * <p>The URI given here must not be relative -- that is, it must include
6020 * the scheme and full path.
6021 *
6022 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006023 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006024 *
6025 * @return Intent The newly created Intent object.
6026 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006027 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6028 * it bad (as parsed by the Uri class) or the Intent data within the
6029 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006030 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006031 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006032 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006033 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006034 int i = 0;
6035 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006036 final boolean androidApp = uri.startsWith("android-app:");
6037
6038 // Validate intent scheme if requested.
6039 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6040 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006041 Intent intent = new Intent(ACTION_VIEW);
6042 try {
6043 intent.setData(Uri.parse(uri));
6044 } catch (IllegalArgumentException e) {
6045 throw new URISyntaxException(uri, e.getMessage());
6046 }
6047 return intent;
6048 }
6049 }
Tom Taylord4a47292009-12-21 13:59:18 -08006050
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006051 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006052 // simple case
6053 if (i == -1) {
6054 if (!androidApp) {
6055 return new Intent(ACTION_VIEW, Uri.parse(uri));
6056 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006057
6058 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006059 } else if (!uri.startsWith("#Intent;", i)) {
6060 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006061 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006062 } else {
6063 i = -1;
6064 }
6065 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006066
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006067 // new format
6068 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006069 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006070 boolean explicitAction = false;
6071 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006072
6073 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006074 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006075 String data;
6076 if (i >= 0) {
6077 data = uri.substring(0, i);
6078 i += 8; // length of "#Intent;"
6079 } else {
6080 data = uri;
6081 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006082
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006083 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006084 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006085 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006086 if (eq < 0) eq = i-1;
6087 int semi = uri.indexOf(';', i);
6088 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006089
6090 // action
6091 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006092 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006093 if (!inSelector) {
6094 explicitAction = true;
6095 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006096 }
6097
6098 // categories
6099 else if (uri.startsWith("category=", i)) {
6100 intent.addCategory(value);
6101 }
6102
6103 // type
6104 else if (uri.startsWith("type=", i)) {
6105 intent.mType = value;
6106 }
6107
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006108 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006109 else if (uri.startsWith("launchFlags=", i)) {
6110 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006111 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6112 intent.mFlags &= ~IMMUTABLE_FLAGS;
6113 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006114 }
6115
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006116 // package
6117 else if (uri.startsWith("package=", i)) {
6118 intent.mPackage = value;
6119 }
6120
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006121 // component
6122 else if (uri.startsWith("component=", i)) {
6123 intent.mComponent = ComponentName.unflattenFromString(value);
6124 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006125
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006126 // scheme
6127 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006128 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006129 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006130 } else {
6131 scheme = value;
6132 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006133 }
6134
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006135 // source bounds
6136 else if (uri.startsWith("sourceBounds=", i)) {
6137 intent.mSourceBounds = Rect.unflattenFromString(value);
6138 }
6139
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006140 // selector
6141 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6142 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006143 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006144 }
6145
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006146 // extra
6147 else {
6148 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006149 // create Bundle if it doesn't already exist
6150 if (intent.mExtras == null) intent.mExtras = new Bundle();
6151 Bundle b = intent.mExtras;
6152 // add EXTRA
6153 if (uri.startsWith("S.", i)) b.putString(key, value);
6154 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6155 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6156 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6157 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6158 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6159 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6160 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6161 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6162 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6163 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006164
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006165 // move to the next item
6166 i = semi + 1;
6167 }
6168
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006169 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006170 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006171 if (baseIntent.mPackage == null) {
6172 baseIntent.setSelector(intent);
6173 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006174 intent = baseIntent;
6175 }
6176
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006177 if (data != null) {
6178 if (data.startsWith("intent:")) {
6179 data = data.substring(7);
6180 if (scheme != null) {
6181 data = scheme + ':' + data;
6182 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006183 } else if (data.startsWith("android-app:")) {
6184 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6185 // Correctly formed android-app, first part is package name.
6186 int end = data.indexOf('/', 14);
6187 if (end < 0) {
6188 // All we have is a package name.
6189 intent.mPackage = data.substring(14);
6190 if (!explicitAction) {
6191 intent.setAction(ACTION_MAIN);
6192 }
6193 data = "";
6194 } else {
6195 // Target the Intent at the given package name always.
6196 String authority = null;
6197 intent.mPackage = data.substring(14, end);
6198 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006199 if ((end+1) < data.length()) {
6200 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6201 // Found a scheme, remember it.
6202 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006203 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006204 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6205 // Found a authority, remember it.
6206 authority = data.substring(end+1, newEnd);
6207 end = newEnd;
6208 }
6209 } else {
6210 // All we have is a scheme.
6211 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006212 }
6213 }
6214 if (scheme == null) {
6215 // If there was no scheme, then this just targets the package.
6216 if (!explicitAction) {
6217 intent.setAction(ACTION_MAIN);
6218 }
6219 data = "";
6220 } else if (authority == null) {
6221 data = scheme + ":";
6222 } else {
6223 data = scheme + "://" + authority + data.substring(end);
6224 }
6225 }
6226 } else {
6227 data = "";
6228 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006229 }
Tom Taylord4a47292009-12-21 13:59:18 -08006230
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006231 if (data.length() > 0) {
6232 try {
6233 intent.mData = Uri.parse(data);
6234 } catch (IllegalArgumentException e) {
6235 throw new URISyntaxException(uri, e.getMessage());
6236 }
6237 }
6238 }
Tom Taylord4a47292009-12-21 13:59:18 -08006239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006240 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006241
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006242 } catch (IndexOutOfBoundsException e) {
6243 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6244 }
6245 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006246
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006247 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006248 return getIntentOld(uri, 0);
6249 }
6250
6251 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006252 Intent intent;
6253
6254 int i = uri.lastIndexOf('#');
6255 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006256 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006257 final int intentFragmentStart = i;
6258 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006259
6260 i++;
6261
6262 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006263 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006264 i += 7;
6265 int j = uri.indexOf(')', i);
6266 action = uri.substring(i, j);
6267 i = j + 1;
6268 }
6269
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006270 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006271
6272 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006273 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006274 i += 11;
6275 int j = uri.indexOf(')', i);
6276 while (i < j) {
6277 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006278 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006279 if (i < sep) {
6280 intent.addCategory(uri.substring(i, sep));
6281 }
6282 i = sep + 1;
6283 }
6284 i = j + 1;
6285 }
6286
6287 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006288 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006289 i += 5;
6290 int j = uri.indexOf(')', i);
6291 intent.mType = uri.substring(i, j);
6292 i = j + 1;
6293 }
6294
6295 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006296 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006297 i += 12;
6298 int j = uri.indexOf(')', i);
6299 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006300 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6301 intent.mFlags &= ~IMMUTABLE_FLAGS;
6302 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006303 i = j + 1;
6304 }
6305
6306 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006307 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006308 i += 10;
6309 int j = uri.indexOf(')', i);
6310 int sep = uri.indexOf('!', i);
6311 if (sep >= 0 && sep < j) {
6312 String pkg = uri.substring(i, sep);
6313 String cls = uri.substring(sep + 1, j);
6314 intent.mComponent = new ComponentName(pkg, cls);
6315 }
6316 i = j + 1;
6317 }
6318
6319 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006320 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006321 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006322
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006323 final int closeParen = uri.indexOf(')', i);
6324 if (closeParen == -1) throw new URISyntaxException(uri,
6325 "EXTRA missing trailing ')'", i);
6326
6327 while (i < closeParen) {
6328 // fetch the key value
6329 int j = uri.indexOf('=', i);
6330 if (j <= i + 1 || i >= closeParen) {
6331 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6332 }
6333 char type = uri.charAt(i);
6334 i++;
6335 String key = uri.substring(i, j);
6336 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006337
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006338 // get type-value
6339 j = uri.indexOf('!', i);
6340 if (j == -1 || j >= closeParen) j = closeParen;
6341 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6342 String value = uri.substring(i, j);
6343 i = j;
6344
6345 // create Bundle if it doesn't already exist
6346 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006347
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006348 // add item to bundle
6349 try {
6350 switch (type) {
6351 case 'S':
6352 intent.mExtras.putString(key, Uri.decode(value));
6353 break;
6354 case 'B':
6355 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6356 break;
6357 case 'b':
6358 intent.mExtras.putByte(key, Byte.parseByte(value));
6359 break;
6360 case 'c':
6361 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6362 break;
6363 case 'd':
6364 intent.mExtras.putDouble(key, Double.parseDouble(value));
6365 break;
6366 case 'f':
6367 intent.mExtras.putFloat(key, Float.parseFloat(value));
6368 break;
6369 case 'i':
6370 intent.mExtras.putInt(key, Integer.parseInt(value));
6371 break;
6372 case 'l':
6373 intent.mExtras.putLong(key, Long.parseLong(value));
6374 break;
6375 case 's':
6376 intent.mExtras.putShort(key, Short.parseShort(value));
6377 break;
6378 default:
6379 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6380 }
6381 } catch (NumberFormatException e) {
6382 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6383 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006384
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006385 char ch = uri.charAt(i);
6386 if (ch == ')') break;
6387 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6388 i++;
6389 }
6390 }
6391
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006392 if (isIntentFragment) {
6393 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6394 } else {
6395 intent.mData = Uri.parse(uri);
6396 }
Tom Taylord4a47292009-12-21 13:59:18 -08006397
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006398 if (intent.mAction == null) {
6399 // By default, if no action is specified, then use VIEW.
6400 intent.mAction = ACTION_VIEW;
6401 }
6402
6403 } else {
6404 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6405 }
6406
6407 return intent;
6408 }
6409
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006410 /** @hide */
6411 public interface CommandOptionHandler {
6412 boolean handleOption(String opt, ShellCommand cmd);
6413 }
6414
6415 /** @hide */
6416 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6417 throws URISyntaxException {
6418 Intent intent = new Intent();
6419 Intent baseIntent = intent;
6420 boolean hasIntentInfo = false;
6421
6422 Uri data = null;
6423 String type = null;
6424
6425 String opt;
6426 while ((opt=cmd.getNextOption()) != null) {
6427 switch (opt) {
6428 case "-a":
6429 intent.setAction(cmd.getNextArgRequired());
6430 if (intent == baseIntent) {
6431 hasIntentInfo = true;
6432 }
6433 break;
6434 case "-d":
6435 data = Uri.parse(cmd.getNextArgRequired());
6436 if (intent == baseIntent) {
6437 hasIntentInfo = true;
6438 }
6439 break;
6440 case "-t":
6441 type = cmd.getNextArgRequired();
6442 if (intent == baseIntent) {
6443 hasIntentInfo = true;
6444 }
6445 break;
6446 case "-c":
6447 intent.addCategory(cmd.getNextArgRequired());
6448 if (intent == baseIntent) {
6449 hasIntentInfo = true;
6450 }
6451 break;
6452 case "-e":
6453 case "--es": {
6454 String key = cmd.getNextArgRequired();
6455 String value = cmd.getNextArgRequired();
6456 intent.putExtra(key, value);
6457 }
6458 break;
6459 case "--esn": {
6460 String key = cmd.getNextArgRequired();
6461 intent.putExtra(key, (String) null);
6462 }
6463 break;
6464 case "--ei": {
6465 String key = cmd.getNextArgRequired();
6466 String value = cmd.getNextArgRequired();
6467 intent.putExtra(key, Integer.decode(value));
6468 }
6469 break;
6470 case "--eu": {
6471 String key = cmd.getNextArgRequired();
6472 String value = cmd.getNextArgRequired();
6473 intent.putExtra(key, Uri.parse(value));
6474 }
6475 break;
6476 case "--ecn": {
6477 String key = cmd.getNextArgRequired();
6478 String value = cmd.getNextArgRequired();
6479 ComponentName cn = ComponentName.unflattenFromString(value);
6480 if (cn == null)
6481 throw new IllegalArgumentException("Bad component name: " + value);
6482 intent.putExtra(key, cn);
6483 }
6484 break;
6485 case "--eia": {
6486 String key = cmd.getNextArgRequired();
6487 String value = cmd.getNextArgRequired();
6488 String[] strings = value.split(",");
6489 int[] list = new int[strings.length];
6490 for (int i = 0; i < strings.length; i++) {
6491 list[i] = Integer.decode(strings[i]);
6492 }
6493 intent.putExtra(key, list);
6494 }
6495 break;
6496 case "--eial": {
6497 String key = cmd.getNextArgRequired();
6498 String value = cmd.getNextArgRequired();
6499 String[] strings = value.split(",");
6500 ArrayList<Integer> list = new ArrayList<>(strings.length);
6501 for (int i = 0; i < strings.length; i++) {
6502 list.add(Integer.decode(strings[i]));
6503 }
6504 intent.putExtra(key, list);
6505 }
6506 break;
6507 case "--el": {
6508 String key = cmd.getNextArgRequired();
6509 String value = cmd.getNextArgRequired();
6510 intent.putExtra(key, Long.valueOf(value));
6511 }
6512 break;
6513 case "--ela": {
6514 String key = cmd.getNextArgRequired();
6515 String value = cmd.getNextArgRequired();
6516 String[] strings = value.split(",");
6517 long[] list = new long[strings.length];
6518 for (int i = 0; i < strings.length; i++) {
6519 list[i] = Long.valueOf(strings[i]);
6520 }
6521 intent.putExtra(key, list);
6522 hasIntentInfo = true;
6523 }
6524 break;
6525 case "--elal": {
6526 String key = cmd.getNextArgRequired();
6527 String value = cmd.getNextArgRequired();
6528 String[] strings = value.split(",");
6529 ArrayList<Long> list = new ArrayList<>(strings.length);
6530 for (int i = 0; i < strings.length; i++) {
6531 list.add(Long.valueOf(strings[i]));
6532 }
6533 intent.putExtra(key, list);
6534 hasIntentInfo = true;
6535 }
6536 break;
6537 case "--ef": {
6538 String key = cmd.getNextArgRequired();
6539 String value = cmd.getNextArgRequired();
6540 intent.putExtra(key, Float.valueOf(value));
6541 hasIntentInfo = true;
6542 }
6543 break;
6544 case "--efa": {
6545 String key = cmd.getNextArgRequired();
6546 String value = cmd.getNextArgRequired();
6547 String[] strings = value.split(",");
6548 float[] list = new float[strings.length];
6549 for (int i = 0; i < strings.length; i++) {
6550 list[i] = Float.valueOf(strings[i]);
6551 }
6552 intent.putExtra(key, list);
6553 hasIntentInfo = true;
6554 }
6555 break;
6556 case "--efal": {
6557 String key = cmd.getNextArgRequired();
6558 String value = cmd.getNextArgRequired();
6559 String[] strings = value.split(",");
6560 ArrayList<Float> list = new ArrayList<>(strings.length);
6561 for (int i = 0; i < strings.length; i++) {
6562 list.add(Float.valueOf(strings[i]));
6563 }
6564 intent.putExtra(key, list);
6565 hasIntentInfo = true;
6566 }
6567 break;
6568 case "--esa": {
6569 String key = cmd.getNextArgRequired();
6570 String value = cmd.getNextArgRequired();
6571 // Split on commas unless they are preceeded by an escape.
6572 // The escape character must be escaped for the string and
6573 // again for the regex, thus four escape characters become one.
6574 String[] strings = value.split("(?<!\\\\),");
6575 intent.putExtra(key, strings);
6576 hasIntentInfo = true;
6577 }
6578 break;
6579 case "--esal": {
6580 String key = cmd.getNextArgRequired();
6581 String value = cmd.getNextArgRequired();
6582 // Split on commas unless they are preceeded by an escape.
6583 // The escape character must be escaped for the string and
6584 // again for the regex, thus four escape characters become one.
6585 String[] strings = value.split("(?<!\\\\),");
6586 ArrayList<String> list = new ArrayList<>(strings.length);
6587 for (int i = 0; i < strings.length; i++) {
6588 list.add(strings[i]);
6589 }
6590 intent.putExtra(key, list);
6591 hasIntentInfo = true;
6592 }
6593 break;
6594 case "--ez": {
6595 String key = cmd.getNextArgRequired();
6596 String value = cmd.getNextArgRequired().toLowerCase();
6597 // Boolean.valueOf() results in false for anything that is not "true", which is
6598 // error-prone in shell commands
6599 boolean arg;
6600 if ("true".equals(value) || "t".equals(value)) {
6601 arg = true;
6602 } else if ("false".equals(value) || "f".equals(value)) {
6603 arg = false;
6604 } else {
6605 try {
6606 arg = Integer.decode(value) != 0;
6607 } catch (NumberFormatException ex) {
6608 throw new IllegalArgumentException("Invalid boolean value: " + value);
6609 }
6610 }
6611
6612 intent.putExtra(key, arg);
6613 }
6614 break;
6615 case "-n": {
6616 String str = cmd.getNextArgRequired();
6617 ComponentName cn = ComponentName.unflattenFromString(str);
6618 if (cn == null)
6619 throw new IllegalArgumentException("Bad component name: " + str);
6620 intent.setComponent(cn);
6621 if (intent == baseIntent) {
6622 hasIntentInfo = true;
6623 }
6624 }
6625 break;
6626 case "-p": {
6627 String str = cmd.getNextArgRequired();
6628 intent.setPackage(str);
6629 if (intent == baseIntent) {
6630 hasIntentInfo = true;
6631 }
6632 }
6633 break;
6634 case "-f":
6635 String str = cmd.getNextArgRequired();
6636 intent.setFlags(Integer.decode(str).intValue());
6637 break;
6638 case "--grant-read-uri-permission":
6639 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6640 break;
6641 case "--grant-write-uri-permission":
6642 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6643 break;
6644 case "--grant-persistable-uri-permission":
6645 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6646 break;
6647 case "--grant-prefix-uri-permission":
6648 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6649 break;
6650 case "--exclude-stopped-packages":
6651 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6652 break;
6653 case "--include-stopped-packages":
6654 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6655 break;
6656 case "--debug-log-resolution":
6657 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6658 break;
6659 case "--activity-brought-to-front":
6660 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6661 break;
6662 case "--activity-clear-top":
6663 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6664 break;
6665 case "--activity-clear-when-task-reset":
6666 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6667 break;
6668 case "--activity-exclude-from-recents":
6669 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6670 break;
6671 case "--activity-launched-from-history":
6672 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6673 break;
6674 case "--activity-multiple-task":
6675 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6676 break;
6677 case "--activity-no-animation":
6678 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6679 break;
6680 case "--activity-no-history":
6681 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6682 break;
6683 case "--activity-no-user-action":
6684 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6685 break;
6686 case "--activity-previous-is-top":
6687 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6688 break;
6689 case "--activity-reorder-to-front":
6690 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6691 break;
6692 case "--activity-reset-task-if-needed":
6693 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6694 break;
6695 case "--activity-single-top":
6696 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6697 break;
6698 case "--activity-clear-task":
6699 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6700 break;
6701 case "--activity-task-on-home":
6702 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6703 break;
6704 case "--receiver-registered-only":
6705 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6706 break;
6707 case "--receiver-replace-pending":
6708 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6709 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006710 case "--receiver-foreground":
6711 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6712 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006713 case "--receiver-no-abort":
6714 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6715 break;
6716 case "--receiver-include-background":
6717 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6718 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006719 case "--selector":
6720 intent.setDataAndType(data, type);
6721 intent = new Intent();
6722 break;
6723 default:
6724 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6725 // Okay, caller handled this option.
6726 } else {
6727 throw new IllegalArgumentException("Unknown option: " + opt);
6728 }
6729 break;
6730 }
6731 }
6732 intent.setDataAndType(data, type);
6733
6734 final boolean hasSelector = intent != baseIntent;
6735 if (hasSelector) {
6736 // A selector was specified; fix up.
6737 baseIntent.setSelector(intent);
6738 intent = baseIntent;
6739 }
6740
6741 String arg = cmd.getNextArg();
6742 baseIntent = null;
6743 if (arg == null) {
6744 if (hasSelector) {
6745 // If a selector has been specified, and no arguments
6746 // have been supplied for the main Intent, then we can
6747 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6748 // need to have a component name specified yet, the
6749 // selector will take care of that.
6750 baseIntent = new Intent(Intent.ACTION_MAIN);
6751 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6752 }
6753 } else if (arg.indexOf(':') >= 0) {
6754 // The argument is a URI. Fully parse it, and use that result
6755 // to fill in any data not specified so far.
6756 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6757 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6758 } else if (arg.indexOf('/') >= 0) {
6759 // The argument is a component name. Build an Intent to launch
6760 // it.
6761 baseIntent = new Intent(Intent.ACTION_MAIN);
6762 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6763 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6764 } else {
6765 // Assume the argument is a package name.
6766 baseIntent = new Intent(Intent.ACTION_MAIN);
6767 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6768 baseIntent.setPackage(arg);
6769 }
6770 if (baseIntent != null) {
6771 Bundle extras = intent.getExtras();
6772 intent.replaceExtras((Bundle)null);
6773 Bundle uriExtras = baseIntent.getExtras();
6774 baseIntent.replaceExtras((Bundle)null);
6775 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6776 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6777 for (String c : cats) {
6778 baseIntent.removeCategory(c);
6779 }
6780 }
6781 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6782 if (extras == null) {
6783 extras = uriExtras;
6784 } else if (uriExtras != null) {
6785 uriExtras.putAll(extras);
6786 extras = uriExtras;
6787 }
6788 intent.replaceExtras(extras);
6789 hasIntentInfo = true;
6790 }
6791
6792 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6793 return intent;
6794 }
6795
6796 /** @hide */
6797 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6798 final String[] lines = new String[] {
6799 "<INTENT> specifications include these flags and arguments:",
6800 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6801 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6802 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6803 " [--esn <EXTRA_KEY> ...]",
6804 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6805 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6806 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6807 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6808 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6809 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6810 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6811 " (mutiple extras passed as Integer[])",
6812 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6813 " (mutiple extras passed as List<Integer>)",
6814 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6815 " (mutiple extras passed as Long[])",
6816 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6817 " (mutiple extras passed as List<Long>)",
6818 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6819 " (mutiple extras passed as Float[])",
6820 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6821 " (mutiple extras passed as List<Float>)",
6822 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6823 " (mutiple extras passed as String[]; to embed a comma into a string,",
6824 " escape it using \"\\,\")",
6825 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6826 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6827 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006828 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006829 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6830 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6831 " [--debug-log-resolution] [--exclude-stopped-packages]",
6832 " [--include-stopped-packages]",
6833 " [--activity-brought-to-front] [--activity-clear-top]",
6834 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6835 " [--activity-launched-from-history] [--activity-multiple-task]",
6836 " [--activity-no-animation] [--activity-no-history]",
6837 " [--activity-no-user-action] [--activity-previous-is-top]",
6838 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6839 " [--activity-single-top] [--activity-clear-task]",
6840 " [--activity-task-on-home]",
6841 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006842 " [--receiver-foreground] [--receiver-no-abort]",
6843 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006844 " [--selector]",
6845 " [<URI> | <PACKAGE> | <COMPONENT>]"
6846 };
6847 for (String line : lines) {
6848 pw.print(prefix);
6849 pw.println(line);
6850 }
6851 }
6852
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006853 /**
6854 * Retrieve the general action to be performed, such as
6855 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6856 * the information in the intent should be interpreted -- most importantly,
6857 * what to do with the data returned by {@link #getData}.
6858 *
6859 * @return The action of this intent or null if none is specified.
6860 *
6861 * @see #setAction
6862 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006863 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006864 return mAction;
6865 }
6866
6867 /**
6868 * Retrieve data this intent is operating on. This URI specifies the name
6869 * of the data; often it uses the content: scheme, specifying data in a
6870 * content provider. Other schemes may be handled by specific activities,
6871 * such as http: by the web browser.
6872 *
6873 * @return The URI of the data this intent is targeting or null.
6874 *
6875 * @see #getScheme
6876 * @see #setData
6877 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006878 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006879 return mData;
6880 }
6881
6882 /**
6883 * The same as {@link #getData()}, but returns the URI as an encoded
6884 * String.
6885 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006886 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006887 return mData != null ? mData.toString() : null;
6888 }
6889
6890 /**
6891 * Return the scheme portion of the intent's data. If the data is null or
6892 * does not include a scheme, null is returned. Otherwise, the scheme
6893 * prefix without the final ':' is returned, i.e. "http".
6894 *
6895 * <p>This is the same as calling getData().getScheme() (and checking for
6896 * null data).
6897 *
6898 * @return The scheme of this intent.
6899 *
6900 * @see #getData
6901 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006902 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006903 return mData != null ? mData.getScheme() : null;
6904 }
6905
6906 /**
6907 * Retrieve any explicit MIME type included in the intent. This is usually
6908 * null, as the type is determined by the intent data.
6909 *
6910 * @return If a type was manually set, it is returned; else null is
6911 * returned.
6912 *
6913 * @see #resolveType(ContentResolver)
6914 * @see #setType
6915 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006916 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006917 return mType;
6918 }
6919
6920 /**
6921 * Return the MIME data type of this intent. If the type field is
6922 * explicitly set, that is simply returned. Otherwise, if the data is set,
6923 * the type of that data is returned. If neither fields are set, a null is
6924 * returned.
6925 *
6926 * @return The MIME type of this intent.
6927 *
6928 * @see #getType
6929 * @see #resolveType(ContentResolver)
6930 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006931 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006932 return resolveType(context.getContentResolver());
6933 }
6934
6935 /**
6936 * Return the MIME data type of this intent. If the type field is
6937 * explicitly set, that is simply returned. Otherwise, if the data is set,
6938 * the type of that data is returned. If neither fields are set, a null is
6939 * returned.
6940 *
6941 * @param resolver A ContentResolver that can be used to determine the MIME
6942 * type of the intent's data.
6943 *
6944 * @return The MIME type of this intent.
6945 *
6946 * @see #getType
6947 * @see #resolveType(Context)
6948 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006949 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006950 if (mType != null) {
6951 return mType;
6952 }
6953 if (mData != null) {
6954 if ("content".equals(mData.getScheme())) {
6955 return resolver.getType(mData);
6956 }
6957 }
6958 return null;
6959 }
6960
6961 /**
6962 * Return the MIME data type of this intent, only if it will be needed for
6963 * intent resolution. This is not generally useful for application code;
6964 * it is used by the frameworks for communicating with back-end system
6965 * services.
6966 *
6967 * @param resolver A ContentResolver that can be used to determine the MIME
6968 * type of the intent's data.
6969 *
6970 * @return The MIME type of this intent, or null if it is unknown or not
6971 * needed.
6972 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006973 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006974 if (mComponent != null) {
6975 return mType;
6976 }
6977 return resolveType(resolver);
6978 }
6979
6980 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006981 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006982 *
6983 * @param category The category to check.
6984 *
6985 * @return boolean True if the intent contains the category, else false.
6986 *
6987 * @see #getCategories
6988 * @see #addCategory
6989 */
6990 public boolean hasCategory(String category) {
6991 return mCategories != null && mCategories.contains(category);
6992 }
6993
6994 /**
6995 * Return the set of all categories in the intent. If there are no categories,
6996 * returns NULL.
6997 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006998 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006999 *
7000 * @see #hasCategory
7001 * @see #addCategory
7002 */
7003 public Set<String> getCategories() {
7004 return mCategories;
7005 }
7006
7007 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007008 * Return the specific selector associated with this Intent. If there is
7009 * none, returns null. See {@link #setSelector} for more information.
7010 *
7011 * @see #setSelector
7012 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007013 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007014 return mSelector;
7015 }
7016
7017 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007018 * Return the {@link ClipData} associated with this Intent. If there is
7019 * none, returns null. See {@link #setClipData} for more information.
7020 *
John Spurlock125d1332013-11-25 11:58:37 -05007021 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007022 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007023 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007024 return mClipData;
7025 }
7026
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007027 /** @hide */
7028 public int getContentUserHint() {
7029 return mContentUserHint;
7030 }
7031
Todd Kennedyb3b431302017-03-20 16:05:48 -07007032 /** @hide */
7033 public String getLaunchToken() {
7034 return mLaunchToken;
7035 }
7036
7037 /** @hide */
7038 public void setLaunchToken(String launchToken) {
7039 mLaunchToken = launchToken;
7040 }
7041
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007043 * Sets the ClassLoader that will be used when unmarshalling
7044 * any Parcelable values from the extras of this Intent.
7045 *
7046 * @param loader a ClassLoader, or null to use the default loader
7047 * at the time of unmarshalling.
7048 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007049 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007050 if (mExtras != null) {
7051 mExtras.setClassLoader(loader);
7052 }
7053 }
7054
7055 /**
7056 * Returns true if an extra value is associated with the given name.
7057 * @param name the extra's name
7058 * @return true if the given extra is present.
7059 */
7060 public boolean hasExtra(String name) {
7061 return mExtras != null && mExtras.containsKey(name);
7062 }
7063
7064 /**
7065 * Returns true if the Intent's extras contain a parcelled file descriptor.
7066 * @return true if the Intent contains a parcelled file descriptor.
7067 */
7068 public boolean hasFileDescriptors() {
7069 return mExtras != null && mExtras.hasFileDescriptors();
7070 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007071
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007072 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007073 public void setAllowFds(boolean allowFds) {
7074 if (mExtras != null) {
7075 mExtras.setAllowFds(allowFds);
7076 }
7077 }
7078
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007079 /** {@hide} */
7080 public void setDefusable(boolean defusable) {
7081 if (mExtras != null) {
7082 mExtras.setDefusable(defusable);
7083 }
7084 }
7085
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007086 /**
7087 * Retrieve extended data from the intent.
7088 *
7089 * @param name The name of the desired item.
7090 *
7091 * @return the value of an item that previously added with putExtra()
7092 * or null if none was found.
7093 *
7094 * @deprecated
7095 * @hide
7096 */
7097 @Deprecated
7098 public Object getExtra(String name) {
7099 return getExtra(name, null);
7100 }
7101
7102 /**
7103 * Retrieve extended data from the intent.
7104 *
7105 * @param name The name of the desired item.
7106 * @param defaultValue the value to be returned if no value of the desired
7107 * type is stored with the given name.
7108 *
7109 * @return the value of an item that previously added with putExtra()
7110 * or the default value if none was found.
7111 *
7112 * @see #putExtra(String, boolean)
7113 */
7114 public boolean getBooleanExtra(String name, boolean defaultValue) {
7115 return mExtras == null ? defaultValue :
7116 mExtras.getBoolean(name, defaultValue);
7117 }
7118
7119 /**
7120 * Retrieve extended data from the intent.
7121 *
7122 * @param name The name of the desired item.
7123 * @param defaultValue the value to be returned if no value of the desired
7124 * type is stored with the given name.
7125 *
7126 * @return the value of an item that previously added with putExtra()
7127 * or the default value if none was found.
7128 *
7129 * @see #putExtra(String, byte)
7130 */
7131 public byte getByteExtra(String name, byte defaultValue) {
7132 return mExtras == null ? defaultValue :
7133 mExtras.getByte(name, defaultValue);
7134 }
7135
7136 /**
7137 * Retrieve extended data from the intent.
7138 *
7139 * @param name The name of the desired item.
7140 * @param defaultValue the value to be returned if no value of the desired
7141 * type is stored with the given name.
7142 *
7143 * @return the value of an item that previously added with putExtra()
7144 * or the default value if none was found.
7145 *
7146 * @see #putExtra(String, short)
7147 */
7148 public short getShortExtra(String name, short defaultValue) {
7149 return mExtras == null ? defaultValue :
7150 mExtras.getShort(name, defaultValue);
7151 }
7152
7153 /**
7154 * Retrieve extended data from the intent.
7155 *
7156 * @param name The name of the desired item.
7157 * @param defaultValue the value to be returned if no value of the desired
7158 * type is stored with the given name.
7159 *
7160 * @return the value of an item that previously added with putExtra()
7161 * or the default value if none was found.
7162 *
7163 * @see #putExtra(String, char)
7164 */
7165 public char getCharExtra(String name, char defaultValue) {
7166 return mExtras == null ? defaultValue :
7167 mExtras.getChar(name, defaultValue);
7168 }
7169
7170 /**
7171 * Retrieve extended data from the intent.
7172 *
7173 * @param name The name of the desired item.
7174 * @param defaultValue the value to be returned if no value of the desired
7175 * type is stored with the given name.
7176 *
7177 * @return the value of an item that previously added with putExtra()
7178 * or the default value if none was found.
7179 *
7180 * @see #putExtra(String, int)
7181 */
7182 public int getIntExtra(String name, int defaultValue) {
7183 return mExtras == null ? defaultValue :
7184 mExtras.getInt(name, defaultValue);
7185 }
7186
7187 /**
7188 * Retrieve extended data from the intent.
7189 *
7190 * @param name The name of the desired item.
7191 * @param defaultValue the value to be returned if no value of the desired
7192 * type is stored with the given name.
7193 *
7194 * @return the value of an item that previously added with putExtra()
7195 * or the default value if none was found.
7196 *
7197 * @see #putExtra(String, long)
7198 */
7199 public long getLongExtra(String name, long defaultValue) {
7200 return mExtras == null ? defaultValue :
7201 mExtras.getLong(name, defaultValue);
7202 }
7203
7204 /**
7205 * Retrieve extended data from the intent.
7206 *
7207 * @param name The name of the desired item.
7208 * @param defaultValue the value to be returned if no value of the desired
7209 * type is stored with the given name.
7210 *
7211 * @return the value of an item that previously added with putExtra(),
7212 * or the default value if no such item is present
7213 *
7214 * @see #putExtra(String, float)
7215 */
7216 public float getFloatExtra(String name, float defaultValue) {
7217 return mExtras == null ? defaultValue :
7218 mExtras.getFloat(name, defaultValue);
7219 }
7220
7221 /**
7222 * Retrieve extended data from the intent.
7223 *
7224 * @param name The name of the desired item.
7225 * @param defaultValue the value to be returned if no value of the desired
7226 * type is stored with the given name.
7227 *
7228 * @return the value of an item that previously added with putExtra()
7229 * or the default value if none was found.
7230 *
7231 * @see #putExtra(String, double)
7232 */
7233 public double getDoubleExtra(String name, double defaultValue) {
7234 return mExtras == null ? defaultValue :
7235 mExtras.getDouble(name, defaultValue);
7236 }
7237
7238 /**
7239 * Retrieve extended data from the intent.
7240 *
7241 * @param name The name of the desired item.
7242 *
7243 * @return the value of an item that previously added with putExtra()
7244 * or null if no String value was found.
7245 *
7246 * @see #putExtra(String, String)
7247 */
7248 public String getStringExtra(String name) {
7249 return mExtras == null ? null : mExtras.getString(name);
7250 }
7251
7252 /**
7253 * Retrieve extended data from the intent.
7254 *
7255 * @param name The name of the desired item.
7256 *
7257 * @return the value of an item that previously added with putExtra()
7258 * or null if no CharSequence value was found.
7259 *
7260 * @see #putExtra(String, CharSequence)
7261 */
7262 public CharSequence getCharSequenceExtra(String name) {
7263 return mExtras == null ? null : mExtras.getCharSequence(name);
7264 }
7265
7266 /**
7267 * Retrieve extended data from the intent.
7268 *
7269 * @param name The name of the desired item.
7270 *
7271 * @return the value of an item that previously added with putExtra()
7272 * or null if no Parcelable value was found.
7273 *
7274 * @see #putExtra(String, Parcelable)
7275 */
7276 public <T extends Parcelable> T getParcelableExtra(String name) {
7277 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7278 }
7279
7280 /**
7281 * Retrieve extended data from the intent.
7282 *
7283 * @param name The name of the desired item.
7284 *
7285 * @return the value of an item that previously added with putExtra()
7286 * or null if no Parcelable[] value was found.
7287 *
7288 * @see #putExtra(String, Parcelable[])
7289 */
7290 public Parcelable[] getParcelableArrayExtra(String name) {
7291 return mExtras == null ? null : mExtras.getParcelableArray(name);
7292 }
7293
7294 /**
7295 * Retrieve extended data from the intent.
7296 *
7297 * @param name The name of the desired item.
7298 *
7299 * @return the value of an item that previously added with putExtra()
7300 * or null if no ArrayList<Parcelable> value was found.
7301 *
7302 * @see #putParcelableArrayListExtra(String, ArrayList)
7303 */
7304 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7305 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7306 }
7307
7308 /**
7309 * Retrieve extended data from the intent.
7310 *
7311 * @param name The name of the desired item.
7312 *
7313 * @return the value of an item that previously added with putExtra()
7314 * or null if no Serializable value was found.
7315 *
7316 * @see #putExtra(String, Serializable)
7317 */
7318 public Serializable getSerializableExtra(String name) {
7319 return mExtras == null ? null : mExtras.getSerializable(name);
7320 }
7321
7322 /**
7323 * Retrieve extended data from the intent.
7324 *
7325 * @param name The name of the desired item.
7326 *
7327 * @return the value of an item that previously added with putExtra()
7328 * or null if no ArrayList<Integer> value was found.
7329 *
7330 * @see #putIntegerArrayListExtra(String, ArrayList)
7331 */
7332 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7333 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7334 }
7335
7336 /**
7337 * Retrieve extended data from the intent.
7338 *
7339 * @param name The name of the desired item.
7340 *
7341 * @return the value of an item that previously added with putExtra()
7342 * or null if no ArrayList<String> value was found.
7343 *
7344 * @see #putStringArrayListExtra(String, ArrayList)
7345 */
7346 public ArrayList<String> getStringArrayListExtra(String name) {
7347 return mExtras == null ? null : mExtras.getStringArrayList(name);
7348 }
7349
7350 /**
7351 * Retrieve extended data from the intent.
7352 *
7353 * @param name The name of the desired item.
7354 *
7355 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007356 * or null if no ArrayList<CharSequence> value was found.
7357 *
7358 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7359 */
7360 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7361 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7362 }
7363
7364 /**
7365 * Retrieve extended data from the intent.
7366 *
7367 * @param name The name of the desired item.
7368 *
7369 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007370 * or null if no boolean array value was found.
7371 *
7372 * @see #putExtra(String, boolean[])
7373 */
7374 public boolean[] getBooleanArrayExtra(String name) {
7375 return mExtras == null ? null : mExtras.getBooleanArray(name);
7376 }
7377
7378 /**
7379 * Retrieve extended data from the intent.
7380 *
7381 * @param name The name of the desired item.
7382 *
7383 * @return the value of an item that previously added with putExtra()
7384 * or null if no byte array value was found.
7385 *
7386 * @see #putExtra(String, byte[])
7387 */
7388 public byte[] getByteArrayExtra(String name) {
7389 return mExtras == null ? null : mExtras.getByteArray(name);
7390 }
7391
7392 /**
7393 * Retrieve extended data from the intent.
7394 *
7395 * @param name The name of the desired item.
7396 *
7397 * @return the value of an item that previously added with putExtra()
7398 * or null if no short array value was found.
7399 *
7400 * @see #putExtra(String, short[])
7401 */
7402 public short[] getShortArrayExtra(String name) {
7403 return mExtras == null ? null : mExtras.getShortArray(name);
7404 }
7405
7406 /**
7407 * Retrieve extended data from the intent.
7408 *
7409 * @param name The name of the desired item.
7410 *
7411 * @return the value of an item that previously added with putExtra()
7412 * or null if no char array value was found.
7413 *
7414 * @see #putExtra(String, char[])
7415 */
7416 public char[] getCharArrayExtra(String name) {
7417 return mExtras == null ? null : mExtras.getCharArray(name);
7418 }
7419
7420 /**
7421 * Retrieve extended data from the intent.
7422 *
7423 * @param name The name of the desired item.
7424 *
7425 * @return the value of an item that previously added with putExtra()
7426 * or null if no int array value was found.
7427 *
7428 * @see #putExtra(String, int[])
7429 */
7430 public int[] getIntArrayExtra(String name) {
7431 return mExtras == null ? null : mExtras.getIntArray(name);
7432 }
7433
7434 /**
7435 * Retrieve extended data from the intent.
7436 *
7437 * @param name The name of the desired item.
7438 *
7439 * @return the value of an item that previously added with putExtra()
7440 * or null if no long array value was found.
7441 *
7442 * @see #putExtra(String, long[])
7443 */
7444 public long[] getLongArrayExtra(String name) {
7445 return mExtras == null ? null : mExtras.getLongArray(name);
7446 }
7447
7448 /**
7449 * Retrieve extended data from the intent.
7450 *
7451 * @param name The name of the desired item.
7452 *
7453 * @return the value of an item that previously added with putExtra()
7454 * or null if no float array value was found.
7455 *
7456 * @see #putExtra(String, float[])
7457 */
7458 public float[] getFloatArrayExtra(String name) {
7459 return mExtras == null ? null : mExtras.getFloatArray(name);
7460 }
7461
7462 /**
7463 * Retrieve extended data from the intent.
7464 *
7465 * @param name The name of the desired item.
7466 *
7467 * @return the value of an item that previously added with putExtra()
7468 * or null if no double array value was found.
7469 *
7470 * @see #putExtra(String, double[])
7471 */
7472 public double[] getDoubleArrayExtra(String name) {
7473 return mExtras == null ? null : mExtras.getDoubleArray(name);
7474 }
7475
7476 /**
7477 * Retrieve extended data from the intent.
7478 *
7479 * @param name The name of the desired item.
7480 *
7481 * @return the value of an item that previously added with putExtra()
7482 * or null if no String array value was found.
7483 *
7484 * @see #putExtra(String, String[])
7485 */
7486 public String[] getStringArrayExtra(String name) {
7487 return mExtras == null ? null : mExtras.getStringArray(name);
7488 }
7489
7490 /**
7491 * Retrieve extended data from the intent.
7492 *
7493 * @param name The name of the desired item.
7494 *
7495 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007496 * or null if no CharSequence array value was found.
7497 *
7498 * @see #putExtra(String, CharSequence[])
7499 */
7500 public CharSequence[] getCharSequenceArrayExtra(String name) {
7501 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7502 }
7503
7504 /**
7505 * Retrieve extended data from the intent.
7506 *
7507 * @param name The name of the desired item.
7508 *
7509 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007510 * or null if no Bundle value was found.
7511 *
7512 * @see #putExtra(String, Bundle)
7513 */
7514 public Bundle getBundleExtra(String name) {
7515 return mExtras == null ? null : mExtras.getBundle(name);
7516 }
7517
7518 /**
7519 * Retrieve extended data from the intent.
7520 *
7521 * @param name The name of the desired item.
7522 *
7523 * @return the value of an item that previously added with putExtra()
7524 * or null if no IBinder value was found.
7525 *
7526 * @see #putExtra(String, IBinder)
7527 *
7528 * @deprecated
7529 * @hide
7530 */
7531 @Deprecated
7532 public IBinder getIBinderExtra(String name) {
7533 return mExtras == null ? null : mExtras.getIBinder(name);
7534 }
7535
7536 /**
7537 * Retrieve extended data from the intent.
7538 *
7539 * @param name The name of the desired item.
7540 * @param defaultValue The default value to return in case no item is
7541 * associated with the key 'name'
7542 *
7543 * @return the value of an item that previously added with putExtra()
7544 * or defaultValue if none was found.
7545 *
7546 * @see #putExtra
7547 *
7548 * @deprecated
7549 * @hide
7550 */
7551 @Deprecated
7552 public Object getExtra(String name, Object defaultValue) {
7553 Object result = defaultValue;
7554 if (mExtras != null) {
7555 Object result2 = mExtras.get(name);
7556 if (result2 != null) {
7557 result = result2;
7558 }
7559 }
7560
7561 return result;
7562 }
7563
7564 /**
7565 * Retrieves a map of extended data from the intent.
7566 *
7567 * @return the map of all extras previously added with putExtra(),
7568 * or null if none have been added.
7569 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007570 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007571 return (mExtras != null)
7572 ? new Bundle(mExtras)
7573 : null;
7574 }
7575
7576 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007577 * Filter extras to only basic types.
7578 * @hide
7579 */
7580 public void removeUnsafeExtras() {
7581 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007582 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007583 }
7584 }
7585
7586 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007587 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7588 * return itself as-is.
7589 * @hide
7590 */
7591 public boolean canStripForHistory() {
7592 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7593 }
7594
7595 /**
7596 * Call it when the system needs to keep an intent for logging purposes to remove fields
7597 * that are not needed for logging.
7598 * @hide
7599 */
7600 public Intent maybeStripForHistory() {
7601 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7602
7603 if (!canStripForHistory()) {
7604 return this;
7605 }
7606 return new Intent(this, COPY_MODE_HISTORY);
7607 }
7608
7609 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007610 * Retrieve any special flags associated with this intent. You will
7611 * normally just set them with {@link #setFlags} and let the system
7612 * take the appropriate action with them.
7613 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007614 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007615 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007616 * @see #addFlags
7617 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007618 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007619 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007620 return mFlags;
7621 }
7622
Dianne Hackborne7f97212011-02-24 14:40:20 -08007623 /** @hide */
7624 public boolean isExcludingStopped() {
7625 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7626 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7627 }
7628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007629 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007630 * Retrieve the application package name this Intent is limited to. When
7631 * resolving an Intent, if non-null this limits the resolution to only
7632 * components in the given application package.
7633 *
7634 * @return The name of the application package for the Intent.
7635 *
7636 * @see #resolveActivity
7637 * @see #setPackage
7638 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007639 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007640 return mPackage;
7641 }
7642
7643 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007644 * Retrieve the concrete component associated with the intent. When receiving
7645 * an intent, this is the component that was found to best handle it (that is,
7646 * yourself) and will always be non-null; in all other cases it will be
7647 * null unless explicitly set.
7648 *
7649 * @return The name of the application component to handle the intent.
7650 *
7651 * @see #resolveActivity
7652 * @see #setComponent
7653 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007654 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007655 return mComponent;
7656 }
7657
7658 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007659 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7660 * used as a hint to the receiver for animations and the like. Null means that there
7661 * is no source bounds.
7662 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007663 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007664 return mSourceBounds;
7665 }
7666
7667 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007668 * Return the Activity component that should be used to handle this intent.
7669 * The appropriate component is determined based on the information in the
7670 * intent, evaluated as follows:
7671 *
7672 * <p>If {@link #getComponent} returns an explicit class, that is returned
7673 * without any further consideration.
7674 *
7675 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7676 * category to be considered.
7677 *
7678 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7679 * action.
7680 *
7681 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7682 * this type.
7683 *
7684 * <p>If {@link #addCategory} has added any categories, the activity must
7685 * handle ALL of the categories specified.
7686 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007687 * <p>If {@link #getPackage} is non-NULL, only activity components in
7688 * that application package will be considered.
7689 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007690 * <p>If there are no activities that satisfy all of these conditions, a
7691 * null string is returned.
7692 *
7693 * <p>If multiple activities are found to satisfy the intent, the one with
7694 * the highest priority will be used. If there are multiple activities
7695 * with the same priority, the system will either pick the best activity
7696 * based on user preference, or resolve to a system class that will allow
7697 * the user to pick an activity and forward from there.
7698 *
7699 * <p>This method is implemented simply by calling
7700 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7701 * true.</p>
7702 * <p> This API is called for you as part of starting an activity from an
7703 * intent. You do not normally need to call it yourself.</p>
7704 *
7705 * @param pm The package manager with which to resolve the Intent.
7706 *
7707 * @return Name of the component implementing an activity that can
7708 * display the intent.
7709 *
7710 * @see #setComponent
7711 * @see #getComponent
7712 * @see #resolveActivityInfo
7713 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007714 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007715 if (mComponent != null) {
7716 return mComponent;
7717 }
7718
7719 ResolveInfo info = pm.resolveActivity(
7720 this, PackageManager.MATCH_DEFAULT_ONLY);
7721 if (info != null) {
7722 return new ComponentName(
7723 info.activityInfo.applicationInfo.packageName,
7724 info.activityInfo.name);
7725 }
7726
7727 return null;
7728 }
7729
7730 /**
7731 * Resolve the Intent into an {@link ActivityInfo}
7732 * describing the activity that should execute the intent. Resolution
7733 * follows the same rules as described for {@link #resolveActivity}, but
7734 * you get back the completely information about the resolved activity
7735 * instead of just its class name.
7736 *
7737 * @param pm The package manager with which to resolve the Intent.
7738 * @param flags Addition information to retrieve as per
7739 * {@link PackageManager#getActivityInfo(ComponentName, int)
7740 * PackageManager.getActivityInfo()}.
7741 *
7742 * @return PackageManager.ActivityInfo
7743 *
7744 * @see #resolveActivity
7745 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007746 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7747 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007748 ActivityInfo ai = null;
7749 if (mComponent != null) {
7750 try {
7751 ai = pm.getActivityInfo(mComponent, flags);
7752 } catch (PackageManager.NameNotFoundException e) {
7753 // ignore
7754 }
7755 } else {
7756 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007757 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007758 if (info != null) {
7759 ai = info.activityInfo;
7760 }
7761 }
7762
7763 return ai;
7764 }
7765
7766 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007767 * Special function for use by the system to resolve service
7768 * intents to system apps. Throws an exception if there are
7769 * multiple potential matches to the Intent. Returns null if
7770 * there are no matches.
7771 * @hide
7772 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007773 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7774 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007775 if (mComponent != null) {
7776 return mComponent;
7777 }
7778
7779 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7780 if (results == null) {
7781 return null;
7782 }
7783 ComponentName comp = null;
7784 for (int i=0; i<results.size(); i++) {
7785 ResolveInfo ri = results.get(i);
7786 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7787 continue;
7788 }
7789 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7790 ri.serviceInfo.name);
7791 if (comp != null) {
7792 throw new IllegalStateException("Multiple system services handle " + this
7793 + ": " + comp + ", " + foundComp);
7794 }
7795 comp = foundComp;
7796 }
7797 return comp;
7798 }
7799
7800 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007801 * Set the general action to be performed.
7802 *
7803 * @param action An action name, such as ACTION_VIEW. Application-specific
7804 * actions should be prefixed with the vendor's package name.
7805 *
7806 * @return Returns the same Intent object, for chaining multiple calls
7807 * into a single statement.
7808 *
7809 * @see #getAction
7810 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007811 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007812 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007813 return this;
7814 }
7815
7816 /**
7817 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007818 * clears any type that was previously set by {@link #setType} or
7819 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007820 *
Nick Pellyccae4122012-01-09 14:12:58 -08007821 * <p><em>Note: scheme matching in the Android framework is
7822 * case-sensitive, unlike the formal RFC. As a result,
7823 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007824 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007825 * {@link #setDataAndNormalize}
7826 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007827 *
Nick Pellyccae4122012-01-09 14:12:58 -08007828 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007829 *
7830 * @return Returns the same Intent object, for chaining multiple calls
7831 * into a single statement.
7832 *
7833 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007834 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007835 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007836 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007837 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 mData = data;
7839 mType = null;
7840 return this;
7841 }
7842
7843 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007844 * Normalize and set the data this intent is operating on.
7845 *
7846 * <p>This method automatically clears any type that was
7847 * previously set (for example, by {@link #setType}).
7848 *
7849 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007850 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007851 * so really this is just a convenience method for
7852 * <pre>
7853 * setData(data.normalize())
7854 * </pre>
7855 *
7856 * @param data The Uri of the data this intent is now targeting.
7857 *
7858 * @return Returns the same Intent object, for chaining multiple calls
7859 * into a single statement.
7860 *
7861 * @see #getData
7862 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007863 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007865 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007866 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007867 }
7868
7869 /**
7870 * Set an explicit MIME data type.
7871 *
7872 * <p>This is used to create intents that only specify a type and not data,
7873 * for example to indicate the type of data to return.
7874 *
7875 * <p>This method automatically clears any data that was
7876 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007877 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007878 * <p><em>Note: MIME type matching in the Android framework is
7879 * case-sensitive, unlike formal RFC MIME types. As a result,
7880 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007881 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7882 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007883 *
7884 * @param type The MIME type of the data being handled by this intent.
7885 *
7886 * @return Returns the same Intent object, for chaining multiple calls
7887 * into a single statement.
7888 *
7889 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007890 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007891 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007892 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007893 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007894 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007895 mData = null;
7896 mType = type;
7897 return this;
7898 }
7899
7900 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007901 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007902 *
Nick Pellyccae4122012-01-09 14:12:58 -08007903 * <p>This is used to create intents that only specify a type and not data,
7904 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007905 *
Nick Pellyccae4122012-01-09 14:12:58 -08007906 * <p>This method automatically clears any data that was
7907 * previously set (for example by {@link #setData}).
7908 *
7909 * <p>The MIME type is normalized using
7910 * {@link #normalizeMimeType} before it is set,
7911 * so really this is just a convenience method for
7912 * <pre>
7913 * setType(Intent.normalizeMimeType(type))
7914 * </pre>
7915 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007916 * @param type The MIME type of the data being handled by this intent.
7917 *
7918 * @return Returns the same Intent object, for chaining multiple calls
7919 * into a single statement.
7920 *
Nick Pellyccae4122012-01-09 14:12:58 -08007921 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007922 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007923 * @see #normalizeMimeType
7924 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007925 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007926 return setType(normalizeMimeType(type));
7927 }
7928
7929 /**
7930 * (Usually optional) Set the data for the intent along with an explicit
7931 * MIME data type. This method should very rarely be used -- it allows you
7932 * to override the MIME type that would ordinarily be inferred from the
7933 * data with your own type given here.
7934 *
7935 * <p><em>Note: MIME type and Uri scheme matching in the
7936 * Android framework is case-sensitive, unlike the formal RFC definitions.
7937 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007938 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007939 * {@link #setDataAndTypeAndNormalize}
7940 * to ensure that they are converted to lower case.</em>
7941 *
7942 * @param data The Uri of the data this intent is now targeting.
7943 * @param type The MIME type of the data being handled by this intent.
7944 *
7945 * @return Returns the same Intent object, for chaining multiple calls
7946 * into a single statement.
7947 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007948 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007949 * @see #setData
7950 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007951 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007952 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007953 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007954 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007955 mData = data;
7956 mType = type;
7957 return this;
7958 }
7959
7960 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007961 * (Usually optional) Normalize and set both the data Uri and an explicit
7962 * MIME data type. This method should very rarely be used -- it allows you
7963 * to override the MIME type that would ordinarily be inferred from the
7964 * data with your own type given here.
7965 *
7966 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007967 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007968 * before they are set, so really this is just a convenience method for
7969 * <pre>
7970 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7971 * </pre>
7972 *
7973 * @param data The Uri of the data this intent is now targeting.
7974 * @param type The MIME type of the data being handled by this intent.
7975 *
7976 * @return Returns the same Intent object, for chaining multiple calls
7977 * into a single statement.
7978 *
7979 * @see #setType
7980 * @see #setData
7981 * @see #setDataAndType
7982 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007983 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007984 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007985 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007986 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007987 }
7988
7989 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007990 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007991 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007992 * activities that provide <em>all</em> of the requested categories will be
7993 * used.
7994 *
7995 * @param category The desired category. This can be either one of the
7996 * predefined Intent categories, or a custom category in your own
7997 * namespace.
7998 *
7999 * @return Returns the same Intent object, for chaining multiple calls
8000 * into a single statement.
8001 *
8002 * @see #hasCategory
8003 * @see #removeCategory
8004 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008005 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008006 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008007 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008008 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008009 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008010 return this;
8011 }
8012
8013 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008014 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008015 *
8016 * @param category The category to remove.
8017 *
8018 * @see #addCategory
8019 */
8020 public void removeCategory(String category) {
8021 if (mCategories != null) {
8022 mCategories.remove(category);
8023 if (mCategories.size() == 0) {
8024 mCategories = null;
8025 }
8026 }
8027 }
8028
8029 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008030 * Set a selector for this Intent. This is a modification to the kinds of
8031 * things the Intent will match. If the selector is set, it will be used
8032 * when trying to find entities that can handle the Intent, instead of the
8033 * main contents of the Intent. This allows you build an Intent containing
8034 * a generic protocol while targeting it more specifically.
8035 *
8036 * <p>An example of where this may be used is with things like
8037 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8038 * Intent that will launch the Browser application. However, the correct
8039 * main entry point of an application is actually {@link #ACTION_MAIN}
8040 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8041 * used to specify the actual Activity to launch. If you launch the browser
8042 * with something different, undesired behavior may happen if the user has
8043 * previously or later launches it the normal way, since they do not match.
8044 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8045 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8046 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8047 *
8048 * <p>Setting a selector does not impact the behavior of
8049 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8050 * desired behavior of a selector -- it does not impact the base meaning
8051 * of the Intent, just what kinds of things will be matched against it
8052 * when determining who can handle it.</p>
8053 *
8054 * <p>You can not use both a selector and {@link #setPackage(String)} on
8055 * the same base Intent.</p>
8056 *
8057 * @param selector The desired selector Intent; set to null to not use
8058 * a special selector.
8059 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008060 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008061 if (selector == this) {
8062 throw new IllegalArgumentException(
8063 "Intent being set as a selector of itself");
8064 }
8065 if (selector != null && mPackage != null) {
8066 throw new IllegalArgumentException(
8067 "Can't set selector when package name is already set");
8068 }
8069 mSelector = selector;
8070 }
8071
8072 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008073 * Set a {@link ClipData} associated with this Intent. This replaces any
8074 * previously set ClipData.
8075 *
8076 * <p>The ClipData in an intent is not used for Intent matching or other
8077 * such operations. Semantically it is like extras, used to transmit
8078 * additional data with the Intent. The main feature of using this over
8079 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8080 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8081 * items included in the clip data. This is useful, in particular, if
8082 * you want to transmit an Intent containing multiple <code>content:</code>
8083 * URIs for which the recipient may not have global permission to access the
8084 * content provider.
8085 *
8086 * <p>If the ClipData contains items that are themselves Intents, any
8087 * grant flags in those Intents will be ignored. Only the top-level flags
8088 * of the main Intent are respected, and will be applied to all Uri or
8089 * Intent items in the clip (or sub-items of the clip).
8090 *
8091 * <p>The MIME type, label, and icon in the ClipData object are not
8092 * directly used by Intent. Applications should generally rely on the
8093 * MIME type of the Intent itself, not what it may find in the ClipData.
8094 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008095 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008096 *
8097 * @param clip The new clip to set. May be null to clear the current clip.
8098 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008099 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008100 mClipData = clip;
8101 }
8102
8103 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008104 * This is NOT a secure mechanism to identify the user who sent the intent.
8105 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8106 * who sent the intent.
8107 * @hide
8108 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008109 public void prepareToLeaveUser(int userId) {
8110 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8111 // We want mContentUserHint to refer to the original user, so don't do anything.
8112 if (mContentUserHint == UserHandle.USER_CURRENT) {
8113 mContentUserHint = userId;
8114 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008115 }
8116
8117 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008118 * Add extended data to the intent. The name must include a package
8119 * prefix, for example the app com.android.contacts would use names
8120 * like "com.android.contacts.ShowAll".
8121 *
8122 * @param name The name of the extra data, with package prefix.
8123 * @param value The boolean data value.
8124 *
8125 * @return Returns the same Intent object, for chaining multiple calls
8126 * into a single statement.
8127 *
8128 * @see #putExtras
8129 * @see #removeExtra
8130 * @see #getBooleanExtra(String, boolean)
8131 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008132 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008133 if (mExtras == null) {
8134 mExtras = new Bundle();
8135 }
8136 mExtras.putBoolean(name, value);
8137 return this;
8138 }
8139
8140 /**
8141 * Add extended data to the intent. The name must include a package
8142 * prefix, for example the app com.android.contacts would use names
8143 * like "com.android.contacts.ShowAll".
8144 *
8145 * @param name The name of the extra data, with package prefix.
8146 * @param value The byte data value.
8147 *
8148 * @return Returns the same Intent object, for chaining multiple calls
8149 * into a single statement.
8150 *
8151 * @see #putExtras
8152 * @see #removeExtra
8153 * @see #getByteExtra(String, byte)
8154 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008155 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008156 if (mExtras == null) {
8157 mExtras = new Bundle();
8158 }
8159 mExtras.putByte(name, value);
8160 return this;
8161 }
8162
8163 /**
8164 * Add extended data to the intent. The name must include a package
8165 * prefix, for example the app com.android.contacts would use names
8166 * like "com.android.contacts.ShowAll".
8167 *
8168 * @param name The name of the extra data, with package prefix.
8169 * @param value The char data value.
8170 *
8171 * @return Returns the same Intent object, for chaining multiple calls
8172 * into a single statement.
8173 *
8174 * @see #putExtras
8175 * @see #removeExtra
8176 * @see #getCharExtra(String, char)
8177 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008178 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008179 if (mExtras == null) {
8180 mExtras = new Bundle();
8181 }
8182 mExtras.putChar(name, value);
8183 return this;
8184 }
8185
8186 /**
8187 * Add extended data to the intent. The name must include a package
8188 * prefix, for example the app com.android.contacts would use names
8189 * like "com.android.contacts.ShowAll".
8190 *
8191 * @param name The name of the extra data, with package prefix.
8192 * @param value The short data value.
8193 *
8194 * @return Returns the same Intent object, for chaining multiple calls
8195 * into a single statement.
8196 *
8197 * @see #putExtras
8198 * @see #removeExtra
8199 * @see #getShortExtra(String, short)
8200 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008201 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008202 if (mExtras == null) {
8203 mExtras = new Bundle();
8204 }
8205 mExtras.putShort(name, value);
8206 return this;
8207 }
8208
8209 /**
8210 * Add extended data to the intent. The name must include a package
8211 * prefix, for example the app com.android.contacts would use names
8212 * like "com.android.contacts.ShowAll".
8213 *
8214 * @param name The name of the extra data, with package prefix.
8215 * @param value The integer data value.
8216 *
8217 * @return Returns the same Intent object, for chaining multiple calls
8218 * into a single statement.
8219 *
8220 * @see #putExtras
8221 * @see #removeExtra
8222 * @see #getIntExtra(String, int)
8223 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008224 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008225 if (mExtras == null) {
8226 mExtras = new Bundle();
8227 }
8228 mExtras.putInt(name, value);
8229 return this;
8230 }
8231
8232 /**
8233 * Add extended data to the intent. The name must include a package
8234 * prefix, for example the app com.android.contacts would use names
8235 * like "com.android.contacts.ShowAll".
8236 *
8237 * @param name The name of the extra data, with package prefix.
8238 * @param value The long data value.
8239 *
8240 * @return Returns the same Intent object, for chaining multiple calls
8241 * into a single statement.
8242 *
8243 * @see #putExtras
8244 * @see #removeExtra
8245 * @see #getLongExtra(String, long)
8246 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008247 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008248 if (mExtras == null) {
8249 mExtras = new Bundle();
8250 }
8251 mExtras.putLong(name, value);
8252 return this;
8253 }
8254
8255 /**
8256 * Add extended data to the intent. The name must include a package
8257 * prefix, for example the app com.android.contacts would use names
8258 * like "com.android.contacts.ShowAll".
8259 *
8260 * @param name The name of the extra data, with package prefix.
8261 * @param value The float data value.
8262 *
8263 * @return Returns the same Intent object, for chaining multiple calls
8264 * into a single statement.
8265 *
8266 * @see #putExtras
8267 * @see #removeExtra
8268 * @see #getFloatExtra(String, float)
8269 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008270 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008271 if (mExtras == null) {
8272 mExtras = new Bundle();
8273 }
8274 mExtras.putFloat(name, value);
8275 return this;
8276 }
8277
8278 /**
8279 * Add extended data to the intent. The name must include a package
8280 * prefix, for example the app com.android.contacts would use names
8281 * like "com.android.contacts.ShowAll".
8282 *
8283 * @param name The name of the extra data, with package prefix.
8284 * @param value The double data value.
8285 *
8286 * @return Returns the same Intent object, for chaining multiple calls
8287 * into a single statement.
8288 *
8289 * @see #putExtras
8290 * @see #removeExtra
8291 * @see #getDoubleExtra(String, double)
8292 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008293 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008294 if (mExtras == null) {
8295 mExtras = new Bundle();
8296 }
8297 mExtras.putDouble(name, value);
8298 return this;
8299 }
8300
8301 /**
8302 * Add extended data to the intent. The name must include a package
8303 * prefix, for example the app com.android.contacts would use names
8304 * like "com.android.contacts.ShowAll".
8305 *
8306 * @param name The name of the extra data, with package prefix.
8307 * @param value The String data value.
8308 *
8309 * @return Returns the same Intent object, for chaining multiple calls
8310 * into a single statement.
8311 *
8312 * @see #putExtras
8313 * @see #removeExtra
8314 * @see #getStringExtra(String)
8315 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008316 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008317 if (mExtras == null) {
8318 mExtras = new Bundle();
8319 }
8320 mExtras.putString(name, value);
8321 return this;
8322 }
8323
8324 /**
8325 * Add extended data to the intent. The name must include a package
8326 * prefix, for example the app com.android.contacts would use names
8327 * like "com.android.contacts.ShowAll".
8328 *
8329 * @param name The name of the extra data, with package prefix.
8330 * @param value The CharSequence data value.
8331 *
8332 * @return Returns the same Intent object, for chaining multiple calls
8333 * into a single statement.
8334 *
8335 * @see #putExtras
8336 * @see #removeExtra
8337 * @see #getCharSequenceExtra(String)
8338 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008339 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008340 if (mExtras == null) {
8341 mExtras = new Bundle();
8342 }
8343 mExtras.putCharSequence(name, value);
8344 return this;
8345 }
8346
8347 /**
8348 * Add extended data to the intent. The name must include a package
8349 * prefix, for example the app com.android.contacts would use names
8350 * like "com.android.contacts.ShowAll".
8351 *
8352 * @param name The name of the extra data, with package prefix.
8353 * @param value The Parcelable data value.
8354 *
8355 * @return Returns the same Intent object, for chaining multiple calls
8356 * into a single statement.
8357 *
8358 * @see #putExtras
8359 * @see #removeExtra
8360 * @see #getParcelableExtra(String)
8361 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008362 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008363 if (mExtras == null) {
8364 mExtras = new Bundle();
8365 }
8366 mExtras.putParcelable(name, value);
8367 return this;
8368 }
8369
8370 /**
8371 * Add extended data to the intent. The name must include a package
8372 * prefix, for example the app com.android.contacts would use names
8373 * like "com.android.contacts.ShowAll".
8374 *
8375 * @param name The name of the extra data, with package prefix.
8376 * @param value The Parcelable[] data value.
8377 *
8378 * @return Returns the same Intent object, for chaining multiple calls
8379 * into a single statement.
8380 *
8381 * @see #putExtras
8382 * @see #removeExtra
8383 * @see #getParcelableArrayExtra(String)
8384 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008385 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008386 if (mExtras == null) {
8387 mExtras = new Bundle();
8388 }
8389 mExtras.putParcelableArray(name, value);
8390 return this;
8391 }
8392
8393 /**
8394 * Add extended data to the intent. The name must include a package
8395 * prefix, for example the app com.android.contacts would use names
8396 * like "com.android.contacts.ShowAll".
8397 *
8398 * @param name The name of the extra data, with package prefix.
8399 * @param value The ArrayList<Parcelable> data value.
8400 *
8401 * @return Returns the same Intent object, for chaining multiple calls
8402 * into a single statement.
8403 *
8404 * @see #putExtras
8405 * @see #removeExtra
8406 * @see #getParcelableArrayListExtra(String)
8407 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008408 public @NonNull Intent putParcelableArrayListExtra(String name,
8409 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008410 if (mExtras == null) {
8411 mExtras = new Bundle();
8412 }
8413 mExtras.putParcelableArrayList(name, value);
8414 return this;
8415 }
8416
8417 /**
8418 * Add extended data to the intent. The name must include a package
8419 * prefix, for example the app com.android.contacts would use names
8420 * like "com.android.contacts.ShowAll".
8421 *
8422 * @param name The name of the extra data, with package prefix.
8423 * @param value The ArrayList<Integer> data value.
8424 *
8425 * @return Returns the same Intent object, for chaining multiple calls
8426 * into a single statement.
8427 *
8428 * @see #putExtras
8429 * @see #removeExtra
8430 * @see #getIntegerArrayListExtra(String)
8431 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008432 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008433 if (mExtras == null) {
8434 mExtras = new Bundle();
8435 }
8436 mExtras.putIntegerArrayList(name, value);
8437 return this;
8438 }
8439
8440 /**
8441 * Add extended data to the intent. The name must include a package
8442 * prefix, for example the app com.android.contacts would use names
8443 * like "com.android.contacts.ShowAll".
8444 *
8445 * @param name The name of the extra data, with package prefix.
8446 * @param value The ArrayList<String> data value.
8447 *
8448 * @return Returns the same Intent object, for chaining multiple calls
8449 * into a single statement.
8450 *
8451 * @see #putExtras
8452 * @see #removeExtra
8453 * @see #getStringArrayListExtra(String)
8454 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008455 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008456 if (mExtras == null) {
8457 mExtras = new Bundle();
8458 }
8459 mExtras.putStringArrayList(name, value);
8460 return this;
8461 }
8462
8463 /**
8464 * Add extended data to the intent. The name must include a package
8465 * prefix, for example the app com.android.contacts would use names
8466 * like "com.android.contacts.ShowAll".
8467 *
8468 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008469 * @param value The ArrayList<CharSequence> data value.
8470 *
8471 * @return Returns the same Intent object, for chaining multiple calls
8472 * into a single statement.
8473 *
8474 * @see #putExtras
8475 * @see #removeExtra
8476 * @see #getCharSequenceArrayListExtra(String)
8477 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008478 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8479 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008480 if (mExtras == null) {
8481 mExtras = new Bundle();
8482 }
8483 mExtras.putCharSequenceArrayList(name, value);
8484 return this;
8485 }
8486
8487 /**
8488 * Add extended data to the intent. The name must include a package
8489 * prefix, for example the app com.android.contacts would use names
8490 * like "com.android.contacts.ShowAll".
8491 *
8492 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008493 * @param value The Serializable data value.
8494 *
8495 * @return Returns the same Intent object, for chaining multiple calls
8496 * into a single statement.
8497 *
8498 * @see #putExtras
8499 * @see #removeExtra
8500 * @see #getSerializableExtra(String)
8501 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008502 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008503 if (mExtras == null) {
8504 mExtras = new Bundle();
8505 }
8506 mExtras.putSerializable(name, value);
8507 return this;
8508 }
8509
8510 /**
8511 * Add extended data to the intent. The name must include a package
8512 * prefix, for example the app com.android.contacts would use names
8513 * like "com.android.contacts.ShowAll".
8514 *
8515 * @param name The name of the extra data, with package prefix.
8516 * @param value The boolean array data value.
8517 *
8518 * @return Returns the same Intent object, for chaining multiple calls
8519 * into a single statement.
8520 *
8521 * @see #putExtras
8522 * @see #removeExtra
8523 * @see #getBooleanArrayExtra(String)
8524 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008525 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008526 if (mExtras == null) {
8527 mExtras = new Bundle();
8528 }
8529 mExtras.putBooleanArray(name, value);
8530 return this;
8531 }
8532
8533 /**
8534 * Add extended data to the intent. The name must include a package
8535 * prefix, for example the app com.android.contacts would use names
8536 * like "com.android.contacts.ShowAll".
8537 *
8538 * @param name The name of the extra data, with package prefix.
8539 * @param value The byte array data value.
8540 *
8541 * @return Returns the same Intent object, for chaining multiple calls
8542 * into a single statement.
8543 *
8544 * @see #putExtras
8545 * @see #removeExtra
8546 * @see #getByteArrayExtra(String)
8547 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008548 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008549 if (mExtras == null) {
8550 mExtras = new Bundle();
8551 }
8552 mExtras.putByteArray(name, value);
8553 return this;
8554 }
8555
8556 /**
8557 * Add extended data to the intent. The name must include a package
8558 * prefix, for example the app com.android.contacts would use names
8559 * like "com.android.contacts.ShowAll".
8560 *
8561 * @param name The name of the extra data, with package prefix.
8562 * @param value The short array data value.
8563 *
8564 * @return Returns the same Intent object, for chaining multiple calls
8565 * into a single statement.
8566 *
8567 * @see #putExtras
8568 * @see #removeExtra
8569 * @see #getShortArrayExtra(String)
8570 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008571 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008572 if (mExtras == null) {
8573 mExtras = new Bundle();
8574 }
8575 mExtras.putShortArray(name, value);
8576 return this;
8577 }
8578
8579 /**
8580 * Add extended data to the intent. The name must include a package
8581 * prefix, for example the app com.android.contacts would use names
8582 * like "com.android.contacts.ShowAll".
8583 *
8584 * @param name The name of the extra data, with package prefix.
8585 * @param value The char array data value.
8586 *
8587 * @return Returns the same Intent object, for chaining multiple calls
8588 * into a single statement.
8589 *
8590 * @see #putExtras
8591 * @see #removeExtra
8592 * @see #getCharArrayExtra(String)
8593 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008594 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008595 if (mExtras == null) {
8596 mExtras = new Bundle();
8597 }
8598 mExtras.putCharArray(name, value);
8599 return this;
8600 }
8601
8602 /**
8603 * Add extended data to the intent. The name must include a package
8604 * prefix, for example the app com.android.contacts would use names
8605 * like "com.android.contacts.ShowAll".
8606 *
8607 * @param name The name of the extra data, with package prefix.
8608 * @param value The int array data value.
8609 *
8610 * @return Returns the same Intent object, for chaining multiple calls
8611 * into a single statement.
8612 *
8613 * @see #putExtras
8614 * @see #removeExtra
8615 * @see #getIntArrayExtra(String)
8616 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008617 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008618 if (mExtras == null) {
8619 mExtras = new Bundle();
8620 }
8621 mExtras.putIntArray(name, value);
8622 return this;
8623 }
8624
8625 /**
8626 * Add extended data to the intent. The name must include a package
8627 * prefix, for example the app com.android.contacts would use names
8628 * like "com.android.contacts.ShowAll".
8629 *
8630 * @param name The name of the extra data, with package prefix.
8631 * @param value The byte array data value.
8632 *
8633 * @return Returns the same Intent object, for chaining multiple calls
8634 * into a single statement.
8635 *
8636 * @see #putExtras
8637 * @see #removeExtra
8638 * @see #getLongArrayExtra(String)
8639 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008640 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008641 if (mExtras == null) {
8642 mExtras = new Bundle();
8643 }
8644 mExtras.putLongArray(name, value);
8645 return this;
8646 }
8647
8648 /**
8649 * Add extended data to the intent. The name must include a package
8650 * prefix, for example the app com.android.contacts would use names
8651 * like "com.android.contacts.ShowAll".
8652 *
8653 * @param name The name of the extra data, with package prefix.
8654 * @param value The float array data value.
8655 *
8656 * @return Returns the same Intent object, for chaining multiple calls
8657 * into a single statement.
8658 *
8659 * @see #putExtras
8660 * @see #removeExtra
8661 * @see #getFloatArrayExtra(String)
8662 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008663 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008664 if (mExtras == null) {
8665 mExtras = new Bundle();
8666 }
8667 mExtras.putFloatArray(name, value);
8668 return this;
8669 }
8670
8671 /**
8672 * Add extended data to the intent. The name must include a package
8673 * prefix, for example the app com.android.contacts would use names
8674 * like "com.android.contacts.ShowAll".
8675 *
8676 * @param name The name of the extra data, with package prefix.
8677 * @param value The double array data value.
8678 *
8679 * @return Returns the same Intent object, for chaining multiple calls
8680 * into a single statement.
8681 *
8682 * @see #putExtras
8683 * @see #removeExtra
8684 * @see #getDoubleArrayExtra(String)
8685 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008686 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008687 if (mExtras == null) {
8688 mExtras = new Bundle();
8689 }
8690 mExtras.putDoubleArray(name, value);
8691 return this;
8692 }
8693
8694 /**
8695 * Add extended data to the intent. The name must include a package
8696 * prefix, for example the app com.android.contacts would use names
8697 * like "com.android.contacts.ShowAll".
8698 *
8699 * @param name The name of the extra data, with package prefix.
8700 * @param value The String array data value.
8701 *
8702 * @return Returns the same Intent object, for chaining multiple calls
8703 * into a single statement.
8704 *
8705 * @see #putExtras
8706 * @see #removeExtra
8707 * @see #getStringArrayExtra(String)
8708 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008709 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008710 if (mExtras == null) {
8711 mExtras = new Bundle();
8712 }
8713 mExtras.putStringArray(name, value);
8714 return this;
8715 }
8716
8717 /**
8718 * Add extended data to the intent. The name must include a package
8719 * prefix, for example the app com.android.contacts would use names
8720 * like "com.android.contacts.ShowAll".
8721 *
8722 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008723 * @param value The CharSequence array data value.
8724 *
8725 * @return Returns the same Intent object, for chaining multiple calls
8726 * into a single statement.
8727 *
8728 * @see #putExtras
8729 * @see #removeExtra
8730 * @see #getCharSequenceArrayExtra(String)
8731 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008732 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008733 if (mExtras == null) {
8734 mExtras = new Bundle();
8735 }
8736 mExtras.putCharSequenceArray(name, value);
8737 return this;
8738 }
8739
8740 /**
8741 * Add extended data to the intent. The name must include a package
8742 * prefix, for example the app com.android.contacts would use names
8743 * like "com.android.contacts.ShowAll".
8744 *
8745 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008746 * @param value The Bundle data value.
8747 *
8748 * @return Returns the same Intent object, for chaining multiple calls
8749 * into a single statement.
8750 *
8751 * @see #putExtras
8752 * @see #removeExtra
8753 * @see #getBundleExtra(String)
8754 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008755 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008756 if (mExtras == null) {
8757 mExtras = new Bundle();
8758 }
8759 mExtras.putBundle(name, value);
8760 return this;
8761 }
8762
8763 /**
8764 * Add extended data to the intent. The name must include a package
8765 * prefix, for example the app com.android.contacts would use names
8766 * like "com.android.contacts.ShowAll".
8767 *
8768 * @param name The name of the extra data, with package prefix.
8769 * @param value The IBinder data value.
8770 *
8771 * @return Returns the same Intent object, for chaining multiple calls
8772 * into a single statement.
8773 *
8774 * @see #putExtras
8775 * @see #removeExtra
8776 * @see #getIBinderExtra(String)
8777 *
8778 * @deprecated
8779 * @hide
8780 */
8781 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008782 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008783 if (mExtras == null) {
8784 mExtras = new Bundle();
8785 }
8786 mExtras.putIBinder(name, value);
8787 return this;
8788 }
8789
8790 /**
8791 * Copy all extras in 'src' in to this intent.
8792 *
8793 * @param src Contains the extras to copy.
8794 *
8795 * @see #putExtra
8796 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008797 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008798 if (src.mExtras != null) {
8799 if (mExtras == null) {
8800 mExtras = new Bundle(src.mExtras);
8801 } else {
8802 mExtras.putAll(src.mExtras);
8803 }
8804 }
8805 return this;
8806 }
8807
8808 /**
8809 * Add a set of extended data to the intent. The keys must include a package
8810 * prefix, for example the app com.android.contacts would use names
8811 * like "com.android.contacts.ShowAll".
8812 *
8813 * @param extras The Bundle of extras to add to this intent.
8814 *
8815 * @see #putExtra
8816 * @see #removeExtra
8817 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008818 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008819 if (mExtras == null) {
8820 mExtras = new Bundle();
8821 }
8822 mExtras.putAll(extras);
8823 return this;
8824 }
8825
8826 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008827 * Completely replace the extras in the Intent with the extras in the
8828 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008829 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008830 * @param src The exact extras contained in this Intent are copied
8831 * into the target intent, replacing any that were previously there.
8832 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008833 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008834 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8835 return this;
8836 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008837
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008838 /**
8839 * Completely replace the extras in the Intent with the given Bundle of
8840 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008841 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008842 * @param extras The new set of extras in the Intent, or null to erase
8843 * all extras.
8844 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008845 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008846 mExtras = extras != null ? new Bundle(extras) : null;
8847 return this;
8848 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008849
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008851 * Remove extended data from the intent.
8852 *
8853 * @see #putExtra
8854 */
8855 public void removeExtra(String name) {
8856 if (mExtras != null) {
8857 mExtras.remove(name);
8858 if (mExtras.size() == 0) {
8859 mExtras = null;
8860 }
8861 }
8862 }
8863
8864 /**
8865 * Set special flags controlling how this intent is handled. Most values
8866 * here depend on the type of component being executed by the Intent,
8867 * specifically the FLAG_ACTIVITY_* flags are all for use with
8868 * {@link Context#startActivity Context.startActivity()} and the
8869 * FLAG_RECEIVER_* flags are all for use with
8870 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8871 *
Scott Main7aee61f2011-02-08 11:25:01 -08008872 * <p>See the
8873 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8874 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008875 * the behavior of your application.
8876 *
8877 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008878 * @return Returns the same Intent object, for chaining multiple calls
8879 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008880 * @see #getFlags
8881 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008882 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008883 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008884 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008885 mFlags = flags;
8886 return this;
8887 }
8888
8889 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008890 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008891 *
8892 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008893 * @return Returns the same Intent object, for chaining multiple calls into
8894 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008895 * @see #setFlags
8896 * @see #getFlags
8897 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008898 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008899 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008900 mFlags |= flags;
8901 return this;
8902 }
8903
8904 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008905 * Remove these flags from the intent.
8906 *
8907 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008908 * @see #setFlags
8909 * @see #getFlags
8910 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008911 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008912 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008913 mFlags &= ~flags;
8914 }
8915
8916 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008917 * (Usually optional) Set an explicit application package name that limits
8918 * the components this Intent will resolve to. If left to the default
8919 * value of null, all components in all applications will considered.
8920 * If non-null, the Intent can only match the components in the given
8921 * application package.
8922 *
8923 * @param packageName The name of the application package to handle the
8924 * intent, or null to allow any application package.
8925 *
8926 * @return Returns the same Intent object, for chaining multiple calls
8927 * into a single statement.
8928 *
8929 * @see #getPackage
8930 * @see #resolveActivity
8931 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008932 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008933 if (packageName != null && mSelector != null) {
8934 throw new IllegalArgumentException(
8935 "Can't set package name when selector is already set");
8936 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008937 mPackage = packageName;
8938 return this;
8939 }
8940
8941 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008942 * (Usually optional) Explicitly set the component to handle the intent.
8943 * If left with the default value of null, the system will determine the
8944 * appropriate class to use based on the other fields (action, data,
8945 * type, categories) in the Intent. If this class is defined, the
8946 * specified class will always be used regardless of the other fields. You
8947 * should only set this value when you know you absolutely want a specific
8948 * class to be used; otherwise it is better to let the system find the
8949 * appropriate class so that you will respect the installed applications
8950 * and user preferences.
8951 *
8952 * @param component The name of the application component to handle the
8953 * intent, or null to let the system find one for you.
8954 *
8955 * @return Returns the same Intent object, for chaining multiple calls
8956 * into a single statement.
8957 *
8958 * @see #setClass
8959 * @see #setClassName(Context, String)
8960 * @see #setClassName(String, String)
8961 * @see #getComponent
8962 * @see #resolveActivity
8963 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008964 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008965 mComponent = component;
8966 return this;
8967 }
8968
8969 /**
8970 * Convenience for calling {@link #setComponent} with an
8971 * explicit class name.
8972 *
8973 * @param packageContext A Context of the application package implementing
8974 * this class.
8975 * @param className The name of a class inside of the application package
8976 * that will be used as the component for this Intent.
8977 *
8978 * @return Returns the same Intent object, for chaining multiple calls
8979 * into a single statement.
8980 *
8981 * @see #setComponent
8982 * @see #setClass
8983 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008984 public @NonNull Intent setClassName(@NonNull Context packageContext,
8985 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008986 mComponent = new ComponentName(packageContext, className);
8987 return this;
8988 }
8989
8990 /**
8991 * Convenience for calling {@link #setComponent} with an
8992 * explicit application package name and class name.
8993 *
8994 * @param packageName The name of the package implementing the desired
8995 * component.
8996 * @param className The name of a class inside of the application package
8997 * that will be used as the component for this Intent.
8998 *
8999 * @return Returns the same Intent object, for chaining multiple calls
9000 * into a single statement.
9001 *
9002 * @see #setComponent
9003 * @see #setClass
9004 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009005 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009006 mComponent = new ComponentName(packageName, className);
9007 return this;
9008 }
9009
9010 /**
9011 * Convenience for calling {@link #setComponent(ComponentName)} with the
9012 * name returned by a {@link Class} object.
9013 *
9014 * @param packageContext A Context of the application package implementing
9015 * this class.
9016 * @param cls The class name to set, equivalent to
9017 * <code>setClassName(context, cls.getName())</code>.
9018 *
9019 * @return Returns the same Intent object, for chaining multiple calls
9020 * into a single statement.
9021 *
9022 * @see #setComponent
9023 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009024 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009025 mComponent = new ComponentName(packageContext, cls);
9026 return this;
9027 }
9028
9029 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009030 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9031 * used as a hint to the receiver for animations and the like. Null means that there
9032 * is no source bounds.
9033 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009034 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009035 if (r != null) {
9036 mSourceBounds = new Rect(r);
9037 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009038 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009039 }
9040 }
9041
Tor Norbyed9273d62013-05-30 15:59:53 -07009042 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009043 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9044 FILL_IN_ACTION,
9045 FILL_IN_DATA,
9046 FILL_IN_CATEGORIES,
9047 FILL_IN_COMPONENT,
9048 FILL_IN_PACKAGE,
9049 FILL_IN_SOURCE_BOUNDS,
9050 FILL_IN_SELECTOR,
9051 FILL_IN_CLIP_DATA
9052 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009053 @Retention(RetentionPolicy.SOURCE)
9054 public @interface FillInFlags {}
9055
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009056 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009057 * Use with {@link #fillIn} to allow the current action value to be
9058 * overwritten, even if it is already set.
9059 */
9060 public static final int FILL_IN_ACTION = 1<<0;
9061
9062 /**
9063 * Use with {@link #fillIn} to allow the current data or type value
9064 * overwritten, even if it is already set.
9065 */
9066 public static final int FILL_IN_DATA = 1<<1;
9067
9068 /**
9069 * Use with {@link #fillIn} to allow the current categories to be
9070 * overwritten, even if they are already set.
9071 */
9072 public static final int FILL_IN_CATEGORIES = 1<<2;
9073
9074 /**
9075 * Use with {@link #fillIn} to allow the current component value to be
9076 * overwritten, even if it is already set.
9077 */
9078 public static final int FILL_IN_COMPONENT = 1<<3;
9079
9080 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009081 * Use with {@link #fillIn} to allow the current package value to be
9082 * overwritten, even if it is already set.
9083 */
9084 public static final int FILL_IN_PACKAGE = 1<<4;
9085
9086 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009087 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009088 * overwritten, even if it is already set.
9089 */
9090 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9091
9092 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009093 * Use with {@link #fillIn} to allow the current selector to be
9094 * overwritten, even if it is already set.
9095 */
9096 public static final int FILL_IN_SELECTOR = 1<<6;
9097
9098 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009099 * Use with {@link #fillIn} to allow the current ClipData to be
9100 * overwritten, even if it is already set.
9101 */
9102 public static final int FILL_IN_CLIP_DATA = 1<<7;
9103
9104 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009105 * Copy the contents of <var>other</var> in to this object, but only
9106 * where fields are not defined by this object. For purposes of a field
9107 * being defined, the following pieces of data in the Intent are
9108 * considered to be separate fields:
9109 *
9110 * <ul>
9111 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009112 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009113 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9114 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009115 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 * <li> component, as set by {@link #setComponent(ComponentName)} or
9117 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009118 * <li> source bounds, as set by {@link #setSourceBounds}.
9119 * <li> selector, as set by {@link #setSelector(Intent)}.
9120 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009121 * <li> each top-level name in the associated extras.
9122 * </ul>
9123 *
9124 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009125 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009126 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9127 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9128 * the restriction where the corresponding field will not be replaced if
9129 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009130 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009131 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9132 * is explicitly specified. The selector will only be copied if
9133 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009134 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009135 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9136 * and Intent B with {action="gotit", data-type="some/thing",
9137 * categories="one","two"}.
9138 *
9139 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9140 * containing: {action="gotit", data-type="some/thing",
9141 * categories="bar"}.
9142 *
9143 * @param other Another Intent whose values are to be used to fill in
9144 * the current one.
9145 * @param flags Options to control which fields can be filled in.
9146 *
9147 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009148 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009149 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009150 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009151 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009152 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009153 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009154 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009155 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009156 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009157 if (other.mAction != null
9158 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009159 mAction = other.mAction;
9160 changes |= FILL_IN_ACTION;
9161 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009162 if ((other.mData != null || other.mType != null)
9163 && ((mData == null && mType == null)
9164 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009165 mData = other.mData;
9166 mType = other.mType;
9167 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009168 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009169 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009170 if (other.mCategories != null
9171 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009172 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009173 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009174 }
9175 changes |= FILL_IN_CATEGORIES;
9176 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009177 if (other.mPackage != null
9178 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009179 // Only do this if mSelector is not set.
9180 if (mSelector == null) {
9181 mPackage = other.mPackage;
9182 changes |= FILL_IN_PACKAGE;
9183 }
9184 }
9185 // Selector is special: it can only be set if explicitly allowed,
9186 // for the same reason as the component name.
9187 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9188 if (mPackage == null) {
9189 mSelector = new Intent(other.mSelector);
9190 mPackage = null;
9191 changes |= FILL_IN_SELECTOR;
9192 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009193 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009194 if (other.mClipData != null
9195 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9196 mClipData = other.mClipData;
9197 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009198 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009199 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009200 // Component is special: it can -only- be set if explicitly allowed,
9201 // since otherwise the sender could force the intent somewhere the
9202 // originator didn't intend.
9203 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009204 mComponent = other.mComponent;
9205 changes |= FILL_IN_COMPONENT;
9206 }
9207 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009208 if (other.mSourceBounds != null
9209 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9210 mSourceBounds = new Rect(other.mSourceBounds);
9211 changes |= FILL_IN_SOURCE_BOUNDS;
9212 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009213 if (mExtras == null) {
9214 if (other.mExtras != null) {
9215 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009216 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009217 }
9218 } else if (other.mExtras != null) {
9219 try {
9220 Bundle newb = new Bundle(other.mExtras);
9221 newb.putAll(mExtras);
9222 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009223 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009224 } catch (RuntimeException e) {
9225 // Modifying the extras can cause us to unparcel the contents
9226 // of the bundle, and if we do this in the system process that
9227 // may fail. We really should handle this (i.e., the Bundle
9228 // impl shouldn't be on top of a plain map), but for now just
9229 // ignore it and keep the original contents. :(
9230 Log.w("Intent", "Failure filling in extras", e);
9231 }
9232 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009233 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9234 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9235 mContentUserHint = other.mContentUserHint;
9236 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009237 return changes;
9238 }
9239
9240 /**
9241 * Wrapper class holding an Intent and implementing comparisons on it for
9242 * the purpose of filtering. The class implements its
9243 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9244 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9245 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9246 * on the wrapped Intent.
9247 */
9248 public static final class FilterComparison {
9249 private final Intent mIntent;
9250 private final int mHashCode;
9251
9252 public FilterComparison(Intent intent) {
9253 mIntent = intent;
9254 mHashCode = intent.filterHashCode();
9255 }
9256
9257 /**
9258 * Return the Intent that this FilterComparison represents.
9259 * @return Returns the Intent held by the FilterComparison. Do
9260 * not modify!
9261 */
9262 public Intent getIntent() {
9263 return mIntent;
9264 }
9265
9266 @Override
9267 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009268 if (obj instanceof FilterComparison) {
9269 Intent other = ((FilterComparison)obj).mIntent;
9270 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009271 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009272 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009273 }
9274
9275 @Override
9276 public int hashCode() {
9277 return mHashCode;
9278 }
9279 }
9280
9281 /**
9282 * Determine if two intents are the same for the purposes of intent
9283 * resolution (filtering). That is, if their action, data, type,
9284 * class, and categories are the same. This does <em>not</em> compare
9285 * any extra data included in the intents.
9286 *
9287 * @param other The other Intent to compare against.
9288 *
9289 * @return Returns true if action, data, type, class, and categories
9290 * are the same.
9291 */
9292 public boolean filterEquals(Intent other) {
9293 if (other == null) {
9294 return false;
9295 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009296 if (!Objects.equals(this.mAction, other.mAction)) return false;
9297 if (!Objects.equals(this.mData, other.mData)) return false;
9298 if (!Objects.equals(this.mType, other.mType)) return false;
9299 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9300 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9301 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009302
9303 return true;
9304 }
9305
9306 /**
9307 * Generate hash code that matches semantics of filterEquals().
9308 *
9309 * @return Returns the hash value of the action, data, type, class, and
9310 * categories.
9311 *
9312 * @see #filterEquals
9313 */
9314 public int filterHashCode() {
9315 int code = 0;
9316 if (mAction != null) {
9317 code += mAction.hashCode();
9318 }
9319 if (mData != null) {
9320 code += mData.hashCode();
9321 }
9322 if (mType != null) {
9323 code += mType.hashCode();
9324 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009325 if (mPackage != null) {
9326 code += mPackage.hashCode();
9327 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009328 if (mComponent != null) {
9329 code += mComponent.hashCode();
9330 }
9331 if (mCategories != null) {
9332 code += mCategories.hashCode();
9333 }
9334 return code;
9335 }
9336
9337 @Override
9338 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009339 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009340
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009341 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009342 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009343 b.append(" }");
9344
9345 return b.toString();
9346 }
9347
9348 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009349 public String toInsecureString() {
9350 StringBuilder b = new StringBuilder(128);
9351
9352 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009353 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009354 b.append(" }");
9355
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009356 return b.toString();
9357 }
Romain Guy4969af72009-06-17 10:53:19 -07009358
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009359 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009360 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009361 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009362
9363 b.append("Intent { ");
9364 toShortString(b, false, true, true, true);
9365 b.append(" }");
9366
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009367 return b.toString();
9368 }
9369
9370 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009371 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9372 StringBuilder b = new StringBuilder(128);
9373 toShortString(b, secure, comp, extras, clip);
9374 return b.toString();
9375 }
9376
9377 /** @hide */
9378 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9379 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009380 boolean first = true;
9381 if (mAction != null) {
9382 b.append("act=").append(mAction);
9383 first = false;
9384 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009385 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009386 if (!first) {
9387 b.append(' ');
9388 }
9389 first = false;
9390 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009391 for (int i=0; i<mCategories.size(); i++) {
9392 if (i > 0) b.append(',');
9393 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009394 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009395 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009396 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009397 if (mData != null) {
9398 if (!first) {
9399 b.append(' ');
9400 }
9401 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009402 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009403 if (secure) {
9404 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009405 } else {
9406 b.append(mData);
9407 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009408 }
9409 if (mType != null) {
9410 if (!first) {
9411 b.append(' ');
9412 }
9413 first = false;
9414 b.append("typ=").append(mType);
9415 }
9416 if (mFlags != 0) {
9417 if (!first) {
9418 b.append(' ');
9419 }
9420 first = false;
9421 b.append("flg=0x").append(Integer.toHexString(mFlags));
9422 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009423 if (mPackage != null) {
9424 if (!first) {
9425 b.append(' ');
9426 }
9427 first = false;
9428 b.append("pkg=").append(mPackage);
9429 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009430 if (comp && mComponent != null) {
9431 if (!first) {
9432 b.append(' ');
9433 }
9434 first = false;
9435 b.append("cmp=").append(mComponent.flattenToShortString());
9436 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009437 if (mSourceBounds != null) {
9438 if (!first) {
9439 b.append(' ');
9440 }
9441 first = false;
9442 b.append("bnds=").append(mSourceBounds.toShortString());
9443 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009444 if (mClipData != null) {
9445 if (!first) {
9446 b.append(' ');
9447 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009448 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009449 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009450 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009451 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009452 if (mClipData.getDescription() != null) {
9453 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9454 } else {
9455 first = true;
9456 }
9457 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009458 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009459 first = false;
9460 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009461 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009462 if (extras && mExtras != null) {
9463 if (!first) {
9464 b.append(' ');
9465 }
9466 first = false;
9467 b.append("(has extras)");
9468 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009469 if (mContentUserHint != UserHandle.USER_CURRENT) {
9470 if (!first) {
9471 b.append(' ');
9472 }
9473 first = false;
9474 b.append("u=").append(mContentUserHint);
9475 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009476 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009477 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009478 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009479 b.append("}");
9480 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009481 }
9482
Yi Jin129fc6c2017-09-28 15:48:38 -07009483 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009484 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9485 // Same input parameters that toString() gives to toShortString().
9486 writeToProto(proto, fieldId, true, true, true, false);
9487 }
9488
9489 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009490 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9491 boolean extras, boolean clip) {
9492 long token = proto.start(fieldId);
9493 if (mAction != null) {
9494 proto.write(IntentProto.ACTION, mAction);
9495 }
9496 if (mCategories != null) {
9497 for (String category : mCategories) {
9498 proto.write(IntentProto.CATEGORIES, category);
9499 }
9500 }
9501 if (mData != null) {
9502 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9503 }
9504 if (mType != null) {
9505 proto.write(IntentProto.TYPE, mType);
9506 }
9507 if (mFlags != 0) {
9508 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9509 }
9510 if (mPackage != null) {
9511 proto.write(IntentProto.PACKAGE, mPackage);
9512 }
9513 if (comp && mComponent != null) {
9514 proto.write(IntentProto.COMPONENT, mComponent.flattenToShortString());
9515 }
9516 if (mSourceBounds != null) {
9517 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9518 }
9519 if (mClipData != null) {
9520 StringBuilder b = new StringBuilder();
9521 if (clip) {
9522 mClipData.toShortString(b);
9523 } else {
9524 mClipData.toShortStringShortItems(b, false);
9525 }
9526 proto.write(IntentProto.CLIP_DATA, b.toString());
9527 }
9528 if (extras && mExtras != null) {
9529 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9530 }
9531 if (mContentUserHint != 0) {
9532 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9533 }
9534 if (mSelector != null) {
9535 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9536 }
9537 proto.end(token);
9538 }
9539
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009540 /**
9541 * Call {@link #toUri} with 0 flags.
9542 * @deprecated Use {@link #toUri} instead.
9543 */
9544 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009545 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009546 return toUri(0);
9547 }
9548
9549 /**
9550 * Convert this Intent into a String holding a URI representation of it.
9551 * The returned URI string has been properly URI encoded, so it can be
9552 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9553 * Intent's data as the base URI, with an additional fragment describing
9554 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009555 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009556 * <p>You can convert the returned string back to an Intent with
9557 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009558 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009559 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009560 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009561 * @return Returns a URI encoding URI string describing the entire contents
9562 * of the Intent.
9563 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009564 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009565 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009566 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9567 if (mPackage == null) {
9568 throw new IllegalArgumentException(
9569 "Intent must include an explicit package name to build an android-app: "
9570 + this);
9571 }
9572 uri.append("android-app://");
9573 uri.append(mPackage);
9574 String scheme = null;
9575 if (mData != null) {
9576 scheme = mData.getScheme();
9577 if (scheme != null) {
9578 uri.append('/');
9579 uri.append(scheme);
9580 String authority = mData.getEncodedAuthority();
9581 if (authority != null) {
9582 uri.append('/');
9583 uri.append(authority);
9584 String path = mData.getEncodedPath();
9585 if (path != null) {
9586 uri.append(path);
9587 }
9588 String queryParams = mData.getEncodedQuery();
9589 if (queryParams != null) {
9590 uri.append('?');
9591 uri.append(queryParams);
9592 }
9593 String fragment = mData.getEncodedFragment();
9594 if (fragment != null) {
9595 uri.append('#');
9596 uri.append(fragment);
9597 }
9598 }
9599 }
9600 }
9601 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9602 mPackage, flags);
9603 return uri.toString();
9604 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009605 String scheme = null;
9606 if (mData != null) {
9607 String data = mData.toString();
9608 if ((flags&URI_INTENT_SCHEME) != 0) {
9609 final int N = data.length();
9610 for (int i=0; i<N; i++) {
9611 char c = data.charAt(i);
9612 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009613 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009614 continue;
9615 }
9616 if (c == ':' && i > 0) {
9617 // Valid scheme.
9618 scheme = data.substring(0, i);
9619 uri.append("intent:");
9620 data = data.substring(i+1);
9621 break;
9622 }
Tom Taylord4a47292009-12-21 13:59:18 -08009623
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009624 // No scheme.
9625 break;
9626 }
9627 }
9628 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009629
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009630 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9631 uri.append("intent:");
9632 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009633
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009634 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009635
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009636 return uri.toString();
9637 }
9638
9639 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9640 String defPackage, int flags) {
9641 StringBuilder frag = new StringBuilder(128);
9642
9643 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009644 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009645 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009646 // Note that for now we are not going to try to handle the
9647 // data part; not clear how to represent this as a URI, and
9648 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009649 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9650 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009651 }
9652
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009653 if (frag.length() > 0) {
9654 uri.append("#Intent;");
9655 uri.append(frag);
9656 uri.append("end");
9657 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009658 }
9659
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009660 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9661 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009662 if (scheme != null) {
9663 uri.append("scheme=").append(scheme).append(';');
9664 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009665 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009666 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009667 }
9668 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009669 for (int i=0; i<mCategories.size(); i++) {
9670 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009671 }
9672 }
9673 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009674 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009675 }
9676 if (mFlags != 0) {
9677 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9678 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009679 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009680 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9681 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009682 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009683 uri.append("component=").append(Uri.encode(
9684 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009685 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009686 if (mSourceBounds != null) {
9687 uri.append("sourceBounds=")
9688 .append(Uri.encode(mSourceBounds.flattenToString()))
9689 .append(';');
9690 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009691 if (mExtras != null) {
9692 for (String key : mExtras.keySet()) {
9693 final Object value = mExtras.get(key);
9694 char entryType =
9695 value instanceof String ? 'S' :
9696 value instanceof Boolean ? 'B' :
9697 value instanceof Byte ? 'b' :
9698 value instanceof Character ? 'c' :
9699 value instanceof Double ? 'd' :
9700 value instanceof Float ? 'f' :
9701 value instanceof Integer ? 'i' :
9702 value instanceof Long ? 'l' :
9703 value instanceof Short ? 's' :
9704 '\0';
9705
9706 if (entryType != '\0') {
9707 uri.append(entryType);
9708 uri.append('.');
9709 uri.append(Uri.encode(key));
9710 uri.append('=');
9711 uri.append(Uri.encode(value.toString()));
9712 uri.append(';');
9713 }
9714 }
9715 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009716 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009717
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009718 public int describeContents() {
9719 return (mExtras != null) ? mExtras.describeContents() : 0;
9720 }
9721
9722 public void writeToParcel(Parcel out, int flags) {
9723 out.writeString(mAction);
9724 Uri.writeToParcel(out, mData);
9725 out.writeString(mType);
9726 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009727 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009728 ComponentName.writeToParcel(mComponent, out);
9729
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009730 if (mSourceBounds != null) {
9731 out.writeInt(1);
9732 mSourceBounds.writeToParcel(out, flags);
9733 } else {
9734 out.writeInt(0);
9735 }
9736
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009737 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009738 final int N = mCategories.size();
9739 out.writeInt(N);
9740 for (int i=0; i<N; i++) {
9741 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009742 }
9743 } else {
9744 out.writeInt(0);
9745 }
9746
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009747 if (mSelector != null) {
9748 out.writeInt(1);
9749 mSelector.writeToParcel(out, flags);
9750 } else {
9751 out.writeInt(0);
9752 }
9753
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009754 if (mClipData != null) {
9755 out.writeInt(1);
9756 mClipData.writeToParcel(out, flags);
9757 } else {
9758 out.writeInt(0);
9759 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009760 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009761 out.writeBundle(mExtras);
9762 }
9763
9764 public static final Parcelable.Creator<Intent> CREATOR
9765 = new Parcelable.Creator<Intent>() {
9766 public Intent createFromParcel(Parcel in) {
9767 return new Intent(in);
9768 }
9769 public Intent[] newArray(int size) {
9770 return new Intent[size];
9771 }
9772 };
9773
Dianne Hackborneb034652009-09-07 00:49:58 -07009774 /** @hide */
9775 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009776 readFromParcel(in);
9777 }
9778
9779 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009780 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009781 mData = Uri.CREATOR.createFromParcel(in);
9782 mType = in.readString();
9783 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009784 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009785 mComponent = ComponentName.readFromParcel(in);
9786
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009787 if (in.readInt() != 0) {
9788 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9789 }
9790
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009791 int N = in.readInt();
9792 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009793 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009794 int i;
9795 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009796 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009797 }
9798 } else {
9799 mCategories = null;
9800 }
9801
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009802 if (in.readInt() != 0) {
9803 mSelector = new Intent(in);
9804 }
9805
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009806 if (in.readInt() != 0) {
9807 mClipData = new ClipData(in);
9808 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009809 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009810 mExtras = in.readBundle();
9811 }
9812
9813 /**
9814 * Parses the "intent" element (and its children) from XML and instantiates
9815 * an Intent object. The given XML parser should be located at the tag
9816 * where parsing should start (often named "intent"), from which the
9817 * basic action, data, type, and package and class name will be
9818 * retrieved. The function will then parse in to any child elements,
9819 * looking for <category android:name="xxx"> tags to add categories and
9820 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9821 * to the intent.
9822 *
9823 * @param resources The Resources to use when inflating resources.
9824 * @param parser The XML parser pointing at an "intent" tag.
9825 * @param attrs The AttributeSet interface for retrieving extended
9826 * attribute data at the current <var>parser</var> location.
9827 * @return An Intent object matching the XML data.
9828 * @throws XmlPullParserException If there was an XML parsing error.
9829 * @throws IOException If there was an I/O error.
9830 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009831 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9832 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009833 throws XmlPullParserException, IOException {
9834 Intent intent = new Intent();
9835
9836 TypedArray sa = resources.obtainAttributes(attrs,
9837 com.android.internal.R.styleable.Intent);
9838
9839 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9840
9841 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9842 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9843 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9844
9845 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9846 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9847 if (packageName != null && className != null) {
9848 intent.setComponent(new ComponentName(packageName, className));
9849 }
9850
9851 sa.recycle();
9852
9853 int outerDepth = parser.getDepth();
9854 int type;
9855 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9856 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9857 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9858 continue;
9859 }
9860
9861 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009862 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009863 sa = resources.obtainAttributes(attrs,
9864 com.android.internal.R.styleable.IntentCategory);
9865 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9866 sa.recycle();
9867
9868 if (cat != null) {
9869 intent.addCategory(cat);
9870 }
9871 XmlUtils.skipCurrentTag(parser);
9872
Craig Mautner21d24a22014-04-23 11:45:37 -07009873 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009874 if (intent.mExtras == null) {
9875 intent.mExtras = new Bundle();
9876 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009877 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009878 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009879
9880 } else {
9881 XmlUtils.skipCurrentTag(parser);
9882 }
9883 }
9884
9885 return intent;
9886 }
Nick Pellyccae4122012-01-09 14:12:58 -08009887
Craig Mautner21d24a22014-04-23 11:45:37 -07009888 /** @hide */
9889 public void saveToXml(XmlSerializer out) throws IOException {
9890 if (mAction != null) {
9891 out.attribute(null, ATTR_ACTION, mAction);
9892 }
9893 if (mData != null) {
9894 out.attribute(null, ATTR_DATA, mData.toString());
9895 }
9896 if (mType != null) {
9897 out.attribute(null, ATTR_TYPE, mType);
9898 }
9899 if (mComponent != null) {
9900 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9901 }
9902 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9903
9904 if (mCategories != null) {
9905 out.startTag(null, TAG_CATEGORIES);
9906 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9907 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9908 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009909 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009910 }
9911 }
9912
9913 /** @hide */
9914 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9915 XmlPullParserException {
9916 Intent intent = new Intent();
9917 final int outerDepth = in.getDepth();
9918
9919 int attrCount = in.getAttributeCount();
9920 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9921 final String attrName = in.getAttributeName(attrNdx);
9922 final String attrValue = in.getAttributeValue(attrNdx);
9923 if (ATTR_ACTION.equals(attrName)) {
9924 intent.setAction(attrValue);
9925 } else if (ATTR_DATA.equals(attrName)) {
9926 intent.setData(Uri.parse(attrValue));
9927 } else if (ATTR_TYPE.equals(attrName)) {
9928 intent.setType(attrValue);
9929 } else if (ATTR_COMPONENT.equals(attrName)) {
9930 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9931 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009932 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009933 } else {
9934 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9935 }
9936 }
9937
9938 int event;
9939 String name;
9940 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9941 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9942 if (event == XmlPullParser.START_TAG) {
9943 name = in.getName();
9944 if (TAG_CATEGORIES.equals(name)) {
9945 attrCount = in.getAttributeCount();
9946 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9947 intent.addCategory(in.getAttributeValue(attrNdx));
9948 }
9949 } else {
9950 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9951 XmlUtils.skipCurrentTag(in);
9952 }
9953 }
9954 }
9955
9956 return intent;
9957 }
9958
Nick Pellyccae4122012-01-09 14:12:58 -08009959 /**
9960 * Normalize a MIME data type.
9961 *
9962 * <p>A normalized MIME type has white-space trimmed,
9963 * content-type parameters removed, and is lower-case.
9964 * This aligns the type with Android best practices for
9965 * intent filtering.
9966 *
9967 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9968 * "text/x-vCard" becomes "text/x-vcard".
9969 *
9970 * <p>All MIME types received from outside Android (such as user input,
9971 * or external sources like Bluetooth, NFC, or the Internet) should
9972 * be normalized before they are used to create an Intent.
9973 *
9974 * @param type MIME data type to normalize
9975 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009976 * @see #setType
9977 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009978 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009979 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009980 if (type == null) {
9981 return null;
9982 }
9983
Elliott Hughescb64d432013-08-02 10:00:44 -07009984 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009985
9986 final int semicolonIndex = type.indexOf(';');
9987 if (semicolonIndex != -1) {
9988 type = type.substring(0, semicolonIndex);
9989 }
9990 return type;
9991 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009992
9993 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009994 * Prepare this {@link Intent} to leave an app process.
9995 *
9996 * @hide
9997 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009998 public void prepareToLeaveProcess(Context context) {
9999 final boolean leavingPackage = (mComponent == null)
10000 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10001 prepareToLeaveProcess(leavingPackage);
10002 }
10003
10004 /**
10005 * Prepare this {@link Intent} to leave an app process.
10006 *
10007 * @hide
10008 */
10009 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010010 setAllowFds(false);
10011
10012 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010013 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010014 }
10015 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010016 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010017 }
10018
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010019 if (mExtras != null && !mExtras.isParcelled()) {
10020 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10021 if (intent instanceof Intent) {
10022 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10023 }
10024 }
10025
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010026 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10027 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010028 switch (mAction) {
10029 case ACTION_MEDIA_REMOVED:
10030 case ACTION_MEDIA_UNMOUNTED:
10031 case ACTION_MEDIA_CHECKING:
10032 case ACTION_MEDIA_NOFS:
10033 case ACTION_MEDIA_MOUNTED:
10034 case ACTION_MEDIA_SHARED:
10035 case ACTION_MEDIA_UNSHARED:
10036 case ACTION_MEDIA_BAD_REMOVAL:
10037 case ACTION_MEDIA_UNMOUNTABLE:
10038 case ACTION_MEDIA_EJECT:
10039 case ACTION_MEDIA_SCANNER_STARTED:
10040 case ACTION_MEDIA_SCANNER_FINISHED:
10041 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010042 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10043 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010044 // Ignore legacy actions
10045 break;
10046 default:
10047 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010048 }
10049 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010050
10051 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10052 && leavingPackage) {
10053 switch (mAction) {
10054 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010055 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010056 // Ignore actions that don't need to grant
10057 break;
10058 default:
10059 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10060 }
10061 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010062 }
10063
10064 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010065 * @hide
10066 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010067 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010068 // We just entered destination process, so we should be able to read all
10069 // parcelables inside.
10070 setDefusable(true);
10071
10072 if (mSelector != null) {
10073 mSelector.prepareToEnterProcess();
10074 }
10075 if (mClipData != null) {
10076 mClipData.prepareToEnterProcess();
10077 }
10078
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010079 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010080 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10081 fixUris(mContentUserHint);
10082 mContentUserHint = UserHandle.USER_CURRENT;
10083 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010084 }
10085 }
10086
10087 /**
10088 * @hide
10089 */
10090 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010091 Uri data = getData();
10092 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010093 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010094 }
10095 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010096 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010097 }
10098 String action = getAction();
10099 if (ACTION_SEND.equals(action)) {
10100 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10101 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010102 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010103 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010104 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010105 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10106 if (streams != null) {
10107 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10108 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010109 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010110 }
10111 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10112 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010113 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10114 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10115 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10116 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10117 if (output != null) {
10118 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10119 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010120 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010121 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010122
10123 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010124 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010125 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10126 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010127 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010128 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010129 * @hide
10130 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010131 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010132 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010133 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010134
10135 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010136 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010137
10138 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010139 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010140 // Inspect contained intents to see if we need to migrate extras. We
10141 // don't promote ClipData to the parent, since ChooserActivity will
10142 // already start the picked item as the caller, and we can't combine
10143 // the flags in a safe way.
10144
10145 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010146 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010147 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10148 if (intent != null) {
10149 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010150 }
10151 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010152 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010153 try {
10154 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10155 if (intents != null) {
10156 for (int i = 0; i < intents.length; i++) {
10157 final Intent intent = (Intent) intents[i];
10158 if (intent != null) {
10159 migrated |= intent.migrateExtraStreamToClipData();
10160 }
10161 }
10162 }
10163 } catch (ClassCastException e) {
10164 }
10165 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010166
10167 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010168 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010169 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10170 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10171 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10172 if (stream != null || text != null || htmlText != null) {
10173 final ClipData clipData = new ClipData(
10174 null, new String[] { getType() },
10175 new ClipData.Item(text, htmlText, null, stream));
10176 setClipData(clipData);
10177 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010178 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010179 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010180 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010181 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010182
10183 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010184 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010185 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10186 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10187 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10188 int num = -1;
10189 if (streams != null) {
10190 num = streams.size();
10191 }
10192 if (texts != null) {
10193 if (num >= 0 && num != texts.size()) {
10194 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010195 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010196 }
10197 num = texts.size();
10198 }
10199 if (htmlTexts != null) {
10200 if (num >= 0 && num != htmlTexts.size()) {
10201 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010202 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010203 }
10204 num = htmlTexts.size();
10205 }
10206 if (num > 0) {
10207 final ClipData clipData = new ClipData(
10208 null, new String[] { getType() },
10209 makeClipItem(streams, texts, htmlTexts, 0));
10210
10211 for (int i = 1; i < num; i++) {
10212 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10213 }
10214
10215 setClipData(clipData);
10216 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010217 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010218 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010219 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010220 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010221 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10222 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10223 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10224 final Uri output;
10225 try {
10226 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10227 } catch (ClassCastException e) {
10228 return false;
10229 }
10230 if (output != null) {
10231 setClipData(ClipData.newRawUri("", output));
10232 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10233 return true;
10234 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010235 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010236
10237 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010238 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010239
Michael Wright19859762017-09-18 20:57:58 +010010240 /**
10241 * Convert the dock state to a human readable format.
10242 * @hide
10243 */
10244 public static String dockStateToString(int dock) {
10245 switch (dock) {
10246 case EXTRA_DOCK_STATE_HE_DESK:
10247 return "EXTRA_DOCK_STATE_HE_DESK";
10248 case EXTRA_DOCK_STATE_LE_DESK:
10249 return "EXTRA_DOCK_STATE_LE_DESK";
10250 case EXTRA_DOCK_STATE_CAR:
10251 return "EXTRA_DOCK_STATE_CAR";
10252 case EXTRA_DOCK_STATE_DESK:
10253 return "EXTRA_DOCK_STATE_DESK";
10254 case EXTRA_DOCK_STATE_UNDOCKED:
10255 return "EXTRA_DOCK_STATE_UNDOCKED";
10256 default:
10257 return Integer.toString(dock);
10258 }
10259 }
10260
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010261 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10262 ArrayList<String> htmlTexts, int which) {
10263 Uri uri = streams != null ? streams.get(which) : null;
10264 CharSequence text = texts != null ? texts.get(which) : null;
10265 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10266 return new ClipData.Item(text, htmlText, null, uri);
10267 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010268
10269 /** @hide */
10270 public boolean isDocument() {
10271 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10272 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010273}