blob: e47de752ec7098f1a8832cce5d286870bc31b9c6 [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.
1731 */
1732 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1733 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1734
1735 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001736 * Specify whether the package should be uninstalled for all users.
1737 * @hide because these should not be part of normal application flow.
1738 */
1739 public static final String EXTRA_UNINSTALL_ALL_USERS
1740 = "android.intent.extra.UNINSTALL_ALL_USERS";
1741
1742 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001743 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1744 * describing the last run version of the platform that was setup.
1745 * @hide
1746 */
1747 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1748
Svet Ganov3695b8a2015-03-24 16:30:25 -07001749 /**
1750 * Activity action: Launch UI to manage the permissions of an app.
1751 * <p>
1752 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1753 * will be managed by the launched UI.
1754 * </p>
1755 * <p>
1756 * Output: Nothing.
1757 * </p>
1758 *
1759 * @see #EXTRA_PACKAGE_NAME
1760 *
1761 * @hide
1762 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001763 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001764 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1765 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1766 "android.intent.action.MANAGE_APP_PERMISSIONS";
1767
1768 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001769 * Activity action: Launch UI to manage permissions.
1770 * <p>
1771 * Input: Nothing.
1772 * </p>
1773 * <p>
1774 * Output: Nothing.
1775 * </p>
1776 *
1777 * @hide
1778 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001779 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001780 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1781 public static final String ACTION_MANAGE_PERMISSIONS =
1782 "android.intent.action.MANAGE_PERMISSIONS";
1783
1784 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001785 * Activity action: Launch UI to review permissions for an app.
1786 * The system uses this intent if permission review for apps not
1787 * supporting the new runtime permissions model is enabled. In
1788 * this mode a permission review is required before any of the
1789 * app components can run.
1790 * <p>
1791 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1792 * permissions will be reviewed (mandatory).
1793 * </p>
1794 * <p>
1795 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1796 * be fired after the permission review (optional).
1797 * </p>
1798 * <p>
1799 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1800 * be invoked after the permission review (optional).
1801 * </p>
1802 * <p>
1803 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1804 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1805 * </p>
1806 * <p>
1807 * Output: Nothing.
1808 * </p>
1809 *
1810 * @see #EXTRA_PACKAGE_NAME
1811 * @see #EXTRA_INTENT
1812 * @see #EXTRA_REMOTE_CALLBACK
1813 * @see #EXTRA_RESULT_NEEDED
1814 *
1815 * @hide
1816 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001817 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001818 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1819 public static final String ACTION_REVIEW_PERMISSIONS =
1820 "android.intent.action.REVIEW_PERMISSIONS";
1821
1822 /**
1823 * Intent extra: A callback for reporting remote result as a bundle.
1824 * <p>
1825 * Type: IRemoteCallback
1826 * </p>
1827 *
1828 * @hide
1829 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001830 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001831 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1832
1833 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001834 * Intent extra: An app package name.
1835 * <p>
1836 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001837 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001838 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001839 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001840 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1841
1842 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001843 * Intent extra: An app split name.
1844 * <p>
1845 * Type: String
1846 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001847 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001848 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1849
1850 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001851 * Intent extra: A {@link ComponentName} value.
1852 * <p>
1853 * Type: String
1854 * </p>
1855 */
1856 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1857
1858 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001859 * Intent extra: An extra for specifying whether a result is needed.
1860 * <p>
1861 * Type: boolean
1862 * </p>
1863 *
1864 * @hide
1865 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001866 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001867 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1868
1869 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001870 * Activity action: Launch UI to manage which apps have a given permission.
1871 * <p>
1872 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1873 * to which will be managed by the launched UI.
1874 * </p>
1875 * <p>
1876 * Output: Nothing.
1877 * </p>
1878 *
1879 * @see #EXTRA_PERMISSION_NAME
1880 *
1881 * @hide
1882 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001883 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001884 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1885 public static final String ACTION_MANAGE_PERMISSION_APPS =
1886 "android.intent.action.MANAGE_PERMISSION_APPS";
1887
1888 /**
1889 * Intent extra: The name of a permission.
1890 * <p>
1891 * Type: String
1892 * </p>
1893 *
1894 * @hide
1895 */
1896 @SystemApi
1897 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1898
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 // ---------------------------------------------------------------------
1900 // ---------------------------------------------------------------------
1901 // Standard intent broadcast actions (see action variable).
1902
1903 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001904 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1905 * <p>
1906 * For historical reasons, the name of this broadcast action refers to the power
1907 * state of the screen but it is actually sent in response to changes in the
1908 * overall interactive state of the device.
1909 * </p><p>
1910 * This broadcast is sent when the device becomes non-interactive which may have
1911 * nothing to do with the screen turning off. To determine the
1912 * actual state of the screen, use {@link android.view.Display#getState}.
1913 * </p><p>
1914 * See {@link android.os.PowerManager#isInteractive} for details.
1915 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001916 * You <em>cannot</em> receive this through components declared in
1917 * manifests, only by explicitly registering for it with
1918 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1919 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001920 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001921 * <p class="note">This is a protected intent that can only be sent
1922 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001923 */
1924 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1925 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001926
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001927 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001928 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1929 * <p>
1930 * For historical reasons, the name of this broadcast action refers to the power
1931 * state of the screen but it is actually sent in response to changes in the
1932 * overall interactive state of the device.
1933 * </p><p>
1934 * This broadcast is sent when the device becomes interactive which may have
1935 * nothing to do with the screen turning on. To determine the
1936 * actual state of the screen, use {@link android.view.Display#getState}.
1937 * </p><p>
1938 * See {@link android.os.PowerManager#isInteractive} for details.
1939 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001940 * You <em>cannot</em> receive this through components declared in
1941 * manifests, only by explicitly registering for it with
1942 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1943 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001944 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001945 * <p class="note">This is a protected intent that can only be sent
1946 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001947 */
1948 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1949 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001950
1951 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001952 * Broadcast Action: Sent after the system stops dreaming.
1953 *
1954 * <p class="note">This is a protected intent that can only be sent by the system.
1955 * It is only sent to registered receivers.</p>
1956 */
1957 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1958 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1959
1960 /**
1961 * Broadcast Action: Sent after the system starts dreaming.
1962 *
1963 * <p class="note">This is a protected intent that can only be sent by the system.
1964 * It is only sent to registered receivers.</p>
1965 */
1966 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1967 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1968
1969 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001970 * 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 -07001971 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001972 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001973 * <p class="note">This is a protected intent that can only be sent
1974 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001975 */
1976 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001977 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001978
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001979 /**
1980 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001981 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001982 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1984 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001985 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001986 * <p class="note">This is a protected intent that can only be sent
1987 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001988 */
1989 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1990 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1991 /**
1992 * Broadcast Action: The time was set.
1993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1996 /**
1997 * Broadcast Action: The date has changed.
1998 */
1999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2000 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2001 /**
2002 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2003 * <ul>
2004 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2005 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002006 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002007 * <p class="note">This is a protected intent that can only be sent
2008 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002009 */
2010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2011 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2012 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002013 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2014 * DNS entries should be tossed.
2015 * @hide
2016 */
2017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2018 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2019 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002020 * Alarm Changed Action: This is broadcast when the AlarmClock
2021 * application's alarm is set or unset. It is used by the
2022 * AlarmClock application and the StatusBar service.
2023 * @hide
2024 */
2025 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2026 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002027
2028 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002029 * Broadcast Action: This is broadcast once, after the user has finished
2030 * booting, but while still in the "locked" state. It can be used to perform
2031 * application-specific initialization, such as installing alarms. You must
2032 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2033 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002034 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002035 * This broadcast is sent immediately at boot by all devices (regardless of
2036 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2037 * higher. Upon receipt of this broadcast, the user is still locked and only
2038 * device-protected storage can be accessed safely. If you want to access
2039 * credential-protected storage, you need to wait for the user to be
2040 * unlocked (typically by entering their lock pattern or PIN for the first
2041 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2042 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2043 * <p>
2044 * To receive this broadcast, your receiver component must be marked as
2045 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002046 * <p class="note">
2047 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002048 *
2049 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002050 */
2051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2052 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2053
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002054 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002055 * Broadcast Action: This is broadcast once, after the user has finished
2056 * booting. It can be used to perform application-specific initialization,
2057 * such as installing alarms. You must hold the
2058 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2059 * order to receive this broadcast.
2060 * <p>
2061 * This broadcast is sent at boot by all devices (both with and without
2062 * direct boot support). Upon receipt of this broadcast, the user is
2063 * unlocked and both device-protected and credential-protected storage can
2064 * accessed safely.
2065 * <p>
2066 * If you need to run while the user is still locked (before they've entered
2067 * their lock pattern or PIN for the first time), you can listen for the
2068 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2069 * <p class="note">
2070 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002071 */
2072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002073 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002075
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002076 /**
2077 * Broadcast Action: This is broadcast when a user action should request a
2078 * temporary system dialog to dismiss. Some examples of temporary system
2079 * dialogs are the notification window-shade and the recent tasks dialog.
2080 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002082 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2083 /**
2084 * Broadcast Action: Trigger the download and eventual installation
2085 * of a package.
2086 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002087 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002088 * <p class="note">This is a protected intent that can only be sent
2089 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002090 *
2091 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002092 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002093 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2095 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2096 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002097 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002098 * device. The data contains the name of the package. Note that the
2099 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002100 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002101 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002102 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2103 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2105 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002106 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002107 * <p class="note">This is a protected intent that can only be sent
2108 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002109 */
2110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2111 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2112 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002113 * Broadcast Action: A new version of an application package has been
2114 * installed, replacing an existing version that was previously installed.
2115 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002116 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002117 * <ul>
2118 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2119 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002120 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002121 * <p class="note">This is a protected intent that can only be sent
2122 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002123 */
2124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2125 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2126 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002127 * Broadcast Action: A new version of your application has been installed
2128 * over an existing one. This is only sent to the application that was
2129 * replaced. It does not contain any additional data; to receive it, just
2130 * use an intent filter for this action.
2131 *
2132 * <p class="note">This is a protected intent that can only be sent
2133 * by the system.
2134 */
2135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2136 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2137 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002138 * Broadcast Action: An existing application package has been removed from
2139 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002140 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002141 * <ul>
2142 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2143 * to the package.
2144 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2145 * application -- data and code -- is being removed.
2146 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2147 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2148 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2155 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002156 * Broadcast Action: An existing application package has been completely
2157 * removed from the device. The data contains the name of the package.
2158 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2159 * {@link #EXTRA_DATA_REMOVED} is true and
2160 * {@link #EXTRA_REPLACING} is false of that broadcast.
2161 *
2162 * <ul>
2163 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2164 * to the package.
2165 * </ul>
2166 *
2167 * <p class="note">This is a protected intent that can only be sent
2168 * by the system.
2169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_PACKAGE_FULLY_REMOVED
2172 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2173 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002174 * Broadcast Action: An existing application package has been changed (for
2175 * example, a component has been enabled or disabled). The data contains
2176 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002177 * <ul>
2178 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002179 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002180 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002181 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2182 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002183 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2190 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002191 * @hide
2192 * Broadcast Action: Ask system services if there is any reason to
2193 * restart the given package. The data contains the name of the
2194 * package.
2195 * <ul>
2196 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2197 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2198 * </ul>
2199 *
2200 * <p class="note">This is a protected intent that can only be sent
2201 * by the system.
2202 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002203 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002204 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2205 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2206 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002207 * Broadcast Action: The user has restarted a package, and all of its
2208 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002209 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002210 * be removed. Note that the restarted package does <em>not</em>
2211 * receive this broadcast.
2212 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002213 * <ul>
2214 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2215 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002216 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002217 * <p class="note">This is a protected intent that can only be sent
2218 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002219 */
2220 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2221 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2222 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002223 * Broadcast Action: The user has cleared the data of a package. This should
2224 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002225 * its persistent data is erased and this broadcast sent.
2226 * Note that the cleared package does <em>not</em>
2227 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002228 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002229 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2230 * package whose data was cleared is an uninstalled instant app, then the UID
2231 * will be -1. The platform keeps some meta-data associated with instant apps
2232 * after they are uninstalled.
2233 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2234 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002235 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002236 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002237 * <p class="note">This is a protected intent that can only be sent
2238 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002239 */
2240 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2241 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2242 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002243 * Broadcast Action: Packages have been suspended.
2244 * <p>Includes the following extras:
2245 * <ul>
2246 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2247 * </ul>
2248 *
2249 * <p class="note">This is a protected intent that can only be sent
2250 * by the system. It is only sent to registered receivers.
2251 */
2252 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2253 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2254 /**
2255 * Broadcast Action: Packages have been unsuspended.
2256 * <p>Includes the following extras:
2257 * <ul>
2258 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2259 * </ul>
2260 *
2261 * <p class="note">This is a protected intent that can only be sent
2262 * by the system. It is only sent to registered receivers.
2263 */
2264 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2265 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2266 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002267 * Broadcast Action: A user ID has been removed from the system. The user
2268 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002269 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002270 * <p class="note">This is a protected intent that can only be sent
2271 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002275
2276 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002277 * Broadcast Action: Sent to the installer package of an application when
2278 * that application is first launched (that is the first time it is moved
2279 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002280 *
2281 * <p class="note">This is a protected intent that can only be sent
2282 * by the system.
2283 */
2284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2285 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2286
2287 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002288 * Broadcast Action: Sent to the system package verifier when a package
2289 * needs to be verified. The data contains the package URI.
2290 * <p class="note">
2291 * This is a protected intent that can only be sent by the system.
2292 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002293 */
2294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2295 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2296
2297 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002298 * Broadcast Action: Sent to the system package verifier when a package is
2299 * verified. The data contains the package URI.
2300 * <p class="note">
2301 * This is a protected intent that can only be sent by the system.
2302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2305
2306 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002307 * Broadcast Action: Sent to the system intent filter verifier when an
2308 * intent filter needs to be verified. The data contains the filter data
2309 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002310 * <p class="note">
2311 * This is a protected intent that can only be sent by the system.
2312 * </p>
2313 *
2314 * @hide
2315 */
2316 @SystemApi
2317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2318 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2319
2320 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002321 * Broadcast Action: Resources for a set of packages (which were
2322 * previously unavailable) are currently
2323 * available since the media on which they exist is available.
2324 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2325 * list of packages whose availability changed.
2326 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2327 * list of uids of packages whose availability changed.
2328 * Note that the
2329 * packages in this list do <em>not</em> receive this broadcast.
2330 * The specified set of packages are now available on the system.
2331 * <p>Includes the following extras:
2332 * <ul>
2333 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2334 * whose resources(were previously unavailable) are currently available.
2335 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2336 * packages whose resources(were previously unavailable)
2337 * are currently available.
2338 * </ul>
2339 *
2340 * <p class="note">This is a protected intent that can only be sent
2341 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002342 */
2343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002344 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2345 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002346
2347 /**
2348 * Broadcast Action: Resources for a set of packages are currently
2349 * unavailable since the media on which they exist is unavailable.
2350 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2351 * list of packages whose availability changed.
2352 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2353 * list of uids of packages whose availability changed.
2354 * The specified set of packages can no longer be
2355 * launched and are practically unavailable on the system.
2356 * <p>Inclues the following extras:
2357 * <ul>
2358 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2359 * whose resources are no longer available.
2360 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2361 * whose resources are no longer available.
2362 * </ul>
2363 *
2364 * <p class="note">This is a protected intent that can only be sent
2365 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002366 */
2367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002368 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002369 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002370
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002371 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002372 * Broadcast Action: preferred activities have changed *explicitly*.
2373 *
2374 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2375 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2376 * be sent.
2377 *
2378 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2379 *
2380 * @hide
2381 */
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2384 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2385
2386
2387 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002388 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002389 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002390 * This should <em>only</em> be used to determine when the wallpaper
2391 * has changed to show the new wallpaper to the user. You should certainly
2392 * never, in response to this, change the wallpaper or other attributes of
2393 * it such as the suggested size. That would be crazy, right? You'd cause
2394 * all kinds of loops, especially if other apps are doing similar things,
2395 * right? Of course. So please don't do this.
2396 *
2397 * @deprecated Modern applications should use
2398 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2399 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2400 * shown behind their UI, rather than watching for this broadcast and
2401 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002402 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002403 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002404 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2405 /**
2406 * Broadcast Action: The current device {@link android.content.res.Configuration}
2407 * (orientation, locale, etc) has changed. When such a change happens, the
2408 * UIs (view hierarchy) will need to be rebuilt based on this new
2409 * information; for the most part, applications don't need to worry about
2410 * this, because the system will take care of stopping and restarting the
2411 * application to make sure it sees the new changes. Some system code that
2412 * can not be restarted will need to watch for this action and handle it
2413 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002414 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002415 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002416 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002417 * in manifests, only by explicitly registering for it with
2418 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2419 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002420 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002421 * <p class="note">This is a protected intent that can only be sent
2422 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002423 *
2424 * @see android.content.res.Configuration
2425 */
2426 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2427 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2428 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002429 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002430 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002431 * <p class="note">This is a protected intent that can only be sent
2432 * by the system.
2433 */
2434 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2435 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2436 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002437 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2438 * charging state, level, and other information about the battery.
2439 * See {@link android.os.BatteryManager} for documentation on the
2440 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002441 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002442 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002443 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002444 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002446 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2447 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2448 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2449 * broadcasts that are sent and can be received through manifest
2450 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002451 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002452 * <p class="note">This is a protected intent that can only be sent
2453 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002454 */
2455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2456 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2457 /**
2458 * Broadcast Action: Indicates low battery condition on the device.
2459 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002460 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002461 * <p class="note">This is a protected intent that can only be sent
2462 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 */
2464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2465 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2466 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002467 * Broadcast Action: Indicates the battery is now okay after being low.
2468 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2469 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002470 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002471 * <p class="note">This is a protected intent that can only be sent
2472 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002473 */
2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2475 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2476 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002477 * Broadcast Action: External power has been connected to the device.
2478 * This is intended for applications that wish to register specifically to this notification.
2479 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2480 * stay active to receive this notification. This action can be used to implement actions
2481 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002482 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002483 * <p class="note">This is a protected intent that can only be sent
2484 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002485 */
2486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002487 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002488 /**
2489 * Broadcast Action: External power has been removed from the device.
2490 * This is intended for applications that wish to register specifically to this notification.
2491 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2492 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002493 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002494 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002495 * <p class="note">This is a protected intent that can only be sent
2496 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002497 */
2498 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002499 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002500 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002501 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002502 * Broadcast Action: Device is shutting down.
2503 * This is broadcast when the device is being shut down (completely turned
2504 * off, not sleeping). Once the broadcast is complete, the final shutdown
2505 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002506 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002507 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002508 * <p class="note">This is a protected intent that can only be sent
2509 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002510 * <p>May include the following extras:
2511 * <ul>
2512 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2513 * shutdown is only for userspace processes. If not set, assumed to be false.
2514 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002515 */
2516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002517 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002518 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002519 * Activity Action: Start this activity to request system shutdown.
2520 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002521 * to request confirmation from the user before shutting down. The optional boolean
2522 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2523 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002524 *
2525 * <p class="note">This is a protected intent that can only be sent
2526 * by the system.
2527 *
2528 * {@hide}
2529 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002530 public static final String ACTION_REQUEST_SHUTDOWN
2531 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002532 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002533 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002534 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002535 * <p class="note">
2536 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002537 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002538 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2539 * or above, this broadcast will no longer be delivered to any
2540 * {@link BroadcastReceiver} defined in your manifest. Instead,
2541 * apps are strongly encouraged to use the improved
2542 * {@link Context#getCacheDir()} behavior so the system can
2543 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002546 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2548 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 * Broadcast Action: Indicates low storage space condition on the device no
2550 * longer exists
2551 * <p class="note">
2552 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002553 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002554 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2555 * or above, this broadcast will no longer be delivered to any
2556 * {@link BroadcastReceiver} defined in your manifest. Instead,
2557 * apps are strongly encouraged to use the improved
2558 * {@link Context#getCacheDir()} behavior so the system can
2559 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002560 */
2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002562 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002563 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2564 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002565 * Broadcast Action: A sticky broadcast that indicates a storage space full
2566 * condition on the device. This is intended for activities that want to be
2567 * able to fill the data partition completely, leaving only enough free
2568 * space to prevent system-wide SQLite failures.
2569 * <p class="note">
2570 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002571 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002572 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2573 * or above, this broadcast will no longer be delivered to any
2574 * {@link BroadcastReceiver} defined in your manifest. Instead,
2575 * apps are strongly encouraged to use the improved
2576 * {@link Context#getCacheDir()} behavior so the system can
2577 * automatically free up storage when needed.
2578 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002579 */
2580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002581 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002582 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2583 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002584 * Broadcast Action: Indicates storage space full condition on the device no
2585 * longer exists.
2586 * <p class="note">
2587 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002588 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002589 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2590 * or above, this broadcast will no longer be delivered to any
2591 * {@link BroadcastReceiver} defined in your manifest. Instead,
2592 * apps are strongly encouraged to use the improved
2593 * {@link Context#getCacheDir()} behavior so the system can
2594 * automatically free up storage when needed.
2595 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002596 */
2597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002598 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002599 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2600 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002601 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2602 * and package management should be started.
2603 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2604 * notification.
2605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2608 /**
2609 * Broadcast Action: The device has entered USB Mass Storage mode.
2610 * This is used mainly for the USB Settings panel.
2611 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2612 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002613 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002614 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002615 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002617 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2618
2619 /**
2620 * Broadcast Action: The device has exited USB Mass Storage mode.
2621 * This is used mainly for the USB Settings panel.
2622 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2623 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002624 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002625 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002626 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002628 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2629
2630 /**
2631 * Broadcast Action: External media has been removed.
2632 * The path to the mount point for the removed media is contained in the Intent.mData field.
2633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2636
2637 /**
2638 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002639 * 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 -07002640 */
2641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2642 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2643
2644 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002645 * Broadcast Action: External media is present, and being disk-checked
2646 * 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 -08002647 */
2648 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2649 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2650
2651 /**
2652 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2653 * 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 -08002654 */
2655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2656 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2657
2658 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002659 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002660 * 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 -07002661 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2662 * media was mounted read only.
2663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2666
2667 /**
2668 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002669 * 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 -07002670 */
2671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2672 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2673
2674 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002675 * Broadcast Action: External media is no longer being shared via USB mass storage.
2676 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2677 *
2678 * @hide
2679 */
2680 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2681
2682 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002683 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2684 * The path to the mount point for the removed media is contained in the Intent.mData field.
2685 */
2686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2687 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2688
2689 /**
2690 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002691 * 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 -07002692 */
2693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2695
2696 /**
2697 * Broadcast Action: User has expressed the desire to remove the external storage media.
2698 * Applications should close all files they have open within the mount point when they receive this intent.
2699 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2700 */
2701 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2702 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2703
2704 /**
2705 * Broadcast Action: The media scanner has started scanning a directory.
2706 * The path to the directory being scanned is contained in the Intent.mData field.
2707 */
2708 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2709 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2710
2711 /**
2712 * Broadcast Action: The media scanner has finished scanning a directory.
2713 * The path to the scanned directory is contained in the Intent.mData field.
2714 */
2715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2716 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2717
2718 /**
2719 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2720 * The path to the file is contained in the Intent.mData field.
2721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2724
2725 /**
2726 * Broadcast Action: The "Media Button" was pressed. Includes a single
2727 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2728 * caused the broadcast.
2729 */
2730 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2731 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2732
2733 /**
2734 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2735 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2736 * caused the broadcast.
2737 */
2738 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2739 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2740
2741 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2742 // location; they are not general-purpose actions.
2743
2744 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002745 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002746 */
2747 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2748 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2749 "android.intent.action.GTALK_CONNECTED";
2750
2751 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002752 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002753 */
2754 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2755 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2756 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002757
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002758 /**
2759 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_INPUT_METHOD_CHANGED =
2763 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002764
2765 /**
2766 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2767 * more radios have been turned off or on. The intent will have the following extra value:</p>
2768 * <ul>
2769 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2770 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2771 * turned off</li>
2772 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002773 *
Peng Xua35b5532016-01-20 00:05:45 -08002774 * <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 -07002775 */
2776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2777 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2778
2779 /**
2780 * Broadcast Action: Some content providers have parts of their namespace
2781 * where they publish new events or items that the user may be especially
2782 * interested in. For these things, they may broadcast this action when the
2783 * set of interesting items change.
2784 *
2785 * For example, GmailProvider sends this notification when the set of unread
2786 * mail in the inbox changes.
2787 *
2788 * <p>The data of the intent identifies which part of which provider
2789 * changed. When queried through the content resolver, the data URI will
2790 * return the data set in question.
2791 *
2792 * <p>The intent will have the following extra values:
2793 * <ul>
2794 * <li><em>count</em> - The number of items in the data set. This is the
2795 * same as the number of items in the cursor returned by querying the
2796 * data URI. </li>
2797 * </ul>
2798 *
2799 * This intent will be sent at boot (if the count is non-zero) and when the
2800 * data set changes. It is possible for the data set to change without the
2801 * count changing (for example, if a new unread message arrives in the same
2802 * sync operation in which a message is archived). The phone should still
2803 * ring/vibrate/etc as normal in this case.
2804 */
2805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2806 public static final String ACTION_PROVIDER_CHANGED =
2807 "android.intent.action.PROVIDER_CHANGED";
2808
2809 /**
2810 * Broadcast Action: Wired Headset plugged in or unplugged.
2811 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002812 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2813 * and documentation.
2814 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002815 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002816 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002817 */
2818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002819 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002820
2821 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002822 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2823 * <ul>
2824 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2825 * </ul>
2826 *
2827 * <p class="note">This is a protected intent that can only be sent
2828 * by the system.
2829 *
2830 * @hide
2831 */
2832 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2833 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2834 = "android.intent.action.ADVANCED_SETTINGS";
2835
2836 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002837 * Broadcast Action: Sent after application restrictions are changed.
2838 *
2839 * <p class="note">This is a protected intent that can only be sent
2840 * by the system.</p>
2841 */
2842 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2843 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2844 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2845
2846 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002847 * Broadcast Action: An outgoing call is about to be placed.
2848 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002849 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002850 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002851 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002852 * the phone number originally intended to be dialed.</li>
2853 * </ul>
2854 * <p>Once the broadcast is finished, the resultData is used as the actual
2855 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002856 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002857 * outgoing call in turn: for example, a parental control application
2858 * might verify that the user is authorized to place the call at that
2859 * time, then a number-rewriting application might add an area code if
2860 * one was not specified.</p>
2861 * <p>For consistency, any receiver whose purpose is to prohibit phone
2862 * calls should have a priority of 0, to ensure it will see the final
2863 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002864 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 * should have a positive priority.
2866 * Negative priorities are reserved for the system for this broadcast;
2867 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002868 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2869 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002870 * <p>Emergency calls cannot be intercepted using this mechanism, and
2871 * other calls cannot be modified to call emergency numbers using this
2872 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002873 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2874 * call to use their own service instead. Those apps should first prevent
2875 * the call from being placed by setting resultData to <code>null</code>
2876 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002877 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002878 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2879 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002880 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002881 * <p class="note">This is a protected intent that can only be sent
2882 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002883 */
2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2885 public static final String ACTION_NEW_OUTGOING_CALL =
2886 "android.intent.action.NEW_OUTGOING_CALL";
2887
2888 /**
2889 * Broadcast Action: Have the device reboot. This is only for use by
2890 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002891 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002892 * <p class="note">This is a protected intent that can only be sent
2893 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002894 */
2895 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2896 public static final String ACTION_REBOOT =
2897 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002898
Wei Huang97ecc9c2009-05-11 17:44:20 -07002899 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002900 * Broadcast Action: A sticky broadcast for changes in the physical
2901 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002902 *
2903 * <p>The intent will have the following extra values:
2904 * <ul>
2905 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002906 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002907 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002908 * <p>This is intended for monitoring the current physical dock state.
2909 * See {@link android.app.UiModeManager} for the normal API dealing with
2910 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002911 */
2912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2913 public static final String ACTION_DOCK_EVENT =
2914 "android.intent.action.DOCK_EVENT";
2915
2916 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002917 * Broadcast Action: A broadcast when idle maintenance can be started.
2918 * This means that the user is not interacting with the device and is
2919 * not expected to do so soon. Typical use of the idle maintenance is
2920 * to perform somehow expensive tasks that can be postponed at a moment
2921 * when they will not degrade user experience.
2922 * <p>
2923 * <p class="note">In order to keep the device responsive in case of an
2924 * unexpected user interaction, implementations of a maintenance task
2925 * should be interruptible. In such a scenario a broadcast with action
2926 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2927 * should not do the maintenance work in
2928 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2929 * maintenance service by {@link Context#startService(Intent)}. Also
2930 * you should hold a wake lock while your maintenance service is running
2931 * to prevent the device going to sleep.
2932 * </p>
2933 * <p>
2934 * <p class="note">This is a protected intent that can only be sent by
2935 * the system.
2936 * </p>
2937 *
2938 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002939 *
2940 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002941 */
2942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2943 public static final String ACTION_IDLE_MAINTENANCE_START =
2944 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2945
2946 /**
2947 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2948 * This means that the user was not interacting with the device as a result
2949 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2950 * was sent and now the user started interacting with the device. Typical
2951 * use of the idle maintenance is to perform somehow expensive tasks that
2952 * can be postponed at a moment when they will not degrade user experience.
2953 * <p>
2954 * <p class="note">In order to keep the device responsive in case of an
2955 * unexpected user interaction, implementations of a maintenance task
2956 * should be interruptible. Hence, on receiving a broadcast with this
2957 * action, the maintenance task should be interrupted as soon as possible.
2958 * In other words, you should not do the maintenance work in
2959 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2960 * maintenance service that was started on receiving of
2961 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2962 * lock you acquired when your maintenance service started.
2963 * </p>
2964 * <p class="note">This is a protected intent that can only be sent
2965 * by the system.
2966 *
2967 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002968 *
2969 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002970 */
2971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2972 public static final String ACTION_IDLE_MAINTENANCE_END =
2973 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2974
2975 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002976 * Broadcast Action: a remote intent is to be broadcasted.
2977 *
2978 * A remote intent is used for remote RPC between devices. The remote intent
2979 * is serialized and sent from one device to another device. The receiving
2980 * device parses the remote intent and broadcasts it. Note that anyone can
2981 * broadcast a remote intent. However, if the intent receiver of the remote intent
2982 * does not trust intent broadcasts from arbitrary intent senders, it should require
2983 * the sender to hold certain permissions so only trusted sender's broadcast will be
2984 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002985 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002986 */
2987 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002988 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002989
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002990 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002991 * Broadcast Action: This is broadcast once when the user is booting after a
2992 * system update. It can be used to perform cleanup or upgrades after a
2993 * system update.
2994 * <p>
2995 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2996 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2997 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2998 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002999 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003000 * @hide
3001 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003002 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003003 public static final String ACTION_PRE_BOOT_COMPLETED =
3004 "android.intent.action.PRE_BOOT_COMPLETED";
3005
Amith Yamasani13593602012-03-22 16:16:17 -07003006 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003007 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003008 * on restricted users. The broadcast intent contains an extra
3009 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3010 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3011 * String[] depending on the restriction type.<p/>
3012 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003013 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3014 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3015 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003016 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3017 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003018 * @see RestrictionEntry
3019 */
3020 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3021 "android.intent.action.GET_RESTRICTION_ENTRIES";
3022
3023 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003024 * Sent the first time a user is starting, to allow system apps to
3025 * perform one time initialization. (This will not be seen by third
3026 * party applications because a newly initialized user does not have any
3027 * third party applications installed for it.) This is sent early in
3028 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003029 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3030 * broadcast, since it is part of a visible user interaction; be as quick
3031 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003032 */
3033 public static final String ACTION_USER_INITIALIZE =
3034 "android.intent.action.USER_INITIALIZE";
3035
3036 /**
3037 * Sent when a user switch is happening, causing the process's user to be
3038 * brought to the foreground. This is only sent to receivers registered
3039 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3040 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003041 * foreground. This is sent as a foreground
3042 * broadcast, since it is part of a visible user interaction; be as quick
3043 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003044 */
3045 public static final String ACTION_USER_FOREGROUND =
3046 "android.intent.action.USER_FOREGROUND";
3047
3048 /**
3049 * Sent when a user switch is happening, causing the process's user to be
3050 * sent to the background. This is only sent to receivers registered
3051 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3052 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003053 * background. This is sent as a foreground
3054 * broadcast, since it is part of a visible user interaction; be as quick
3055 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003056 */
3057 public static final String ACTION_USER_BACKGROUND =
3058 "android.intent.action.USER_BACKGROUND";
3059
3060 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003061 * Broadcast sent to the system when a user is added. Carries an extra
3062 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3063 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003064 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003065 * @hide
3066 */
3067 public static final String ACTION_USER_ADDED =
3068 "android.intent.action.USER_ADDED";
3069
3070 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003071 * Broadcast sent by the system when a user is started. Carries an extra
3072 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003073 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003074 * that has been started. This is sent as a foreground
3075 * broadcast, since it is part of a visible user interaction; be as quick
3076 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003077 * @hide
3078 */
3079 public static final String ACTION_USER_STARTED =
3080 "android.intent.action.USER_STARTED";
3081
3082 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003083 * Broadcast sent when a user is in the process of starting. Carries an extra
3084 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3085 * sent to registered receivers, not manifest receivers. It is sent to all
3086 * users (including the one that is being started). You must hold
3087 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3088 * this broadcast. This is sent as a background broadcast, since
3089 * its result is not part of the primary UX flow; to safely keep track of
3090 * started/stopped state of a user you can use this in conjunction with
3091 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3092 * other user state broadcasts since those are foreground broadcasts so can
3093 * execute in a different order.
3094 * @hide
3095 */
3096 public static final String ACTION_USER_STARTING =
3097 "android.intent.action.USER_STARTING";
3098
3099 /**
3100 * Broadcast sent when a user is going to be stopped. Carries an extra
3101 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3102 * sent to registered receivers, not manifest receivers. It is sent to all
3103 * users (including the one that is being stopped). You must hold
3104 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3105 * this broadcast. The user will not stop until all receivers have
3106 * handled the broadcast. This is sent as a background broadcast, since
3107 * its result is not part of the primary UX flow; to safely keep track of
3108 * started/stopped state of a user you can use this in conjunction with
3109 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3110 * other user state broadcasts since those are foreground broadcasts so can
3111 * execute in a different order.
3112 * @hide
3113 */
3114 public static final String ACTION_USER_STOPPING =
3115 "android.intent.action.USER_STOPPING";
3116
3117 /**
3118 * Broadcast sent to the system when a user is stopped. Carries an extra
3119 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3120 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3121 * specific package. This is only sent to registered receivers, not manifest
3122 * receivers. It is sent to all running users <em>except</em> the one that
3123 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003124 * @hide
3125 */
3126 public static final String ACTION_USER_STOPPED =
3127 "android.intent.action.USER_STOPPED";
3128
3129 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003130 * 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 -07003131 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003132 * one that has been removed. The user will not be completely removed until all receivers have
3133 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003134 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003135 * @hide
3136 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003137 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003138 public static final String ACTION_USER_REMOVED =
3139 "android.intent.action.USER_REMOVED";
3140
3141 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003142 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003143 * the userHandle of the user to become the current one. This is only sent to
3144 * registered receivers, not manifest receivers. It is sent to all running users.
3145 * You must hold
3146 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003147 * @hide
3148 */
3149 public static final String ACTION_USER_SWITCHED =
3150 "android.intent.action.USER_SWITCHED";
3151
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003152 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003153 * Broadcast Action: Sent when the credential-encrypted private storage has
3154 * become unlocked for the target user. This is only sent to registered
3155 * receivers, not manifest receivers.
3156 */
3157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3158 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3159
3160 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003161 * Broadcast sent to the system when a user's information changes. Carries an extra
3162 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003163 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003164 * @hide
3165 */
3166 public static final String ACTION_USER_INFO_CHANGED =
3167 "android.intent.action.USER_INFO_CHANGED";
3168
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003169 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003170 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3171 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003172 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3173 * that need to display merged content across both primary and managed profiles need to
3174 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003175 * not manifest receivers.
3176 */
3177 public static final String ACTION_MANAGED_PROFILE_ADDED =
3178 "android.intent.action.MANAGED_PROFILE_ADDED";
3179
3180 /**
3181 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003182 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3183 * Only applications (for example Launchers) that need to display merged content across both
3184 * primary and managed profiles need to worry about this broadcast. This is only sent to
3185 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003186 */
3187 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3188 "android.intent.action.MANAGED_PROFILE_REMOVED";
3189
3190 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003191 * Broadcast sent to the primary user when the credential-encrypted private storage for
3192 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3193 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3194 * Launchers) that need to display merged content across both primary and managed profiles
3195 * need to worry about this broadcast. This is only sent to registered receivers,
3196 * not manifest receivers.
3197 */
3198 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3199 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3200
3201 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003202 * Broadcast sent to the primary user when an associated managed profile has become available.
3203 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003204 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3205 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3206 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003207 */
Rubin Xue95057a2016-04-01 16:49:25 +01003208 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3209 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3210
3211 /**
3212 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3213 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3214 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3215 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3216 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3217 */
3218 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3219 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003220
3221 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003222 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3223 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3224 * the device was locked or unlocked.
3225 *
3226 * This is only sent to registered receivers.
3227 *
3228 * @hide
3229 */
3230 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3231 "android.intent.action.DEVICE_LOCKED_CHANGED";
3232
3233 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003234 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3235 */
3236 public static final String ACTION_QUICK_CLOCK =
3237 "android.intent.action.QUICK_CLOCK";
3238
Michael Wright0087a142013-02-05 16:29:39 -08003239 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003240 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003241 * @hide
3242 */
3243 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003244 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003245
Justin Kohd378ad72013-04-01 12:18:26 -07003246 /**
3247 * Broadcast Action: A global button was pressed. Includes a single
3248 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3249 * caused the broadcast.
3250 * @hide
3251 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003252 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003253 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3254
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003255 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003256 * Broadcast Action: Sent when media resource is granted.
3257 * <p>
3258 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3259 * granted.
3260 * </p>
3261 * <p class="note">
3262 * This is a protected intent that can only be sent by the system.
3263 * </p>
3264 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003265 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003266 * </p>
3267 *
3268 * @hide
3269 */
3270 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3271 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3272
3273 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003274 * Broadcast Action: An overlay package has changed. The data contains the
3275 * name of the overlay package which has changed. This is broadcast on all
3276 * changes to the OverlayInfo returned by {@link
3277 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3278 * most common change is a state change that will change whether the
3279 * overlay is enabled or not.
3280 * @hide
3281 */
3282 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3283
3284 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003285 * Activity Action: Allow the user to select and return one or more existing
3286 * documents. When invoked, the system will display the various
3287 * {@link DocumentsProvider} instances installed on the device, letting the
3288 * user interactively navigate through them. These documents include local
3289 * media, such as photos and video, and documents provided by installed
3290 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003291 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003292 * Each document is represented as a {@code content://} URI backed by a
3293 * {@link DocumentsProvider}, which can be opened as a stream with
3294 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3295 * {@link android.provider.DocumentsContract.Document} metadata.
3296 * <p>
3297 * All selected documents are returned to the calling application with
3298 * persistable read and write permission grants. If you want to maintain
3299 * access to the documents across device reboots, you need to explicitly
3300 * take the persistable permissions using
3301 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3302 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003303 * Callers must indicate the acceptable document MIME types through
3304 * {@link #setType(String)}. For example, to select photos, use
3305 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3306 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3307 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003308 * <p>
3309 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003310 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3311 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003312 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003313 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3314 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003315 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003316 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003317 * Callers can set a document URI through
3318 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3319 * location of documents navigator. System will do its best to launch the
3320 * navigator in the specified document if it's a folder, or the folder that
3321 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003322 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003323 * Output: The URI of the item that was picked, returned in
3324 * {@link #getData()}. This must be a {@code content://} URI so that any
3325 * receiver can access it. If multiple documents were selected, they are
3326 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003327 *
3328 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003329 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003330 * @see #ACTION_CREATE_DOCUMENT
3331 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003332 */
3333 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3334 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3335
3336 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003337 * Activity Action: Allow the user to create a new document. When invoked,
3338 * the system will display the various {@link DocumentsProvider} instances
3339 * installed on the device, letting the user navigate through them. The
3340 * returned document may be a newly created document with no content, or it
3341 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003342 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003343 * Each document is represented as a {@code content://} URI backed by a
3344 * {@link DocumentsProvider}, which can be opened as a stream with
3345 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3346 * {@link android.provider.DocumentsContract.Document} metadata.
3347 * <p>
3348 * Callers must indicate the concrete MIME type of the document being
3349 * created by setting {@link #setType(String)}. This MIME type cannot be
3350 * changed after the document is created.
3351 * <p>
3352 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3353 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003354 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003355 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3356 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003357 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003358 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003359 * Callers can set a document URI through
3360 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3361 * location of documents navigator. System will do its best to launch the
3362 * navigator in the specified document if it's a folder, or the folder that
3363 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003364 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003365 * Output: The URI of the item that was created. This must be a
3366 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003367 *
3368 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003369 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003370 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003371 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003372 */
3373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3374 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3375
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003376 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003377 * Activity Action: Allow the user to pick a directory subtree. When
3378 * invoked, the system will display the various {@link DocumentsProvider}
3379 * instances installed on the device, letting the user navigate through
3380 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003381 * <p>
3382 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003383 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3384 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3385 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003386 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003387 * Callers can set a document URI through
3388 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3389 * location of documents navigator. System will do its best to launch the
3390 * navigator in the specified document if it's a folder, or the folder that
3391 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003392 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003393 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003394 *
3395 * @see DocumentsContract
3396 */
3397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003398 public static final String
3399 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003400
Felipe Lemec7b1f892016-01-15 15:02:31 -08003401 /**
Peng Xua35b5532016-01-20 00:05:45 -08003402 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3403 * exisiting sensor being disconnected.
3404 *
3405 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3406 *
3407 * {@hide}
3408 */
3409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3410 public static final String
3411 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3412
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003413 /**
Sam Line707f832017-04-13 17:00:55 -07003414 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003415 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003416 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003417 */
3418 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003419 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003420 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3421
Christopher Tate6597e342015-02-17 12:15:25 -08003422 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003423 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3424 * is about to be performed.
3425 * @hide
3426 */
3427 @SystemApi
3428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3429 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3430 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3431
3432 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003433 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3434 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3435 *
3436 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3437 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003438 * @hide
3439 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003440 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003441 public static final String EXTRA_FORCE_MASTER_CLEAR =
3442 "android.intent.extra.FORCE_MASTER_CLEAR";
3443
3444 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003445 * A broadcast action to trigger a factory reset.
3446 *
3447 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3448 *
3449 * <p>Not for use by third-party applications.
3450 *
3451 * @see #EXTRA_FORCE_MASTER_CLEAR
3452 *
3453 * {@hide}
3454 */
3455 @SystemApi
3456 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3457 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3458
3459 /**
3460 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3461 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3462 *
3463 * <p>Not for use by third-party applications.
3464 *
3465 * @hide
3466 */
3467 @SystemApi
3468 public static final String EXTRA_FORCE_FACTORY_RESET =
3469 "android.intent.extra.FORCE_FACTORY_RESET";
3470
3471 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003472 * Broadcast action: report that a settings element is being restored from backup. The intent
3473 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3474 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3475 * is the value of that settings entry prior to the restore operation, and
3476 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3477 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3478 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003479 *
3480 * <p>This broadcast is sent only for settings provider entries known to require special handling
3481 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3482 * the provider's backup agent implementation.
3483 *
3484 * @see #EXTRA_SETTING_NAME
3485 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3486 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003487 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003488 * {@hide}
3489 */
3490 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3491
3492 /** {@hide} */
3493 public static final String EXTRA_SETTING_NAME = "setting_name";
3494 /** {@hide} */
3495 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3496 /** {@hide} */
3497 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003498 /** {@hide} */
3499 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003500
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003501 /**
3502 * Activity Action: Process a piece of text.
3503 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3504 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3505 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3506 */
3507 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3508 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003509
3510 /**
3511 * Broadcast Action: The sim card state has changed.
3512 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3513 * because TelephonyIntents is an internal class.
3514 * @hide
3515 */
3516 @SystemApi
3517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3518 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3519
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003520 /**
fionaxu90fee272017-03-31 12:45:12 -07003521 * Broadcast Action: indicate that the phone service state has changed.
3522 * The intent will have the following extra values:</p>
3523 * <p>
3524 * @see #EXTRA_VOICE_REG_STATE
3525 * @see #EXTRA_DATA_REG_STATE
3526 * @see #EXTRA_VOICE_ROAMING_TYPE
3527 * @see #EXTRA_DATA_ROAMING_TYPE
3528 * @see #EXTRA_OPERATOR_ALPHA_LONG
3529 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3530 * @see #EXTRA_OPERATOR_NUMERIC
3531 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3532 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3533 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3534 * @see #EXTRA_MANUAL
3535 * @see #EXTRA_VOICE_RADIO_TECH
3536 * @see #EXTRA_DATA_RADIO_TECH
3537 * @see #EXTRA_CSS_INDICATOR
3538 * @see #EXTRA_NETWORK_ID
3539 * @see #EXTRA_SYSTEM_ID
3540 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3541 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3542 * @see #EXTRA_EMERGENCY_ONLY
3543 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3544 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3545 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3546 *
3547 * <p class="note">
3548 * Requires the READ_PHONE_STATE permission.
3549 *
3550 * <p class="note">This is a protected intent that can only be sent by the system.
3551 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003552 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003553 */
3554 @Deprecated
3555 @SystemApi
3556 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3557 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3558
3559 /**
3560 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3561 * state.
3562 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3563 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3564 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3565 * @see android.telephony.ServiceState#STATE_POWER_OFF
3566 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003567 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003568 */
3569 @Deprecated
3570 @SystemApi
3571 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3572
3573 /**
3574 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3575 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3576 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3577 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3578 * @see android.telephony.ServiceState#STATE_POWER_OFF
3579 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003580 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003581 */
3582 @Deprecated
3583 @SystemApi
3584 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3585
3586 /**
3587 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3588 * type.
3589 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003590 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003591 */
3592 @Deprecated
3593 @SystemApi
3594 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3595
3596 /**
3597 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3598 * type.
3599 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003600 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003601 */
3602 @Deprecated
3603 @SystemApi
3604 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3605
3606 /**
3607 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3608 * registered voice operator name in long alphanumeric format.
3609 * {@code null} if the operator name is not known or unregistered.
3610 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003611 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003612 */
3613 @Deprecated
3614 @SystemApi
3615 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3616
3617 /**
3618 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3619 * registered voice operator name in short alphanumeric format.
3620 * {@code null} if the operator name is not known or unregistered.
3621 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003622 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003623 */
3624 @Deprecated
3625 @SystemApi
3626 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3627
3628 /**
3629 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3630 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3631 * network.
3632 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003633 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003634 */
3635 @Deprecated
3636 @SystemApi
3637 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3638
3639 /**
3640 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3641 * registered data operator name in long alphanumeric format.
3642 * {@code null} if the operator name is not known or unregistered.
3643 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003644 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003645 */
3646 @Deprecated
3647 @SystemApi
3648 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3649
3650 /**
3651 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3652 * registered data operator name in short alphanumeric format.
3653 * {@code null} if the operator name is not known or unregistered.
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_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3660
3661 /**
3662 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3663 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3664 * data operator.
3665 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003666 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003667 */
3668 @Deprecated
3669 @SystemApi
3670 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3671
3672 /**
3673 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3674 * network selection mode is manual.
3675 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3676 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003677 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003678 */
3679 @Deprecated
3680 @SystemApi
3681 public static final String EXTRA_MANUAL = "manual";
3682
3683 /**
3684 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3685 * radio technology.
3686 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003687 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003688 */
3689 @Deprecated
3690 @SystemApi
3691 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3692
3693 /**
3694 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3695 * radio technology.
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_DATA_RADIO_TECH = "dataRadioTechnology";
3702
3703 /**
3704 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3705 * support on CDMA network.
3706 * Will be {@code true} if support, {@code false} otherwise.
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_CSS_INDICATOR = "cssIndicator";
3713
3714 /**
3715 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3716 * id. {@code Integer.MAX_VALUE} if unknown.
3717 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003718 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003719 */
3720 @Deprecated
3721 @SystemApi
3722 public static final String EXTRA_NETWORK_ID = "networkId";
3723
3724 /**
3725 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3726 * {@code Integer.MAX_VALUE} if unknown.
3727 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003728 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003729 */
3730 @Deprecated
3731 @SystemApi
3732 public static final String EXTRA_SYSTEM_ID = "systemId";
3733
3734 /**
3735 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3736 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3737 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003738 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003739 */
3740 @Deprecated
3741 @SystemApi
3742 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3743
3744 /**
3745 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3746 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3747 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003748 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003749 */
3750 @Deprecated
3751 @SystemApi
3752 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3753
3754 /**
3755 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3756 * only mode.
3757 * {@code true} if in emergency only mode, {@code false} otherwise.
3758 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003759 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003760 */
3761 @Deprecated
3762 @SystemApi
3763 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3764
3765 /**
3766 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3767 * registration state is roaming.
3768 * {@code true} if registration indicates roaming, {@code false} otherwise
3769 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003770 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003771 */
3772 @Deprecated
3773 @SystemApi
3774 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3775 "isDataRoamingFromRegistration";
3776
3777 /**
3778 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3779 * aggregation is in use.
3780 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3781 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003782 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003783 */
3784 @Deprecated
3785 @SystemApi
3786 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3787
3788 /**
3789 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3790 * is reduced from the rsrp threshold while calculating signal strength level.
3791 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003792 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003793 */
3794 @Deprecated
3795 @SystemApi
3796 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3797
3798 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003799 * The name of the extra used to define the text to be processed, as a
3800 * CharSequence. Note that this may be a styled CharSequence, so you must use
3801 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003802 */
3803 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3804 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003805 * 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 +00003806 */
3807 public static final String EXTRA_PROCESS_TEXT_READONLY =
3808 "android.intent.extra.PROCESS_TEXT_READONLY";
3809
Bryce Leebc58f592015-09-25 16:43:01 -07003810 /**
3811 * Broadcast action: reports when a new thermal event has been reached. When the device
3812 * is reaching its maximum temperatue, the thermal level reported
3813 * {@hide}
3814 */
3815 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3816 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3817
3818 /** {@hide} */
3819 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3820
3821 /**
3822 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003823 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003824 * {@hide}
3825 */
3826 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3827
3828 /**
3829 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003830 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003831 * {@hide}
3832 */
3833 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3834
3835 /**
3836 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003837 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003838 * {@hide}
3839 */
3840 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3841
3842
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003843 // ---------------------------------------------------------------------
3844 // ---------------------------------------------------------------------
3845 // Standard intent categories (see addCategory()).
3846
3847 /**
3848 * Set if the activity should be an option for the default action
3849 * (center press) to perform on a piece of data. Setting this will
3850 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003851 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003852 * Intent when initiating an action -- it is for use in intent filters
3853 * specified in packages.
3854 */
3855 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3856 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3857 /**
3858 * Activities that can be safely invoked from a browser must support this
3859 * category. For example, if the user is viewing a web page or an e-mail
3860 * and clicks on a link in the text, the Intent generated execute that
3861 * link will require the BROWSABLE category, so that only activities
3862 * supporting this category will be considered as possible actions. By
3863 * supporting this category, you are promising that there is nothing
3864 * damaging (without user intervention) that can happen by invoking any
3865 * matching Intent.
3866 */
3867 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3868 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3869 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003870 * Categories for activities that can participate in voice interaction.
3871 * An activity that supports this category must be prepared to run with
3872 * no UI shown at all (though in some case it may have a UI shown), and
3873 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3874 */
3875 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3876 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3877 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003878 * Set if the activity should be considered as an alternative action to
3879 * the data the user is currently viewing. See also
3880 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3881 * applies to the selection in a list of items.
3882 *
3883 * <p>Supporting this category means that you would like your activity to be
3884 * displayed in the set of alternative things the user can do, usually as
3885 * part of the current activity's options menu. You will usually want to
3886 * include a specific label in the &lt;intent-filter&gt; of this action
3887 * describing to the user what it does.
3888 *
3889 * <p>The action of IntentFilter with this category is important in that it
3890 * describes the specific action the target will perform. This generally
3891 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3892 * a specific name such as "com.android.camera.action.CROP. Only one
3893 * alternative of any particular action will be shown to the user, so using
3894 * a specific action like this makes sure that your alternative will be
3895 * displayed while also allowing other applications to provide their own
3896 * overrides of that particular action.
3897 */
3898 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3899 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3900 /**
3901 * Set if the activity should be considered as an alternative selection
3902 * action to the data the user has currently selected. This is like
3903 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3904 * of items from which the user can select, giving them alternatives to the
3905 * default action that will be performed on it.
3906 */
3907 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3908 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3909 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003910 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003911 */
3912 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3913 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3914 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003915 * Should be displayed in the top-level launcher.
3916 */
3917 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3918 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3919 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003920 * Indicates an activity optimized for Leanback mode, and that should
3921 * be displayed in the Leanback launcher.
3922 */
3923 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3924 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3925 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003926 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3927 * @hide
3928 */
3929 @SystemApi
3930 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3931 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003932 * Provides information about the package it is in; typically used if
3933 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3934 * a front-door to the user without having to be shown in the all apps list.
3935 */
3936 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3937 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3938 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003939 * This is the home activity, that is the first activity that is displayed
3940 * when the device boots.
3941 */
3942 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3943 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3944 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003945 * This is the home activity that is displayed when the device is finished setting up and ready
3946 * for use.
3947 * @hide
3948 */
3949 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3950 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3951 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003952 * This is the setup wizard activity, that is the first activity that is displayed
3953 * when the user sets up the device for the first time.
3954 * @hide
3955 */
3956 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3957 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3958 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07003959 * This is the home activity, that is the activity that serves as the launcher app
3960 * from there the user can start other apps. Often components with lower/higher
3961 * priority intent filters handle the home intent, for example SetupWizard, to
3962 * setup the device and we need to be able to distinguish the home app from these
3963 * setup helpers.
3964 * @hide
3965 */
3966 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3967 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
3968 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003969 * This activity is a preference panel.
3970 */
3971 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3972 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3973 /**
3974 * This activity is a development preference panel.
3975 */
3976 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3977 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3978 /**
3979 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003980 */
3981 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3982 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3983 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003984 * This activity allows the user to browse and download new applications.
3985 */
3986 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3987 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3988 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003989 * This activity may be exercised by the monkey or other automated test tools.
3990 */
3991 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3992 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3993 /**
3994 * To be used as a test (not part of the normal user experience).
3995 */
3996 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3997 /**
3998 * To be used as a unit test (run through the Test Harness).
3999 */
4000 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4001 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004002 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004003 * experience).
4004 */
4005 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004006
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004007 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004008 * Used to indicate that an intent only wants URIs that can be opened with
4009 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4010 * must support at least the columns defined in {@link OpenableColumns} when
4011 * queried.
4012 *
4013 * @see #ACTION_GET_CONTENT
4014 * @see #ACTION_OPEN_DOCUMENT
4015 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004016 */
4017 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4018 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4019
4020 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004021 * Used to indicate that an intent filter can accept files which are not necessarily
4022 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4023 * at least streamable via
4024 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4025 * using one of the stream types exposed via
4026 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4027 *
4028 * @see #ACTION_SEND
4029 * @see #ACTION_SEND_MULTIPLE
4030 */
4031 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4032 public static final String CATEGORY_TYPED_OPENABLE =
4033 "android.intent.category.TYPED_OPENABLE";
4034
4035 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004036 * To be used as code under test for framework instrumentation tests.
4037 */
4038 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4039 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004040 /**
4041 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004042 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4043 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004044 */
4045 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4046 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4047 /**
4048 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004049 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4050 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004051 */
4052 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4053 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004054 /**
4055 * An activity to run when device is inserted into a analog (low end) dock.
4056 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4057 * information, see {@link android.app.UiModeManager}.
4058 */
4059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4060 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4061
4062 /**
4063 * An activity to run when device is inserted into a digital (high end) dock.
4064 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4065 * information, see {@link android.app.UiModeManager}.
4066 */
4067 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4068 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004069
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004070 /**
4071 * Used to indicate that the activity can be used in a car environment.
4072 */
4073 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4074 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4075
Zak Cohendb6ca492017-01-26 14:09:00 -08004076 /**
4077 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4078 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4079 * information, see {@link android.app.UiModeManager}.
4080 */
4081 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4082 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004083 // ---------------------------------------------------------------------
4084 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004085 // Application launch intent categories (see addCategory()).
4086
4087 /**
4088 * Used with {@link #ACTION_MAIN} to launch the browser application.
4089 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004090 * <p>NOTE: This should not be used as the primary key of an Intent,
4091 * since it will not result in the app launching with the correct
4092 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004093 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004094 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004095 */
4096 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4097 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4098
4099 /**
4100 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4101 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004102 * <p>NOTE: This should not be used as the primary key of an Intent,
4103 * since it will not result in the app launching with the correct
4104 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004105 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004106 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004107 */
4108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4109 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4110
4111 /**
4112 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4113 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004114 * <p>NOTE: This should not be used as the primary key of an Intent,
4115 * since it will not result in the app launching with the correct
4116 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004117 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004118 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004119 */
4120 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4121 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4122
4123 /**
4124 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4125 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004126 * <p>NOTE: This should not be used as the primary key of an Intent,
4127 * since it will not result in the app launching with the correct
4128 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004129 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004130 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004131 */
4132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4133 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4134
4135 /**
4136 * Used with {@link #ACTION_MAIN} to launch the email application.
4137 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004138 * <p>NOTE: This should not be used as the primary key of an Intent,
4139 * since it will not result in the app launching with the correct
4140 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004141 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004142 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004143 */
4144 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4145 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4146
4147 /**
4148 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4149 * The activity should be able to view and manipulate image and video files
4150 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004151 * <p>NOTE: This should not be used as the primary key of an Intent,
4152 * since it will not result in the app launching with the correct
4153 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004154 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004155 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004156 */
4157 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4158 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4159
4160 /**
4161 * Used with {@link #ACTION_MAIN} to launch the maps application.
4162 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004163 * <p>NOTE: This should not be used as the primary key of an Intent,
4164 * since it will not result in the app launching with the correct
4165 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004166 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004167 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004168 */
4169 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4170 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4171
4172 /**
4173 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4174 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004175 * <p>NOTE: This should not be used as the primary key of an Intent,
4176 * since it will not result in the app launching with the correct
4177 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004178 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004179 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004180 */
4181 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4182 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4183
4184 /**
4185 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004186 * The activity should be able to play, browse, or manipulate music files
4187 * stored on the device.
4188 * <p>NOTE: This should not be used as the primary key of an Intent,
4189 * since it will not result in the app launching with the correct
4190 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004191 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004192 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004193 */
4194 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4195 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4196
4197 // ---------------------------------------------------------------------
4198 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004199 // Standard extra data keys.
4200
4201 /**
4202 * The initial data to place in a newly created record. Use with
4203 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4204 * fields as would be given to the underlying ContentProvider.insert()
4205 * call.
4206 */
4207 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4208
4209 /**
4210 * A constant CharSequence that is associated with the Intent, used with
4211 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4212 * this may be a styled CharSequence, so you must use
4213 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4214 * retrieve it.
4215 */
4216 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4217
4218 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004219 * A constant String that is associated with the Intent, used with
4220 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4221 * as HTML formatted text. Note that you <em>must</em> also supply
4222 * {@link #EXTRA_TEXT}.
4223 */
4224 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4225
4226 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004227 * A content: URI holding a stream of data associated with the Intent,
4228 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004229 */
4230 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4231
4232 /**
4233 * A String[] holding e-mail addresses that should be delivered to.
4234 */
4235 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4236
4237 /**
4238 * A String[] holding e-mail addresses that should be carbon copied.
4239 */
4240 public static final String EXTRA_CC = "android.intent.extra.CC";
4241
4242 /**
4243 * A String[] holding e-mail addresses that should be blind carbon copied.
4244 */
4245 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4246
4247 /**
4248 * A constant string holding the desired subject line of a message.
4249 */
4250 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4251
4252 /**
4253 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004254 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004255 */
4256 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4257
4258 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004259 * An int representing the user id to be used.
4260 *
4261 * @hide
4262 */
4263 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4264
4265 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004266 * An int representing the task id to be retrieved. This is used when a launch from recents is
4267 * intercepted by another action such as credentials confirmation to remember which task should
4268 * be resumed when complete.
4269 *
4270 * @hide
4271 */
4272 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4273
4274 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004275 * An Intent[] describing additional, alternate choices you would like shown with
4276 * {@link #ACTION_CHOOSER}.
4277 *
4278 * <p>An app may be capable of providing several different payload types to complete a
4279 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4280 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4281 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4282 * photo data or a hosted link where the photos can be viewed.</p>
4283 *
4284 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4285 * first/primary/preferred intent in the set. Additional intents specified in
4286 * this extra are ordered; by default intents that appear earlier in the array will be
4287 * preferred over intents that appear later in the array as matches for the same
4288 * target component. To alter this preference, a calling app may also supply
4289 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4290 */
4291 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4292
4293 /**
Adam Powell52c39212016-04-07 15:14:18 -07004294 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4295 * and omitted from a list of components presented to the user.
4296 *
4297 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4298 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4299 * from your own package or other apps from your organization if the idea of sending to those
4300 * targets would be redundant with other app functionality. Filtered components will not
4301 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4302 */
4303 public static final String EXTRA_EXCLUDE_COMPONENTS
4304 = "android.intent.extra.EXCLUDE_COMPONENTS";
4305
4306 /**
4307 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4308 * describing additional high-priority deep-link targets for the chooser to present to the user.
4309 *
4310 * <p>Targets provided in this way will be presented inline with all other targets provided
4311 * by services from other apps. They will be prioritized before other service targets, but
4312 * after those targets provided by sources that the user has manually pinned to the front.</p>
4313 *
4314 * @see #ACTION_CHOOSER
4315 */
4316 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4317
4318 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004319 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4320 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4321 *
4322 * <p>An app preparing an action for another app to complete may wish to allow the user to
4323 * disambiguate between several options for completing the action based on the chosen target
4324 * or otherwise refine the action before it is invoked.
4325 * </p>
4326 *
4327 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4328 * <ul>
4329 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4330 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4331 * chosen target beyond the first</li>
4332 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4333 * should fill in and send once the disambiguation is complete</li>
4334 * </ul>
4335 */
4336 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4337 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4338
4339 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004340 * An {@code ArrayList} of {@code String} annotations describing content for
4341 * {@link #ACTION_CHOOSER}.
4342 *
4343 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4344 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4345 *
4346 * <p>Annotations should describe the major components or topics of the content. It is up to
4347 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4348 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004349 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4350 * character. Performance on customized annotations can suffer, if they are rarely used for
4351 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4352 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004353 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004354 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004355 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004356 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004357 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004358 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004359 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004360 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004361 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004362 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4363 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4364 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4365 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4366 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004367 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004368 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4369 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004370 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004371 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004372 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004373 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004374 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004375 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004376 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004377 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004378 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004379 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004380 * Christmas and Thanksgiving.</li>
4381 * </ul>
4382 */
4383 public static final String EXTRA_CONTENT_ANNOTATIONS
4384 = "android.intent.extra.CONTENT_ANNOTATIONS";
4385
4386 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004387 * A {@link ResultReceiver} used to return data back to the sender.
4388 *
4389 * <p>Used to complete an app-specific
4390 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4391 *
4392 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4393 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4394 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4395 * when the user selects a target component from the chooser. It is up to the recipient
4396 * to send a result to this ResultReceiver to signal that disambiguation is complete
4397 * and that the chooser should invoke the user's choice.</p>
4398 *
4399 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4400 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4401 * to match and fill in the final Intent or ChooserTarget before starting it.
4402 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4403 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4404 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4405 *
4406 * <p>The result code passed to the ResultReceiver should be
4407 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4408 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4409 * the chooser should finish without starting a target.</p>
4410 */
4411 public static final String EXTRA_RESULT_RECEIVER
4412 = "android.intent.extra.RESULT_RECEIVER";
4413
4414 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004415 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004416 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004417 */
4418 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4419
4420 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004421 * A Parcelable[] of {@link Intent} or
4422 * {@link android.content.pm.LabeledIntent} objects as set with
4423 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4424 * a the front of the list of choices, when shown to the user with a
4425 * {@link #ACTION_CHOOSER}.
4426 */
4427 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4428
4429 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004430 * A {@link IntentSender} to start after ephemeral installation success.
4431 * @hide
4432 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004433 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4434
4435 /**
4436 * A {@link IntentSender} to start after ephemeral installation failure.
4437 * @hide
4438 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004439 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4440
4441 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004442 * The host name that triggered an ephemeral resolution.
4443 * @hide
4444 */
4445 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4446
4447 /**
4448 * An opaque token to track ephemeral resolution.
4449 * @hide
4450 */
4451 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4452
4453 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004454 * The version code of the app to install components from.
4455 * @hide
4456 */
4457 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4458
4459 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004460 * The app that triggered the ephemeral installation.
4461 * @hide
4462 */
4463 public static final String EXTRA_CALLING_PACKAGE
4464 = "android.intent.extra.CALLING_PACKAGE";
4465
4466 /**
4467 * Optional calling app provided bundle containing additional launch information the
4468 * installer may use.
4469 * @hide
4470 */
4471 public static final String EXTRA_VERIFICATION_BUNDLE
4472 = "android.intent.extra.VERIFICATION_BUNDLE";
4473
4474 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004475 * A Bundle forming a mapping of potential target package names to different extras Bundles
4476 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4477 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4478 * be currently installed on the device.
4479 *
4480 * <p>An application may choose to provide alternate extras for the case where a user
4481 * selects an activity from a predetermined set of target packages. If the activity
4482 * the user selects from the chooser belongs to a package with its package name as
4483 * a key in this bundle, the corresponding extras for that package will be merged with
4484 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4485 * extra has the same key as an extra already present in the intent it will overwrite
4486 * the extra from the intent.</p>
4487 *
4488 * <p><em>Examples:</em>
4489 * <ul>
4490 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4491 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4492 * parameters for that target.</li>
4493 * <li>An application may offer additional metadata for known targets of a given intent
4494 * to pass along information only relevant to that target such as account or content
4495 * identifiers already known to that application.</li>
4496 * </ul></p>
4497 */
4498 public static final String EXTRA_REPLACEMENT_EXTRAS =
4499 "android.intent.extra.REPLACEMENT_EXTRAS";
4500
4501 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004502 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4503 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4504 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4505 * {@link ComponentName} of the chosen component.
4506 *
4507 * <p>In some situations this callback may never come, for example if the user abandons
4508 * the chooser, switches to another task or any number of other reasons. Apps should not
4509 * be written assuming that this callback will always occur.</p>
4510 */
4511 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4512 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4513
4514 /**
4515 * The {@link ComponentName} chosen by the user to complete an action.
4516 *
4517 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4518 */
4519 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4520
4521 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004522 * A {@link android.view.KeyEvent} object containing the event that
4523 * triggered the creation of the Intent it is in.
4524 */
4525 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4526
4527 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004528 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4529 * before shutting down.
4530 *
4531 * {@hide}
4532 */
4533 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4534
4535 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004536 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4537 * requested by the user.
4538 *
4539 * {@hide}
4540 */
4541 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4542 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4543
4544 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004545 * 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 -07004546 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4547 * of restarting the application.
4548 */
4549 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4550
4551 /**
4552 * A String holding the phone number originally entered in
4553 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4554 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4555 */
4556 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004557
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558 /**
4559 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4560 * intents to supply the uid the package had been assigned. Also an optional
4561 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4562 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4563 * purpose.
4564 */
4565 public static final String EXTRA_UID = "android.intent.extra.UID";
4566
4567 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004568 * @hide String array of package names.
4569 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004570 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004571 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4572
4573 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004574 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4575 * intents to indicate whether this represents a full uninstall (removing
4576 * both the code and its data) or a partial uninstall (leaving its data,
4577 * implying that this is an update).
4578 */
4579 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004580
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004581 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004582 * @hide
4583 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4584 * intents to indicate that at this point the package has been removed for
4585 * all users on the device.
4586 */
4587 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4588 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4589
4590 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004591 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4592 * intents to indicate that this is a replacement of the package, so this
4593 * broadcast will immediately be followed by an add broadcast for a
4594 * different version of the same package.
4595 */
4596 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004597
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004598 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004599 * Used as an int extra field in {@link android.app.AlarmManager} intents
4600 * to tell the application being invoked how many pending alarms are being
4601 * delievered with the intent. For one-shot alarms this will always be 1.
4602 * For recurring alarms, this might be greater than 1 if the device was
4603 * asleep or powered off at the time an earlier alarm would have been
4604 * delivered.
4605 */
4606 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004607
Jacek Surazski86b6c532009-05-13 14:38:28 +02004608 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004609 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4610 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004611 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4612 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004613 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4614 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4615 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004616 */
4617 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4618
4619 /**
4620 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4621 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004622 */
4623 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4624
4625 /**
4626 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4627 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004628 */
4629 public static final int EXTRA_DOCK_STATE_DESK = 1;
4630
4631 /**
4632 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4633 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004634 */
4635 public static final int EXTRA_DOCK_STATE_CAR = 2;
4636
4637 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004638 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4639 * to represent that the phone is in a analog (low end) dock.
4640 */
4641 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4642
4643 /**
4644 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4645 * to represent that the phone is in a digital (high end) dock.
4646 */
4647 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4648
4649 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004650 * Boolean that can be supplied as meta-data with a dock activity, to
4651 * indicate that the dock should take over the home key when it is active.
4652 */
4653 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004654
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004655 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004656 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4657 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004658 */
4659 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4660
4661 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004662 * Used in the extra field in the remote intent. It's astring token passed with the
4663 * remote intent.
4664 */
4665 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4666 "android.intent.extra.remote_intent_token";
4667
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004668 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004669 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004670 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004671 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004672 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004673 "android.intent.extra.changed_component_name";
4674
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004675 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004676 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004677 * and contains a string array of all of the components that have changed. If
4678 * the state of the overall package has changed, then it will contain an entry
4679 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004680 */
4681 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4682 "android.intent.extra.changed_component_name_list";
4683
4684 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004685 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004686 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004687 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4688 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4689 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004690 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004691 */
4692 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4693 "android.intent.extra.changed_package_list";
4694
4695 /**
4696 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004697 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4698 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004699 * and contains an integer array of uids of all of the components
4700 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004701 */
4702 public static final String EXTRA_CHANGED_UID_LIST =
4703 "android.intent.extra.changed_uid_list";
4704
4705 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004706 * @hide
4707 * Magic extra system code can use when binding, to give a label for
4708 * who it is that has bound to a service. This is an integer giving
4709 * a framework string resource that can be displayed to the user.
4710 */
4711 public static final String EXTRA_CLIENT_LABEL =
4712 "android.intent.extra.client_label";
4713
4714 /**
4715 * @hide
4716 * Magic extra system code can use when binding, to give a PendingIntent object
4717 * that can be launched for the user to disable the system's use of this
4718 * service.
4719 */
4720 public static final String EXTRA_CLIENT_INTENT =
4721 "android.intent.extra.client_intent";
4722
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004723 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004724 * Extra used to indicate that an intent should only return data that is on
4725 * the local device. This is a boolean extra; the default is false. If true,
4726 * an implementation should only allow the user to select data that is
4727 * already on the device, not requiring it be downloaded from a remote
4728 * service when opened.
4729 *
4730 * @see #ACTION_GET_CONTENT
4731 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004732 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004733 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004734 */
4735 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004736 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004737
Amith Yamasani13593602012-03-22 16:16:17 -07004738 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004739 * Extra used to indicate that an intent can allow the user to select and
4740 * return multiple items. This is a boolean extra; the default is false. If
4741 * true, an implementation is allowed to present the user with a UI where
4742 * they can pick multiple items that are all returned to the caller. When
4743 * this happens, they should be returned as the {@link #getClipData()} part
4744 * of the result Intent.
4745 *
4746 * @see #ACTION_GET_CONTENT
4747 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004748 */
4749 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004750 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004751
4752 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004753 * The integer userHandle carried with broadcast intents related to addition, removal and
4754 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4755 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4756 *
Amith Yamasani13593602012-03-22 16:16:17 -07004757 * @hide
4758 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004759 public static final String EXTRA_USER_HANDLE =
4760 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004761
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004762 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004763 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4764 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4765 */
4766 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004767 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004768
4769 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004770 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004771 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4772 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004773 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004774 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4775
4776 /**
4777 * Extra sent in the intent to the BroadcastReceiver that handles
4778 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4779 * the restrictions as key/value pairs.
4780 */
4781 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4782 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004783
Amith Yamasani86118ba2013-03-28 14:33:16 -07004784 /**
4785 * Extra used in the response from a BroadcastReceiver that handles
4786 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4787 */
4788 public static final String EXTRA_RESTRICTIONS_INTENT =
4789 "android.intent.extra.restrictions_intent";
4790
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004791 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004792 * Extra used to communicate a set of acceptable MIME types. The type of the
4793 * extra is {@code String[]}. Values may be a combination of concrete MIME
4794 * types (such as "image/png") and/or partial MIME types (such as
4795 * "audio/*").
4796 *
4797 * @see #ACTION_GET_CONTENT
4798 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004799 */
4800 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4801
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004802 /**
4803 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4804 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004805 * When this is true, hardware devices can use this information to determine that
4806 * they shouldn't do a complete shutdown of their device since this is not a
4807 * complete shutdown down to the kernel, but only user space restarting.
4808 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004809 */
4810 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4811 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4812
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004813 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004814 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4815 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4816 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4817 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004818 *
4819 * @hide for internal use only.
4820 */
4821 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4822 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004823 /** @hide */
4824 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4825 /** @hide */
4826 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4827 /** @hide */
4828 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004829
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004830 /** {@hide} */
4831 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4832
qingxi240c2bb2017-04-12 17:31:18 -07004833 /**
4834 * {@hide}
4835 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4836 */
Rubin Xue8490f12015-06-25 12:17:48 +01004837 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4838
Santos Cordon15a13782015-03-31 18:32:31 -07004839 /**
qingxi240c2bb2017-04-12 17:31:18 -07004840 * {@hide}
4841 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4842 * reset for the device with eSIM. This extra will be sent together with
4843 * {@link #ACTION_FACTORY_RESET}
4844 */
4845 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4846
4847 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004848 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4849 * activation request.
4850 * TODO: Add information about the structure and response data used with the pending intent.
4851 * @hide
4852 */
4853 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4854 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4855
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004856 /**
4857 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004858 *
4859 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004860 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004861 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004862 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4863
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004864 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004865 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4866 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4867 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004868 *
4869 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004870 * @see #ACTION_QUICK_VIEW
4871 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004872 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004873 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004874 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4875 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004876
4877 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004878 * An optional extra of {@code String[]} indicating which quick view features should be made
4879 * available to the user in the quick view UI while handing a
4880 * {@link Intent#ACTION_QUICK_VIEW} intent.
4881 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4882 * Quick viewer can implement features not listed below.
4883 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4884 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4885 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4886 * <p>
4887 * Requirements:
4888 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4889 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4890 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4891 * internal policies.
4892 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4893 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4894 * disable or hide features.
4895 *
4896 * @see #ACTION_QUICK_VIEW
4897 */
4898 public static final String EXTRA_QUICK_VIEW_FEATURES =
4899 "android.intent.extra.QUICK_VIEW_FEATURES";
4900
4901 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004902 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004903 * When a profile goes into quiet mode, all apps in the profile are killed and the
4904 * profile user is stopped. Widgets originating from the profile are masked, and app
4905 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004906 */
4907 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004908
4909 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004910 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004911 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004912 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4913 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004914 *
4915 * @hide
4916 */
4917 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4918 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4919
4920 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004921 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4922 * whether to show the chooser or not when there is only one application available
4923 * to choose from.
4924 *
4925 * @hide
4926 */
4927 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4928 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4929
4930 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004931 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004932 * to represent that a video codec is allowed to use.
4933 *
4934 * @hide
4935 */
4936 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4937
4938 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004939 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004940 * to represent that a audio codec is allowed to use.
4941 *
4942 * @hide
4943 */
4944 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4945
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004946 // ---------------------------------------------------------------------
4947 // ---------------------------------------------------------------------
4948 // Intent flags (see mFlags variable).
4949
Tor Norbyed9273d62013-05-30 15:59:53 -07004950 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004951 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004952 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4953 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004954 @Retention(RetentionPolicy.SOURCE)
4955 public @interface GrantUriMode {}
4956
Jeff Sharkey846318a2014-04-04 12:12:41 -07004957 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004958 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004959 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4960 @Retention(RetentionPolicy.SOURCE)
4961 public @interface AccessUriMode {}
4962
4963 /**
4964 * Test if given mode flags specify an access mode, which must be at least
4965 * read and/or write.
4966 *
4967 * @hide
4968 */
4969 public static boolean isAccessUriMode(int modeFlags) {
4970 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4971 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4972 }
4973
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004974 /** @hide */
4975 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4976 FLAG_GRANT_READ_URI_PERMISSION,
4977 FLAG_GRANT_WRITE_URI_PERMISSION,
4978 FLAG_FROM_BACKGROUND,
4979 FLAG_DEBUG_LOG_RESOLUTION,
4980 FLAG_EXCLUDE_STOPPED_PACKAGES,
4981 FLAG_INCLUDE_STOPPED_PACKAGES,
4982 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
4983 FLAG_GRANT_PREFIX_URI_PERMISSION,
4984 FLAG_DEBUG_TRIAGED_MISSING,
4985 FLAG_IGNORE_EPHEMERAL,
4986 FLAG_ACTIVITY_NO_HISTORY,
4987 FLAG_ACTIVITY_SINGLE_TOP,
4988 FLAG_ACTIVITY_NEW_TASK,
4989 FLAG_ACTIVITY_MULTIPLE_TASK,
4990 FLAG_ACTIVITY_CLEAR_TOP,
4991 FLAG_ACTIVITY_FORWARD_RESULT,
4992 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4993 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4994 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4995 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4996 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4997 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4998 FLAG_ACTIVITY_NEW_DOCUMENT,
4999 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5000 FLAG_ACTIVITY_NO_USER_ACTION,
5001 FLAG_ACTIVITY_REORDER_TO_FRONT,
5002 FLAG_ACTIVITY_NO_ANIMATION,
5003 FLAG_ACTIVITY_CLEAR_TASK,
5004 FLAG_ACTIVITY_TASK_ON_HOME,
5005 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5006 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5007 FLAG_RECEIVER_REGISTERED_ONLY,
5008 FLAG_RECEIVER_REPLACE_PENDING,
5009 FLAG_RECEIVER_FOREGROUND,
5010 FLAG_RECEIVER_NO_ABORT,
5011 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5012 FLAG_RECEIVER_BOOT_UPGRADE,
5013 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5014 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5015 FLAG_RECEIVER_FROM_SHELL,
5016 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5017 })
5018 @Retention(RetentionPolicy.SOURCE)
5019 public @interface Flags {}
5020
5021 /** @hide */
5022 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5023 FLAG_FROM_BACKGROUND,
5024 FLAG_DEBUG_LOG_RESOLUTION,
5025 FLAG_EXCLUDE_STOPPED_PACKAGES,
5026 FLAG_INCLUDE_STOPPED_PACKAGES,
5027 FLAG_DEBUG_TRIAGED_MISSING,
5028 FLAG_IGNORE_EPHEMERAL,
5029 FLAG_ACTIVITY_NO_HISTORY,
5030 FLAG_ACTIVITY_SINGLE_TOP,
5031 FLAG_ACTIVITY_NEW_TASK,
5032 FLAG_ACTIVITY_MULTIPLE_TASK,
5033 FLAG_ACTIVITY_CLEAR_TOP,
5034 FLAG_ACTIVITY_FORWARD_RESULT,
5035 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5036 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5037 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5038 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5039 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5040 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5041 FLAG_ACTIVITY_NEW_DOCUMENT,
5042 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5043 FLAG_ACTIVITY_NO_USER_ACTION,
5044 FLAG_ACTIVITY_REORDER_TO_FRONT,
5045 FLAG_ACTIVITY_NO_ANIMATION,
5046 FLAG_ACTIVITY_CLEAR_TASK,
5047 FLAG_ACTIVITY_TASK_ON_HOME,
5048 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5049 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5050 FLAG_RECEIVER_REGISTERED_ONLY,
5051 FLAG_RECEIVER_REPLACE_PENDING,
5052 FLAG_RECEIVER_FOREGROUND,
5053 FLAG_RECEIVER_NO_ABORT,
5054 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5055 FLAG_RECEIVER_BOOT_UPGRADE,
5056 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5057 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5058 FLAG_RECEIVER_FROM_SHELL,
5059 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5060 })
5061 @Retention(RetentionPolicy.SOURCE)
5062 public @interface MutableFlags {}
5063
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005064 /**
5065 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005066 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005067 * specified in its ClipData. When applying to an Intent's ClipData,
5068 * all URIs as well as recursive traversals through data or other ClipData
5069 * in Intent items will be granted; only the grant flags of the top-level
5070 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005071 */
5072 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5073 /**
5074 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005075 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005076 * specified in its ClipData. When applying to an Intent's ClipData,
5077 * all URIs as well as recursive traversals through data or other ClipData
5078 * in Intent items will be granted; only the grant flags of the top-level
5079 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005080 */
5081 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5082 /**
5083 * Can be set by the caller to indicate that this Intent is coming from
5084 * a background operation, not from direct user interaction.
5085 */
5086 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5087 /**
5088 * A flag you can enable for debugging: when set, log messages will be
5089 * printed during the resolution of this intent to show you what has
5090 * been found to create the final resolved list.
5091 */
5092 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005093 /**
5094 * If set, this intent will not match any components in packages that
5095 * are currently stopped. If this is not set, then the default behavior
5096 * is to include such applications in the result.
5097 */
5098 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5099 /**
5100 * If set, this intent will always match any components in packages that
5101 * are currently stopped. This is the default behavior when
5102 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5103 * flags are set, this one wins (it allows overriding of exclude for
5104 * places where the framework may automatically set the exclude flag).
5105 */
5106 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005107
5108 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005109 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005110 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005111 * persisted across device reboots until explicitly revoked with
5112 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5113 * grant for possible persisting; the receiving application must call
5114 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5115 * actually persist.
5116 *
5117 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5118 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5119 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005120 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005121 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005122 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005123
5124 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005125 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5126 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5127 * applies to any URI that is a prefix match against the original granted
5128 * URI. (Without this flag, the URI must match exactly for access to be
5129 * granted.) Another URI is considered a prefix match only when scheme,
5130 * authority, and all path segments defined by the prefix are an exact
5131 * match.
5132 */
5133 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5134
5135 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005136 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005137 * homework and verified that they correctly handle packages and components
5138 * that come and go over time. In particular:
5139 * <ul>
5140 * <li>Apps installed on external storage, which will appear to be
5141 * uninstalled while the the device is ejected.
5142 * <li>Apps with encryption unaware components, which will appear to not
5143 * exist while the device is locked.
5144 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005145 *
5146 * @hide
5147 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005148 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005149
5150 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005151 * Internal flag used to indicate ephemeral applications should not be
5152 * considered when resolving the intent.
5153 *
5154 * @hide
5155 */
5156 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5157
5158 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005159 * If set, the new activity is not kept in the history stack. As soon as
5160 * the user navigates away from it, the activity is finished. This may also
5161 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5162 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005163 *
5164 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5165 * is never invoked when the current activity starts a new activity which
5166 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005167 */
5168 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5169 /**
5170 * If set, the activity will not be launched if it is already running
5171 * at the top of the history stack.
5172 */
5173 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5174 /**
5175 * If set, this activity will become the start of a new task on this
5176 * history stack. A task (from the activity that started it to the
5177 * next task activity) defines an atomic group of activities that the
5178 * user can move to. Tasks can be moved to the foreground and background;
5179 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005180 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005181 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5182 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005183 *
5184 * <p>This flag is generally used by activities that want
5185 * to present a "launcher" style behavior: they give the user a list of
5186 * separate things that can be done, which otherwise run completely
5187 * independently of the activity launching them.
5188 *
5189 * <p>When using this flag, if a task is already running for the activity
5190 * you are now starting, then a new activity will not be started; instead,
5191 * the current task will simply be brought to the front of the screen with
5192 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5193 * to disable this behavior.
5194 *
5195 * <p>This flag can not be used when the caller is requesting a result from
5196 * the activity being launched.
5197 */
5198 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5199 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005200 * This flag is used to create a new task and launch an activity into it.
5201 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5202 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5203 * search through existing tasks for ones matching this Intent. Only if no such
5204 * task is found would a new task be created. When paired with
5205 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5206 * the search for a matching task and unconditionally start a new task.
5207 *
5208 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5209 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005210 * top-level application launcher.</strong> Used in conjunction with
5211 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5212 * behavior of bringing an existing task to the foreground. When set,
5213 * a new task is <em>always</em> started to host the Activity for the
5214 * Intent, regardless of whether there is already an existing task running
5215 * the same thing.
5216 *
5217 * <p><strong>Because the default system does not include graphical task management,
5218 * you should not use this flag unless you provide some way for a user to
5219 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005220 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005221 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5222 * creating new document tasks.
5223 *
5224 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005225 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005226 *
Scott Main7aee61f2011-02-08 11:25:01 -08005227 * <p>See
5228 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5229 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005230 *
5231 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5232 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005233 */
5234 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5235 /**
5236 * If set, and the activity being launched is already running in the
5237 * current task, then instead of launching a new instance of that activity,
5238 * all of the other activities on top of it will be closed and this Intent
5239 * will be delivered to the (now on top) old activity as a new Intent.
5240 *
5241 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5242 * If D calls startActivity() with an Intent that resolves to the component
5243 * of activity B, then C and D will be finished and B receive the given
5244 * Intent, resulting in the stack now being: A, B.
5245 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005246 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005247 * either receive the new intent you are starting here in its
5248 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005249 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005250 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5251 * the same intent, then it will be finished and re-created; for all other
5252 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5253 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005254 *
5255 * <p>This launch mode can also be used to good effect in conjunction with
5256 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5257 * of a task, it will bring any currently running instance of that task
5258 * to the foreground, and then clear it to its root state. This is
5259 * especially useful, for example, when launching an activity from the
5260 * notification manager.
5261 *
Scott Main7aee61f2011-02-08 11:25:01 -08005262 * <p>See
5263 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5264 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005265 */
5266 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5267 /**
5268 * If set and this intent is being used to launch a new activity from an
5269 * existing one, then the reply target of the existing activity will be
5270 * transfered to the new activity. This way the new activity can call
5271 * {@link android.app.Activity#setResult} and have that result sent back to
5272 * the reply target of the original activity.
5273 */
5274 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5275 /**
5276 * If set and this intent is being used to launch a new activity from an
5277 * existing one, the current activity will not be counted as the top
5278 * activity for deciding whether the new intent should be delivered to
5279 * the top instead of starting a new one. The previous activity will
5280 * be used as the top, with the assumption being that the current activity
5281 * will finish itself immediately.
5282 */
5283 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5284 /**
5285 * If set, the new activity is not kept in the list of recently launched
5286 * activities.
5287 */
5288 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5289 /**
5290 * This flag is not normally set by application code, but set for you by
5291 * the system as described in the
5292 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5293 * launchMode} documentation for the singleTask mode.
5294 */
5295 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5296 /**
5297 * If set, and this activity is either being started in a new task or
5298 * bringing to the top an existing task, then it will be launched as
5299 * the front door of the task. This will result in the application of
5300 * any affinities needed to have that task in the proper state (either
5301 * moving activities to or from it), or simply resetting that task to
5302 * its initial state if needed.
5303 */
5304 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5305 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005306 * This flag is not normally set by application code, but set for you by
5307 * the system if this activity is being launched from history
5308 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005309 */
5310 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005311 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005312 * @deprecated As of API 21 this performs identically to
5313 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005314 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005315 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005316 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005317 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005318 * This flag is used to open a document into a new task rooted at the activity launched
5319 * by this Intent. Through the use of this flag, or its equivalent attribute,
5320 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005321 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005322 *
Craig Mautner026596b2014-05-21 15:35:44 -07005323 * <p>The use of the activity attribute form of this,
5324 * {@link android.R.attr#documentLaunchMode}, is
5325 * preferred over the Intent flag described here. The attribute form allows the
5326 * Activity to specify multiple document behavior for all launchers of the Activity
5327 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005328 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005329 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5330 * it is kept after the activity is finished is different than the use of
5331 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5332 * this flag is being used to create a new recents entry, then by default that entry
5333 * will be removed once the activity is finished. You can modify this behavior with
5334 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5335 *
Craig Mautner026596b2014-05-21 15:35:44 -07005336 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5337 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5338 * equivalent of the Activity manifest specifying {@link
5339 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5340 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5341 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005342 *
Craig Mautner026596b2014-05-21 15:35:44 -07005343 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005344 *
Craig Mautner026596b2014-05-21 15:35:44 -07005345 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005346 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5347 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005348 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005349 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005350 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005351 * callback from occurring on the current frontmost activity before it is
5352 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005353 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005354 * <p>Typically, an activity can rely on that callback to indicate that an
5355 * explicit user action has caused their activity to be moved out of the
5356 * foreground. The callback marks an appropriate point in the activity's
5357 * lifecycle for it to dismiss any notifications that it intends to display
5358 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005359 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005360 * <p>If an activity is ever started via any non-user-driven events such as
5361 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5362 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005363 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005364 */
5365 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005366 /**
5367 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5368 * this flag will cause the launched activity to be brought to the front of its
5369 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005370 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005371 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5372 * If D calls startActivity() with an Intent that resolves to the component
5373 * of activity B, then B will be brought to the front of the history stack,
5374 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005375 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005376 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005377 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005378 */
5379 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005381 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5382 * this flag will prevent the system from applying an activity transition
5383 * animation to go to the next activity state. This doesn't mean an
5384 * animation will never run -- if another activity change happens that doesn't
5385 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005386 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005387 * when you are going to do a series of activity operations but the
5388 * animation seen by the user shouldn't be driven by the first activity
5389 * change but rather a later one.
5390 */
5391 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5392 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005393 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5394 * this flag will cause any existing task that would be associated with the
5395 * activity to be cleared before the activity is started. That is, the activity
5396 * becomes the new root of an otherwise empty task, and any old activities
5397 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5398 */
5399 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5400 /**
5401 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5402 * this flag will cause a newly launching task to be placed on top of the current
5403 * home activity task (if there is one). That is, pressing back from the task
5404 * will always return the user to home even if that was not the last activity they
5405 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5406 */
5407 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5408 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005409 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5410 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005411 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005412 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005413 * this flag. When set and the task's activity is finished, the recents
5414 * entry will remain in the interface for the user to re-launch it, like a
5415 * recents entry for a top-level application.
5416 * <p>
5417 * The receiving activity can override this request with
5418 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5419 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005420 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005421 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005422 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005423
5424 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005425 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5426 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005427 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5428 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005429 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005430 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005431
5432 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005433 * If set, when sending a broadcast only registered receivers will be
5434 * called -- no BroadcastReceiver components will be launched.
5435 */
5436 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005437 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005438 * If set, when sending a broadcast the new broadcast will replace
5439 * any existing pending broadcast that matches it. Matching is defined
5440 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5441 * true for the intents of the two broadcasts. When a match is found,
5442 * the new broadcast (and receivers associated with it) will replace the
5443 * existing one in the pending broadcast list, remaining at the same
5444 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005445 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005446 * <p>This flag is most typically used with sticky broadcasts, which
5447 * only care about delivering the most recent values of the broadcast
5448 * to their receivers.
5449 */
5450 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5451 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005452 * If set, when sending a broadcast the recipient is allowed to run at
5453 * foreground priority, with a shorter timeout interval. During normal
5454 * broadcasts the receivers are not automatically hoisted out of the
5455 * background priority class.
5456 */
5457 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5458 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005459 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5460 * They can still propagate results through to later receivers, but they can not prevent
5461 * later receivers from seeing the broadcast.
5462 */
5463 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5464 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005465 * If set, when sending a broadcast <i>before boot has completed</i> only
5466 * registered receivers will be called -- no BroadcastReceiver components
5467 * will be launched. Sticky intent state will be recorded properly even
5468 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5469 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005470 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005471 * <p>This flag is only for use by system sevices as a convenience to
5472 * avoid having to implement a more complex mechanism around detection
5473 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005474 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005475 * @hide
5476 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005477 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005478 /**
5479 * Set when this broadcast is for a boot upgrade, a special mode that
5480 * allows the broadcast to be sent before the system is ready and launches
5481 * the app process with no providers running in it.
5482 * @hide
5483 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005484 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005485 /**
5486 * If set, the broadcast will always go to manifest receivers in background (cached
5487 * or not running) apps, regardless of whether that would be done by default. By
5488 * default they will only receive broadcasts if the broadcast has specified an
5489 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005490 *
5491 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5492 * the broadcast code there must also be changed to match.
5493 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005494 * @hide
5495 */
5496 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5497 /**
5498 * If set, the broadcast will never go to manifest receivers in background (cached
5499 * or not running) apps, regardless of whether that would be done by default. By
5500 * default they will receive broadcasts if the broadcast has specified an
5501 * explicit component or package name.
5502 * @hide
5503 */
5504 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005505 /**
5506 * If set, this broadcast is being sent from the shell.
5507 * @hide
5508 */
5509 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005510
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005511 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005512 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5513 * will not receive broadcasts.
5514 *
5515 * <em>This flag has no effect when used by an Instant App.</em>
5516 */
5517 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5518
5519 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005520 * @hide Flags that can't be changed with PendingIntent.
5521 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005522 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5523 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5524 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005525
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005526 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005527 // ---------------------------------------------------------------------
5528 // toUri() and parseUri() options.
5529
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005530 /** @hide */
5531 @IntDef(flag = true, prefix = { "URI_" }, value = {
5532 URI_ALLOW_UNSAFE,
5533 URI_ANDROID_APP_SCHEME,
5534 URI_INTENT_SCHEME,
5535 })
5536 @Retention(RetentionPolicy.SOURCE)
5537 public @interface UriFlags {}
5538
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005539 /**
5540 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5541 * always has the "intent:" scheme. This syntax can be used when you want
5542 * to later disambiguate between URIs that are intended to describe an
5543 * Intent vs. all others that should be treated as raw URIs. When used
5544 * with {@link #parseUri}, any other scheme will result in a generic
5545 * VIEW action for that raw URI.
5546 */
5547 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005548
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005549 /**
5550 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5551 * always has the "android-app:" scheme. This is a variation of
5552 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5553 * http/https URI being delivered to a specific package name. The format
5554 * is:
5555 *
5556 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005557 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005558 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005559 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5560 * you must also include a scheme; including a path also requires both a host and a scheme.
5561 * The final #Intent; fragment can be used without a scheme, host, or path.
5562 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005563 * used with intents that have a {@link #setSelector}, since the base intent
5564 * will always have an explicit package name.</p>
5565 *
5566 * <p>Some examples of how this scheme maps to Intent objects:</p>
5567 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5568 * <colgroup align="left" />
5569 * <colgroup align="left" />
5570 * <thead>
5571 * <tr><th>URI</th> <th>Intent</th></tr>
5572 * </thead>
5573 *
5574 * <tbody>
5575 * <tr><td><code>android-app://com.example.app</code></td>
5576 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5577 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5578 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5579 * </table></td>
5580 * </tr>
5581 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5582 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5583 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5584 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5585 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5586 * </table></td>
5587 * </tr>
5588 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5589 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5590 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5591 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5592 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5593 * </table></td>
5594 * </tr>
5595 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5596 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5597 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5598 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5599 * </table></td>
5600 * </tr>
5601 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5602 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5603 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5604 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5605 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5606 * </table></td>
5607 * </tr>
5608 * <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>
5609 * <td><table border="" style="margin:0" >
5610 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5611 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5612 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5613 * </table></td>
5614 * </tr>
5615 * </tbody>
5616 * </table>
5617 */
5618 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5619
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005620 /**
5621 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5622 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5623 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5624 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5625 * generated Intent can not cause unexpected data access to happen.
5626 *
5627 * <p>If you do not trust the source of the URI being parsed, you should still do further
5628 * processing to protect yourself from it. In particular, when using it to start an
5629 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5630 * that can handle it.</p>
5631 */
5632 public static final int URI_ALLOW_UNSAFE = 1<<2;
5633
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005634 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005635
5636 private String mAction;
5637 private Uri mData;
5638 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005639 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005640 private ComponentName mComponent;
5641 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005642 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005643 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005644 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005645 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005646 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005647 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005648 /** Token to track instant app launches. Local only; do not copy cross-process. */
5649 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005650
5651 // ---------------------------------------------------------------------
5652
Makoto Onuki97f82f22017-05-31 16:20:21 -07005653 private static final int COPY_MODE_ALL = 0;
5654 private static final int COPY_MODE_FILTER = 1;
5655 private static final int COPY_MODE_HISTORY = 2;
5656
5657 /** @hide */
5658 @IntDef(value = {COPY_MODE_ALL, COPY_MODE_FILTER, COPY_MODE_HISTORY})
5659 @Retention(RetentionPolicy.SOURCE)
5660 public @interface CopyMode {}
5661
5662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005663 /**
5664 * Create an empty intent.
5665 */
5666 public Intent() {
5667 }
5668
5669 /**
5670 * Copy constructor.
5671 */
5672 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005673 this(o, COPY_MODE_ALL);
5674 }
5675
5676 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005677 this.mAction = o.mAction;
5678 this.mData = o.mData;
5679 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005680 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005681 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005682
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005683 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005684 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005685 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005686
5687 if (copyMode != COPY_MODE_FILTER) {
5688 this.mFlags = o.mFlags;
5689 this.mContentUserHint = o.mContentUserHint;
5690 this.mLaunchToken = o.mLaunchToken;
5691 if (o.mSourceBounds != null) {
5692 this.mSourceBounds = new Rect(o.mSourceBounds);
5693 }
5694 if (o.mSelector != null) {
5695 this.mSelector = new Intent(o.mSelector);
5696 }
5697
5698 if (copyMode != COPY_MODE_HISTORY) {
5699 if (o.mExtras != null) {
5700 this.mExtras = new Bundle(o.mExtras);
5701 }
5702 if (o.mClipData != null) {
5703 this.mClipData = new ClipData(o.mClipData);
5704 }
5705 } else {
5706 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5707 this.mExtras = Bundle.STRIPPED;
5708 }
5709
5710 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5711 // history.
5712 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005713 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005714 }
5715
5716 @Override
5717 public Object clone() {
5718 return new Intent(this);
5719 }
5720
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005721 /**
5722 * Make a clone of only the parts of the Intent that are relevant for
5723 * filter matching: the action, data, type, component, and categories.
5724 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005725 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005726 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005727 }
5728
5729 /**
5730 * Create an intent with a given action. All other fields (data, type,
5731 * class) are null. Note that the action <em>must</em> be in a
5732 * namespace because Intents are used globally in the system -- for
5733 * example the system VIEW action is android.intent.action.VIEW; an
5734 * application's custom action would be something like
5735 * com.google.app.myapp.CUSTOM_ACTION.
5736 *
5737 * @param action The Intent action, such as ACTION_VIEW.
5738 */
5739 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005740 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005741 }
5742
5743 /**
5744 * Create an intent with a given action and for a given data url. Note
5745 * that the action <em>must</em> be in a namespace because Intents are
5746 * used globally in the system -- for example the system VIEW action is
5747 * android.intent.action.VIEW; an application's custom action would be
5748 * something like com.google.app.myapp.CUSTOM_ACTION.
5749 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005750 * <p><em>Note: scheme and host name matching in the Android framework is
5751 * case-sensitive, unlike the formal RFC. As a result,
5752 * you should always ensure that you write your Uri with these elements
5753 * using lower case letters, and normalize any Uris you receive from
5754 * outside of Android to ensure the scheme and host is lower case.</em></p>
5755 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 * @param action The Intent action, such as ACTION_VIEW.
5757 * @param uri The Intent data URI.
5758 */
5759 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005760 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005761 mData = uri;
5762 }
5763
5764 /**
5765 * Create an intent for a specific component. All other fields (action, data,
5766 * type, class) are null, though they can be modified later with explicit
5767 * calls. This provides a convenient way to create an intent that is
5768 * intended to execute a hard-coded class name, rather than relying on the
5769 * system to find an appropriate class for you; see {@link #setComponent}
5770 * for more information on the repercussions of this.
5771 *
5772 * @param packageContext A Context of the application package implementing
5773 * this class.
5774 * @param cls The component class that is to be used for the intent.
5775 *
5776 * @see #setClass
5777 * @see #setComponent
5778 * @see #Intent(String, android.net.Uri , Context, Class)
5779 */
5780 public Intent(Context packageContext, Class<?> cls) {
5781 mComponent = new ComponentName(packageContext, cls);
5782 }
5783
5784 /**
5785 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005786 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005787 * construct the Intent and then calling {@link #setClass} to set its
5788 * class.
5789 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005790 * <p><em>Note: scheme and host name matching in the Android framework is
5791 * case-sensitive, unlike the formal RFC. As a result,
5792 * you should always ensure that you write your Uri with these elements
5793 * using lower case letters, and normalize any Uris you receive from
5794 * outside of Android to ensure the scheme and host is lower case.</em></p>
5795 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005796 * @param action The Intent action, such as ACTION_VIEW.
5797 * @param uri The Intent data URI.
5798 * @param packageContext A Context of the application package implementing
5799 * this class.
5800 * @param cls The component class that is to be used for the intent.
5801 *
5802 * @see #Intent(String, android.net.Uri)
5803 * @see #Intent(Context, Class)
5804 * @see #setClass
5805 * @see #setComponent
5806 */
5807 public Intent(String action, Uri uri,
5808 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005809 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005810 mData = uri;
5811 mComponent = new ComponentName(packageContext, cls);
5812 }
5813
5814 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005815 * Create an intent to launch the main (root) activity of a task. This
5816 * is the Intent that is started when the application's is launched from
5817 * Home. For anything else that wants to launch an application in the
5818 * same way, it is important that they use an Intent structured the same
5819 * way, and can use this function to ensure this is the case.
5820 *
5821 * <p>The returned Intent has the given Activity component as its explicit
5822 * component, {@link #ACTION_MAIN} as its action, and includes the
5823 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5824 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5825 * to do that through {@link #addFlags(int)} on the returned Intent.
5826 *
5827 * @param mainActivity The main activity component that this Intent will
5828 * launch.
5829 * @return Returns a newly created Intent that can be used to launch the
5830 * activity as a main application entry.
5831 *
5832 * @see #setClass
5833 * @see #setComponent
5834 */
5835 public static Intent makeMainActivity(ComponentName mainActivity) {
5836 Intent intent = new Intent(ACTION_MAIN);
5837 intent.setComponent(mainActivity);
5838 intent.addCategory(CATEGORY_LAUNCHER);
5839 return intent;
5840 }
5841
5842 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005843 * Make an Intent for the main activity of an application, without
5844 * specifying a specific activity to run but giving a selector to find
5845 * the activity. This results in a final Intent that is structured
5846 * the same as when the application is launched from
5847 * Home. For anything else that wants to launch an application in the
5848 * same way, it is important that they use an Intent structured the same
5849 * way, and can use this function to ensure this is the case.
5850 *
5851 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5852 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5853 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5854 * to do that through {@link #addFlags(int)} on the returned Intent.
5855 *
5856 * @param selectorAction The action name of the Intent's selector.
5857 * @param selectorCategory The name of a category to add to the Intent's
5858 * selector.
5859 * @return Returns a newly created Intent that can be used to launch the
5860 * activity as a main application entry.
5861 *
5862 * @see #setSelector(Intent)
5863 */
5864 public static Intent makeMainSelectorActivity(String selectorAction,
5865 String selectorCategory) {
5866 Intent intent = new Intent(ACTION_MAIN);
5867 intent.addCategory(CATEGORY_LAUNCHER);
5868 Intent selector = new Intent();
5869 selector.setAction(selectorAction);
5870 selector.addCategory(selectorCategory);
5871 intent.setSelector(selector);
5872 return intent;
5873 }
5874
5875 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005876 * Make an Intent that can be used to re-launch an application's task
5877 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5878 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5879 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5880 *
5881 * @param mainActivity The activity component that is the root of the
5882 * task; this is the activity that has been published in the application's
5883 * manifest as the main launcher icon.
5884 *
5885 * @return Returns a newly created Intent that can be used to relaunch the
5886 * activity's task in its root state.
5887 */
5888 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5889 Intent intent = makeMainActivity(mainActivity);
5890 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5891 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5892 return intent;
5893 }
5894
5895 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005896 * Call {@link #parseUri} with 0 flags.
5897 * @deprecated Use {@link #parseUri} instead.
5898 */
5899 @Deprecated
5900 public static Intent getIntent(String uri) throws URISyntaxException {
5901 return parseUri(uri, 0);
5902 }
Tom Taylord4a47292009-12-21 13:59:18 -08005903
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005904 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005905 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005906 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005907 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005908 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005909 *
5910 * <p>The URI given here must not be relative -- that is, it must include
5911 * the scheme and full path.
5912 *
5913 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005914 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005915 *
5916 * @return Intent The newly created Intent object.
5917 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005918 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5919 * it bad (as parsed by the Uri class) or the Intent data within the
5920 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005921 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005922 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005923 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005924 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005925 int i = 0;
5926 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005927 final boolean androidApp = uri.startsWith("android-app:");
5928
5929 // Validate intent scheme if requested.
5930 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5931 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005932 Intent intent = new Intent(ACTION_VIEW);
5933 try {
5934 intent.setData(Uri.parse(uri));
5935 } catch (IllegalArgumentException e) {
5936 throw new URISyntaxException(uri, e.getMessage());
5937 }
5938 return intent;
5939 }
5940 }
Tom Taylord4a47292009-12-21 13:59:18 -08005941
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005942 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005943 // simple case
5944 if (i == -1) {
5945 if (!androidApp) {
5946 return new Intent(ACTION_VIEW, Uri.parse(uri));
5947 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948
5949 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005950 } else if (!uri.startsWith("#Intent;", i)) {
5951 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005952 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005953 } else {
5954 i = -1;
5955 }
5956 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 // new format
5959 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005960 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005961 boolean explicitAction = false;
5962 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963
5964 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005965 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005966 String data;
5967 if (i >= 0) {
5968 data = uri.substring(0, i);
5969 i += 8; // length of "#Intent;"
5970 } else {
5971 data = uri;
5972 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005973
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005974 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005975 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005976 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005977 if (eq < 0) eq = i-1;
5978 int semi = uri.indexOf(';', i);
5979 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005980
5981 // action
5982 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005983 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005984 if (!inSelector) {
5985 explicitAction = true;
5986 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005987 }
5988
5989 // categories
5990 else if (uri.startsWith("category=", i)) {
5991 intent.addCategory(value);
5992 }
5993
5994 // type
5995 else if (uri.startsWith("type=", i)) {
5996 intent.mType = value;
5997 }
5998
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005999 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006000 else if (uri.startsWith("launchFlags=", i)) {
6001 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006002 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6003 intent.mFlags &= ~IMMUTABLE_FLAGS;
6004 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 }
6006
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006007 // package
6008 else if (uri.startsWith("package=", i)) {
6009 intent.mPackage = value;
6010 }
6011
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006012 // component
6013 else if (uri.startsWith("component=", i)) {
6014 intent.mComponent = ComponentName.unflattenFromString(value);
6015 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006016
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006017 // scheme
6018 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006019 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006020 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006021 } else {
6022 scheme = value;
6023 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006024 }
6025
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006026 // source bounds
6027 else if (uri.startsWith("sourceBounds=", i)) {
6028 intent.mSourceBounds = Rect.unflattenFromString(value);
6029 }
6030
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006031 // selector
6032 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6033 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006034 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006035 }
6036
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006037 // extra
6038 else {
6039 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006040 // create Bundle if it doesn't already exist
6041 if (intent.mExtras == null) intent.mExtras = new Bundle();
6042 Bundle b = intent.mExtras;
6043 // add EXTRA
6044 if (uri.startsWith("S.", i)) b.putString(key, value);
6045 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6046 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6047 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6048 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6049 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6050 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6051 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6052 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6053 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6054 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006055
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006056 // move to the next item
6057 i = semi + 1;
6058 }
6059
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006060 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006061 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006062 if (baseIntent.mPackage == null) {
6063 baseIntent.setSelector(intent);
6064 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006065 intent = baseIntent;
6066 }
6067
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006068 if (data != null) {
6069 if (data.startsWith("intent:")) {
6070 data = data.substring(7);
6071 if (scheme != null) {
6072 data = scheme + ':' + data;
6073 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006074 } else if (data.startsWith("android-app:")) {
6075 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6076 // Correctly formed android-app, first part is package name.
6077 int end = data.indexOf('/', 14);
6078 if (end < 0) {
6079 // All we have is a package name.
6080 intent.mPackage = data.substring(14);
6081 if (!explicitAction) {
6082 intent.setAction(ACTION_MAIN);
6083 }
6084 data = "";
6085 } else {
6086 // Target the Intent at the given package name always.
6087 String authority = null;
6088 intent.mPackage = data.substring(14, end);
6089 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006090 if ((end+1) < data.length()) {
6091 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6092 // Found a scheme, remember it.
6093 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006094 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006095 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6096 // Found a authority, remember it.
6097 authority = data.substring(end+1, newEnd);
6098 end = newEnd;
6099 }
6100 } else {
6101 // All we have is a scheme.
6102 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006103 }
6104 }
6105 if (scheme == null) {
6106 // If there was no scheme, then this just targets the package.
6107 if (!explicitAction) {
6108 intent.setAction(ACTION_MAIN);
6109 }
6110 data = "";
6111 } else if (authority == null) {
6112 data = scheme + ":";
6113 } else {
6114 data = scheme + "://" + authority + data.substring(end);
6115 }
6116 }
6117 } else {
6118 data = "";
6119 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006120 }
Tom Taylord4a47292009-12-21 13:59:18 -08006121
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006122 if (data.length() > 0) {
6123 try {
6124 intent.mData = Uri.parse(data);
6125 } catch (IllegalArgumentException e) {
6126 throw new URISyntaxException(uri, e.getMessage());
6127 }
6128 }
6129 }
Tom Taylord4a47292009-12-21 13:59:18 -08006130
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006131 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006132
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006133 } catch (IndexOutOfBoundsException e) {
6134 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6135 }
6136 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006137
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006138 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006139 return getIntentOld(uri, 0);
6140 }
6141
6142 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006143 Intent intent;
6144
6145 int i = uri.lastIndexOf('#');
6146 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006147 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006148 final int intentFragmentStart = i;
6149 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006150
6151 i++;
6152
6153 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006154 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006155 i += 7;
6156 int j = uri.indexOf(')', i);
6157 action = uri.substring(i, j);
6158 i = j + 1;
6159 }
6160
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006161 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006162
6163 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006164 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006165 i += 11;
6166 int j = uri.indexOf(')', i);
6167 while (i < j) {
6168 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006169 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006170 if (i < sep) {
6171 intent.addCategory(uri.substring(i, sep));
6172 }
6173 i = sep + 1;
6174 }
6175 i = j + 1;
6176 }
6177
6178 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006179 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006180 i += 5;
6181 int j = uri.indexOf(')', i);
6182 intent.mType = uri.substring(i, j);
6183 i = j + 1;
6184 }
6185
6186 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006187 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006188 i += 12;
6189 int j = uri.indexOf(')', i);
6190 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006191 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6192 intent.mFlags &= ~IMMUTABLE_FLAGS;
6193 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006194 i = j + 1;
6195 }
6196
6197 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006198 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006199 i += 10;
6200 int j = uri.indexOf(')', i);
6201 int sep = uri.indexOf('!', i);
6202 if (sep >= 0 && sep < j) {
6203 String pkg = uri.substring(i, sep);
6204 String cls = uri.substring(sep + 1, j);
6205 intent.mComponent = new ComponentName(pkg, cls);
6206 }
6207 i = j + 1;
6208 }
6209
6210 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006211 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006212 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006213
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006214 final int closeParen = uri.indexOf(')', i);
6215 if (closeParen == -1) throw new URISyntaxException(uri,
6216 "EXTRA missing trailing ')'", i);
6217
6218 while (i < closeParen) {
6219 // fetch the key value
6220 int j = uri.indexOf('=', i);
6221 if (j <= i + 1 || i >= closeParen) {
6222 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6223 }
6224 char type = uri.charAt(i);
6225 i++;
6226 String key = uri.substring(i, j);
6227 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006228
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006229 // get type-value
6230 j = uri.indexOf('!', i);
6231 if (j == -1 || j >= closeParen) j = closeParen;
6232 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6233 String value = uri.substring(i, j);
6234 i = j;
6235
6236 // create Bundle if it doesn't already exist
6237 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006238
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006239 // add item to bundle
6240 try {
6241 switch (type) {
6242 case 'S':
6243 intent.mExtras.putString(key, Uri.decode(value));
6244 break;
6245 case 'B':
6246 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6247 break;
6248 case 'b':
6249 intent.mExtras.putByte(key, Byte.parseByte(value));
6250 break;
6251 case 'c':
6252 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6253 break;
6254 case 'd':
6255 intent.mExtras.putDouble(key, Double.parseDouble(value));
6256 break;
6257 case 'f':
6258 intent.mExtras.putFloat(key, Float.parseFloat(value));
6259 break;
6260 case 'i':
6261 intent.mExtras.putInt(key, Integer.parseInt(value));
6262 break;
6263 case 'l':
6264 intent.mExtras.putLong(key, Long.parseLong(value));
6265 break;
6266 case 's':
6267 intent.mExtras.putShort(key, Short.parseShort(value));
6268 break;
6269 default:
6270 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6271 }
6272 } catch (NumberFormatException e) {
6273 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6274 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006275
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006276 char ch = uri.charAt(i);
6277 if (ch == ')') break;
6278 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6279 i++;
6280 }
6281 }
6282
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006283 if (isIntentFragment) {
6284 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6285 } else {
6286 intent.mData = Uri.parse(uri);
6287 }
Tom Taylord4a47292009-12-21 13:59:18 -08006288
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006289 if (intent.mAction == null) {
6290 // By default, if no action is specified, then use VIEW.
6291 intent.mAction = ACTION_VIEW;
6292 }
6293
6294 } else {
6295 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6296 }
6297
6298 return intent;
6299 }
6300
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006301 /** @hide */
6302 public interface CommandOptionHandler {
6303 boolean handleOption(String opt, ShellCommand cmd);
6304 }
6305
6306 /** @hide */
6307 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6308 throws URISyntaxException {
6309 Intent intent = new Intent();
6310 Intent baseIntent = intent;
6311 boolean hasIntentInfo = false;
6312
6313 Uri data = null;
6314 String type = null;
6315
6316 String opt;
6317 while ((opt=cmd.getNextOption()) != null) {
6318 switch (opt) {
6319 case "-a":
6320 intent.setAction(cmd.getNextArgRequired());
6321 if (intent == baseIntent) {
6322 hasIntentInfo = true;
6323 }
6324 break;
6325 case "-d":
6326 data = Uri.parse(cmd.getNextArgRequired());
6327 if (intent == baseIntent) {
6328 hasIntentInfo = true;
6329 }
6330 break;
6331 case "-t":
6332 type = cmd.getNextArgRequired();
6333 if (intent == baseIntent) {
6334 hasIntentInfo = true;
6335 }
6336 break;
6337 case "-c":
6338 intent.addCategory(cmd.getNextArgRequired());
6339 if (intent == baseIntent) {
6340 hasIntentInfo = true;
6341 }
6342 break;
6343 case "-e":
6344 case "--es": {
6345 String key = cmd.getNextArgRequired();
6346 String value = cmd.getNextArgRequired();
6347 intent.putExtra(key, value);
6348 }
6349 break;
6350 case "--esn": {
6351 String key = cmd.getNextArgRequired();
6352 intent.putExtra(key, (String) null);
6353 }
6354 break;
6355 case "--ei": {
6356 String key = cmd.getNextArgRequired();
6357 String value = cmd.getNextArgRequired();
6358 intent.putExtra(key, Integer.decode(value));
6359 }
6360 break;
6361 case "--eu": {
6362 String key = cmd.getNextArgRequired();
6363 String value = cmd.getNextArgRequired();
6364 intent.putExtra(key, Uri.parse(value));
6365 }
6366 break;
6367 case "--ecn": {
6368 String key = cmd.getNextArgRequired();
6369 String value = cmd.getNextArgRequired();
6370 ComponentName cn = ComponentName.unflattenFromString(value);
6371 if (cn == null)
6372 throw new IllegalArgumentException("Bad component name: " + value);
6373 intent.putExtra(key, cn);
6374 }
6375 break;
6376 case "--eia": {
6377 String key = cmd.getNextArgRequired();
6378 String value = cmd.getNextArgRequired();
6379 String[] strings = value.split(",");
6380 int[] list = new int[strings.length];
6381 for (int i = 0; i < strings.length; i++) {
6382 list[i] = Integer.decode(strings[i]);
6383 }
6384 intent.putExtra(key, list);
6385 }
6386 break;
6387 case "--eial": {
6388 String key = cmd.getNextArgRequired();
6389 String value = cmd.getNextArgRequired();
6390 String[] strings = value.split(",");
6391 ArrayList<Integer> list = new ArrayList<>(strings.length);
6392 for (int i = 0; i < strings.length; i++) {
6393 list.add(Integer.decode(strings[i]));
6394 }
6395 intent.putExtra(key, list);
6396 }
6397 break;
6398 case "--el": {
6399 String key = cmd.getNextArgRequired();
6400 String value = cmd.getNextArgRequired();
6401 intent.putExtra(key, Long.valueOf(value));
6402 }
6403 break;
6404 case "--ela": {
6405 String key = cmd.getNextArgRequired();
6406 String value = cmd.getNextArgRequired();
6407 String[] strings = value.split(",");
6408 long[] list = new long[strings.length];
6409 for (int i = 0; i < strings.length; i++) {
6410 list[i] = Long.valueOf(strings[i]);
6411 }
6412 intent.putExtra(key, list);
6413 hasIntentInfo = true;
6414 }
6415 break;
6416 case "--elal": {
6417 String key = cmd.getNextArgRequired();
6418 String value = cmd.getNextArgRequired();
6419 String[] strings = value.split(",");
6420 ArrayList<Long> list = new ArrayList<>(strings.length);
6421 for (int i = 0; i < strings.length; i++) {
6422 list.add(Long.valueOf(strings[i]));
6423 }
6424 intent.putExtra(key, list);
6425 hasIntentInfo = true;
6426 }
6427 break;
6428 case "--ef": {
6429 String key = cmd.getNextArgRequired();
6430 String value = cmd.getNextArgRequired();
6431 intent.putExtra(key, Float.valueOf(value));
6432 hasIntentInfo = true;
6433 }
6434 break;
6435 case "--efa": {
6436 String key = cmd.getNextArgRequired();
6437 String value = cmd.getNextArgRequired();
6438 String[] strings = value.split(",");
6439 float[] list = new float[strings.length];
6440 for (int i = 0; i < strings.length; i++) {
6441 list[i] = Float.valueOf(strings[i]);
6442 }
6443 intent.putExtra(key, list);
6444 hasIntentInfo = true;
6445 }
6446 break;
6447 case "--efal": {
6448 String key = cmd.getNextArgRequired();
6449 String value = cmd.getNextArgRequired();
6450 String[] strings = value.split(",");
6451 ArrayList<Float> list = new ArrayList<>(strings.length);
6452 for (int i = 0; i < strings.length; i++) {
6453 list.add(Float.valueOf(strings[i]));
6454 }
6455 intent.putExtra(key, list);
6456 hasIntentInfo = true;
6457 }
6458 break;
6459 case "--esa": {
6460 String key = cmd.getNextArgRequired();
6461 String value = cmd.getNextArgRequired();
6462 // Split on commas unless they are preceeded by an escape.
6463 // The escape character must be escaped for the string and
6464 // again for the regex, thus four escape characters become one.
6465 String[] strings = value.split("(?<!\\\\),");
6466 intent.putExtra(key, strings);
6467 hasIntentInfo = true;
6468 }
6469 break;
6470 case "--esal": {
6471 String key = cmd.getNextArgRequired();
6472 String value = cmd.getNextArgRequired();
6473 // Split on commas unless they are preceeded by an escape.
6474 // The escape character must be escaped for the string and
6475 // again for the regex, thus four escape characters become one.
6476 String[] strings = value.split("(?<!\\\\),");
6477 ArrayList<String> list = new ArrayList<>(strings.length);
6478 for (int i = 0; i < strings.length; i++) {
6479 list.add(strings[i]);
6480 }
6481 intent.putExtra(key, list);
6482 hasIntentInfo = true;
6483 }
6484 break;
6485 case "--ez": {
6486 String key = cmd.getNextArgRequired();
6487 String value = cmd.getNextArgRequired().toLowerCase();
6488 // Boolean.valueOf() results in false for anything that is not "true", which is
6489 // error-prone in shell commands
6490 boolean arg;
6491 if ("true".equals(value) || "t".equals(value)) {
6492 arg = true;
6493 } else if ("false".equals(value) || "f".equals(value)) {
6494 arg = false;
6495 } else {
6496 try {
6497 arg = Integer.decode(value) != 0;
6498 } catch (NumberFormatException ex) {
6499 throw new IllegalArgumentException("Invalid boolean value: " + value);
6500 }
6501 }
6502
6503 intent.putExtra(key, arg);
6504 }
6505 break;
6506 case "-n": {
6507 String str = cmd.getNextArgRequired();
6508 ComponentName cn = ComponentName.unflattenFromString(str);
6509 if (cn == null)
6510 throw new IllegalArgumentException("Bad component name: " + str);
6511 intent.setComponent(cn);
6512 if (intent == baseIntent) {
6513 hasIntentInfo = true;
6514 }
6515 }
6516 break;
6517 case "-p": {
6518 String str = cmd.getNextArgRequired();
6519 intent.setPackage(str);
6520 if (intent == baseIntent) {
6521 hasIntentInfo = true;
6522 }
6523 }
6524 break;
6525 case "-f":
6526 String str = cmd.getNextArgRequired();
6527 intent.setFlags(Integer.decode(str).intValue());
6528 break;
6529 case "--grant-read-uri-permission":
6530 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6531 break;
6532 case "--grant-write-uri-permission":
6533 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6534 break;
6535 case "--grant-persistable-uri-permission":
6536 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6537 break;
6538 case "--grant-prefix-uri-permission":
6539 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6540 break;
6541 case "--exclude-stopped-packages":
6542 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6543 break;
6544 case "--include-stopped-packages":
6545 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6546 break;
6547 case "--debug-log-resolution":
6548 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6549 break;
6550 case "--activity-brought-to-front":
6551 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6552 break;
6553 case "--activity-clear-top":
6554 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6555 break;
6556 case "--activity-clear-when-task-reset":
6557 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6558 break;
6559 case "--activity-exclude-from-recents":
6560 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6561 break;
6562 case "--activity-launched-from-history":
6563 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6564 break;
6565 case "--activity-multiple-task":
6566 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6567 break;
6568 case "--activity-no-animation":
6569 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6570 break;
6571 case "--activity-no-history":
6572 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6573 break;
6574 case "--activity-no-user-action":
6575 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6576 break;
6577 case "--activity-previous-is-top":
6578 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6579 break;
6580 case "--activity-reorder-to-front":
6581 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6582 break;
6583 case "--activity-reset-task-if-needed":
6584 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6585 break;
6586 case "--activity-single-top":
6587 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6588 break;
6589 case "--activity-clear-task":
6590 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6591 break;
6592 case "--activity-task-on-home":
6593 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6594 break;
6595 case "--receiver-registered-only":
6596 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6597 break;
6598 case "--receiver-replace-pending":
6599 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6600 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006601 case "--receiver-foreground":
6602 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6603 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006604 case "--receiver-no-abort":
6605 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6606 break;
6607 case "--receiver-include-background":
6608 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6609 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006610 case "--selector":
6611 intent.setDataAndType(data, type);
6612 intent = new Intent();
6613 break;
6614 default:
6615 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6616 // Okay, caller handled this option.
6617 } else {
6618 throw new IllegalArgumentException("Unknown option: " + opt);
6619 }
6620 break;
6621 }
6622 }
6623 intent.setDataAndType(data, type);
6624
6625 final boolean hasSelector = intent != baseIntent;
6626 if (hasSelector) {
6627 // A selector was specified; fix up.
6628 baseIntent.setSelector(intent);
6629 intent = baseIntent;
6630 }
6631
6632 String arg = cmd.getNextArg();
6633 baseIntent = null;
6634 if (arg == null) {
6635 if (hasSelector) {
6636 // If a selector has been specified, and no arguments
6637 // have been supplied for the main Intent, then we can
6638 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6639 // need to have a component name specified yet, the
6640 // selector will take care of that.
6641 baseIntent = new Intent(Intent.ACTION_MAIN);
6642 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6643 }
6644 } else if (arg.indexOf(':') >= 0) {
6645 // The argument is a URI. Fully parse it, and use that result
6646 // to fill in any data not specified so far.
6647 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6648 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6649 } else if (arg.indexOf('/') >= 0) {
6650 // The argument is a component name. Build an Intent to launch
6651 // it.
6652 baseIntent = new Intent(Intent.ACTION_MAIN);
6653 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6654 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6655 } else {
6656 // Assume the argument is a package name.
6657 baseIntent = new Intent(Intent.ACTION_MAIN);
6658 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6659 baseIntent.setPackage(arg);
6660 }
6661 if (baseIntent != null) {
6662 Bundle extras = intent.getExtras();
6663 intent.replaceExtras((Bundle)null);
6664 Bundle uriExtras = baseIntent.getExtras();
6665 baseIntent.replaceExtras((Bundle)null);
6666 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6667 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6668 for (String c : cats) {
6669 baseIntent.removeCategory(c);
6670 }
6671 }
6672 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6673 if (extras == null) {
6674 extras = uriExtras;
6675 } else if (uriExtras != null) {
6676 uriExtras.putAll(extras);
6677 extras = uriExtras;
6678 }
6679 intent.replaceExtras(extras);
6680 hasIntentInfo = true;
6681 }
6682
6683 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6684 return intent;
6685 }
6686
6687 /** @hide */
6688 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6689 final String[] lines = new String[] {
6690 "<INTENT> specifications include these flags and arguments:",
6691 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6692 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6693 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6694 " [--esn <EXTRA_KEY> ...]",
6695 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6696 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6697 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6698 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6699 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6700 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6701 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6702 " (mutiple extras passed as Integer[])",
6703 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6704 " (mutiple extras passed as List<Integer>)",
6705 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6706 " (mutiple extras passed as Long[])",
6707 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6708 " (mutiple extras passed as List<Long>)",
6709 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6710 " (mutiple extras passed as Float[])",
6711 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6712 " (mutiple extras passed as List<Float>)",
6713 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6714 " (mutiple extras passed as String[]; to embed a comma into a string,",
6715 " escape it using \"\\,\")",
6716 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6717 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6718 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006719 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006720 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6721 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6722 " [--debug-log-resolution] [--exclude-stopped-packages]",
6723 " [--include-stopped-packages]",
6724 " [--activity-brought-to-front] [--activity-clear-top]",
6725 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6726 " [--activity-launched-from-history] [--activity-multiple-task]",
6727 " [--activity-no-animation] [--activity-no-history]",
6728 " [--activity-no-user-action] [--activity-previous-is-top]",
6729 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6730 " [--activity-single-top] [--activity-clear-task]",
6731 " [--activity-task-on-home]",
6732 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006733 " [--receiver-foreground] [--receiver-no-abort]",
6734 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006735 " [--selector]",
6736 " [<URI> | <PACKAGE> | <COMPONENT>]"
6737 };
6738 for (String line : lines) {
6739 pw.print(prefix);
6740 pw.println(line);
6741 }
6742 }
6743
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006744 /**
6745 * Retrieve the general action to be performed, such as
6746 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6747 * the information in the intent should be interpreted -- most importantly,
6748 * what to do with the data returned by {@link #getData}.
6749 *
6750 * @return The action of this intent or null if none is specified.
6751 *
6752 * @see #setAction
6753 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006754 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006755 return mAction;
6756 }
6757
6758 /**
6759 * Retrieve data this intent is operating on. This URI specifies the name
6760 * of the data; often it uses the content: scheme, specifying data in a
6761 * content provider. Other schemes may be handled by specific activities,
6762 * such as http: by the web browser.
6763 *
6764 * @return The URI of the data this intent is targeting or null.
6765 *
6766 * @see #getScheme
6767 * @see #setData
6768 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006769 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006770 return mData;
6771 }
6772
6773 /**
6774 * The same as {@link #getData()}, but returns the URI as an encoded
6775 * String.
6776 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006777 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006778 return mData != null ? mData.toString() : null;
6779 }
6780
6781 /**
6782 * Return the scheme portion of the intent's data. If the data is null or
6783 * does not include a scheme, null is returned. Otherwise, the scheme
6784 * prefix without the final ':' is returned, i.e. "http".
6785 *
6786 * <p>This is the same as calling getData().getScheme() (and checking for
6787 * null data).
6788 *
6789 * @return The scheme of this intent.
6790 *
6791 * @see #getData
6792 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006793 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006794 return mData != null ? mData.getScheme() : null;
6795 }
6796
6797 /**
6798 * Retrieve any explicit MIME type included in the intent. This is usually
6799 * null, as the type is determined by the intent data.
6800 *
6801 * @return If a type was manually set, it is returned; else null is
6802 * returned.
6803 *
6804 * @see #resolveType(ContentResolver)
6805 * @see #setType
6806 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006807 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006808 return mType;
6809 }
6810
6811 /**
6812 * Return the MIME data type of this intent. If the type field is
6813 * explicitly set, that is simply returned. Otherwise, if the data is set,
6814 * the type of that data is returned. If neither fields are set, a null is
6815 * returned.
6816 *
6817 * @return The MIME type of this intent.
6818 *
6819 * @see #getType
6820 * @see #resolveType(ContentResolver)
6821 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006822 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006823 return resolveType(context.getContentResolver());
6824 }
6825
6826 /**
6827 * Return the MIME data type of this intent. If the type field is
6828 * explicitly set, that is simply returned. Otherwise, if the data is set,
6829 * the type of that data is returned. If neither fields are set, a null is
6830 * returned.
6831 *
6832 * @param resolver A ContentResolver that can be used to determine the MIME
6833 * type of the intent's data.
6834 *
6835 * @return The MIME type of this intent.
6836 *
6837 * @see #getType
6838 * @see #resolveType(Context)
6839 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006840 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006841 if (mType != null) {
6842 return mType;
6843 }
6844 if (mData != null) {
6845 if ("content".equals(mData.getScheme())) {
6846 return resolver.getType(mData);
6847 }
6848 }
6849 return null;
6850 }
6851
6852 /**
6853 * Return the MIME data type of this intent, only if it will be needed for
6854 * intent resolution. This is not generally useful for application code;
6855 * it is used by the frameworks for communicating with back-end system
6856 * services.
6857 *
6858 * @param resolver A ContentResolver that can be used to determine the MIME
6859 * type of the intent's data.
6860 *
6861 * @return The MIME type of this intent, or null if it is unknown or not
6862 * needed.
6863 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006864 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006865 if (mComponent != null) {
6866 return mType;
6867 }
6868 return resolveType(resolver);
6869 }
6870
6871 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006872 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006873 *
6874 * @param category The category to check.
6875 *
6876 * @return boolean True if the intent contains the category, else false.
6877 *
6878 * @see #getCategories
6879 * @see #addCategory
6880 */
6881 public boolean hasCategory(String category) {
6882 return mCategories != null && mCategories.contains(category);
6883 }
6884
6885 /**
6886 * Return the set of all categories in the intent. If there are no categories,
6887 * returns NULL.
6888 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006889 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006890 *
6891 * @see #hasCategory
6892 * @see #addCategory
6893 */
6894 public Set<String> getCategories() {
6895 return mCategories;
6896 }
6897
6898 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006899 * Return the specific selector associated with this Intent. If there is
6900 * none, returns null. See {@link #setSelector} for more information.
6901 *
6902 * @see #setSelector
6903 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006904 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006905 return mSelector;
6906 }
6907
6908 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006909 * Return the {@link ClipData} associated with this Intent. If there is
6910 * none, returns null. See {@link #setClipData} for more information.
6911 *
John Spurlock125d1332013-11-25 11:58:37 -05006912 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006913 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006914 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006915 return mClipData;
6916 }
6917
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006918 /** @hide */
6919 public int getContentUserHint() {
6920 return mContentUserHint;
6921 }
6922
Todd Kennedyb3b431302017-03-20 16:05:48 -07006923 /** @hide */
6924 public String getLaunchToken() {
6925 return mLaunchToken;
6926 }
6927
6928 /** @hide */
6929 public void setLaunchToken(String launchToken) {
6930 mLaunchToken = launchToken;
6931 }
6932
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006933 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006934 * Sets the ClassLoader that will be used when unmarshalling
6935 * any Parcelable values from the extras of this Intent.
6936 *
6937 * @param loader a ClassLoader, or null to use the default loader
6938 * at the time of unmarshalling.
6939 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006940 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006941 if (mExtras != null) {
6942 mExtras.setClassLoader(loader);
6943 }
6944 }
6945
6946 /**
6947 * Returns true if an extra value is associated with the given name.
6948 * @param name the extra's name
6949 * @return true if the given extra is present.
6950 */
6951 public boolean hasExtra(String name) {
6952 return mExtras != null && mExtras.containsKey(name);
6953 }
6954
6955 /**
6956 * Returns true if the Intent's extras contain a parcelled file descriptor.
6957 * @return true if the Intent contains a parcelled file descriptor.
6958 */
6959 public boolean hasFileDescriptors() {
6960 return mExtras != null && mExtras.hasFileDescriptors();
6961 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006962
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006963 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006964 public void setAllowFds(boolean allowFds) {
6965 if (mExtras != null) {
6966 mExtras.setAllowFds(allowFds);
6967 }
6968 }
6969
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006970 /** {@hide} */
6971 public void setDefusable(boolean defusable) {
6972 if (mExtras != null) {
6973 mExtras.setDefusable(defusable);
6974 }
6975 }
6976
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006977 /**
6978 * Retrieve extended data from the intent.
6979 *
6980 * @param name The name of the desired item.
6981 *
6982 * @return the value of an item that previously added with putExtra()
6983 * or null if none was found.
6984 *
6985 * @deprecated
6986 * @hide
6987 */
6988 @Deprecated
6989 public Object getExtra(String name) {
6990 return getExtra(name, null);
6991 }
6992
6993 /**
6994 * Retrieve extended data from the intent.
6995 *
6996 * @param name The name of the desired item.
6997 * @param defaultValue the value to be returned if no value of the desired
6998 * type is stored with the given name.
6999 *
7000 * @return the value of an item that previously added with putExtra()
7001 * or the default value if none was found.
7002 *
7003 * @see #putExtra(String, boolean)
7004 */
7005 public boolean getBooleanExtra(String name, boolean defaultValue) {
7006 return mExtras == null ? defaultValue :
7007 mExtras.getBoolean(name, defaultValue);
7008 }
7009
7010 /**
7011 * Retrieve extended data from the intent.
7012 *
7013 * @param name The name of the desired item.
7014 * @param defaultValue the value to be returned if no value of the desired
7015 * type is stored with the given name.
7016 *
7017 * @return the value of an item that previously added with putExtra()
7018 * or the default value if none was found.
7019 *
7020 * @see #putExtra(String, byte)
7021 */
7022 public byte getByteExtra(String name, byte defaultValue) {
7023 return mExtras == null ? defaultValue :
7024 mExtras.getByte(name, defaultValue);
7025 }
7026
7027 /**
7028 * Retrieve extended data from the intent.
7029 *
7030 * @param name The name of the desired item.
7031 * @param defaultValue the value to be returned if no value of the desired
7032 * type is stored with the given name.
7033 *
7034 * @return the value of an item that previously added with putExtra()
7035 * or the default value if none was found.
7036 *
7037 * @see #putExtra(String, short)
7038 */
7039 public short getShortExtra(String name, short defaultValue) {
7040 return mExtras == null ? defaultValue :
7041 mExtras.getShort(name, defaultValue);
7042 }
7043
7044 /**
7045 * Retrieve extended data from the intent.
7046 *
7047 * @param name The name of the desired item.
7048 * @param defaultValue the value to be returned if no value of the desired
7049 * type is stored with the given name.
7050 *
7051 * @return the value of an item that previously added with putExtra()
7052 * or the default value if none was found.
7053 *
7054 * @see #putExtra(String, char)
7055 */
7056 public char getCharExtra(String name, char defaultValue) {
7057 return mExtras == null ? defaultValue :
7058 mExtras.getChar(name, defaultValue);
7059 }
7060
7061 /**
7062 * Retrieve extended data from the intent.
7063 *
7064 * @param name The name of the desired item.
7065 * @param defaultValue the value to be returned if no value of the desired
7066 * type is stored with the given name.
7067 *
7068 * @return the value of an item that previously added with putExtra()
7069 * or the default value if none was found.
7070 *
7071 * @see #putExtra(String, int)
7072 */
7073 public int getIntExtra(String name, int defaultValue) {
7074 return mExtras == null ? defaultValue :
7075 mExtras.getInt(name, defaultValue);
7076 }
7077
7078 /**
7079 * Retrieve extended data from the intent.
7080 *
7081 * @param name The name of the desired item.
7082 * @param defaultValue the value to be returned if no value of the desired
7083 * type is stored with the given name.
7084 *
7085 * @return the value of an item that previously added with putExtra()
7086 * or the default value if none was found.
7087 *
7088 * @see #putExtra(String, long)
7089 */
7090 public long getLongExtra(String name, long defaultValue) {
7091 return mExtras == null ? defaultValue :
7092 mExtras.getLong(name, defaultValue);
7093 }
7094
7095 /**
7096 * Retrieve extended data from the intent.
7097 *
7098 * @param name The name of the desired item.
7099 * @param defaultValue the value to be returned if no value of the desired
7100 * type is stored with the given name.
7101 *
7102 * @return the value of an item that previously added with putExtra(),
7103 * or the default value if no such item is present
7104 *
7105 * @see #putExtra(String, float)
7106 */
7107 public float getFloatExtra(String name, float defaultValue) {
7108 return mExtras == null ? defaultValue :
7109 mExtras.getFloat(name, defaultValue);
7110 }
7111
7112 /**
7113 * Retrieve extended data from the intent.
7114 *
7115 * @param name The name of the desired item.
7116 * @param defaultValue the value to be returned if no value of the desired
7117 * type is stored with the given name.
7118 *
7119 * @return the value of an item that previously added with putExtra()
7120 * or the default value if none was found.
7121 *
7122 * @see #putExtra(String, double)
7123 */
7124 public double getDoubleExtra(String name, double defaultValue) {
7125 return mExtras == null ? defaultValue :
7126 mExtras.getDouble(name, defaultValue);
7127 }
7128
7129 /**
7130 * Retrieve extended data from the intent.
7131 *
7132 * @param name The name of the desired item.
7133 *
7134 * @return the value of an item that previously added with putExtra()
7135 * or null if no String value was found.
7136 *
7137 * @see #putExtra(String, String)
7138 */
7139 public String getStringExtra(String name) {
7140 return mExtras == null ? null : mExtras.getString(name);
7141 }
7142
7143 /**
7144 * Retrieve extended data from the intent.
7145 *
7146 * @param name The name of the desired item.
7147 *
7148 * @return the value of an item that previously added with putExtra()
7149 * or null if no CharSequence value was found.
7150 *
7151 * @see #putExtra(String, CharSequence)
7152 */
7153 public CharSequence getCharSequenceExtra(String name) {
7154 return mExtras == null ? null : mExtras.getCharSequence(name);
7155 }
7156
7157 /**
7158 * Retrieve extended data from the intent.
7159 *
7160 * @param name The name of the desired item.
7161 *
7162 * @return the value of an item that previously added with putExtra()
7163 * or null if no Parcelable value was found.
7164 *
7165 * @see #putExtra(String, Parcelable)
7166 */
7167 public <T extends Parcelable> T getParcelableExtra(String name) {
7168 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7169 }
7170
7171 /**
7172 * Retrieve extended data from the intent.
7173 *
7174 * @param name The name of the desired item.
7175 *
7176 * @return the value of an item that previously added with putExtra()
7177 * or null if no Parcelable[] value was found.
7178 *
7179 * @see #putExtra(String, Parcelable[])
7180 */
7181 public Parcelable[] getParcelableArrayExtra(String name) {
7182 return mExtras == null ? null : mExtras.getParcelableArray(name);
7183 }
7184
7185 /**
7186 * Retrieve extended data from the intent.
7187 *
7188 * @param name The name of the desired item.
7189 *
7190 * @return the value of an item that previously added with putExtra()
7191 * or null if no ArrayList<Parcelable> value was found.
7192 *
7193 * @see #putParcelableArrayListExtra(String, ArrayList)
7194 */
7195 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7196 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7197 }
7198
7199 /**
7200 * Retrieve extended data from the intent.
7201 *
7202 * @param name The name of the desired item.
7203 *
7204 * @return the value of an item that previously added with putExtra()
7205 * or null if no Serializable value was found.
7206 *
7207 * @see #putExtra(String, Serializable)
7208 */
7209 public Serializable getSerializableExtra(String name) {
7210 return mExtras == null ? null : mExtras.getSerializable(name);
7211 }
7212
7213 /**
7214 * Retrieve extended data from the intent.
7215 *
7216 * @param name The name of the desired item.
7217 *
7218 * @return the value of an item that previously added with putExtra()
7219 * or null if no ArrayList<Integer> value was found.
7220 *
7221 * @see #putIntegerArrayListExtra(String, ArrayList)
7222 */
7223 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7224 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7225 }
7226
7227 /**
7228 * Retrieve extended data from the intent.
7229 *
7230 * @param name The name of the desired item.
7231 *
7232 * @return the value of an item that previously added with putExtra()
7233 * or null if no ArrayList<String> value was found.
7234 *
7235 * @see #putStringArrayListExtra(String, ArrayList)
7236 */
7237 public ArrayList<String> getStringArrayListExtra(String name) {
7238 return mExtras == null ? null : mExtras.getStringArrayList(name);
7239 }
7240
7241 /**
7242 * Retrieve extended data from the intent.
7243 *
7244 * @param name The name of the desired item.
7245 *
7246 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007247 * or null if no ArrayList<CharSequence> value was found.
7248 *
7249 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7250 */
7251 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7252 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7253 }
7254
7255 /**
7256 * Retrieve extended data from the intent.
7257 *
7258 * @param name The name of the desired item.
7259 *
7260 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007261 * or null if no boolean array value was found.
7262 *
7263 * @see #putExtra(String, boolean[])
7264 */
7265 public boolean[] getBooleanArrayExtra(String name) {
7266 return mExtras == null ? null : mExtras.getBooleanArray(name);
7267 }
7268
7269 /**
7270 * Retrieve extended data from the intent.
7271 *
7272 * @param name The name of the desired item.
7273 *
7274 * @return the value of an item that previously added with putExtra()
7275 * or null if no byte array value was found.
7276 *
7277 * @see #putExtra(String, byte[])
7278 */
7279 public byte[] getByteArrayExtra(String name) {
7280 return mExtras == null ? null : mExtras.getByteArray(name);
7281 }
7282
7283 /**
7284 * Retrieve extended data from the intent.
7285 *
7286 * @param name The name of the desired item.
7287 *
7288 * @return the value of an item that previously added with putExtra()
7289 * or null if no short array value was found.
7290 *
7291 * @see #putExtra(String, short[])
7292 */
7293 public short[] getShortArrayExtra(String name) {
7294 return mExtras == null ? null : mExtras.getShortArray(name);
7295 }
7296
7297 /**
7298 * Retrieve extended data from the intent.
7299 *
7300 * @param name The name of the desired item.
7301 *
7302 * @return the value of an item that previously added with putExtra()
7303 * or null if no char array value was found.
7304 *
7305 * @see #putExtra(String, char[])
7306 */
7307 public char[] getCharArrayExtra(String name) {
7308 return mExtras == null ? null : mExtras.getCharArray(name);
7309 }
7310
7311 /**
7312 * Retrieve extended data from the intent.
7313 *
7314 * @param name The name of the desired item.
7315 *
7316 * @return the value of an item that previously added with putExtra()
7317 * or null if no int array value was found.
7318 *
7319 * @see #putExtra(String, int[])
7320 */
7321 public int[] getIntArrayExtra(String name) {
7322 return mExtras == null ? null : mExtras.getIntArray(name);
7323 }
7324
7325 /**
7326 * Retrieve extended data from the intent.
7327 *
7328 * @param name The name of the desired item.
7329 *
7330 * @return the value of an item that previously added with putExtra()
7331 * or null if no long array value was found.
7332 *
7333 * @see #putExtra(String, long[])
7334 */
7335 public long[] getLongArrayExtra(String name) {
7336 return mExtras == null ? null : mExtras.getLongArray(name);
7337 }
7338
7339 /**
7340 * Retrieve extended data from the intent.
7341 *
7342 * @param name The name of the desired item.
7343 *
7344 * @return the value of an item that previously added with putExtra()
7345 * or null if no float array value was found.
7346 *
7347 * @see #putExtra(String, float[])
7348 */
7349 public float[] getFloatArrayExtra(String name) {
7350 return mExtras == null ? null : mExtras.getFloatArray(name);
7351 }
7352
7353 /**
7354 * Retrieve extended data from the intent.
7355 *
7356 * @param name The name of the desired item.
7357 *
7358 * @return the value of an item that previously added with putExtra()
7359 * or null if no double array value was found.
7360 *
7361 * @see #putExtra(String, double[])
7362 */
7363 public double[] getDoubleArrayExtra(String name) {
7364 return mExtras == null ? null : mExtras.getDoubleArray(name);
7365 }
7366
7367 /**
7368 * Retrieve extended data from the intent.
7369 *
7370 * @param name The name of the desired item.
7371 *
7372 * @return the value of an item that previously added with putExtra()
7373 * or null if no String array value was found.
7374 *
7375 * @see #putExtra(String, String[])
7376 */
7377 public String[] getStringArrayExtra(String name) {
7378 return mExtras == null ? null : mExtras.getStringArray(name);
7379 }
7380
7381 /**
7382 * Retrieve extended data from the intent.
7383 *
7384 * @param name The name of the desired item.
7385 *
7386 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007387 * or null if no CharSequence array value was found.
7388 *
7389 * @see #putExtra(String, CharSequence[])
7390 */
7391 public CharSequence[] getCharSequenceArrayExtra(String name) {
7392 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7393 }
7394
7395 /**
7396 * Retrieve extended data from the intent.
7397 *
7398 * @param name The name of the desired item.
7399 *
7400 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007401 * or null if no Bundle value was found.
7402 *
7403 * @see #putExtra(String, Bundle)
7404 */
7405 public Bundle getBundleExtra(String name) {
7406 return mExtras == null ? null : mExtras.getBundle(name);
7407 }
7408
7409 /**
7410 * Retrieve extended data from the intent.
7411 *
7412 * @param name The name of the desired item.
7413 *
7414 * @return the value of an item that previously added with putExtra()
7415 * or null if no IBinder value was found.
7416 *
7417 * @see #putExtra(String, IBinder)
7418 *
7419 * @deprecated
7420 * @hide
7421 */
7422 @Deprecated
7423 public IBinder getIBinderExtra(String name) {
7424 return mExtras == null ? null : mExtras.getIBinder(name);
7425 }
7426
7427 /**
7428 * Retrieve extended data from the intent.
7429 *
7430 * @param name The name of the desired item.
7431 * @param defaultValue The default value to return in case no item is
7432 * associated with the key 'name'
7433 *
7434 * @return the value of an item that previously added with putExtra()
7435 * or defaultValue if none was found.
7436 *
7437 * @see #putExtra
7438 *
7439 * @deprecated
7440 * @hide
7441 */
7442 @Deprecated
7443 public Object getExtra(String name, Object defaultValue) {
7444 Object result = defaultValue;
7445 if (mExtras != null) {
7446 Object result2 = mExtras.get(name);
7447 if (result2 != null) {
7448 result = result2;
7449 }
7450 }
7451
7452 return result;
7453 }
7454
7455 /**
7456 * Retrieves a map of extended data from the intent.
7457 *
7458 * @return the map of all extras previously added with putExtra(),
7459 * or null if none have been added.
7460 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007461 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007462 return (mExtras != null)
7463 ? new Bundle(mExtras)
7464 : null;
7465 }
7466
7467 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007468 * Filter extras to only basic types.
7469 * @hide
7470 */
7471 public void removeUnsafeExtras() {
7472 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007473 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007474 }
7475 }
7476
7477 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007478 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7479 * return itself as-is.
7480 * @hide
7481 */
7482 public boolean canStripForHistory() {
7483 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7484 }
7485
7486 /**
7487 * Call it when the system needs to keep an intent for logging purposes to remove fields
7488 * that are not needed for logging.
7489 * @hide
7490 */
7491 public Intent maybeStripForHistory() {
7492 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7493
7494 if (!canStripForHistory()) {
7495 return this;
7496 }
7497 return new Intent(this, COPY_MODE_HISTORY);
7498 }
7499
7500 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007501 * Retrieve any special flags associated with this intent. You will
7502 * normally just set them with {@link #setFlags} and let the system
7503 * take the appropriate action with them.
7504 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007505 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007506 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007507 * @see #addFlags
7508 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007509 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007510 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007511 return mFlags;
7512 }
7513
Dianne Hackborne7f97212011-02-24 14:40:20 -08007514 /** @hide */
7515 public boolean isExcludingStopped() {
7516 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7517 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7518 }
7519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007520 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007521 * Retrieve the application package name this Intent is limited to. When
7522 * resolving an Intent, if non-null this limits the resolution to only
7523 * components in the given application package.
7524 *
7525 * @return The name of the application package for the Intent.
7526 *
7527 * @see #resolveActivity
7528 * @see #setPackage
7529 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007530 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007531 return mPackage;
7532 }
7533
7534 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007535 * Retrieve the concrete component associated with the intent. When receiving
7536 * an intent, this is the component that was found to best handle it (that is,
7537 * yourself) and will always be non-null; in all other cases it will be
7538 * null unless explicitly set.
7539 *
7540 * @return The name of the application component to handle the intent.
7541 *
7542 * @see #resolveActivity
7543 * @see #setComponent
7544 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007545 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007546 return mComponent;
7547 }
7548
7549 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007550 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7551 * used as a hint to the receiver for animations and the like. Null means that there
7552 * is no source bounds.
7553 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007554 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007555 return mSourceBounds;
7556 }
7557
7558 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007559 * Return the Activity component that should be used to handle this intent.
7560 * The appropriate component is determined based on the information in the
7561 * intent, evaluated as follows:
7562 *
7563 * <p>If {@link #getComponent} returns an explicit class, that is returned
7564 * without any further consideration.
7565 *
7566 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7567 * category to be considered.
7568 *
7569 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7570 * action.
7571 *
7572 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7573 * this type.
7574 *
7575 * <p>If {@link #addCategory} has added any categories, the activity must
7576 * handle ALL of the categories specified.
7577 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007578 * <p>If {@link #getPackage} is non-NULL, only activity components in
7579 * that application package will be considered.
7580 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007581 * <p>If there are no activities that satisfy all of these conditions, a
7582 * null string is returned.
7583 *
7584 * <p>If multiple activities are found to satisfy the intent, the one with
7585 * the highest priority will be used. If there are multiple activities
7586 * with the same priority, the system will either pick the best activity
7587 * based on user preference, or resolve to a system class that will allow
7588 * the user to pick an activity and forward from there.
7589 *
7590 * <p>This method is implemented simply by calling
7591 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7592 * true.</p>
7593 * <p> This API is called for you as part of starting an activity from an
7594 * intent. You do not normally need to call it yourself.</p>
7595 *
7596 * @param pm The package manager with which to resolve the Intent.
7597 *
7598 * @return Name of the component implementing an activity that can
7599 * display the intent.
7600 *
7601 * @see #setComponent
7602 * @see #getComponent
7603 * @see #resolveActivityInfo
7604 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007605 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007606 if (mComponent != null) {
7607 return mComponent;
7608 }
7609
7610 ResolveInfo info = pm.resolveActivity(
7611 this, PackageManager.MATCH_DEFAULT_ONLY);
7612 if (info != null) {
7613 return new ComponentName(
7614 info.activityInfo.applicationInfo.packageName,
7615 info.activityInfo.name);
7616 }
7617
7618 return null;
7619 }
7620
7621 /**
7622 * Resolve the Intent into an {@link ActivityInfo}
7623 * describing the activity that should execute the intent. Resolution
7624 * follows the same rules as described for {@link #resolveActivity}, but
7625 * you get back the completely information about the resolved activity
7626 * instead of just its class name.
7627 *
7628 * @param pm The package manager with which to resolve the Intent.
7629 * @param flags Addition information to retrieve as per
7630 * {@link PackageManager#getActivityInfo(ComponentName, int)
7631 * PackageManager.getActivityInfo()}.
7632 *
7633 * @return PackageManager.ActivityInfo
7634 *
7635 * @see #resolveActivity
7636 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007637 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7638 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007639 ActivityInfo ai = null;
7640 if (mComponent != null) {
7641 try {
7642 ai = pm.getActivityInfo(mComponent, flags);
7643 } catch (PackageManager.NameNotFoundException e) {
7644 // ignore
7645 }
7646 } else {
7647 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007648 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007649 if (info != null) {
7650 ai = info.activityInfo;
7651 }
7652 }
7653
7654 return ai;
7655 }
7656
7657 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007658 * Special function for use by the system to resolve service
7659 * intents to system apps. Throws an exception if there are
7660 * multiple potential matches to the Intent. Returns null if
7661 * there are no matches.
7662 * @hide
7663 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007664 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7665 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007666 if (mComponent != null) {
7667 return mComponent;
7668 }
7669
7670 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7671 if (results == null) {
7672 return null;
7673 }
7674 ComponentName comp = null;
7675 for (int i=0; i<results.size(); i++) {
7676 ResolveInfo ri = results.get(i);
7677 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7678 continue;
7679 }
7680 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7681 ri.serviceInfo.name);
7682 if (comp != null) {
7683 throw new IllegalStateException("Multiple system services handle " + this
7684 + ": " + comp + ", " + foundComp);
7685 }
7686 comp = foundComp;
7687 }
7688 return comp;
7689 }
7690
7691 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007692 * Set the general action to be performed.
7693 *
7694 * @param action An action name, such as ACTION_VIEW. Application-specific
7695 * actions should be prefixed with the vendor's package name.
7696 *
7697 * @return Returns the same Intent object, for chaining multiple calls
7698 * into a single statement.
7699 *
7700 * @see #getAction
7701 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007702 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007703 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007704 return this;
7705 }
7706
7707 /**
7708 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007709 * clears any type that was previously set by {@link #setType} or
7710 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007711 *
Nick Pellyccae4122012-01-09 14:12:58 -08007712 * <p><em>Note: scheme matching in the Android framework is
7713 * case-sensitive, unlike the formal RFC. As a result,
7714 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007715 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007716 * {@link #setDataAndNormalize}
7717 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007718 *
Nick Pellyccae4122012-01-09 14:12:58 -08007719 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007720 *
7721 * @return Returns the same Intent object, for chaining multiple calls
7722 * into a single statement.
7723 *
7724 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007725 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007726 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007727 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007728 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007729 mData = data;
7730 mType = null;
7731 return this;
7732 }
7733
7734 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007735 * Normalize and set the data this intent is operating on.
7736 *
7737 * <p>This method automatically clears any type that was
7738 * previously set (for example, by {@link #setType}).
7739 *
7740 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007741 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007742 * so really this is just a convenience method for
7743 * <pre>
7744 * setData(data.normalize())
7745 * </pre>
7746 *
7747 * @param data The Uri of the data this intent is now targeting.
7748 *
7749 * @return Returns the same Intent object, for chaining multiple calls
7750 * into a single statement.
7751 *
7752 * @see #getData
7753 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007754 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007755 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007756 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007757 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007758 }
7759
7760 /**
7761 * Set an explicit MIME data type.
7762 *
7763 * <p>This is used to create intents that only specify a type and not data,
7764 * for example to indicate the type of data to return.
7765 *
7766 * <p>This method automatically clears any data that was
7767 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007768 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007769 * <p><em>Note: MIME type matching in the Android framework is
7770 * case-sensitive, unlike formal RFC MIME types. As a result,
7771 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007772 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7773 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007774 *
7775 * @param type The MIME type of the data being handled by this intent.
7776 *
7777 * @return Returns the same Intent object, for chaining multiple calls
7778 * into a single statement.
7779 *
7780 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007781 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007782 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007783 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007784 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007785 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007786 mData = null;
7787 mType = type;
7788 return this;
7789 }
7790
7791 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007792 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007793 *
Nick Pellyccae4122012-01-09 14:12:58 -08007794 * <p>This is used to create intents that only specify a type and not data,
7795 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007796 *
Nick Pellyccae4122012-01-09 14:12:58 -08007797 * <p>This method automatically clears any data that was
7798 * previously set (for example by {@link #setData}).
7799 *
7800 * <p>The MIME type is normalized using
7801 * {@link #normalizeMimeType} before it is set,
7802 * so really this is just a convenience method for
7803 * <pre>
7804 * setType(Intent.normalizeMimeType(type))
7805 * </pre>
7806 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007807 * @param type The MIME type of the data being handled by this intent.
7808 *
7809 * @return Returns the same Intent object, for chaining multiple calls
7810 * into a single statement.
7811 *
Nick Pellyccae4122012-01-09 14:12:58 -08007812 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007813 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007814 * @see #normalizeMimeType
7815 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007816 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007817 return setType(normalizeMimeType(type));
7818 }
7819
7820 /**
7821 * (Usually optional) Set the data for the intent along with an explicit
7822 * MIME data type. This method should very rarely be used -- it allows you
7823 * to override the MIME type that would ordinarily be inferred from the
7824 * data with your own type given here.
7825 *
7826 * <p><em>Note: MIME type and Uri scheme matching in the
7827 * Android framework is case-sensitive, unlike the formal RFC definitions.
7828 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007829 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007830 * {@link #setDataAndTypeAndNormalize}
7831 * to ensure that they are converted to lower case.</em>
7832 *
7833 * @param data The Uri of the data this intent is now targeting.
7834 * @param type The MIME type of the data being handled by this intent.
7835 *
7836 * @return Returns the same Intent object, for chaining multiple calls
7837 * into a single statement.
7838 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007839 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007840 * @see #setData
7841 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007842 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007843 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007844 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007845 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 mData = data;
7847 mType = type;
7848 return this;
7849 }
7850
7851 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007852 * (Usually optional) Normalize and set both the data Uri and an explicit
7853 * MIME data type. This method should very rarely be used -- it allows you
7854 * to override the MIME type that would ordinarily be inferred from the
7855 * data with your own type given here.
7856 *
7857 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007858 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007859 * before they are set, so really this is just a convenience method for
7860 * <pre>
7861 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7862 * </pre>
7863 *
7864 * @param data The Uri of the data this intent is now targeting.
7865 * @param type The MIME type of the data being handled by this intent.
7866 *
7867 * @return Returns the same Intent object, for chaining multiple calls
7868 * into a single statement.
7869 *
7870 * @see #setType
7871 * @see #setData
7872 * @see #setDataAndType
7873 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007874 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007875 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007876 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007877 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007878 }
7879
7880 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007881 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007882 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007883 * activities that provide <em>all</em> of the requested categories will be
7884 * used.
7885 *
7886 * @param category The desired category. This can be either one of the
7887 * predefined Intent categories, or a custom category in your own
7888 * namespace.
7889 *
7890 * @return Returns the same Intent object, for chaining multiple calls
7891 * into a single statement.
7892 *
7893 * @see #hasCategory
7894 * @see #removeCategory
7895 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007896 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007897 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007898 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007899 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007900 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007901 return this;
7902 }
7903
7904 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007905 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007906 *
7907 * @param category The category to remove.
7908 *
7909 * @see #addCategory
7910 */
7911 public void removeCategory(String category) {
7912 if (mCategories != null) {
7913 mCategories.remove(category);
7914 if (mCategories.size() == 0) {
7915 mCategories = null;
7916 }
7917 }
7918 }
7919
7920 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007921 * Set a selector for this Intent. This is a modification to the kinds of
7922 * things the Intent will match. If the selector is set, it will be used
7923 * when trying to find entities that can handle the Intent, instead of the
7924 * main contents of the Intent. This allows you build an Intent containing
7925 * a generic protocol while targeting it more specifically.
7926 *
7927 * <p>An example of where this may be used is with things like
7928 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7929 * Intent that will launch the Browser application. However, the correct
7930 * main entry point of an application is actually {@link #ACTION_MAIN}
7931 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7932 * used to specify the actual Activity to launch. If you launch the browser
7933 * with something different, undesired behavior may happen if the user has
7934 * previously or later launches it the normal way, since they do not match.
7935 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7936 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7937 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7938 *
7939 * <p>Setting a selector does not impact the behavior of
7940 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7941 * desired behavior of a selector -- it does not impact the base meaning
7942 * of the Intent, just what kinds of things will be matched against it
7943 * when determining who can handle it.</p>
7944 *
7945 * <p>You can not use both a selector and {@link #setPackage(String)} on
7946 * the same base Intent.</p>
7947 *
7948 * @param selector The desired selector Intent; set to null to not use
7949 * a special selector.
7950 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007951 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007952 if (selector == this) {
7953 throw new IllegalArgumentException(
7954 "Intent being set as a selector of itself");
7955 }
7956 if (selector != null && mPackage != null) {
7957 throw new IllegalArgumentException(
7958 "Can't set selector when package name is already set");
7959 }
7960 mSelector = selector;
7961 }
7962
7963 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007964 * Set a {@link ClipData} associated with this Intent. This replaces any
7965 * previously set ClipData.
7966 *
7967 * <p>The ClipData in an intent is not used for Intent matching or other
7968 * such operations. Semantically it is like extras, used to transmit
7969 * additional data with the Intent. The main feature of using this over
7970 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7971 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7972 * items included in the clip data. This is useful, in particular, if
7973 * you want to transmit an Intent containing multiple <code>content:</code>
7974 * URIs for which the recipient may not have global permission to access the
7975 * content provider.
7976 *
7977 * <p>If the ClipData contains items that are themselves Intents, any
7978 * grant flags in those Intents will be ignored. Only the top-level flags
7979 * of the main Intent are respected, and will be applied to all Uri or
7980 * Intent items in the clip (or sub-items of the clip).
7981 *
7982 * <p>The MIME type, label, and icon in the ClipData object are not
7983 * directly used by Intent. Applications should generally rely on the
7984 * MIME type of the Intent itself, not what it may find in the ClipData.
7985 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007986 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007987 *
7988 * @param clip The new clip to set. May be null to clear the current clip.
7989 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007990 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007991 mClipData = clip;
7992 }
7993
7994 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007995 * This is NOT a secure mechanism to identify the user who sent the intent.
7996 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7997 * who sent the intent.
7998 * @hide
7999 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008000 public void prepareToLeaveUser(int userId) {
8001 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8002 // We want mContentUserHint to refer to the original user, so don't do anything.
8003 if (mContentUserHint == UserHandle.USER_CURRENT) {
8004 mContentUserHint = userId;
8005 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008006 }
8007
8008 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008009 * Add extended data to the intent. The name must include a package
8010 * prefix, for example the app com.android.contacts would use names
8011 * like "com.android.contacts.ShowAll".
8012 *
8013 * @param name The name of the extra data, with package prefix.
8014 * @param value The boolean data value.
8015 *
8016 * @return Returns the same Intent object, for chaining multiple calls
8017 * into a single statement.
8018 *
8019 * @see #putExtras
8020 * @see #removeExtra
8021 * @see #getBooleanExtra(String, boolean)
8022 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008023 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008024 if (mExtras == null) {
8025 mExtras = new Bundle();
8026 }
8027 mExtras.putBoolean(name, value);
8028 return this;
8029 }
8030
8031 /**
8032 * Add extended data to the intent. The name must include a package
8033 * prefix, for example the app com.android.contacts would use names
8034 * like "com.android.contacts.ShowAll".
8035 *
8036 * @param name The name of the extra data, with package prefix.
8037 * @param value The byte data value.
8038 *
8039 * @return Returns the same Intent object, for chaining multiple calls
8040 * into a single statement.
8041 *
8042 * @see #putExtras
8043 * @see #removeExtra
8044 * @see #getByteExtra(String, byte)
8045 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008046 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008047 if (mExtras == null) {
8048 mExtras = new Bundle();
8049 }
8050 mExtras.putByte(name, value);
8051 return this;
8052 }
8053
8054 /**
8055 * Add extended data to the intent. The name must include a package
8056 * prefix, for example the app com.android.contacts would use names
8057 * like "com.android.contacts.ShowAll".
8058 *
8059 * @param name The name of the extra data, with package prefix.
8060 * @param value The char data value.
8061 *
8062 * @return Returns the same Intent object, for chaining multiple calls
8063 * into a single statement.
8064 *
8065 * @see #putExtras
8066 * @see #removeExtra
8067 * @see #getCharExtra(String, char)
8068 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008069 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 if (mExtras == null) {
8071 mExtras = new Bundle();
8072 }
8073 mExtras.putChar(name, value);
8074 return this;
8075 }
8076
8077 /**
8078 * Add extended data to the intent. The name must include a package
8079 * prefix, for example the app com.android.contacts would use names
8080 * like "com.android.contacts.ShowAll".
8081 *
8082 * @param name The name of the extra data, with package prefix.
8083 * @param value The short data value.
8084 *
8085 * @return Returns the same Intent object, for chaining multiple calls
8086 * into a single statement.
8087 *
8088 * @see #putExtras
8089 * @see #removeExtra
8090 * @see #getShortExtra(String, short)
8091 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008092 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008093 if (mExtras == null) {
8094 mExtras = new Bundle();
8095 }
8096 mExtras.putShort(name, value);
8097 return this;
8098 }
8099
8100 /**
8101 * Add extended data to the intent. The name must include a package
8102 * prefix, for example the app com.android.contacts would use names
8103 * like "com.android.contacts.ShowAll".
8104 *
8105 * @param name The name of the extra data, with package prefix.
8106 * @param value The integer data value.
8107 *
8108 * @return Returns the same Intent object, for chaining multiple calls
8109 * into a single statement.
8110 *
8111 * @see #putExtras
8112 * @see #removeExtra
8113 * @see #getIntExtra(String, int)
8114 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008115 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008116 if (mExtras == null) {
8117 mExtras = new Bundle();
8118 }
8119 mExtras.putInt(name, value);
8120 return this;
8121 }
8122
8123 /**
8124 * Add extended data to the intent. The name must include a package
8125 * prefix, for example the app com.android.contacts would use names
8126 * like "com.android.contacts.ShowAll".
8127 *
8128 * @param name The name of the extra data, with package prefix.
8129 * @param value The long data value.
8130 *
8131 * @return Returns the same Intent object, for chaining multiple calls
8132 * into a single statement.
8133 *
8134 * @see #putExtras
8135 * @see #removeExtra
8136 * @see #getLongExtra(String, long)
8137 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008138 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008139 if (mExtras == null) {
8140 mExtras = new Bundle();
8141 }
8142 mExtras.putLong(name, value);
8143 return this;
8144 }
8145
8146 /**
8147 * Add extended data to the intent. The name must include a package
8148 * prefix, for example the app com.android.contacts would use names
8149 * like "com.android.contacts.ShowAll".
8150 *
8151 * @param name The name of the extra data, with package prefix.
8152 * @param value The float data value.
8153 *
8154 * @return Returns the same Intent object, for chaining multiple calls
8155 * into a single statement.
8156 *
8157 * @see #putExtras
8158 * @see #removeExtra
8159 * @see #getFloatExtra(String, float)
8160 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008161 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008162 if (mExtras == null) {
8163 mExtras = new Bundle();
8164 }
8165 mExtras.putFloat(name, value);
8166 return this;
8167 }
8168
8169 /**
8170 * Add extended data to the intent. The name must include a package
8171 * prefix, for example the app com.android.contacts would use names
8172 * like "com.android.contacts.ShowAll".
8173 *
8174 * @param name The name of the extra data, with package prefix.
8175 * @param value The double data value.
8176 *
8177 * @return Returns the same Intent object, for chaining multiple calls
8178 * into a single statement.
8179 *
8180 * @see #putExtras
8181 * @see #removeExtra
8182 * @see #getDoubleExtra(String, double)
8183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008184 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008185 if (mExtras == null) {
8186 mExtras = new Bundle();
8187 }
8188 mExtras.putDouble(name, value);
8189 return this;
8190 }
8191
8192 /**
8193 * Add extended data to the intent. The name must include a package
8194 * prefix, for example the app com.android.contacts would use names
8195 * like "com.android.contacts.ShowAll".
8196 *
8197 * @param name The name of the extra data, with package prefix.
8198 * @param value The String data value.
8199 *
8200 * @return Returns the same Intent object, for chaining multiple calls
8201 * into a single statement.
8202 *
8203 * @see #putExtras
8204 * @see #removeExtra
8205 * @see #getStringExtra(String)
8206 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008207 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008208 if (mExtras == null) {
8209 mExtras = new Bundle();
8210 }
8211 mExtras.putString(name, value);
8212 return this;
8213 }
8214
8215 /**
8216 * Add extended data to the intent. The name must include a package
8217 * prefix, for example the app com.android.contacts would use names
8218 * like "com.android.contacts.ShowAll".
8219 *
8220 * @param name The name of the extra data, with package prefix.
8221 * @param value The CharSequence data value.
8222 *
8223 * @return Returns the same Intent object, for chaining multiple calls
8224 * into a single statement.
8225 *
8226 * @see #putExtras
8227 * @see #removeExtra
8228 * @see #getCharSequenceExtra(String)
8229 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008230 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008231 if (mExtras == null) {
8232 mExtras = new Bundle();
8233 }
8234 mExtras.putCharSequence(name, value);
8235 return this;
8236 }
8237
8238 /**
8239 * Add extended data to the intent. The name must include a package
8240 * prefix, for example the app com.android.contacts would use names
8241 * like "com.android.contacts.ShowAll".
8242 *
8243 * @param name The name of the extra data, with package prefix.
8244 * @param value The Parcelable data value.
8245 *
8246 * @return Returns the same Intent object, for chaining multiple calls
8247 * into a single statement.
8248 *
8249 * @see #putExtras
8250 * @see #removeExtra
8251 * @see #getParcelableExtra(String)
8252 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008253 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008254 if (mExtras == null) {
8255 mExtras = new Bundle();
8256 }
8257 mExtras.putParcelable(name, value);
8258 return this;
8259 }
8260
8261 /**
8262 * Add extended data to the intent. The name must include a package
8263 * prefix, for example the app com.android.contacts would use names
8264 * like "com.android.contacts.ShowAll".
8265 *
8266 * @param name The name of the extra data, with package prefix.
8267 * @param value The Parcelable[] data value.
8268 *
8269 * @return Returns the same Intent object, for chaining multiple calls
8270 * into a single statement.
8271 *
8272 * @see #putExtras
8273 * @see #removeExtra
8274 * @see #getParcelableArrayExtra(String)
8275 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008276 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008277 if (mExtras == null) {
8278 mExtras = new Bundle();
8279 }
8280 mExtras.putParcelableArray(name, value);
8281 return this;
8282 }
8283
8284 /**
8285 * Add extended data to the intent. The name must include a package
8286 * prefix, for example the app com.android.contacts would use names
8287 * like "com.android.contacts.ShowAll".
8288 *
8289 * @param name The name of the extra data, with package prefix.
8290 * @param value The ArrayList<Parcelable> data value.
8291 *
8292 * @return Returns the same Intent object, for chaining multiple calls
8293 * into a single statement.
8294 *
8295 * @see #putExtras
8296 * @see #removeExtra
8297 * @see #getParcelableArrayListExtra(String)
8298 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008299 public @NonNull Intent putParcelableArrayListExtra(String name,
8300 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008301 if (mExtras == null) {
8302 mExtras = new Bundle();
8303 }
8304 mExtras.putParcelableArrayList(name, value);
8305 return this;
8306 }
8307
8308 /**
8309 * Add extended data to the intent. The name must include a package
8310 * prefix, for example the app com.android.contacts would use names
8311 * like "com.android.contacts.ShowAll".
8312 *
8313 * @param name The name of the extra data, with package prefix.
8314 * @param value The ArrayList<Integer> data value.
8315 *
8316 * @return Returns the same Intent object, for chaining multiple calls
8317 * into a single statement.
8318 *
8319 * @see #putExtras
8320 * @see #removeExtra
8321 * @see #getIntegerArrayListExtra(String)
8322 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008323 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008324 if (mExtras == null) {
8325 mExtras = new Bundle();
8326 }
8327 mExtras.putIntegerArrayList(name, value);
8328 return this;
8329 }
8330
8331 /**
8332 * Add extended data to the intent. The name must include a package
8333 * prefix, for example the app com.android.contacts would use names
8334 * like "com.android.contacts.ShowAll".
8335 *
8336 * @param name The name of the extra data, with package prefix.
8337 * @param value The ArrayList<String> data value.
8338 *
8339 * @return Returns the same Intent object, for chaining multiple calls
8340 * into a single statement.
8341 *
8342 * @see #putExtras
8343 * @see #removeExtra
8344 * @see #getStringArrayListExtra(String)
8345 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008346 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008347 if (mExtras == null) {
8348 mExtras = new Bundle();
8349 }
8350 mExtras.putStringArrayList(name, value);
8351 return this;
8352 }
8353
8354 /**
8355 * Add extended data to the intent. The name must include a package
8356 * prefix, for example the app com.android.contacts would use names
8357 * like "com.android.contacts.ShowAll".
8358 *
8359 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008360 * @param value The ArrayList<CharSequence> data value.
8361 *
8362 * @return Returns the same Intent object, for chaining multiple calls
8363 * into a single statement.
8364 *
8365 * @see #putExtras
8366 * @see #removeExtra
8367 * @see #getCharSequenceArrayListExtra(String)
8368 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008369 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8370 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008371 if (mExtras == null) {
8372 mExtras = new Bundle();
8373 }
8374 mExtras.putCharSequenceArrayList(name, value);
8375 return this;
8376 }
8377
8378 /**
8379 * Add extended data to the intent. The name must include a package
8380 * prefix, for example the app com.android.contacts would use names
8381 * like "com.android.contacts.ShowAll".
8382 *
8383 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008384 * @param value The Serializable data value.
8385 *
8386 * @return Returns the same Intent object, for chaining multiple calls
8387 * into a single statement.
8388 *
8389 * @see #putExtras
8390 * @see #removeExtra
8391 * @see #getSerializableExtra(String)
8392 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008393 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008394 if (mExtras == null) {
8395 mExtras = new Bundle();
8396 }
8397 mExtras.putSerializable(name, value);
8398 return this;
8399 }
8400
8401 /**
8402 * Add extended data to the intent. The name must include a package
8403 * prefix, for example the app com.android.contacts would use names
8404 * like "com.android.contacts.ShowAll".
8405 *
8406 * @param name The name of the extra data, with package prefix.
8407 * @param value The boolean array data value.
8408 *
8409 * @return Returns the same Intent object, for chaining multiple calls
8410 * into a single statement.
8411 *
8412 * @see #putExtras
8413 * @see #removeExtra
8414 * @see #getBooleanArrayExtra(String)
8415 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008416 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008417 if (mExtras == null) {
8418 mExtras = new Bundle();
8419 }
8420 mExtras.putBooleanArray(name, value);
8421 return this;
8422 }
8423
8424 /**
8425 * Add extended data to the intent. The name must include a package
8426 * prefix, for example the app com.android.contacts would use names
8427 * like "com.android.contacts.ShowAll".
8428 *
8429 * @param name The name of the extra data, with package prefix.
8430 * @param value The byte array data value.
8431 *
8432 * @return Returns the same Intent object, for chaining multiple calls
8433 * into a single statement.
8434 *
8435 * @see #putExtras
8436 * @see #removeExtra
8437 * @see #getByteArrayExtra(String)
8438 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008439 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008440 if (mExtras == null) {
8441 mExtras = new Bundle();
8442 }
8443 mExtras.putByteArray(name, value);
8444 return this;
8445 }
8446
8447 /**
8448 * Add extended data to the intent. The name must include a package
8449 * prefix, for example the app com.android.contacts would use names
8450 * like "com.android.contacts.ShowAll".
8451 *
8452 * @param name The name of the extra data, with package prefix.
8453 * @param value The short array data value.
8454 *
8455 * @return Returns the same Intent object, for chaining multiple calls
8456 * into a single statement.
8457 *
8458 * @see #putExtras
8459 * @see #removeExtra
8460 * @see #getShortArrayExtra(String)
8461 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008462 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008463 if (mExtras == null) {
8464 mExtras = new Bundle();
8465 }
8466 mExtras.putShortArray(name, value);
8467 return this;
8468 }
8469
8470 /**
8471 * Add extended data to the intent. The name must include a package
8472 * prefix, for example the app com.android.contacts would use names
8473 * like "com.android.contacts.ShowAll".
8474 *
8475 * @param name The name of the extra data, with package prefix.
8476 * @param value The char array data value.
8477 *
8478 * @return Returns the same Intent object, for chaining multiple calls
8479 * into a single statement.
8480 *
8481 * @see #putExtras
8482 * @see #removeExtra
8483 * @see #getCharArrayExtra(String)
8484 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008485 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008486 if (mExtras == null) {
8487 mExtras = new Bundle();
8488 }
8489 mExtras.putCharArray(name, value);
8490 return this;
8491 }
8492
8493 /**
8494 * Add extended data to the intent. The name must include a package
8495 * prefix, for example the app com.android.contacts would use names
8496 * like "com.android.contacts.ShowAll".
8497 *
8498 * @param name The name of the extra data, with package prefix.
8499 * @param value The int array data value.
8500 *
8501 * @return Returns the same Intent object, for chaining multiple calls
8502 * into a single statement.
8503 *
8504 * @see #putExtras
8505 * @see #removeExtra
8506 * @see #getIntArrayExtra(String)
8507 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008508 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008509 if (mExtras == null) {
8510 mExtras = new Bundle();
8511 }
8512 mExtras.putIntArray(name, value);
8513 return this;
8514 }
8515
8516 /**
8517 * Add extended data to the intent. The name must include a package
8518 * prefix, for example the app com.android.contacts would use names
8519 * like "com.android.contacts.ShowAll".
8520 *
8521 * @param name The name of the extra data, with package prefix.
8522 * @param value The byte array data value.
8523 *
8524 * @return Returns the same Intent object, for chaining multiple calls
8525 * into a single statement.
8526 *
8527 * @see #putExtras
8528 * @see #removeExtra
8529 * @see #getLongArrayExtra(String)
8530 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008531 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008532 if (mExtras == null) {
8533 mExtras = new Bundle();
8534 }
8535 mExtras.putLongArray(name, value);
8536 return this;
8537 }
8538
8539 /**
8540 * Add extended data to the intent. The name must include a package
8541 * prefix, for example the app com.android.contacts would use names
8542 * like "com.android.contacts.ShowAll".
8543 *
8544 * @param name The name of the extra data, with package prefix.
8545 * @param value The float array data value.
8546 *
8547 * @return Returns the same Intent object, for chaining multiple calls
8548 * into a single statement.
8549 *
8550 * @see #putExtras
8551 * @see #removeExtra
8552 * @see #getFloatArrayExtra(String)
8553 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008554 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 if (mExtras == null) {
8556 mExtras = new Bundle();
8557 }
8558 mExtras.putFloatArray(name, value);
8559 return this;
8560 }
8561
8562 /**
8563 * Add extended data to the intent. The name must include a package
8564 * prefix, for example the app com.android.contacts would use names
8565 * like "com.android.contacts.ShowAll".
8566 *
8567 * @param name The name of the extra data, with package prefix.
8568 * @param value The double array data value.
8569 *
8570 * @return Returns the same Intent object, for chaining multiple calls
8571 * into a single statement.
8572 *
8573 * @see #putExtras
8574 * @see #removeExtra
8575 * @see #getDoubleArrayExtra(String)
8576 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008577 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008578 if (mExtras == null) {
8579 mExtras = new Bundle();
8580 }
8581 mExtras.putDoubleArray(name, value);
8582 return this;
8583 }
8584
8585 /**
8586 * Add extended data to the intent. The name must include a package
8587 * prefix, for example the app com.android.contacts would use names
8588 * like "com.android.contacts.ShowAll".
8589 *
8590 * @param name The name of the extra data, with package prefix.
8591 * @param value The String array data value.
8592 *
8593 * @return Returns the same Intent object, for chaining multiple calls
8594 * into a single statement.
8595 *
8596 * @see #putExtras
8597 * @see #removeExtra
8598 * @see #getStringArrayExtra(String)
8599 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008600 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008601 if (mExtras == null) {
8602 mExtras = new Bundle();
8603 }
8604 mExtras.putStringArray(name, value);
8605 return this;
8606 }
8607
8608 /**
8609 * Add extended data to the intent. The name must include a package
8610 * prefix, for example the app com.android.contacts would use names
8611 * like "com.android.contacts.ShowAll".
8612 *
8613 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008614 * @param value The CharSequence array data value.
8615 *
8616 * @return Returns the same Intent object, for chaining multiple calls
8617 * into a single statement.
8618 *
8619 * @see #putExtras
8620 * @see #removeExtra
8621 * @see #getCharSequenceArrayExtra(String)
8622 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008623 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008624 if (mExtras == null) {
8625 mExtras = new Bundle();
8626 }
8627 mExtras.putCharSequenceArray(name, value);
8628 return this;
8629 }
8630
8631 /**
8632 * Add extended data to the intent. The name must include a package
8633 * prefix, for example the app com.android.contacts would use names
8634 * like "com.android.contacts.ShowAll".
8635 *
8636 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008637 * @param value The Bundle data value.
8638 *
8639 * @return Returns the same Intent object, for chaining multiple calls
8640 * into a single statement.
8641 *
8642 * @see #putExtras
8643 * @see #removeExtra
8644 * @see #getBundleExtra(String)
8645 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008646 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008647 if (mExtras == null) {
8648 mExtras = new Bundle();
8649 }
8650 mExtras.putBundle(name, value);
8651 return this;
8652 }
8653
8654 /**
8655 * Add extended data to the intent. The name must include a package
8656 * prefix, for example the app com.android.contacts would use names
8657 * like "com.android.contacts.ShowAll".
8658 *
8659 * @param name The name of the extra data, with package prefix.
8660 * @param value The IBinder data value.
8661 *
8662 * @return Returns the same Intent object, for chaining multiple calls
8663 * into a single statement.
8664 *
8665 * @see #putExtras
8666 * @see #removeExtra
8667 * @see #getIBinderExtra(String)
8668 *
8669 * @deprecated
8670 * @hide
8671 */
8672 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008673 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008674 if (mExtras == null) {
8675 mExtras = new Bundle();
8676 }
8677 mExtras.putIBinder(name, value);
8678 return this;
8679 }
8680
8681 /**
8682 * Copy all extras in 'src' in to this intent.
8683 *
8684 * @param src Contains the extras to copy.
8685 *
8686 * @see #putExtra
8687 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008688 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008689 if (src.mExtras != null) {
8690 if (mExtras == null) {
8691 mExtras = new Bundle(src.mExtras);
8692 } else {
8693 mExtras.putAll(src.mExtras);
8694 }
8695 }
8696 return this;
8697 }
8698
8699 /**
8700 * Add a set of extended data to the intent. The keys must include a package
8701 * prefix, for example the app com.android.contacts would use names
8702 * like "com.android.contacts.ShowAll".
8703 *
8704 * @param extras The Bundle of extras to add to this intent.
8705 *
8706 * @see #putExtra
8707 * @see #removeExtra
8708 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008709 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008710 if (mExtras == null) {
8711 mExtras = new Bundle();
8712 }
8713 mExtras.putAll(extras);
8714 return this;
8715 }
8716
8717 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008718 * Completely replace the extras in the Intent with the extras in the
8719 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008720 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008721 * @param src The exact extras contained in this Intent are copied
8722 * into the target intent, replacing any that were previously there.
8723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008724 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008725 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8726 return this;
8727 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008728
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008729 /**
8730 * Completely replace the extras in the Intent with the given Bundle of
8731 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008732 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008733 * @param extras The new set of extras in the Intent, or null to erase
8734 * all extras.
8735 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008736 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008737 mExtras = extras != null ? new Bundle(extras) : null;
8738 return this;
8739 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008740
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008741 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008742 * Remove extended data from the intent.
8743 *
8744 * @see #putExtra
8745 */
8746 public void removeExtra(String name) {
8747 if (mExtras != null) {
8748 mExtras.remove(name);
8749 if (mExtras.size() == 0) {
8750 mExtras = null;
8751 }
8752 }
8753 }
8754
8755 /**
8756 * Set special flags controlling how this intent is handled. Most values
8757 * here depend on the type of component being executed by the Intent,
8758 * specifically the FLAG_ACTIVITY_* flags are all for use with
8759 * {@link Context#startActivity Context.startActivity()} and the
8760 * FLAG_RECEIVER_* flags are all for use with
8761 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8762 *
Scott Main7aee61f2011-02-08 11:25:01 -08008763 * <p>See the
8764 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8765 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008766 * the behavior of your application.
8767 *
8768 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008769 * @return Returns the same Intent object, for chaining multiple calls
8770 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008771 * @see #getFlags
8772 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008773 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008774 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008775 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008776 mFlags = flags;
8777 return this;
8778 }
8779
8780 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008781 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008782 *
8783 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008784 * @return Returns the same Intent object, for chaining multiple calls into
8785 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008786 * @see #setFlags
8787 * @see #getFlags
8788 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008789 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008790 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008791 mFlags |= flags;
8792 return this;
8793 }
8794
8795 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008796 * Remove these flags from the intent.
8797 *
8798 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008799 * @see #setFlags
8800 * @see #getFlags
8801 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008802 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008803 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008804 mFlags &= ~flags;
8805 }
8806
8807 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008808 * (Usually optional) Set an explicit application package name that limits
8809 * the components this Intent will resolve to. If left to the default
8810 * value of null, all components in all applications will considered.
8811 * If non-null, the Intent can only match the components in the given
8812 * application package.
8813 *
8814 * @param packageName The name of the application package to handle the
8815 * intent, or null to allow any application package.
8816 *
8817 * @return Returns the same Intent object, for chaining multiple calls
8818 * into a single statement.
8819 *
8820 * @see #getPackage
8821 * @see #resolveActivity
8822 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008823 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008824 if (packageName != null && mSelector != null) {
8825 throw new IllegalArgumentException(
8826 "Can't set package name when selector is already set");
8827 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008828 mPackage = packageName;
8829 return this;
8830 }
8831
8832 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008833 * (Usually optional) Explicitly set the component to handle the intent.
8834 * If left with the default value of null, the system will determine the
8835 * appropriate class to use based on the other fields (action, data,
8836 * type, categories) in the Intent. If this class is defined, the
8837 * specified class will always be used regardless of the other fields. You
8838 * should only set this value when you know you absolutely want a specific
8839 * class to be used; otherwise it is better to let the system find the
8840 * appropriate class so that you will respect the installed applications
8841 * and user preferences.
8842 *
8843 * @param component The name of the application component to handle the
8844 * intent, or null to let the system find one for you.
8845 *
8846 * @return Returns the same Intent object, for chaining multiple calls
8847 * into a single statement.
8848 *
8849 * @see #setClass
8850 * @see #setClassName(Context, String)
8851 * @see #setClassName(String, String)
8852 * @see #getComponent
8853 * @see #resolveActivity
8854 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008855 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008856 mComponent = component;
8857 return this;
8858 }
8859
8860 /**
8861 * Convenience for calling {@link #setComponent} with an
8862 * explicit class name.
8863 *
8864 * @param packageContext A Context of the application package implementing
8865 * this class.
8866 * @param className The name of a class inside of the application package
8867 * that will be used as the component for this Intent.
8868 *
8869 * @return Returns the same Intent object, for chaining multiple calls
8870 * into a single statement.
8871 *
8872 * @see #setComponent
8873 * @see #setClass
8874 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008875 public @NonNull Intent setClassName(@NonNull Context packageContext,
8876 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008877 mComponent = new ComponentName(packageContext, className);
8878 return this;
8879 }
8880
8881 /**
8882 * Convenience for calling {@link #setComponent} with an
8883 * explicit application package name and class name.
8884 *
8885 * @param packageName The name of the package implementing the desired
8886 * component.
8887 * @param className The name of a class inside of the application package
8888 * that will be used as the component for this Intent.
8889 *
8890 * @return Returns the same Intent object, for chaining multiple calls
8891 * into a single statement.
8892 *
8893 * @see #setComponent
8894 * @see #setClass
8895 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008896 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008897 mComponent = new ComponentName(packageName, className);
8898 return this;
8899 }
8900
8901 /**
8902 * Convenience for calling {@link #setComponent(ComponentName)} with the
8903 * name returned by a {@link Class} object.
8904 *
8905 * @param packageContext A Context of the application package implementing
8906 * this class.
8907 * @param cls The class name to set, equivalent to
8908 * <code>setClassName(context, cls.getName())</code>.
8909 *
8910 * @return Returns the same Intent object, for chaining multiple calls
8911 * into a single statement.
8912 *
8913 * @see #setComponent
8914 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008915 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008916 mComponent = new ComponentName(packageContext, cls);
8917 return this;
8918 }
8919
8920 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008921 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8922 * used as a hint to the receiver for animations and the like. Null means that there
8923 * is no source bounds.
8924 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008925 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008926 if (r != null) {
8927 mSourceBounds = new Rect(r);
8928 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008929 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008930 }
8931 }
8932
Tor Norbyed9273d62013-05-30 15:59:53 -07008933 /** @hide */
8934 @IntDef(flag = true,
8935 value = {
8936 FILL_IN_ACTION,
8937 FILL_IN_DATA,
8938 FILL_IN_CATEGORIES,
8939 FILL_IN_COMPONENT,
8940 FILL_IN_PACKAGE,
8941 FILL_IN_SOURCE_BOUNDS,
8942 FILL_IN_SELECTOR,
8943 FILL_IN_CLIP_DATA
8944 })
8945 @Retention(RetentionPolicy.SOURCE)
8946 public @interface FillInFlags {}
8947
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008948 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008949 * Use with {@link #fillIn} to allow the current action value to be
8950 * overwritten, even if it is already set.
8951 */
8952 public static final int FILL_IN_ACTION = 1<<0;
8953
8954 /**
8955 * Use with {@link #fillIn} to allow the current data or type value
8956 * overwritten, even if it is already set.
8957 */
8958 public static final int FILL_IN_DATA = 1<<1;
8959
8960 /**
8961 * Use with {@link #fillIn} to allow the current categories to be
8962 * overwritten, even if they are already set.
8963 */
8964 public static final int FILL_IN_CATEGORIES = 1<<2;
8965
8966 /**
8967 * Use with {@link #fillIn} to allow the current component value to be
8968 * overwritten, even if it is already set.
8969 */
8970 public static final int FILL_IN_COMPONENT = 1<<3;
8971
8972 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008973 * Use with {@link #fillIn} to allow the current package value to be
8974 * overwritten, even if it is already set.
8975 */
8976 public static final int FILL_IN_PACKAGE = 1<<4;
8977
8978 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008979 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008980 * overwritten, even if it is already set.
8981 */
8982 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8983
8984 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008985 * Use with {@link #fillIn} to allow the current selector to be
8986 * overwritten, even if it is already set.
8987 */
8988 public static final int FILL_IN_SELECTOR = 1<<6;
8989
8990 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008991 * Use with {@link #fillIn} to allow the current ClipData to be
8992 * overwritten, even if it is already set.
8993 */
8994 public static final int FILL_IN_CLIP_DATA = 1<<7;
8995
8996 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008997 * Copy the contents of <var>other</var> in to this object, but only
8998 * where fields are not defined by this object. For purposes of a field
8999 * being defined, the following pieces of data in the Intent are
9000 * considered to be separate fields:
9001 *
9002 * <ul>
9003 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009004 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009005 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9006 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009007 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009008 * <li> component, as set by {@link #setComponent(ComponentName)} or
9009 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009010 * <li> source bounds, as set by {@link #setSourceBounds}.
9011 * <li> selector, as set by {@link #setSelector(Intent)}.
9012 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009013 * <li> each top-level name in the associated extras.
9014 * </ul>
9015 *
9016 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009017 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009018 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9019 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9020 * the restriction where the corresponding field will not be replaced if
9021 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009022 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009023 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9024 * is explicitly specified. The selector will only be copied if
9025 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009026 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009027 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9028 * and Intent B with {action="gotit", data-type="some/thing",
9029 * categories="one","two"}.
9030 *
9031 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9032 * containing: {action="gotit", data-type="some/thing",
9033 * categories="bar"}.
9034 *
9035 * @param other Another Intent whose values are to be used to fill in
9036 * the current one.
9037 * @param flags Options to control which fields can be filled in.
9038 *
9039 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009040 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009041 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009042 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009043 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009044 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009045 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009046 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009047 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009048 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009049 if (other.mAction != null
9050 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009051 mAction = other.mAction;
9052 changes |= FILL_IN_ACTION;
9053 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009054 if ((other.mData != null || other.mType != null)
9055 && ((mData == null && mType == null)
9056 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009057 mData = other.mData;
9058 mType = other.mType;
9059 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009060 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009061 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009062 if (other.mCategories != null
9063 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009064 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009065 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009066 }
9067 changes |= FILL_IN_CATEGORIES;
9068 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009069 if (other.mPackage != null
9070 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009071 // Only do this if mSelector is not set.
9072 if (mSelector == null) {
9073 mPackage = other.mPackage;
9074 changes |= FILL_IN_PACKAGE;
9075 }
9076 }
9077 // Selector is special: it can only be set if explicitly allowed,
9078 // for the same reason as the component name.
9079 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9080 if (mPackage == null) {
9081 mSelector = new Intent(other.mSelector);
9082 mPackage = null;
9083 changes |= FILL_IN_SELECTOR;
9084 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009085 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009086 if (other.mClipData != null
9087 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9088 mClipData = other.mClipData;
9089 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009090 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009091 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009092 // Component is special: it can -only- be set if explicitly allowed,
9093 // since otherwise the sender could force the intent somewhere the
9094 // originator didn't intend.
9095 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009096 mComponent = other.mComponent;
9097 changes |= FILL_IN_COMPONENT;
9098 }
9099 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009100 if (other.mSourceBounds != null
9101 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9102 mSourceBounds = new Rect(other.mSourceBounds);
9103 changes |= FILL_IN_SOURCE_BOUNDS;
9104 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009105 if (mExtras == null) {
9106 if (other.mExtras != null) {
9107 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009108 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009109 }
9110 } else if (other.mExtras != null) {
9111 try {
9112 Bundle newb = new Bundle(other.mExtras);
9113 newb.putAll(mExtras);
9114 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009115 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 } catch (RuntimeException e) {
9117 // Modifying the extras can cause us to unparcel the contents
9118 // of the bundle, and if we do this in the system process that
9119 // may fail. We really should handle this (i.e., the Bundle
9120 // impl shouldn't be on top of a plain map), but for now just
9121 // ignore it and keep the original contents. :(
9122 Log.w("Intent", "Failure filling in extras", e);
9123 }
9124 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009125 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9126 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9127 mContentUserHint = other.mContentUserHint;
9128 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009129 return changes;
9130 }
9131
9132 /**
9133 * Wrapper class holding an Intent and implementing comparisons on it for
9134 * the purpose of filtering. The class implements its
9135 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9136 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9137 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9138 * on the wrapped Intent.
9139 */
9140 public static final class FilterComparison {
9141 private final Intent mIntent;
9142 private final int mHashCode;
9143
9144 public FilterComparison(Intent intent) {
9145 mIntent = intent;
9146 mHashCode = intent.filterHashCode();
9147 }
9148
9149 /**
9150 * Return the Intent that this FilterComparison represents.
9151 * @return Returns the Intent held by the FilterComparison. Do
9152 * not modify!
9153 */
9154 public Intent getIntent() {
9155 return mIntent;
9156 }
9157
9158 @Override
9159 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009160 if (obj instanceof FilterComparison) {
9161 Intent other = ((FilterComparison)obj).mIntent;
9162 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009163 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009164 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009165 }
9166
9167 @Override
9168 public int hashCode() {
9169 return mHashCode;
9170 }
9171 }
9172
9173 /**
9174 * Determine if two intents are the same for the purposes of intent
9175 * resolution (filtering). That is, if their action, data, type,
9176 * class, and categories are the same. This does <em>not</em> compare
9177 * any extra data included in the intents.
9178 *
9179 * @param other The other Intent to compare against.
9180 *
9181 * @return Returns true if action, data, type, class, and categories
9182 * are the same.
9183 */
9184 public boolean filterEquals(Intent other) {
9185 if (other == null) {
9186 return false;
9187 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009188 if (!Objects.equals(this.mAction, other.mAction)) return false;
9189 if (!Objects.equals(this.mData, other.mData)) return false;
9190 if (!Objects.equals(this.mType, other.mType)) return false;
9191 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9192 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9193 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009194
9195 return true;
9196 }
9197
9198 /**
9199 * Generate hash code that matches semantics of filterEquals().
9200 *
9201 * @return Returns the hash value of the action, data, type, class, and
9202 * categories.
9203 *
9204 * @see #filterEquals
9205 */
9206 public int filterHashCode() {
9207 int code = 0;
9208 if (mAction != null) {
9209 code += mAction.hashCode();
9210 }
9211 if (mData != null) {
9212 code += mData.hashCode();
9213 }
9214 if (mType != null) {
9215 code += mType.hashCode();
9216 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009217 if (mPackage != null) {
9218 code += mPackage.hashCode();
9219 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009220 if (mComponent != null) {
9221 code += mComponent.hashCode();
9222 }
9223 if (mCategories != null) {
9224 code += mCategories.hashCode();
9225 }
9226 return code;
9227 }
9228
9229 @Override
9230 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009231 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009232
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009233 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009234 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009235 b.append(" }");
9236
9237 return b.toString();
9238 }
9239
9240 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009241 public String toInsecureString() {
9242 StringBuilder b = new StringBuilder(128);
9243
9244 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009245 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009246 b.append(" }");
9247
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009248 return b.toString();
9249 }
Romain Guy4969af72009-06-17 10:53:19 -07009250
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009251 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009252 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009253 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009254
9255 b.append("Intent { ");
9256 toShortString(b, false, true, true, true);
9257 b.append(" }");
9258
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009259 return b.toString();
9260 }
9261
9262 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009263 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9264 StringBuilder b = new StringBuilder(128);
9265 toShortString(b, secure, comp, extras, clip);
9266 return b.toString();
9267 }
9268
9269 /** @hide */
9270 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9271 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009272 boolean first = true;
9273 if (mAction != null) {
9274 b.append("act=").append(mAction);
9275 first = false;
9276 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009277 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009278 if (!first) {
9279 b.append(' ');
9280 }
9281 first = false;
9282 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009283 for (int i=0; i<mCategories.size(); i++) {
9284 if (i > 0) b.append(',');
9285 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009286 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009287 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009288 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009289 if (mData != null) {
9290 if (!first) {
9291 b.append(' ');
9292 }
9293 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009294 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009295 if (secure) {
9296 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009297 } else {
9298 b.append(mData);
9299 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009300 }
9301 if (mType != null) {
9302 if (!first) {
9303 b.append(' ');
9304 }
9305 first = false;
9306 b.append("typ=").append(mType);
9307 }
9308 if (mFlags != 0) {
9309 if (!first) {
9310 b.append(' ');
9311 }
9312 first = false;
9313 b.append("flg=0x").append(Integer.toHexString(mFlags));
9314 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009315 if (mPackage != null) {
9316 if (!first) {
9317 b.append(' ');
9318 }
9319 first = false;
9320 b.append("pkg=").append(mPackage);
9321 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009322 if (comp && mComponent != null) {
9323 if (!first) {
9324 b.append(' ');
9325 }
9326 first = false;
9327 b.append("cmp=").append(mComponent.flattenToShortString());
9328 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009329 if (mSourceBounds != null) {
9330 if (!first) {
9331 b.append(' ');
9332 }
9333 first = false;
9334 b.append("bnds=").append(mSourceBounds.toShortString());
9335 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009336 if (mClipData != null) {
9337 if (!first) {
9338 b.append(' ');
9339 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009340 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009341 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009342 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009343 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009344 if (mClipData.getDescription() != null) {
9345 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9346 } else {
9347 first = true;
9348 }
9349 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009350 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009351 first = false;
9352 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009353 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009354 if (extras && mExtras != null) {
9355 if (!first) {
9356 b.append(' ');
9357 }
9358 first = false;
9359 b.append("(has extras)");
9360 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009361 if (mContentUserHint != UserHandle.USER_CURRENT) {
9362 if (!first) {
9363 b.append(' ');
9364 }
9365 first = false;
9366 b.append("u=").append(mContentUserHint);
9367 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009368 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009369 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009370 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009371 b.append("}");
9372 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009373 }
9374
Yi Jin129fc6c2017-09-28 15:48:38 -07009375 /** @hide */
9376 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9377 boolean extras, boolean clip) {
9378 long token = proto.start(fieldId);
9379 if (mAction != null) {
9380 proto.write(IntentProto.ACTION, mAction);
9381 }
9382 if (mCategories != null) {
9383 for (String category : mCategories) {
9384 proto.write(IntentProto.CATEGORIES, category);
9385 }
9386 }
9387 if (mData != null) {
9388 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9389 }
9390 if (mType != null) {
9391 proto.write(IntentProto.TYPE, mType);
9392 }
9393 if (mFlags != 0) {
9394 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9395 }
9396 if (mPackage != null) {
9397 proto.write(IntentProto.PACKAGE, mPackage);
9398 }
9399 if (comp && mComponent != null) {
9400 proto.write(IntentProto.COMPONENT, mComponent.flattenToShortString());
9401 }
9402 if (mSourceBounds != null) {
9403 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9404 }
9405 if (mClipData != null) {
9406 StringBuilder b = new StringBuilder();
9407 if (clip) {
9408 mClipData.toShortString(b);
9409 } else {
9410 mClipData.toShortStringShortItems(b, false);
9411 }
9412 proto.write(IntentProto.CLIP_DATA, b.toString());
9413 }
9414 if (extras && mExtras != null) {
9415 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9416 }
9417 if (mContentUserHint != 0) {
9418 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9419 }
9420 if (mSelector != null) {
9421 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9422 }
9423 proto.end(token);
9424 }
9425
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009426 /**
9427 * Call {@link #toUri} with 0 flags.
9428 * @deprecated Use {@link #toUri} instead.
9429 */
9430 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009431 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009432 return toUri(0);
9433 }
9434
9435 /**
9436 * Convert this Intent into a String holding a URI representation of it.
9437 * The returned URI string has been properly URI encoded, so it can be
9438 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9439 * Intent's data as the base URI, with an additional fragment describing
9440 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009441 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009442 * <p>You can convert the returned string back to an Intent with
9443 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009444 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009445 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009446 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009447 * @return Returns a URI encoding URI string describing the entire contents
9448 * of the Intent.
9449 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009450 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009451 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009452 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9453 if (mPackage == null) {
9454 throw new IllegalArgumentException(
9455 "Intent must include an explicit package name to build an android-app: "
9456 + this);
9457 }
9458 uri.append("android-app://");
9459 uri.append(mPackage);
9460 String scheme = null;
9461 if (mData != null) {
9462 scheme = mData.getScheme();
9463 if (scheme != null) {
9464 uri.append('/');
9465 uri.append(scheme);
9466 String authority = mData.getEncodedAuthority();
9467 if (authority != null) {
9468 uri.append('/');
9469 uri.append(authority);
9470 String path = mData.getEncodedPath();
9471 if (path != null) {
9472 uri.append(path);
9473 }
9474 String queryParams = mData.getEncodedQuery();
9475 if (queryParams != null) {
9476 uri.append('?');
9477 uri.append(queryParams);
9478 }
9479 String fragment = mData.getEncodedFragment();
9480 if (fragment != null) {
9481 uri.append('#');
9482 uri.append(fragment);
9483 }
9484 }
9485 }
9486 }
9487 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9488 mPackage, flags);
9489 return uri.toString();
9490 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009491 String scheme = null;
9492 if (mData != null) {
9493 String data = mData.toString();
9494 if ((flags&URI_INTENT_SCHEME) != 0) {
9495 final int N = data.length();
9496 for (int i=0; i<N; i++) {
9497 char c = data.charAt(i);
9498 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009499 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009500 continue;
9501 }
9502 if (c == ':' && i > 0) {
9503 // Valid scheme.
9504 scheme = data.substring(0, i);
9505 uri.append("intent:");
9506 data = data.substring(i+1);
9507 break;
9508 }
Tom Taylord4a47292009-12-21 13:59:18 -08009509
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009510 // No scheme.
9511 break;
9512 }
9513 }
9514 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009515
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009516 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9517 uri.append("intent:");
9518 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009519
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009520 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009521
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009522 return uri.toString();
9523 }
9524
9525 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9526 String defPackage, int flags) {
9527 StringBuilder frag = new StringBuilder(128);
9528
9529 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009530 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009531 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009532 // Note that for now we are not going to try to handle the
9533 // data part; not clear how to represent this as a URI, and
9534 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009535 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9536 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009537 }
9538
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009539 if (frag.length() > 0) {
9540 uri.append("#Intent;");
9541 uri.append(frag);
9542 uri.append("end");
9543 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009544 }
9545
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009546 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9547 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009548 if (scheme != null) {
9549 uri.append("scheme=").append(scheme).append(';');
9550 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009551 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009552 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009553 }
9554 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009555 for (int i=0; i<mCategories.size(); i++) {
9556 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009557 }
9558 }
9559 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009560 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009561 }
9562 if (mFlags != 0) {
9563 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9564 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009565 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009566 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9567 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009568 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009569 uri.append("component=").append(Uri.encode(
9570 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009571 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009572 if (mSourceBounds != null) {
9573 uri.append("sourceBounds=")
9574 .append(Uri.encode(mSourceBounds.flattenToString()))
9575 .append(';');
9576 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009577 if (mExtras != null) {
9578 for (String key : mExtras.keySet()) {
9579 final Object value = mExtras.get(key);
9580 char entryType =
9581 value instanceof String ? 'S' :
9582 value instanceof Boolean ? 'B' :
9583 value instanceof Byte ? 'b' :
9584 value instanceof Character ? 'c' :
9585 value instanceof Double ? 'd' :
9586 value instanceof Float ? 'f' :
9587 value instanceof Integer ? 'i' :
9588 value instanceof Long ? 'l' :
9589 value instanceof Short ? 's' :
9590 '\0';
9591
9592 if (entryType != '\0') {
9593 uri.append(entryType);
9594 uri.append('.');
9595 uri.append(Uri.encode(key));
9596 uri.append('=');
9597 uri.append(Uri.encode(value.toString()));
9598 uri.append(';');
9599 }
9600 }
9601 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009602 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009603
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009604 public int describeContents() {
9605 return (mExtras != null) ? mExtras.describeContents() : 0;
9606 }
9607
9608 public void writeToParcel(Parcel out, int flags) {
9609 out.writeString(mAction);
9610 Uri.writeToParcel(out, mData);
9611 out.writeString(mType);
9612 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009613 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009614 ComponentName.writeToParcel(mComponent, out);
9615
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009616 if (mSourceBounds != null) {
9617 out.writeInt(1);
9618 mSourceBounds.writeToParcel(out, flags);
9619 } else {
9620 out.writeInt(0);
9621 }
9622
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009623 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009624 final int N = mCategories.size();
9625 out.writeInt(N);
9626 for (int i=0; i<N; i++) {
9627 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009628 }
9629 } else {
9630 out.writeInt(0);
9631 }
9632
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009633 if (mSelector != null) {
9634 out.writeInt(1);
9635 mSelector.writeToParcel(out, flags);
9636 } else {
9637 out.writeInt(0);
9638 }
9639
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009640 if (mClipData != null) {
9641 out.writeInt(1);
9642 mClipData.writeToParcel(out, flags);
9643 } else {
9644 out.writeInt(0);
9645 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009646 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009647 out.writeBundle(mExtras);
9648 }
9649
9650 public static final Parcelable.Creator<Intent> CREATOR
9651 = new Parcelable.Creator<Intent>() {
9652 public Intent createFromParcel(Parcel in) {
9653 return new Intent(in);
9654 }
9655 public Intent[] newArray(int size) {
9656 return new Intent[size];
9657 }
9658 };
9659
Dianne Hackborneb034652009-09-07 00:49:58 -07009660 /** @hide */
9661 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009662 readFromParcel(in);
9663 }
9664
9665 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009666 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009667 mData = Uri.CREATOR.createFromParcel(in);
9668 mType = in.readString();
9669 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009670 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009671 mComponent = ComponentName.readFromParcel(in);
9672
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009673 if (in.readInt() != 0) {
9674 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9675 }
9676
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009677 int N = in.readInt();
9678 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009679 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009680 int i;
9681 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009682 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009683 }
9684 } else {
9685 mCategories = null;
9686 }
9687
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009688 if (in.readInt() != 0) {
9689 mSelector = new Intent(in);
9690 }
9691
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009692 if (in.readInt() != 0) {
9693 mClipData = new ClipData(in);
9694 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009695 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009696 mExtras = in.readBundle();
9697 }
9698
9699 /**
9700 * Parses the "intent" element (and its children) from XML and instantiates
9701 * an Intent object. The given XML parser should be located at the tag
9702 * where parsing should start (often named "intent"), from which the
9703 * basic action, data, type, and package and class name will be
9704 * retrieved. The function will then parse in to any child elements,
9705 * looking for <category android:name="xxx"> tags to add categories and
9706 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9707 * to the intent.
9708 *
9709 * @param resources The Resources to use when inflating resources.
9710 * @param parser The XML parser pointing at an "intent" tag.
9711 * @param attrs The AttributeSet interface for retrieving extended
9712 * attribute data at the current <var>parser</var> location.
9713 * @return An Intent object matching the XML data.
9714 * @throws XmlPullParserException If there was an XML parsing error.
9715 * @throws IOException If there was an I/O error.
9716 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009717 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9718 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009719 throws XmlPullParserException, IOException {
9720 Intent intent = new Intent();
9721
9722 TypedArray sa = resources.obtainAttributes(attrs,
9723 com.android.internal.R.styleable.Intent);
9724
9725 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9726
9727 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9728 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9729 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9730
9731 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9732 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9733 if (packageName != null && className != null) {
9734 intent.setComponent(new ComponentName(packageName, className));
9735 }
9736
9737 sa.recycle();
9738
9739 int outerDepth = parser.getDepth();
9740 int type;
9741 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9742 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9743 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9744 continue;
9745 }
9746
9747 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009748 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009749 sa = resources.obtainAttributes(attrs,
9750 com.android.internal.R.styleable.IntentCategory);
9751 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9752 sa.recycle();
9753
9754 if (cat != null) {
9755 intent.addCategory(cat);
9756 }
9757 XmlUtils.skipCurrentTag(parser);
9758
Craig Mautner21d24a22014-04-23 11:45:37 -07009759 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009760 if (intent.mExtras == null) {
9761 intent.mExtras = new Bundle();
9762 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009763 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009764 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009765
9766 } else {
9767 XmlUtils.skipCurrentTag(parser);
9768 }
9769 }
9770
9771 return intent;
9772 }
Nick Pellyccae4122012-01-09 14:12:58 -08009773
Craig Mautner21d24a22014-04-23 11:45:37 -07009774 /** @hide */
9775 public void saveToXml(XmlSerializer out) throws IOException {
9776 if (mAction != null) {
9777 out.attribute(null, ATTR_ACTION, mAction);
9778 }
9779 if (mData != null) {
9780 out.attribute(null, ATTR_DATA, mData.toString());
9781 }
9782 if (mType != null) {
9783 out.attribute(null, ATTR_TYPE, mType);
9784 }
9785 if (mComponent != null) {
9786 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9787 }
9788 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9789
9790 if (mCategories != null) {
9791 out.startTag(null, TAG_CATEGORIES);
9792 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9793 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9794 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009795 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009796 }
9797 }
9798
9799 /** @hide */
9800 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9801 XmlPullParserException {
9802 Intent intent = new Intent();
9803 final int outerDepth = in.getDepth();
9804
9805 int attrCount = in.getAttributeCount();
9806 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9807 final String attrName = in.getAttributeName(attrNdx);
9808 final String attrValue = in.getAttributeValue(attrNdx);
9809 if (ATTR_ACTION.equals(attrName)) {
9810 intent.setAction(attrValue);
9811 } else if (ATTR_DATA.equals(attrName)) {
9812 intent.setData(Uri.parse(attrValue));
9813 } else if (ATTR_TYPE.equals(attrName)) {
9814 intent.setType(attrValue);
9815 } else if (ATTR_COMPONENT.equals(attrName)) {
9816 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9817 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009818 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009819 } else {
9820 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9821 }
9822 }
9823
9824 int event;
9825 String name;
9826 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9827 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9828 if (event == XmlPullParser.START_TAG) {
9829 name = in.getName();
9830 if (TAG_CATEGORIES.equals(name)) {
9831 attrCount = in.getAttributeCount();
9832 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9833 intent.addCategory(in.getAttributeValue(attrNdx));
9834 }
9835 } else {
9836 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9837 XmlUtils.skipCurrentTag(in);
9838 }
9839 }
9840 }
9841
9842 return intent;
9843 }
9844
Nick Pellyccae4122012-01-09 14:12:58 -08009845 /**
9846 * Normalize a MIME data type.
9847 *
9848 * <p>A normalized MIME type has white-space trimmed,
9849 * content-type parameters removed, and is lower-case.
9850 * This aligns the type with Android best practices for
9851 * intent filtering.
9852 *
9853 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9854 * "text/x-vCard" becomes "text/x-vcard".
9855 *
9856 * <p>All MIME types received from outside Android (such as user input,
9857 * or external sources like Bluetooth, NFC, or the Internet) should
9858 * be normalized before they are used to create an Intent.
9859 *
9860 * @param type MIME data type to normalize
9861 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009862 * @see #setType
9863 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009865 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009866 if (type == null) {
9867 return null;
9868 }
9869
Elliott Hughescb64d432013-08-02 10:00:44 -07009870 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009871
9872 final int semicolonIndex = type.indexOf(';');
9873 if (semicolonIndex != -1) {
9874 type = type.substring(0, semicolonIndex);
9875 }
9876 return type;
9877 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009878
9879 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009880 * Prepare this {@link Intent} to leave an app process.
9881 *
9882 * @hide
9883 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009884 public void prepareToLeaveProcess(Context context) {
9885 final boolean leavingPackage = (mComponent == null)
9886 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9887 prepareToLeaveProcess(leavingPackage);
9888 }
9889
9890 /**
9891 * Prepare this {@link Intent} to leave an app process.
9892 *
9893 * @hide
9894 */
9895 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009896 setAllowFds(false);
9897
9898 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009899 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009900 }
9901 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009902 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009903 }
9904
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009905 if (mExtras != null && !mExtras.isParcelled()) {
9906 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9907 if (intent instanceof Intent) {
9908 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9909 }
9910 }
9911
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009912 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9913 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009914 switch (mAction) {
9915 case ACTION_MEDIA_REMOVED:
9916 case ACTION_MEDIA_UNMOUNTED:
9917 case ACTION_MEDIA_CHECKING:
9918 case ACTION_MEDIA_NOFS:
9919 case ACTION_MEDIA_MOUNTED:
9920 case ACTION_MEDIA_SHARED:
9921 case ACTION_MEDIA_UNSHARED:
9922 case ACTION_MEDIA_BAD_REMOVAL:
9923 case ACTION_MEDIA_UNMOUNTABLE:
9924 case ACTION_MEDIA_EJECT:
9925 case ACTION_MEDIA_SCANNER_STARTED:
9926 case ACTION_MEDIA_SCANNER_FINISHED:
9927 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009928 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9929 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009930 // Ignore legacy actions
9931 break;
9932 default:
9933 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009934 }
9935 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009936
9937 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9938 && leavingPackage) {
9939 switch (mAction) {
9940 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -07009941 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009942 // Ignore actions that don't need to grant
9943 break;
9944 default:
9945 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9946 }
9947 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009948 }
9949
9950 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009951 * @hide
9952 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009953 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009954 // We just entered destination process, so we should be able to read all
9955 // parcelables inside.
9956 setDefusable(true);
9957
9958 if (mSelector != null) {
9959 mSelector.prepareToEnterProcess();
9960 }
9961 if (mClipData != null) {
9962 mClipData.prepareToEnterProcess();
9963 }
9964
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009965 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009966 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9967 fixUris(mContentUserHint);
9968 mContentUserHint = UserHandle.USER_CURRENT;
9969 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009970 }
9971 }
9972
9973 /**
9974 * @hide
9975 */
9976 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009977 Uri data = getData();
9978 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009979 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009980 }
9981 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009982 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009983 }
9984 String action = getAction();
9985 if (ACTION_SEND.equals(action)) {
9986 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9987 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009988 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009989 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009990 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009991 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9992 if (streams != null) {
9993 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9994 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009995 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009996 }
9997 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9998 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009999 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10000 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10001 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10002 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10003 if (output != null) {
10004 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10005 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010006 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010007 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010008
10009 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010010 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010011 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10012 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010013 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010014 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010015 * @hide
10016 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010017 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010018 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010019 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010020
10021 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010022 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010023
10024 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010025 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010026 // Inspect contained intents to see if we need to migrate extras. We
10027 // don't promote ClipData to the parent, since ChooserActivity will
10028 // already start the picked item as the caller, and we can't combine
10029 // the flags in a safe way.
10030
10031 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010032 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010033 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10034 if (intent != null) {
10035 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010036 }
10037 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010038 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010039 try {
10040 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10041 if (intents != null) {
10042 for (int i = 0; i < intents.length; i++) {
10043 final Intent intent = (Intent) intents[i];
10044 if (intent != null) {
10045 migrated |= intent.migrateExtraStreamToClipData();
10046 }
10047 }
10048 }
10049 } catch (ClassCastException e) {
10050 }
10051 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010052
10053 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010054 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010055 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10056 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10057 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10058 if (stream != null || text != null || htmlText != null) {
10059 final ClipData clipData = new ClipData(
10060 null, new String[] { getType() },
10061 new ClipData.Item(text, htmlText, null, stream));
10062 setClipData(clipData);
10063 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010064 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010065 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010066 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010067 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010068
10069 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010070 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010071 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10072 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10073 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10074 int num = -1;
10075 if (streams != null) {
10076 num = streams.size();
10077 }
10078 if (texts != null) {
10079 if (num >= 0 && num != texts.size()) {
10080 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010081 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010082 }
10083 num = texts.size();
10084 }
10085 if (htmlTexts != null) {
10086 if (num >= 0 && num != htmlTexts.size()) {
10087 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010088 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010089 }
10090 num = htmlTexts.size();
10091 }
10092 if (num > 0) {
10093 final ClipData clipData = new ClipData(
10094 null, new String[] { getType() },
10095 makeClipItem(streams, texts, htmlTexts, 0));
10096
10097 for (int i = 1; i < num; i++) {
10098 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10099 }
10100
10101 setClipData(clipData);
10102 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010103 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010104 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010105 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010106 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010107 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10108 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10109 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10110 final Uri output;
10111 try {
10112 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10113 } catch (ClassCastException e) {
10114 return false;
10115 }
10116 if (output != null) {
10117 setClipData(ClipData.newRawUri("", output));
10118 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10119 return true;
10120 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010121 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010122
10123 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010124 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010125
Michael Wright19859762017-09-18 20:57:58 +010010126 /**
10127 * Convert the dock state to a human readable format.
10128 * @hide
10129 */
10130 public static String dockStateToString(int dock) {
10131 switch (dock) {
10132 case EXTRA_DOCK_STATE_HE_DESK:
10133 return "EXTRA_DOCK_STATE_HE_DESK";
10134 case EXTRA_DOCK_STATE_LE_DESK:
10135 return "EXTRA_DOCK_STATE_LE_DESK";
10136 case EXTRA_DOCK_STATE_CAR:
10137 return "EXTRA_DOCK_STATE_CAR";
10138 case EXTRA_DOCK_STATE_DESK:
10139 return "EXTRA_DOCK_STATE_DESK";
10140 case EXTRA_DOCK_STATE_UNDOCKED:
10141 return "EXTRA_DOCK_STATE_UNDOCKED";
10142 default:
10143 return Integer.toString(dock);
10144 }
10145 }
10146
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010147 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10148 ArrayList<String> htmlTexts, int which) {
10149 Uri uri = streams != null ? streams.get(which) : null;
10150 CharSequence text = texts != null ? texts.get(which) : null;
10151 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10152 return new ClipData.Item(text, htmlText, null, uri);
10153 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010154
10155 /** @hide */
10156 public boolean isDocument() {
10157 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10158 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010159}