blob: 4923171bd3a6b4b90a2a8787e96ec875b329cbfa [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Makoto Onuki7d1911f2017-06-09 12:30:09 -070019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060024import android.annotation.NonNull;
25import android.annotation.Nullable;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070026import android.annotation.SdkConstant;
27import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050028import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070029import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050030import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060031import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.content.pm.PackageManager;
33import android.content.pm.ResolveInfo;
34import android.content.res.Resources;
35import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080036import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060038import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.os.Bundle;
40import android.os.IBinder;
41import android.os.Parcel;
42import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000043import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050044import android.os.ResultReceiver;
45import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070046import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010047import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070048import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070049import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070050import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070052import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054import android.util.AttributeSet;
55import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070056import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070057
Dianne Hackborn2269d1572010-02-24 19:54:22 -080058import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070059
Jason Monk2f68e8a2016-02-23 17:57:28 -050060import org.xmlpull.v1.XmlPullParser;
61import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070062import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070063
64import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080065import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070067import java.lang.annotation.Retention;
68import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070069import java.net.URISyntaxException;
70import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080071import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070072import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080073import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070074import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070075import java.util.Set;
76
77/**
78 * An intent is an abstract description of an operation to be performed. It
79 * can be used with {@link Context#startActivity(Intent) startActivity} to
80 * launch an {@link android.app.Activity},
81 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
82 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
83 * and {@link android.content.Context#startService} or
84 * {@link android.content.Context#bindService} to communicate with a
85 * background {@link android.app.Service}.
86 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 * <p>An Intent provides a facility for performing late runtime binding between the code in
88 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070089 * can be thought of as the glue between activities. It is basically a passive data structure
90 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070091 *
92 * <div class="special reference">
93 * <h3>Developer Guides</h3>
94 * <p>For information about how to create and resolve intents, read the
95 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
96 * developer guide.</p>
97 * </div>
98 *
99 * <a name="IntentStructure"></a>
100 * <h3>Intent Structure</h3>
101 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700102 *
103 * <ul>
104 * <li> <p><b>action</b> -- The general action to be performed, such as
105 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
106 * etc.</p>
107 * </li>
108 * <li> <p><b>data</b> -- The data to operate on, such as a person record
109 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
110 * </li>
111 * </ul>
112 *
113 *
114 * <p>Some examples of action/data pairs are:</p>
115 *
116 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700117 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700118 * information about the person whose identifier is "1".</p>
119 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700120 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * the phone dialer with the person filled in.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700125 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * a particular URI.</p>
127 * </li>
128 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
129 * the phone dialer with the given number filled in.</p>
130 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700131 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * information about the person whose identifier is "1".</p>
133 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700134 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * a list of people, which the user can browse through. This example is a
136 * typical top-level entry into the Contacts application, showing you the
137 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700138 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700139 * being used to start an activity to display that person.</p>
140 * </li>
141 * </ul>
142 *
143 * <p>In addition to these primary attributes, there are a number of secondary
144 * attributes that you can also include with an intent:</p>
145 *
146 * <ul>
147 * <li> <p><b>category</b> -- Gives additional information about the action
148 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
149 * appear in the Launcher as a top-level application, while
150 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
151 * of alternative actions the user can perform on a piece of data.</p>
152 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
153 * intent data. Normally the type is inferred from the data itself.
154 * By setting this attribute, you disable that evaluation and force
155 * an explicit type.</p>
156 * <li> <p><b>component</b> -- Specifies an explicit name of a component
157 * class to use for the intent. Normally this is determined by looking
158 * at the other information in the intent (the action, data/type, and
159 * categories) and matching that with a component that can handle it.
160 * If this attribute is set then none of the evaluation is performed,
161 * and this component is used exactly as is. By specifying this attribute,
162 * all of the other Intent attributes become optional.</p>
163 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
164 * This can be used to provide extended information to the component.
165 * For example, if we have a action to send an e-mail message, we could
166 * also include extra pieces of data here to supply a subject, body,
167 * etc.</p>
168 * </ul>
169 *
170 * <p>Here are some examples of other operations you can specify as intents
171 * using these additional parameters:</p>
172 *
173 * <ul>
174 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
175 * Launch the home screen.</p>
176 * </li>
177 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
178 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
179 * vnd.android.cursor.item/phone}</i></b>
180 * -- Display the list of people's phone numbers, allowing the user to
181 * browse through them and pick one and return it to the parent activity.</p>
182 * </li>
183 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
184 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
185 * -- Display all pickers for data that can be opened with
186 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
187 * allowing the user to pick one of them and then some data inside of it
188 * and returning the resulting URI to the caller. This can be used,
189 * for example, in an e-mail application to allow the user to pick some
190 * data to include as an attachment.</p>
191 * </li>
192 * </ul>
193 *
194 * <p>There are a variety of standard Intent action and category constants
195 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700196 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700197 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700198 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700199 *
200 * <p>Put together, the set of actions, data types, categories, and extra data
201 * defines a language for the system allowing for the expression of phrases
202 * such as "call john smith's cell". As applications are added to the system,
203 * they can extend this language by adding new actions, types, and categories, or
204 * they can modify the behavior of existing phrases by supplying their own
205 * activities that handle them.</p>
206 *
207 * <a name="IntentResolution"></a>
208 * <h3>Intent Resolution</h3>
209 *
210 * <p>There are two primary forms of intents you will use.
211 *
212 * <ul>
213 * <li> <p><b>Explicit Intents</b> have specified a component (via
214 * {@link #setComponent} or {@link #setClass}), which provides the exact
215 * class to be run. Often these will not include any other information,
216 * simply being a way for an application to launch various internal
217 * activities it has as the user interacts with the application.
218 *
219 * <li> <p><b>Implicit Intents</b> have not specified a component;
220 * instead, they must include enough information for the system to
221 * determine which of the available components is best to run for that
222 * intent.
223 * </ul>
224 *
225 * <p>When using implicit intents, given such an arbitrary intent we need to
226 * know what to do with it. This is handled by the process of <em>Intent
227 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
228 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
229 * more activities/receivers) that can handle it.</p>
230 *
231 * <p>The intent resolution mechanism basically revolves around matching an
232 * Intent against all of the &lt;intent-filter&gt; descriptions in the
233 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
234 * objects explicitly registered with {@link Context#registerReceiver}.) More
235 * details on this can be found in the documentation on the {@link
236 * IntentFilter} class.</p>
237 *
238 * <p>There are three pieces of information in the Intent that are used for
239 * resolution: the action, type, and category. Using this information, a query
240 * is done on the {@link PackageManager} for a component that can handle the
241 * intent. The appropriate component is determined based on the intent
242 * information supplied in the <code>AndroidManifest.xml</code> file as
243 * follows:</p>
244 *
245 * <ul>
246 * <li> <p>The <b>action</b>, if given, must be listed by the component as
247 * one it handles.</p>
248 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
249 * already supplied in the Intent. Like the action, if a type is
250 * included in the intent (either explicitly or implicitly in its
251 * data), then this must be listed by the component as one it handles.</p>
252 * <li> For data that is not a <code>content:</code> URI and where no explicit
253 * type is included in the Intent, instead the <b>scheme</b> of the
254 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
255 * considered. Again like the action, if we are matching a scheme it
256 * must be listed by the component as one it can handle.
257 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
258 * by the activity as categories it handles. That is, if you include
259 * the categories {@link #CATEGORY_LAUNCHER} and
260 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
261 * with an intent that lists <em>both</em> of those categories.
262 * Activities will very often need to support the
263 * {@link #CATEGORY_DEFAULT} so that they can be found by
264 * {@link Context#startActivity Context.startActivity()}.</p>
265 * </ul>
266 *
267 * <p>For example, consider the Note Pad sample application that
268 * allows user to browse through a list of notes data and view details about
269 * individual items. Text in italics indicate places were you would replace a
270 * name with one specific to your own package.</p>
271 *
272 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
273 * package="<i>com.android.notepad</i>"&gt;
274 * &lt;application android:icon="@drawable/app_notes"
275 * android:label="@string/app_name"&gt;
276 *
277 * &lt;provider class=".NotePadProvider"
278 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
279 *
280 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.MAIN" /&gt;
283 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.VIEW" /&gt;
287 * &lt;action android:name="android.intent.action.EDIT" /&gt;
288 * &lt;action android:name="android.intent.action.PICK" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700293 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
294 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 * &lt;/activity&gt;
298 *
299 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
300 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.VIEW" /&gt;
302 * &lt;action android:name="android.intent.action.EDIT" /&gt;
303 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
304 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700305 * &lt;/intent-filter&gt;
306 *
307 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700308 * &lt;action android:name="android.intent.action.INSERT" /&gt;
309 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
310 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700311 * &lt;/intent-filter&gt;
312 *
313 * &lt;/activity&gt;
314 *
315 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
316 * android:theme="@android:style/Theme.Dialog"&gt;
317 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700318 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
319 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
320 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
321 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
322 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700323 * &lt;/intent-filter&gt;
324 * &lt;/activity&gt;
325 *
326 * &lt;/application&gt;
327 * &lt;/manifest&gt;</pre>
328 *
329 * <p>The first activity,
330 * <code>com.android.notepad.NotesList</code>, serves as our main
331 * entry into the app. It can do three things as described by its three intent
332 * templates:
333 * <ol>
334 * <li><pre>
335 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700336 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
337 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700338 * &lt;/intent-filter&gt;</pre>
339 * <p>This provides a top-level entry into the NotePad application: the standard
340 * MAIN action is a main entry point (not requiring any other information in
341 * the Intent), and the LAUNCHER category says that this entry point should be
342 * listed in the application launcher.</p>
343 * <li><pre>
344 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700345 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
346 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
347 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
348 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700349 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700350 * &lt;/intent-filter&gt;</pre>
351 * <p>This declares the things that the activity can do on a directory of
352 * notes. The type being supported is given with the &lt;type&gt; tag, where
353 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
354 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
355 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
356 * The activity allows the user to view or edit the directory of data (via
357 * the VIEW and EDIT actions), or to pick a particular note and return it
358 * to the caller (via the PICK action). Note also the DEFAULT category
359 * supplied here: this is <em>required</em> for the
360 * {@link Context#startActivity Context.startActivity} method to resolve your
361 * activity when its component name is not explicitly specified.</p>
362 * <li><pre>
363 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700364 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
365 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
366 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700367 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700368 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700369 * the user without needing to know where it came from. The data type
370 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
371 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
372 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
373 * The GET_CONTENT action is similar to the PICK action, where the activity
374 * will return to its caller a piece of data selected by the user. Here,
375 * however, the caller specifies the type of data they desire instead of
376 * the type of data the user will be picking from.</p>
377 * </ol>
378 *
379 * <p>Given these capabilities, the following intents will resolve to the
380 * NotesList activity:</p>
381 *
382 * <ul>
383 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
384 * activities that can be used as top-level entry points into an
385 * application.</p>
386 * <li> <p><b>{ action=android.app.action.MAIN,
387 * category=android.app.category.LAUNCHER }</b> is the actual intent
388 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700389 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700390 * data=content://com.google.provider.NotePad/notes }</b>
391 * displays a list of all the notes under
392 * "content://com.google.provider.NotePad/notes", which
393 * the user can browse through and see the details on.</p>
394 * <li> <p><b>{ action=android.app.action.PICK
395 * data=content://com.google.provider.NotePad/notes }</b>
396 * provides a list of the notes under
397 * "content://com.google.provider.NotePad/notes", from which
398 * the user can pick a note whose data URL is returned back to the caller.</p>
399 * <li> <p><b>{ action=android.app.action.GET_CONTENT
400 * type=vnd.android.cursor.item/vnd.google.note }</b>
401 * is similar to the pick action, but allows the caller to specify the
402 * kind of data they want back so that the system can find the appropriate
403 * activity to pick something of that data type.</p>
404 * </ul>
405 *
406 * <p>The second activity,
407 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
408 * note entry and allows them to edit it. It can do two things as described
409 * by its two intent templates:
410 * <ol>
411 * <li><pre>
412 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700413 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
414 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
415 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
416 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700417 * &lt;/intent-filter&gt;</pre>
418 * <p>The first, primary, purpose of this activity is to let the user interact
419 * with a single note, as decribed by the MIME type
420 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
421 * either VIEW a note or allow the user to EDIT it. Again we support the
422 * DEFAULT category to allow the activity to be launched without explicitly
423 * specifying its component.</p>
424 * <li><pre>
425 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700426 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
427 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
428 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700429 * &lt;/intent-filter&gt;</pre>
430 * <p>The secondary use of this activity is to insert a new note entry into
431 * an existing directory of notes. This is used when the user creates a new
432 * note: the INSERT action is executed on the directory of notes, causing
433 * this activity to run and have the user create the new note data which
434 * it then adds to the content provider.</p>
435 * </ol>
436 *
437 * <p>Given these capabilities, the following intents will resolve to the
438 * NoteEditor activity:</p>
439 *
440 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700441 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700442 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
443 * shows the user the content of note <var>{ID}</var>.</p>
444 * <li> <p><b>{ action=android.app.action.EDIT
445 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
446 * allows the user to edit the content of note <var>{ID}</var>.</p>
447 * <li> <p><b>{ action=android.app.action.INSERT
448 * data=content://com.google.provider.NotePad/notes }</b>
449 * creates a new, empty note in the notes list at
450 * "content://com.google.provider.NotePad/notes"
451 * and allows the user to edit it. If they keep their changes, the URI
452 * of the newly created note is returned to the caller.</p>
453 * </ul>
454 *
455 * <p>The last activity,
456 * <code>com.android.notepad.TitleEditor</code>, allows the user to
457 * edit the title of a note. This could be implemented as a class that the
458 * application directly invokes (by explicitly setting its component in
459 * the Intent), but here we show a way you can publish alternative
460 * operations on existing data:</p>
461 *
462 * <pre>
463 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700464 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
465 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
466 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
467 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
468 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700469 * &lt;/intent-filter&gt;</pre>
470 *
471 * <p>In the single intent template here, we
472 * have created our own private action called
473 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
474 * edit the title of a note. It must be invoked on a specific note
475 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
476 * view and edit actions, but here displays and edits the title contained
477 * in the note data.
478 *
479 * <p>In addition to supporting the default category as usual, our title editor
480 * also supports two other standard categories: ALTERNATIVE and
481 * SELECTED_ALTERNATIVE. Implementing
482 * these categories allows others to find the special action it provides
483 * without directly knowing about it, through the
484 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
485 * more often to build dynamic menu items with
486 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
487 * template here was also supply an explicit name for the template
488 * (via <code>android:label="@string/resolve_title"</code>) to better control
489 * what the user sees when presented with this activity as an alternative
490 * action to the data they are viewing.
491 *
492 * <p>Given these capabilities, the following intent will resolve to the
493 * TitleEditor activity:</p>
494 *
495 * <ul>
496 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
497 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
498 * displays and allows the user to edit the title associated
499 * with note <var>{ID}</var>.</p>
500 * </ul>
501 *
502 * <h3>Standard Activity Actions</h3>
503 *
504 * <p>These are the current standard actions that Intent defines for launching
505 * activities (usually through {@link Context#startActivity}. The most
506 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
507 * {@link #ACTION_EDIT}.
508 *
509 * <ul>
510 * <li> {@link #ACTION_MAIN}
511 * <li> {@link #ACTION_VIEW}
512 * <li> {@link #ACTION_ATTACH_DATA}
513 * <li> {@link #ACTION_EDIT}
514 * <li> {@link #ACTION_PICK}
515 * <li> {@link #ACTION_CHOOSER}
516 * <li> {@link #ACTION_GET_CONTENT}
517 * <li> {@link #ACTION_DIAL}
518 * <li> {@link #ACTION_CALL}
519 * <li> {@link #ACTION_SEND}
520 * <li> {@link #ACTION_SENDTO}
521 * <li> {@link #ACTION_ANSWER}
522 * <li> {@link #ACTION_INSERT}
523 * <li> {@link #ACTION_DELETE}
524 * <li> {@link #ACTION_RUN}
525 * <li> {@link #ACTION_SYNC}
526 * <li> {@link #ACTION_PICK_ACTIVITY}
527 * <li> {@link #ACTION_SEARCH}
528 * <li> {@link #ACTION_WEB_SEARCH}
529 * <li> {@link #ACTION_FACTORY_TEST}
530 * </ul>
531 *
532 * <h3>Standard Broadcast Actions</h3>
533 *
534 * <p>These are the current standard actions that Intent defines for receiving
535 * broadcasts (usually through {@link Context#registerReceiver} or a
536 * &lt;receiver&gt; tag in a manifest).
537 *
538 * <ul>
539 * <li> {@link #ACTION_TIME_TICK}
540 * <li> {@link #ACTION_TIME_CHANGED}
541 * <li> {@link #ACTION_TIMEZONE_CHANGED}
542 * <li> {@link #ACTION_BOOT_COMPLETED}
543 * <li> {@link #ACTION_PACKAGE_ADDED}
544 * <li> {@link #ACTION_PACKAGE_CHANGED}
545 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546 * <li> {@link #ACTION_PACKAGE_RESTARTED}
547 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000548 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
549 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * <li> {@link #ACTION_UID_REMOVED}
551 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700552 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700553 * <li> {@link #ACTION_POWER_DISCONNECTED}
554 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700555 * </ul>
556 *
557 * <h3>Standard Categories</h3>
558 *
559 * <p>These are the current standard categories that can be used to further
560 * clarify an Intent via {@link #addCategory}.
561 *
562 * <ul>
563 * <li> {@link #CATEGORY_DEFAULT}
564 * <li> {@link #CATEGORY_BROWSABLE}
565 * <li> {@link #CATEGORY_TAB}
566 * <li> {@link #CATEGORY_ALTERNATIVE}
567 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
568 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * <li> {@link #CATEGORY_HOME}
571 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400573 * <li> {@link #CATEGORY_CAR_DOCK}
574 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500575 * <li> {@link #CATEGORY_LE_DESK_DOCK}
576 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200577 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700578 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800579 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700580 * </ul>
581 *
582 * <h3>Standard Extra Data</h3>
583 *
584 * <p>These are the current standard fields that can be used as extra data via
585 * {@link #putExtra}.
586 *
587 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800588 * <li> {@link #EXTRA_ALARM_COUNT}
589 * <li> {@link #EXTRA_BCC}
590 * <li> {@link #EXTRA_CC}
591 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
592 * <li> {@link #EXTRA_DATA_REMOVED}
593 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500594 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
595 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_DOCK_STATE_CAR}
597 * <li> {@link #EXTRA_DOCK_STATE_DESK}
598 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
599 * <li> {@link #EXTRA_DONT_KILL_APP}
600 * <li> {@link #EXTRA_EMAIL}
601 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700604 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800605 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700606 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
608 * <li> {@link #EXTRA_REPLACING}
609 * <li> {@link #EXTRA_SHORTCUT_ICON}
610 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
611 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_SHORTCUT_NAME}
614 * <li> {@link #EXTRA_SUBJECT}
615 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800617 * <li> {@link #EXTRA_TITLE}
618 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 * </ul>
620 *
621 * <h3>Flags</h3>
622 *
623 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800624 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
625 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700626 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800627public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700628 private static final String ATTR_ACTION = "action";
629 private static final String TAG_CATEGORIES = "categories";
630 private static final String ATTR_CATEGORY = "category";
631 private static final String TAG_EXTRA = "extra";
632 private static final String ATTR_TYPE = "type";
633 private static final String ATTR_COMPONENT = "component";
634 private static final String ATTR_DATA = "data";
635 private static final String ATTR_FLAGS = "flags";
636
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700637 // ---------------------------------------------------------------------
638 // ---------------------------------------------------------------------
639 // Standard intent activity actions (see action variable).
640
641 /**
642 * Activity Action: Start as a main entry point, does not expect to
643 * receive data.
644 * <p>Input: nothing
645 * <p>Output: nothing
646 */
647 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
648 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800649
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700650 /**
651 * Activity Action: Display the data to the user. This is the most common
652 * action performed on data -- it is the generic action you can use on
653 * a piece of data to get the most reasonable thing to occur. For example,
654 * when used on a contacts entry it will view the entry; when used on a
655 * mailto: URI it will bring up a compose window filled with the information
656 * supplied by the URI; when used with a tel: URI it will invoke the
657 * dialer.
658 * <p>Input: {@link #getData} is URI from which to retrieve data.
659 * <p>Output: nothing.
660 */
661 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
662 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800663
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700664 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700665 * Extra that can be included on activity intents coming from the storage UI
666 * when it launches sub-activities to manage various types of storage. For example,
667 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
668 * the images on the device, and in that case also include this extra to tell the
669 * app it is coming from the storage UI so should help the user manage storage of
670 * this type.
671 */
672 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
673
674 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
676 * performed on a piece of data.
677 */
678 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800679
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700680 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900681 * Activity Action: Quick view the data. Launches a quick viewer for
682 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900683 * <p>Activities handling this intent action should handle the vast majority of
684 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700685 * <p>Quick viewers must render the quick view image locally, and must not send
686 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900687 * <p>Input: {@link #getData} is a mandatory content URI of the item to
688 * preview. {@link #getClipData} contains an optional list of content URIs
689 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
690 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700691 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
692 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700693 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900694 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700695 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700696 */
697 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
698 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
699
700 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700701 * Used to indicate that some piece of data should be attached to some other
702 * place. For example, image data could be attached to a contact. It is up
703 * to the recipient to decide where the data should be attached; the intent
704 * does not specify the ultimate destination.
705 * <p>Input: {@link #getData} is URI of data to be attached.
706 * <p>Output: nothing.
707 */
708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
709 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800710
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700711 /**
712 * Activity Action: Provide explicit editable access to the given data.
713 * <p>Input: {@link #getData} is URI of data to be edited.
714 * <p>Output: nothing.
715 */
716 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
717 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800718
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700719 /**
720 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
721 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
722 * The extras can contain type specific data to pass through to the editing/creating
723 * activity.
724 * <p>Output: The URI of the item that was picked. This must be a content:
725 * URI so that any receiver can access it.
726 */
727 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
728 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800729
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 /**
731 * Activity Action: Pick an item from the data, returning what was selected.
732 * <p>Input: {@link #getData} is URI containing a directory of data
733 * (vnd.android.cursor.dir/*) from which to pick an item.
734 * <p>Output: The URI of the item that was picked.
735 */
736 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
737 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800738
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700739 /**
740 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800742 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
743 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
745 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800746 * (value: ShortcutIconResource).</p>
747 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 * @see #EXTRA_SHORTCUT_INTENT
750 * @see #EXTRA_SHORTCUT_NAME
751 * @see #EXTRA_SHORTCUT_ICON
752 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
753 * @see android.content.Intent.ShortcutIconResource
754 */
755 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
756 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
757
758 /**
759 * The name of the extra used to define the Intent of a shortcut.
760 *
761 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800762 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700763 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
766 /**
767 * The name of the extra used to define the name of a shortcut.
768 *
769 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800770 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700771 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
774 /**
775 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
776 *
777 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800778 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700779 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800780 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700781 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
782 /**
783 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
784 *
785 * @see #ACTION_CREATE_SHORTCUT
786 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800787 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700788 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800789 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
791 "android.intent.extra.shortcut.ICON_RESOURCE";
792
793 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500794 * An activity that provides a user interface for adjusting application preferences.
795 * Optional but recommended settings for all applications which have settings.
796 */
797 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
798 public static final String ACTION_APPLICATION_PREFERENCES
799 = "android.intent.action.APPLICATION_PREFERENCES";
800
801 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700802 * Activity Action: Launch an activity showing the app information.
803 * For applications which install other applications (such as app stores), it is recommended
804 * to handle this action for providing the app information to the user.
805 *
806 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
807 * to be displayed.
808 * <p>Output: Nothing.
809 */
810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
811 public static final String ACTION_SHOW_APP_INFO
812 = "android.intent.action.SHOW_APP_INFO";
813
814 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800815 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700816 *
817 * @see Intent#ACTION_CREATE_SHORTCUT
818 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800819 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
820 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821 */
822 public static class ShortcutIconResource implements Parcelable {
823 /**
824 * The package name of the application containing the icon.
825 */
826 public String packageName;
827
828 /**
829 * The resource name of the icon, including package, name and type.
830 */
831 public String resourceName;
832
833 /**
834 * Creates a new ShortcutIconResource for the specified context and resource
835 * identifier.
836 *
837 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700838 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700839 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700840 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700841 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700842 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 ShortcutIconResource icon = new ShortcutIconResource();
844 icon.packageName = context.getPackageName();
845 icon.resourceName = context.getResources().getResourceName(resourceId);
846 return icon;
847 }
848
849 /**
850 * Used to read a ShortcutIconResource from a Parcel.
851 */
852 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
853 new Parcelable.Creator<ShortcutIconResource>() {
854
855 public ShortcutIconResource createFromParcel(Parcel source) {
856 ShortcutIconResource icon = new ShortcutIconResource();
857 icon.packageName = source.readString();
858 icon.resourceName = source.readString();
859 return icon;
860 }
861
862 public ShortcutIconResource[] newArray(int size) {
863 return new ShortcutIconResource[size];
864 }
865 };
866
867 /**
868 * No special parcel contents.
869 */
870 public int describeContents() {
871 return 0;
872 }
873
874 public void writeToParcel(Parcel dest, int flags) {
875 dest.writeString(packageName);
876 dest.writeString(resourceName);
877 }
878
879 @Override
880 public String toString() {
881 return resourceName;
882 }
883 }
884
885 /**
886 * Activity Action: Display an activity chooser, allowing the user to pick
887 * what they want to before proceeding. This can be used as an alternative
888 * to the standard activity picker that is displayed by the system when
889 * you try to start an activity with multiple possible matches, with these
890 * differences in behavior:
891 * <ul>
892 * <li>You can specify the title that will appear in the activity chooser.
893 * <li>The user does not have the option to make one of the matching
894 * activities a preferred activity, and all possible activities will
895 * always be shown even if one of them is currently marked as the
896 * preferred activity.
897 * </ul>
898 * <p>
899 * This action should be used when the user will naturally expect to
900 * select an activity in order to proceed. An example if when not to use
901 * it is when the user clicks on a "mailto:" link. They would naturally
902 * expect to go directly to their mail app, so startActivity() should be
903 * called directly: it will
904 * either launch the current preferred app, or put up a dialog allowing the
905 * user to pick an app to use and optionally marking that as preferred.
906 * <p>
907 * In contrast, if the user is selecting a menu item to send a picture
908 * they are viewing to someone else, there are many different things they
909 * may want to do at this point: send it through e-mail, upload it to a
910 * web service, etc. In this case the CHOOSER action should be used, to
911 * always present to the user a list of the things they can do, with a
912 * nice title given by the caller such as "Send this photo with:".
913 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700914 * If you need to grant URI permissions through a chooser, you must specify
915 * the permissions to be granted on the ACTION_CHOOSER Intent
916 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
917 * {@link #setClipData} to specify the URIs to be granted as well as
918 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
919 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
920 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700921 * As a convenience, an Intent of this form can be created with the
922 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700923 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700924 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
926 * and can optionally have a {@link #EXTRA_TITLE} field containing the
927 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700928 * <p>
929 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 */
931 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
932 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
933
934 /**
935 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
936 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700937 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
938 * target intent, also optionally supplying a title. If the target
939 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
940 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
941 * set in the returned chooser intent, with its ClipData set appropriately:
942 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500943 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700944 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700945 * @param target The Intent that the user will be selecting an activity
946 * to perform.
947 * @param title Optional title that will be displayed in the chooser.
948 * @return Return a new Intent object that you can hand to
949 * {@link Context#startActivity(Intent) Context.startActivity()} and
950 * related methods.
951 */
952 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700953 return createChooser(target, title, null);
954 }
955
956 /**
957 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
958 *
959 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
960 * target intent, also optionally supplying a title. If the target
961 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
962 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
963 * set in the returned chooser intent, with its ClipData set appropriately:
964 * either a direct reflection of {@link #getClipData()} if that is non-null,
965 * or a new ClipData built from {@link #getData()}.</p>
966 *
967 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
968 * when the user makes a choice. This can be useful if the calling application wants
969 * to remember the last chosen target and surface it as a more prominent or one-touch
970 * affordance elsewhere in the UI for next time.</p>
971 *
972 * @param target The Intent that the user will be selecting an activity
973 * to perform.
974 * @param title Optional title that will be displayed in the chooser.
975 * @param sender Optional IntentSender to be called when a choice is made.
976 * @return Return a new Intent object that you can hand to
977 * {@link Context#startActivity(Intent) Context.startActivity()} and
978 * related methods.
979 */
980 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700981 Intent intent = new Intent(ACTION_CHOOSER);
982 intent.putExtra(EXTRA_INTENT, target);
983 if (title != null) {
984 intent.putExtra(EXTRA_TITLE, title);
985 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700986
Adam Powell0b3c1122014-10-09 12:50:14 -0700987 if (sender != null) {
988 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
989 }
990
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700991 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700992 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
993 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
994 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700995 if (permFlags != 0) {
996 ClipData targetClipData = target.getClipData();
997 if (targetClipData == null && target.getData() != null) {
998 ClipData.Item item = new ClipData.Item(target.getData());
999 String[] mimeTypes;
1000 if (target.getType() != null) {
1001 mimeTypes = new String[] { target.getType() };
1002 } else {
1003 mimeTypes = new String[] { };
1004 }
1005 targetClipData = new ClipData(null, mimeTypes, item);
1006 }
1007 if (targetClipData != null) {
1008 intent.setClipData(targetClipData);
1009 intent.addFlags(permFlags);
1010 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001011 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001013 return intent;
1014 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001015
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 /**
1017 * Activity Action: Allow the user to select a particular kind of data and
1018 * return it. This is different than {@link #ACTION_PICK} in that here we
1019 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001020 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001021 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001022 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001023 * etc.
1024 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001025 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001026 * of data, such as a person contact, you set the MIME type to the kind of
1027 * data you want and launch it with {@link Context#startActivity(Intent)}.
1028 * The system will then launch the best application to select that kind
1029 * of data for you.
1030 * <p>
1031 * You may also be interested in any of a set of types of content the user
1032 * can pick. For example, an e-mail application that wants to allow the
1033 * user to add an attachment to an e-mail message can use this action to
1034 * bring up a list of all of the types of content the user can attach.
1035 * <p>
1036 * In this case, you should wrap the GET_CONTENT intent with a chooser
1037 * (through {@link #createChooser}), which will give the proper interface
1038 * for the user to pick how to send your data and allow you to specify
1039 * a prompt indicating what they are doing. You will usually specify a
1040 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1041 * broad range of content types the user can select from.
1042 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001043 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 * only pick from data that can be represented as a stream. This is
1045 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1046 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001048 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001049 * is locally available on the device. For example, if this extra is set
1050 * to true then an image picker should not show any pictures that are available
1051 * from a remote server but not already on the local device (thus requiring
1052 * they be downloaded when opened).
1053 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001054 * If the caller can handle multiple returned items (the user performing
1055 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1056 * to indicate this.
1057 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001058 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1059 * that no URI is supplied in the intent, as there are no constraints on
1060 * where the returned data originally comes from. You may also include the
1061 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001062 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001063 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1064 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001065 * <p>
1066 * Output: The URI of the item that was picked. This must be a content:
1067 * URI so that any receiver can access it.
1068 */
1069 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1070 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1071 /**
1072 * Activity Action: Dial a number as specified by the data. This shows a
1073 * UI with the number being dialed, allowing the user to explicitly
1074 * initiate the call.
1075 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1076 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1077 * number.
1078 * <p>Output: nothing.
1079 */
1080 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1081 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1082 /**
1083 * Activity Action: Perform a call to someone specified by the data.
1084 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1085 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1086 * number.
1087 * <p>Output: nothing.
1088 *
1089 * <p>Note: there will be restrictions on which applications can initiate a
1090 * call; most applications should use the {@link #ACTION_DIAL}.
1091 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1092 * numbers. Applications can <strong>dial</strong> emergency numbers using
1093 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001094 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001095 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001096 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001097 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001098 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001099 */
1100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1101 public static final String ACTION_CALL = "android.intent.action.CALL";
1102 /**
1103 * Activity Action: Perform a call to an emergency number specified by the
1104 * data.
1105 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1106 * tel: URI of an explicit phone number.
1107 * <p>Output: nothing.
1108 * @hide
1109 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001110 @SystemApi
1111 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001112 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1113 /**
1114 * Activity action: Perform a call to any number (emergency or not)
1115 * specified by the data.
1116 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1117 * tel: URI of an explicit phone number.
1118 * <p>Output: nothing.
1119 * @hide
1120 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001121 @SystemApi
1122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001123 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001124
Santos Cordon15a13782015-03-31 18:32:31 -07001125 /**
fionaxuadfe7002017-02-17 17:20:46 -08001126 * Activity Action: Main entry point for carrier setup apps.
1127 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1128 * carrier service and typically require
1129 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1130 * fulfill their duties.
1131 */
1132 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1133 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1134 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001135 * Activity Action: Send a message to someone specified by the data.
1136 * <p>Input: {@link #getData} is URI describing the target.
1137 * <p>Output: nothing.
1138 */
1139 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1140 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1141 /**
1142 * Activity Action: Deliver some data to someone else. Who the data is
1143 * being delivered to is not specified; it is up to the receiver of this
1144 * action to ask the user where the data should be sent.
1145 * <p>
1146 * When launching a SEND intent, you should usually wrap it in a chooser
1147 * (through {@link #createChooser}), which will give the proper interface
1148 * for the user to pick how to send your data and allow you to specify
1149 * a prompt indicating what they are doing.
1150 * <p>
1151 * Input: {@link #getType} is the MIME type of the data being sent.
1152 * get*Extra can have either a {@link #EXTRA_TEXT}
1153 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1154 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1155 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1156 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001157 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1158 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1159 * your text with HTML formatting.
1160 * <p>
1161 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1162 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1163 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1164 * content: URIs and other advanced features of {@link ClipData}. If
1165 * using this approach, you still must supply the same data through the
1166 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1167 * for compatibility with old applications. If you don't set a ClipData,
1168 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001169 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001170 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1171 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1172 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1173 * be openable only as asset typed files using
1174 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1175 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001176 * Optional standard extras, which may be interpreted by some recipients as
1177 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1178 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1179 * <p>
1180 * Output: nothing.
1181 */
1182 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1183 public static final String ACTION_SEND = "android.intent.action.SEND";
1184 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001185 * Activity Action: Deliver multiple data to someone else.
1186 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001187 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001188 * <p>
1189 * Input: {@link #getType} is the MIME type of the data being sent.
1190 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001191 * #EXTRA_STREAM} field, containing the data to be sent. If using
1192 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1193 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001194 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001195 * Multiple types are supported, and receivers should handle mixed types
1196 * whenever possible. The right way for the receiver to check them is to
1197 * use the content resolver on each URI. The intent sender should try to
1198 * put the most concrete mime type in the intent type, but it can fall
1199 * back to {@literal <type>/*} or {@literal *}/* as needed.
1200 * <p>
1201 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1202 * be image/jpg, but if you are sending image/jpg and image/png, then the
1203 * intent's type should be image/*.
1204 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001205 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1206 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1207 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1208 * content: URIs and other advanced features of {@link ClipData}. If
1209 * using this approach, you still must supply the same data through the
1210 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1211 * for compatibility with old applications. If you don't set a ClipData,
1212 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1213 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001214 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1215 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1216 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1217 * be openable only as asset typed files using
1218 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1219 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001220 * Optional standard extras, which may be interpreted by some recipients as
1221 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1222 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1223 * <p>
1224 * Output: nothing.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1228 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001229 * Activity Action: Handle an incoming phone call.
1230 * <p>Input: nothing.
1231 * <p>Output: nothing.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1235 /**
1236 * Activity Action: Insert an empty item into the given container.
1237 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1238 * in which to place the data.
1239 * <p>Output: URI of the new data that was created.
1240 */
1241 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1242 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1243 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001244 * Activity Action: Create a new item in the given container, initializing it
1245 * from the current contents of the clipboard.
1246 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1247 * in which to place the data.
1248 * <p>Output: URI of the new data that was created.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1252 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001253 * Activity Action: Delete the given data from its container.
1254 * <p>Input: {@link #getData} is URI of data to be deleted.
1255 * <p>Output: nothing.
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1259 /**
1260 * Activity Action: Run the data, whatever that means.
1261 * <p>Input: ? (Note: this is currently specific to the test harness.)
1262 * <p>Output: nothing.
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_RUN = "android.intent.action.RUN";
1266 /**
1267 * Activity Action: Perform a data synchronization.
1268 * <p>Input: ?
1269 * <p>Output: ?
1270 */
1271 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1272 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1273 /**
1274 * Activity Action: Pick an activity given an intent, returning the class
1275 * selected.
1276 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1277 * used with {@link PackageManager#queryIntentActivities} to determine the
1278 * set of activities from which to pick.
1279 * <p>Output: Class name of the activity that was selected.
1280 */
1281 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1282 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1283 /**
1284 * Activity Action: Perform a search.
1285 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1286 * is the text to search for. If empty, simply
1287 * enter your search results Activity with the search UI activated.
1288 * <p>Output: nothing.
1289 */
1290 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1291 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1292 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001293 * Activity Action: Start the platform-defined tutorial
1294 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1295 * is the text to search for. If empty, simply
1296 * enter your search results Activity with the search UI activated.
1297 * <p>Output: nothing.
1298 */
1299 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1300 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1301 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001302 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001303 * <p>
1304 * Input: {@link android.app.SearchManager#QUERY
1305 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1306 * a url starts with http or https, the site will be opened. If it is plain
1307 * text, Google search will be applied.
1308 * <p>
1309 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001310 */
1311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001313
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 /**
Jim Miller07994402012-05-02 14:22:27 -07001315 * Activity Action: Perform assist action.
1316 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001317 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1318 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001319 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1320 * information.
Jim Miller07994402012-05-02 14:22:27 -07001321 * Output: nothing.
1322 */
1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001325
1326 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001327 * Activity Action: Perform voice assist action.
1328 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001329 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1330 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001331 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001332 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001333 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001334 */
Amith Yamasani16452032017-03-03 10:15:57 -08001335 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001336 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1337 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1338
1339 /**
Adam Skory7140a252013-09-11 12:04:58 +01001340 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1341 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001342 */
1343 public static final String EXTRA_ASSIST_PACKAGE
1344 = "android.intent.extra.ASSIST_PACKAGE";
1345
1346 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001347 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1348 * application package at the time the assist was invoked.
1349 */
1350 public static final String EXTRA_ASSIST_UID
1351 = "android.intent.extra.ASSIST_UID";
1352
1353 /**
Adam Skory7140a252013-09-11 12:04:58 +01001354 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1355 * information supplied by the current foreground app at the time of the assist request.
1356 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001357 */
1358 public static final String EXTRA_ASSIST_CONTEXT
1359 = "android.intent.extra.ASSIST_CONTEXT";
1360
Jim Miller07994402012-05-02 14:22:27 -07001361 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001362 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1363 * keyboard as the primary input device for assistance.
1364 */
1365 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1366 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1367
1368 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001369 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1370 * that was used to invoke the assist.
1371 */
1372 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1373 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1374
1375 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001376 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001377 * <p>Input: Nothing.
1378 * <p>Output: nothing.
1379 */
1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1382 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001383 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001384 * <p>Input: Nothing.
1385 * <p>Output: Nothing.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1389
1390 /**
1391 * Activity Action: Show activity for reporting a bug.
1392 * <p>Input: Nothing.
1393 * <p>Output: Nothing.
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1397
1398 /**
1399 * Activity Action: Main entry point for factory tests. Only used when
1400 * the device is booting in factory test node. The implementing package
1401 * must be installed in the system image.
1402 * <p>Input: nothing
1403 * <p>Output: nothing
1404 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001406 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1407
1408 /**
1409 * Activity Action: The user pressed the "call" button to go to the dialer
1410 * or other appropriate UI for placing a call.
1411 * <p>Input: Nothing.
1412 * <p>Output: Nothing.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1416
1417 /**
1418 * Activity Action: Start Voice Command.
1419 * <p>Input: Nothing.
1420 * <p>Output: Nothing.
1421 */
1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001424
1425 /**
1426 * Activity Action: Start action associated with long pressing on the
1427 * search key.
1428 * <p>Input: Nothing.
1429 * <p>Output: Nothing.
1430 */
1431 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1432 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001433
Jacek Surazski86b6c532009-05-13 14:38:28 +02001434 /**
1435 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1436 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001437 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001438 * <p>Input: No data is specified. The bug report is passed in using
1439 * an {@link #EXTRA_BUG_REPORT} field.
1440 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001441 *
1442 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001443 */
1444 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1445 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001446
1447 /**
1448 * Activity Action: Show power usage information to the user.
1449 * <p>Input: Nothing.
1450 * <p>Output: Nothing.
1451 */
1452 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1453 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001454
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001455 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001456 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1457 * to run.
1458 * <p>Input: Nothing.
1459 * <p>Output: Nothing.
1460 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1461 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1462 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001463 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001464 */
1465 @Deprecated
1466 @SystemApi
1467 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1468 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1469
1470 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001471 * Activity Action: Setup wizard to launch after a platform update. This
1472 * activity should have a string meta-data field associated with it,
1473 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1474 * the platform for setup. The activity will be launched only if
1475 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1476 * same value.
1477 * <p>Input: Nothing.
1478 * <p>Output: Nothing.
1479 * @hide
1480 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001481 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001482 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1483 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001484
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001485 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001486 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1487 * <p>Input: Nothing.
1488 * <p>Output: Nothing.
1489 * @hide
1490 */
1491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1492 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001493 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001494
1495 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001496 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1497 * <p>Input: Nothing.
1498 * <p>Output: Nothing.
1499 * @hide
1500 */
1501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1502 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001503 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001504
1505 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001506 * Activity Action: Show settings for managing network data usage of a
1507 * specific application. Applications should define an activity that offers
1508 * options to control data usage.
1509 */
1510 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1511 public static final String ACTION_MANAGE_NETWORK_USAGE =
1512 "android.intent.action.MANAGE_NETWORK_USAGE";
1513
1514 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001515 * Activity Action: Launch application installer.
1516 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001517 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001518 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1519 * you can also use "package:<package-name>" to install an application for the
1520 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001521 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1522 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1523 * <p>
1524 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1525 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001526 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001527 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001528 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1529 * in order to launch the application installer.
1530 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 *
1532 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1533 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1534 * @see #EXTRA_RETURN_RESULT
1535 */
1536 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1537 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1538
1539 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001540 * Activity Action: Activity to handle split installation failures.
1541 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1542 * but the split that contains the application isn't installed. When a split is
1543 * installed in this manner, the containing package usually doesn't know this is
1544 * happening. However, if an error occurs during installation, the containing
1545 * package can define a single activity handling this action to deal with such
1546 * failures.
1547 * <p>The activity handling this action must be in the base package.
1548 * <p>
1549 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1550 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1551 */
1552 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1553 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1554
1555 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001556 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001557 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001558 * @deprecated Do not use. This will go away.
1559 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1560 */
1561 @SystemApi
1562 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1563 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1564 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1565 /**
1566 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001567 * <p class="note">
1568 * This is a protected intent that can only be sent by the system.
1569 * </p>
1570 *
1571 * @hide
1572 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001573 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001574 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1576 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001577
1578 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001579 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001580 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001581 * @deprecated Do not use. This will go away.
1582 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1583 */
1584 @SystemApi
1585 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1586 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1587 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1588 /**
1589 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001590 * <p>
1591 * The system will have a persistent connection to this service.
1592 * This is a protected intent that can only be sent by the system.
1593 * </p>
1594 *
1595 * @hide
1596 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001598 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1600 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001601
1602 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001603 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001604 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001605 * @deprecated Do not use. This will go away.
1606 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1607 */
1608 @SystemApi
1609 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1610 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1611 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1612 /**
1613 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001614 *
1615 * <p class="note">
1616 * This is a protected intent that can only be sent by the system.
1617 * </p>
1618 *
1619 * @hide
1620 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001621 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001622 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001623 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1624 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001625
1626 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001627 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1628 * package. Specifies the installer package name; this package will receive the
1629 * {@link #ACTION_APP_ERROR} intent.
1630 */
1631 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1632 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1633
1634 /**
1635 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1636 * package. Specifies that the application being installed should not be
1637 * treated as coming from an unknown source, but as coming from the app
1638 * invoking the Intent. For this to work you must start the installer with
1639 * startActivityForResult().
1640 */
1641 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1642 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1643
1644 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001645 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1646 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001647 * data field originated from.
1648 */
rich cannings706e8ba2012-08-20 13:20:14 -07001649 public static final String EXTRA_ORIGINATING_URI
1650 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001651
1652 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001653 * This extra can be used with any Intent used to launch an activity, supplying information
1654 * about who is launching that activity. This field contains a {@link android.net.Uri}
1655 * object, typically an http: or https: URI of the web site that the referral came from;
1656 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1657 * a native application that it came from.
1658 *
1659 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1660 * instead of directly retrieving the extra. It is also valid for applications to
1661 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1662 * a string, not a Uri; the field here, if supplied, will always take precedence,
1663 * however.</p>
1664 *
1665 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001666 */
1667 public static final String EXTRA_REFERRER
1668 = "android.intent.extra.REFERRER";
1669
1670 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001671 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1672 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1673 * not be created, in particular when Intent extras are supplied through the
1674 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1675 * schemes.
1676 *
1677 * @see #EXTRA_REFERRER
1678 */
1679 public static final String EXTRA_REFERRER_NAME
1680 = "android.intent.extra.REFERRER_NAME";
1681
1682 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001683 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001684 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001685 * Currently only a system app that hosts the provider authority "downloads" or holds the
1686 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001687 * @hide
1688 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001689 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001690 public static final String EXTRA_ORIGINATING_UID
1691 = "android.intent.extra.ORIGINATING_UID";
1692
1693 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001694 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1695 * package. Tells the installer UI to skip the confirmation with the user
1696 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001697 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1698 * will no longer show an interstitial message about updating existing
1699 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001700 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001701 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001702 public static final String EXTRA_ALLOW_REPLACE
1703 = "android.intent.extra.ALLOW_REPLACE";
1704
1705 /**
1706 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1707 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1708 * return to the application the result code of the install/uninstall. The returned result
1709 * code will be {@link android.app.Activity#RESULT_OK} on success or
1710 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1711 */
1712 public static final String EXTRA_RETURN_RESULT
1713 = "android.intent.extra.RETURN_RESULT";
1714
1715 /**
1716 * Package manager install result code. @hide because result codes are not
1717 * yet ready to be exposed.
1718 */
1719 public static final String EXTRA_INSTALL_RESULT
1720 = "android.intent.extra.INSTALL_RESULT";
1721
1722 /**
1723 * Activity Action: Launch application uninstaller.
1724 * <p>
1725 * Input: The data must be a package: URI whose scheme specific part is
1726 * the package name of the current installed package to be uninstalled.
1727 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1728 * <p>
1729 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1730 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001731 * <p>
1732 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1733 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001734 */
1735 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1736 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1737
1738 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001739 * Specify whether the package should be uninstalled for all users.
1740 * @hide because these should not be part of normal application flow.
1741 */
1742 public static final String EXTRA_UNINSTALL_ALL_USERS
1743 = "android.intent.extra.UNINSTALL_ALL_USERS";
1744
1745 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001746 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1747 * describing the last run version of the platform that was setup.
1748 * @hide
1749 */
1750 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1751
Svet Ganov3695b8a2015-03-24 16:30:25 -07001752 /**
1753 * Activity action: Launch UI to manage the permissions of an app.
1754 * <p>
1755 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1756 * will be managed by the launched UI.
1757 * </p>
1758 * <p>
1759 * Output: Nothing.
1760 * </p>
1761 *
1762 * @see #EXTRA_PACKAGE_NAME
1763 *
1764 * @hide
1765 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001766 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001767 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1768 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1769 "android.intent.action.MANAGE_APP_PERMISSIONS";
1770
1771 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001772 * Activity action: Launch UI to manage permissions.
1773 * <p>
1774 * Input: Nothing.
1775 * </p>
1776 * <p>
1777 * Output: Nothing.
1778 * </p>
1779 *
1780 * @hide
1781 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001782 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001783 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1784 public static final String ACTION_MANAGE_PERMISSIONS =
1785 "android.intent.action.MANAGE_PERMISSIONS";
1786
1787 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001788 * Activity action: Launch UI to review permissions for an app.
1789 * The system uses this intent if permission review for apps not
1790 * supporting the new runtime permissions model is enabled. In
1791 * this mode a permission review is required before any of the
1792 * app components can run.
1793 * <p>
1794 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1795 * permissions will be reviewed (mandatory).
1796 * </p>
1797 * <p>
1798 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1799 * be fired after the permission review (optional).
1800 * </p>
1801 * <p>
1802 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1803 * be invoked after the permission review (optional).
1804 * </p>
1805 * <p>
1806 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1807 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1808 * </p>
1809 * <p>
1810 * Output: Nothing.
1811 * </p>
1812 *
1813 * @see #EXTRA_PACKAGE_NAME
1814 * @see #EXTRA_INTENT
1815 * @see #EXTRA_REMOTE_CALLBACK
1816 * @see #EXTRA_RESULT_NEEDED
1817 *
1818 * @hide
1819 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001820 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001821 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1822 public static final String ACTION_REVIEW_PERMISSIONS =
1823 "android.intent.action.REVIEW_PERMISSIONS";
1824
1825 /**
1826 * Intent extra: A callback for reporting remote result as a bundle.
1827 * <p>
1828 * Type: IRemoteCallback
1829 * </p>
1830 *
1831 * @hide
1832 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001833 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001834 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1835
1836 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001837 * Intent extra: An app package name.
1838 * <p>
1839 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001840 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001841 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001842 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001843 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1844
1845 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001846 * Intent extra: An app split name.
1847 * <p>
1848 * Type: String
1849 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001850 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001851 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1852
1853 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001854 * Intent extra: A {@link ComponentName} value.
1855 * <p>
1856 * Type: String
1857 * </p>
1858 */
1859 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1860
1861 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001862 * Intent extra: An extra for specifying whether a result is needed.
1863 * <p>
1864 * Type: boolean
1865 * </p>
1866 *
1867 * @hide
1868 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001869 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001870 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1871
1872 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001873 * Activity action: Launch UI to manage which apps have a given permission.
1874 * <p>
1875 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1876 * to which will be managed by the launched UI.
1877 * </p>
1878 * <p>
1879 * Output: Nothing.
1880 * </p>
1881 *
1882 * @see #EXTRA_PERMISSION_NAME
1883 *
1884 * @hide
1885 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001886 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001887 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1888 public static final String ACTION_MANAGE_PERMISSION_APPS =
1889 "android.intent.action.MANAGE_PERMISSION_APPS";
1890
1891 /**
1892 * Intent extra: The name of a permission.
1893 * <p>
1894 * Type: String
1895 * </p>
1896 *
1897 * @hide
1898 */
1899 @SystemApi
1900 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1901
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001902 // ---------------------------------------------------------------------
1903 // ---------------------------------------------------------------------
1904 // Standard intent broadcast actions (see action variable).
1905
1906 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001907 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1908 * <p>
1909 * For historical reasons, the name of this broadcast action refers to the power
1910 * state of the screen but it is actually sent in response to changes in the
1911 * overall interactive state of the device.
1912 * </p><p>
1913 * This broadcast is sent when the device becomes non-interactive which may have
1914 * nothing to do with the screen turning off. To determine the
1915 * actual state of the screen, use {@link android.view.Display#getState}.
1916 * </p><p>
1917 * See {@link android.os.PowerManager#isInteractive} for details.
1918 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001919 * You <em>cannot</em> receive this through components declared in
1920 * manifests, only by explicitly registering for it with
1921 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1922 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001923 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001924 * <p class="note">This is a protected intent that can only be sent
1925 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001929
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001930 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001931 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1932 * <p>
1933 * For historical reasons, the name of this broadcast action refers to the power
1934 * state of the screen but it is actually sent in response to changes in the
1935 * overall interactive state of the device.
1936 * </p><p>
1937 * This broadcast is sent when the device becomes interactive which may have
1938 * nothing to do with the screen turning on. To determine the
1939 * actual state of the screen, use {@link android.view.Display#getState}.
1940 * </p><p>
1941 * See {@link android.os.PowerManager#isInteractive} for details.
1942 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001943 * You <em>cannot</em> receive this through components declared in
1944 * manifests, only by explicitly registering for it with
1945 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1946 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001947 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001948 * <p class="note">This is a protected intent that can only be sent
1949 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 */
1951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1952 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001953
1954 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001955 * Broadcast Action: Sent after the system stops dreaming.
1956 *
1957 * <p class="note">This is a protected intent that can only be sent by the system.
1958 * It is only sent to registered receivers.</p>
1959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1962
1963 /**
1964 * Broadcast Action: Sent after the system starts dreaming.
1965 *
1966 * <p class="note">This is a protected intent that can only be sent by the system.
1967 * It is only sent to registered receivers.</p>
1968 */
1969 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1970 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1971
1972 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001973 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001974 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001975 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001976 * <p class="note">This is a protected intent that can only be sent
1977 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001980 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001981
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001982 /**
1983 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001984 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001985 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001986 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1987 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001989 * <p class="note">This is a protected intent that can only be sent
1990 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1993 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1994 /**
1995 * Broadcast Action: The time was set.
1996 */
1997 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1998 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1999 /**
2000 * Broadcast Action: The date has changed.
2001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2003 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2004 /**
2005 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2006 * <ul>
2007 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2008 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002009 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002010 * <p class="note">This is a protected intent that can only be sent
2011 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 */
2013 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2014 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2015 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002016 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2017 * DNS entries should be tossed.
2018 * @hide
2019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2022 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 * Alarm Changed Action: This is broadcast when the AlarmClock
2024 * application's alarm is set or unset. It is used by the
2025 * AlarmClock application and the StatusBar service.
2026 * @hide
2027 */
2028 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2029 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002030
2031 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002032 * Broadcast Action: This is broadcast once, after the user has finished
2033 * booting, but while still in the "locked" state. It can be used to perform
2034 * application-specific initialization, such as installing alarms. You must
2035 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2036 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002037 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002038 * This broadcast is sent immediately at boot by all devices (regardless of
2039 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2040 * higher. Upon receipt of this broadcast, the user is still locked and only
2041 * device-protected storage can be accessed safely. If you want to access
2042 * credential-protected storage, you need to wait for the user to be
2043 * unlocked (typically by entering their lock pattern or PIN for the first
2044 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2045 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2046 * <p>
2047 * To receive this broadcast, your receiver component must be marked as
2048 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002049 * <p class="note">
2050 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002051 *
2052 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002053 */
2054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2055 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2056
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002058 * Broadcast Action: This is broadcast once, after the user has finished
2059 * booting. It can be used to perform application-specific initialization,
2060 * such as installing alarms. You must hold the
2061 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2062 * order to receive this broadcast.
2063 * <p>
2064 * This broadcast is sent at boot by all devices (both with and without
2065 * direct boot support). Upon receipt of this broadcast, the user is
2066 * unlocked and both device-protected and credential-protected storage can
2067 * accessed safely.
2068 * <p>
2069 * If you need to run while the user is still locked (before they've entered
2070 * their lock pattern or PIN for the first time), you can listen for the
2071 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2072 * <p class="note">
2073 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 */
2075 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002076 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002078
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 /**
2080 * Broadcast Action: This is broadcast when a user action should request a
2081 * temporary system dialog to dismiss. Some examples of temporary system
2082 * dialogs are the notification window-shade and the recent tasks dialog.
2083 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002084 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002085 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2086 /**
2087 * Broadcast Action: Trigger the download and eventual installation
2088 * of a package.
2089 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002090 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002091 * <p class="note">This is a protected intent that can only be sent
2092 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002093 *
2094 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002095 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002096 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2098 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2099 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002100 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002101 * device. The data contains the name of the package. Note that the
2102 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002103 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002105 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2106 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002107 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2108 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002109 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002110 * <p class="note">This is a protected intent that can only be sent
2111 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002112 */
2113 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2114 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2115 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002116 * Broadcast Action: A new version of an application package has been
2117 * installed, replacing an existing version that was previously installed.
2118 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002119 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002120 * <ul>
2121 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2122 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002123 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2129 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002130 * Broadcast Action: A new version of your application has been installed
2131 * over an existing one. This is only sent to the application that was
2132 * replaced. It does not contain any additional data; to receive it, just
2133 * use an intent filter for this action.
2134 *
2135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
2137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2140 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002141 * Broadcast Action: An existing application package has been removed from
2142 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002143 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002144 * <ul>
2145 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2146 * to the package.
2147 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2148 * application -- data and code -- is being removed.
2149 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2150 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2151 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002152 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2158 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002159 * Broadcast Action: An existing application package has been completely
2160 * removed from the device. The data contains the name of the package.
2161 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2162 * {@link #EXTRA_DATA_REMOVED} is true and
2163 * {@link #EXTRA_REPLACING} is false of that broadcast.
2164 *
2165 * <ul>
2166 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2167 * to the package.
2168 * </ul>
2169 *
2170 * <p class="note">This is a protected intent that can only be sent
2171 * by the system.
2172 */
2173 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2174 public static final String ACTION_PACKAGE_FULLY_REMOVED
2175 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2176 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002177 * Broadcast Action: An existing application package has been changed (for
2178 * example, a component has been enabled or disabled). The data contains
2179 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002180 * <ul>
2181 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002182 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002183 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002184 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2185 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002186 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002187 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002188 * <p class="note">This is a protected intent that can only be sent
2189 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002190 */
2191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2192 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2193 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002194 * @hide
2195 * Broadcast Action: Ask system services if there is any reason to
2196 * restart the given package. The data contains the name of the
2197 * package.
2198 * <ul>
2199 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2200 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2201 * </ul>
2202 *
2203 * <p class="note">This is a protected intent that can only be sent
2204 * by the system.
2205 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002206 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2208 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2209 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002210 * Broadcast Action: The user has restarted a package, and all of its
2211 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002212 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002213 * be removed. Note that the restarted package does <em>not</em>
2214 * receive this broadcast.
2215 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002216 * <ul>
2217 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2218 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002219 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002220 * <p class="note">This is a protected intent that can only be sent
2221 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002222 */
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2225 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 * Broadcast Action: The user has cleared the data of a package. This should
2227 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002228 * its persistent data is erased and this broadcast sent.
2229 * Note that the cleared package does <em>not</em>
2230 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002231 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002232 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2233 * package whose data was cleared is an uninstalled instant app, then the UID
2234 * will be -1. The platform keeps some meta-data associated with instant apps
2235 * after they are uninstalled.
2236 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2237 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002238 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002239 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002240 * <p class="note">This is a protected intent that can only be sent
2241 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002242 */
2243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2244 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2245 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002246 * Broadcast Action: Packages have been suspended.
2247 * <p>Includes the following extras:
2248 * <ul>
2249 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2250 * </ul>
2251 *
2252 * <p class="note">This is a protected intent that can only be sent
2253 * by the system. It is only sent to registered receivers.
2254 */
2255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2256 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2257 /**
2258 * Broadcast Action: Packages have been unsuspended.
2259 * <p>Includes the following extras:
2260 * <ul>
2261 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2262 * </ul>
2263 *
2264 * <p class="note">This is a protected intent that can only be sent
2265 * by the system. It is only sent to registered receivers.
2266 */
2267 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2268 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2269 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002270 * Broadcast Action: A user ID has been removed from the system. The user
2271 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002272 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002273 * <p class="note">This is a protected intent that can only be sent
2274 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002275 */
2276 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2277 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002278
2279 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002280 * Broadcast Action: Sent to the installer package of an application when
2281 * that application is first launched (that is the first time it is moved
2282 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002283 *
2284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
2286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2289
2290 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002291 * Broadcast Action: Sent to the system package verifier when a package
2292 * needs to be verified. The data contains the package URI.
2293 * <p class="note">
2294 * This is a protected intent that can only be sent by the system.
2295 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2299
2300 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002301 * Broadcast Action: Sent to the system package verifier when a package is
2302 * verified. The data contains the package URI.
2303 * <p class="note">
2304 * This is a protected intent that can only be sent by the system.
2305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2308
2309 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002310 * Broadcast Action: Sent to the system intent filter verifier when an
2311 * intent filter needs to be verified. The data contains the filter data
2312 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002313 * <p class="note">
2314 * This is a protected intent that can only be sent by the system.
2315 * </p>
2316 *
2317 * @hide
2318 */
2319 @SystemApi
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2322
2323 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002324 * Broadcast Action: Resources for a set of packages (which were
2325 * previously unavailable) are currently
2326 * available since the media on which they exist is available.
2327 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2328 * list of packages whose availability changed.
2329 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2330 * list of uids of packages whose availability changed.
2331 * Note that the
2332 * packages in this list do <em>not</em> receive this broadcast.
2333 * The specified set of packages are now available on the system.
2334 * <p>Includes the following extras:
2335 * <ul>
2336 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2337 * whose resources(were previously unavailable) are currently available.
2338 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2339 * packages whose resources(were previously unavailable)
2340 * are currently available.
2341 * </ul>
2342 *
2343 * <p class="note">This is a protected intent that can only be sent
2344 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002347 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2348 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002349
2350 /**
2351 * Broadcast Action: Resources for a set of packages are currently
2352 * unavailable since the media on which they exist is unavailable.
2353 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2354 * list of packages whose availability changed.
2355 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2356 * list of uids of packages whose availability changed.
2357 * The specified set of packages can no longer be
2358 * launched and are practically unavailable on the system.
2359 * <p>Inclues the following extras:
2360 * <ul>
2361 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2362 * whose resources are no longer available.
2363 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2364 * whose resources are no longer available.
2365 * </ul>
2366 *
2367 * <p class="note">This is a protected intent that can only be sent
2368 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002371 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002372 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002373
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002374 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002375 * Broadcast Action: preferred activities have changed *explicitly*.
2376 *
2377 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2378 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2379 * be sent.
2380 *
2381 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2382 *
2383 * @hide
2384 */
2385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2386 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2387 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2388
2389
2390 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002391 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002392 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002393 * This should <em>only</em> be used to determine when the wallpaper
2394 * has changed to show the new wallpaper to the user. You should certainly
2395 * never, in response to this, change the wallpaper or other attributes of
2396 * it such as the suggested size. That would be crazy, right? You'd cause
2397 * all kinds of loops, especially if other apps are doing similar things,
2398 * right? Of course. So please don't do this.
2399 *
2400 * @deprecated Modern applications should use
2401 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2402 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2403 * shown behind their UI, rather than watching for this broadcast and
2404 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002406 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002407 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2408 /**
2409 * Broadcast Action: The current device {@link android.content.res.Configuration}
2410 * (orientation, locale, etc) has changed. When such a change happens, the
2411 * UIs (view hierarchy) will need to be rebuilt based on this new
2412 * information; for the most part, applications don't need to worry about
2413 * this, because the system will take care of stopping and restarting the
2414 * application to make sure it sees the new changes. Some system code that
2415 * can not be restarted will need to watch for this action and handle it
2416 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002417 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002418 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002419 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002420 * in manifests, only by explicitly registering for it with
2421 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2422 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002423 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002424 * <p class="note">This is a protected intent that can only be sent
2425 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002426 *
2427 * @see android.content.res.Configuration
2428 */
2429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2430 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2431 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002432 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002433 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
2436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2438 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2439 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002440 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2441 * charging state, level, and other information about the battery.
2442 * See {@link android.os.BatteryManager} for documentation on the
2443 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002444 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002446 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002447 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002448 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002449 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2450 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2451 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2452 * broadcasts that are sent and can be received through manifest
2453 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002454 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002455 * <p class="note">This is a protected intent that can only be sent
2456 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002457 */
2458 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2459 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2460 /**
2461 * Broadcast Action: Indicates low battery condition on the device.
2462 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002463 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002464 * <p class="note">This is a protected intent that can only be sent
2465 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2469 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002470 * Broadcast Action: Indicates the battery is now okay after being low.
2471 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2472 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002473 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002474 * <p class="note">This is a protected intent that can only be sent
2475 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002476 */
2477 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2478 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2479 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002480 * Broadcast Action: External power has been connected to the device.
2481 * This is intended for applications that wish to register specifically to this notification.
2482 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2483 * stay active to receive this notification. This action can be used to implement actions
2484 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002485 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002486 * <p class="note">This is a protected intent that can only be sent
2487 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002488 */
2489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002490 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002491 /**
2492 * Broadcast Action: External power has been removed from the device.
2493 * This is intended for applications that wish to register specifically to this notification.
2494 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2495 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002496 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002497 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002498 * <p class="note">This is a protected intent that can only be sent
2499 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002502 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002503 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002504 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002505 * Broadcast Action: Device is shutting down.
2506 * This is broadcast when the device is being shut down (completely turned
2507 * off, not sleeping). Once the broadcast is complete, the final shutdown
2508 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002509 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002510 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002511 * <p class="note">This is a protected intent that can only be sent
2512 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002513 * <p>May include the following extras:
2514 * <ul>
2515 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2516 * shutdown is only for userspace processes. If not set, assumed to be false.
2517 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002520 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002521 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002522 * Activity Action: Start this activity to request system shutdown.
2523 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002524 * to request confirmation from the user before shutting down. The optional boolean
2525 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2526 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002527 *
2528 * <p class="note">This is a protected intent that can only be sent
2529 * by the system.
2530 *
2531 * {@hide}
2532 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002533 public static final String ACTION_REQUEST_SHUTDOWN
2534 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002535 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002536 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002537 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002538 * <p class="note">
2539 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002540 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002541 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2542 * or above, this broadcast will no longer be delivered to any
2543 * {@link BroadcastReceiver} defined in your manifest. Instead,
2544 * apps are strongly encouraged to use the improved
2545 * {@link Context#getCacheDir()} behavior so the system can
2546 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002550 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2551 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 * Broadcast Action: Indicates low storage space condition on the device no
2553 * longer exists
2554 * <p class="note">
2555 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002556 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002557 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2558 * or above, this broadcast will no longer be delivered to any
2559 * {@link BroadcastReceiver} defined in your manifest. Instead,
2560 * apps are strongly encouraged to use the improved
2561 * {@link Context#getCacheDir()} behavior so the system can
2562 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002563 */
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002565 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002566 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2567 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002568 * Broadcast Action: A sticky broadcast that indicates a storage space full
2569 * condition on the device. This is intended for activities that want to be
2570 * able to fill the data partition completely, leaving only enough free
2571 * space to prevent system-wide SQLite failures.
2572 * <p class="note">
2573 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002574 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002575 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2576 * or above, this broadcast will no longer be delivered to any
2577 * {@link BroadcastReceiver} defined in your manifest. Instead,
2578 * apps are strongly encouraged to use the improved
2579 * {@link Context#getCacheDir()} behavior so the system can
2580 * automatically free up storage when needed.
2581 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002584 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002585 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2586 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002587 * Broadcast Action: Indicates storage space full condition on the device no
2588 * longer exists.
2589 * <p class="note">
2590 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002591 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002592 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2593 * or above, this broadcast will no longer be delivered to any
2594 * {@link BroadcastReceiver} defined in your manifest. Instead,
2595 * apps are strongly encouraged to use the improved
2596 * {@link Context#getCacheDir()} behavior so the system can
2597 * automatically free up storage when needed.
2598 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002599 */
2600 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002601 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002602 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2603 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002604 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2605 * and package management should be started.
2606 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2607 * notification.
2608 */
2609 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2610 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2611 /**
2612 * Broadcast Action: The device has entered USB Mass Storage mode.
2613 * This is used mainly for the USB Settings panel.
2614 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2615 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002616 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002617 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002618 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002620 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2621
2622 /**
2623 * Broadcast Action: The device has exited USB Mass Storage mode.
2624 * This is used mainly for the USB Settings panel.
2625 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2626 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002627 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002628 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002629 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002631 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2632
2633 /**
2634 * Broadcast Action: External media has been removed.
2635 * The path to the mount point for the removed media is contained in the Intent.mData field.
2636 */
2637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2638 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2639
2640 /**
2641 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002642 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2646
2647 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002648 * Broadcast Action: External media is present, and being disk-checked
2649 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2652 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2653
2654 /**
2655 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2656 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2660
2661 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002662 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002663 * The path to the mount point for the mounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002664 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2665 * media was mounted read only.
2666 */
2667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2668 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2669
2670 /**
2671 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002672 * The path to the mount point for the shared media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 */
2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2676
2677 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002678 * Broadcast Action: External media is no longer being shared via USB mass storage.
2679 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2680 *
2681 * @hide
2682 */
2683 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2684
2685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002686 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2687 * The path to the mount point for the removed media is contained in the Intent.mData field.
2688 */
2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2690 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2691
2692 /**
2693 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002694 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2697 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2698
2699 /**
2700 * Broadcast Action: User has expressed the desire to remove the external storage media.
2701 * Applications should close all files they have open within the mount point when they receive this intent.
2702 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2703 */
2704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2705 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2706
2707 /**
2708 * Broadcast Action: The media scanner has started scanning a directory.
2709 * The path to the directory being scanned is contained in the Intent.mData field.
2710 */
2711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2712 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2713
2714 /**
2715 * Broadcast Action: The media scanner has finished scanning a directory.
2716 * The path to the scanned directory is contained in the Intent.mData field.
2717 */
2718 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2719 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2720
2721 /**
2722 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2723 * The path to the file is contained in the Intent.mData field.
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2727
2728 /**
2729 * Broadcast Action: The "Media Button" was pressed. Includes a single
2730 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2731 * caused the broadcast.
2732 */
2733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2734 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2735
2736 /**
2737 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2738 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2739 * caused the broadcast.
2740 */
2741 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2742 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2743
2744 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2745 // location; they are not general-purpose actions.
2746
2747 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002748 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002749 */
2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2751 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2752 "android.intent.action.GTALK_CONNECTED";
2753
2754 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002755 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002756 */
2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2759 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002760
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002761 /**
2762 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002763 */
2764 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2765 public static final String ACTION_INPUT_METHOD_CHANGED =
2766 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767
2768 /**
2769 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2770 * more radios have been turned off or on. The intent will have the following extra value:</p>
2771 * <ul>
2772 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2773 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2774 * turned off</li>
2775 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002776 *
Peng Xua35b5532016-01-20 00:05:45 -08002777 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2781
2782 /**
2783 * Broadcast Action: Some content providers have parts of their namespace
2784 * where they publish new events or items that the user may be especially
2785 * interested in. For these things, they may broadcast this action when the
2786 * set of interesting items change.
2787 *
2788 * For example, GmailProvider sends this notification when the set of unread
2789 * mail in the inbox changes.
2790 *
2791 * <p>The data of the intent identifies which part of which provider
2792 * changed. When queried through the content resolver, the data URI will
2793 * return the data set in question.
2794 *
2795 * <p>The intent will have the following extra values:
2796 * <ul>
2797 * <li><em>count</em> - The number of items in the data set. This is the
2798 * same as the number of items in the cursor returned by querying the
2799 * data URI. </li>
2800 * </ul>
2801 *
2802 * This intent will be sent at boot (if the count is non-zero) and when the
2803 * data set changes. It is possible for the data set to change without the
2804 * count changing (for example, if a new unread message arrives in the same
2805 * sync operation in which a message is archived). The phone should still
2806 * ring/vibrate/etc as normal in this case.
2807 */
2808 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2809 public static final String ACTION_PROVIDER_CHANGED =
2810 "android.intent.action.PROVIDER_CHANGED";
2811
2812 /**
2813 * Broadcast Action: Wired Headset plugged in or unplugged.
2814 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002815 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2816 * and documentation.
2817 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002818 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002819 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002820 */
2821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002822 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002823
2824 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002825 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2826 * <ul>
2827 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2828 * </ul>
2829 *
2830 * <p class="note">This is a protected intent that can only be sent
2831 * by the system.
2832 *
2833 * @hide
2834 */
2835 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2836 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2837 = "android.intent.action.ADVANCED_SETTINGS";
2838
2839 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002840 * Broadcast Action: Sent after application restrictions are changed.
2841 *
2842 * <p class="note">This is a protected intent that can only be sent
2843 * by the system.</p>
2844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2847 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2848
2849 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002850 * Broadcast Action: An outgoing call is about to be placed.
2851 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002852 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002853 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002854 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002855 * the phone number originally intended to be dialed.</li>
2856 * </ul>
2857 * <p>Once the broadcast is finished, the resultData is used as the actual
2858 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002859 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002860 * outgoing call in turn: for example, a parental control application
2861 * might verify that the user is authorized to place the call at that
2862 * time, then a number-rewriting application might add an area code if
2863 * one was not specified.</p>
2864 * <p>For consistency, any receiver whose purpose is to prohibit phone
2865 * calls should have a priority of 0, to ensure it will see the final
2866 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002867 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002868 * should have a positive priority.
2869 * Negative priorities are reserved for the system for this broadcast;
2870 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002871 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2872 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 * <p>Emergency calls cannot be intercepted using this mechanism, and
2874 * other calls cannot be modified to call emergency numbers using this
2875 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002876 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2877 * call to use their own service instead. Those apps should first prevent
2878 * the call from being placed by setting resultData to <code>null</code>
2879 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002880 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002881 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2882 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002883 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002884 * <p class="note">This is a protected intent that can only be sent
2885 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002886 */
2887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2888 public static final String ACTION_NEW_OUTGOING_CALL =
2889 "android.intent.action.NEW_OUTGOING_CALL";
2890
2891 /**
2892 * Broadcast Action: Have the device reboot. This is only for use by
2893 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002895 * <p class="note">This is a protected intent that can only be sent
2896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002897 */
2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2899 public static final String ACTION_REBOOT =
2900 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002901
Wei Huang97ecc9c2009-05-11 17:44:20 -07002902 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002903 * Broadcast Action: A sticky broadcast for changes in the physical
2904 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002905 *
2906 * <p>The intent will have the following extra values:
2907 * <ul>
2908 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002909 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002910 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002911 * <p>This is intended for monitoring the current physical dock state.
2912 * See {@link android.app.UiModeManager} for the normal API dealing with
2913 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002914 */
2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2916 public static final String ACTION_DOCK_EVENT =
2917 "android.intent.action.DOCK_EVENT";
2918
2919 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002920 * Broadcast Action: A broadcast when idle maintenance can be started.
2921 * This means that the user is not interacting with the device and is
2922 * not expected to do so soon. Typical use of the idle maintenance is
2923 * to perform somehow expensive tasks that can be postponed at a moment
2924 * when they will not degrade user experience.
2925 * <p>
2926 * <p class="note">In order to keep the device responsive in case of an
2927 * unexpected user interaction, implementations of a maintenance task
2928 * should be interruptible. In such a scenario a broadcast with action
2929 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2930 * should not do the maintenance work in
2931 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2932 * maintenance service by {@link Context#startService(Intent)}. Also
2933 * you should hold a wake lock while your maintenance service is running
2934 * to prevent the device going to sleep.
2935 * </p>
2936 * <p>
2937 * <p class="note">This is a protected intent that can only be sent by
2938 * the system.
2939 * </p>
2940 *
2941 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002942 *
2943 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002944 */
2945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2946 public static final String ACTION_IDLE_MAINTENANCE_START =
2947 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2948
2949 /**
2950 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2951 * This means that the user was not interacting with the device as a result
2952 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2953 * was sent and now the user started interacting with the device. Typical
2954 * use of the idle maintenance is to perform somehow expensive tasks that
2955 * can be postponed at a moment when they will not degrade user experience.
2956 * <p>
2957 * <p class="note">In order to keep the device responsive in case of an
2958 * unexpected user interaction, implementations of a maintenance task
2959 * should be interruptible. Hence, on receiving a broadcast with this
2960 * action, the maintenance task should be interrupted as soon as possible.
2961 * In other words, you should not do the maintenance work in
2962 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2963 * maintenance service that was started on receiving of
2964 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2965 * lock you acquired when your maintenance service started.
2966 * </p>
2967 * <p class="note">This is a protected intent that can only be sent
2968 * by the system.
2969 *
2970 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002971 *
2972 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002973 */
2974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2975 public static final String ACTION_IDLE_MAINTENANCE_END =
2976 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2977
2978 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002979 * Broadcast Action: a remote intent is to be broadcasted.
2980 *
2981 * A remote intent is used for remote RPC between devices. The remote intent
2982 * is serialized and sent from one device to another device. The receiving
2983 * device parses the remote intent and broadcasts it. Note that anyone can
2984 * broadcast a remote intent. However, if the intent receiver of the remote intent
2985 * does not trust intent broadcasts from arbitrary intent senders, it should require
2986 * the sender to hold certain permissions so only trusted sender's broadcast will be
2987 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002988 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002989 */
2990 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002991 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002992
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002993 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002994 * Broadcast Action: This is broadcast once when the user is booting after a
2995 * system update. It can be used to perform cleanup or upgrades after a
2996 * system update.
2997 * <p>
2998 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2999 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3000 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3001 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003002 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003003 * @hide
3004 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003005 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003006 public static final String ACTION_PRE_BOOT_COMPLETED =
3007 "android.intent.action.PRE_BOOT_COMPLETED";
3008
Amith Yamasani13593602012-03-22 16:16:17 -07003009 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003010 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003011 * on restricted users. The broadcast intent contains an extra
3012 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3013 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3014 * String[] depending on the restriction type.<p/>
3015 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003016 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3017 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3018 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003019 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3020 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003021 * @see RestrictionEntry
3022 */
3023 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3024 "android.intent.action.GET_RESTRICTION_ENTRIES";
3025
3026 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003027 * Sent the first time a user is starting, to allow system apps to
3028 * perform one time initialization. (This will not be seen by third
3029 * party applications because a newly initialized user does not have any
3030 * third party applications installed for it.) This is sent early in
3031 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003032 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3033 * broadcast, since it is part of a visible user interaction; be as quick
3034 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003035 */
3036 public static final String ACTION_USER_INITIALIZE =
3037 "android.intent.action.USER_INITIALIZE";
3038
3039 /**
3040 * Sent when a user switch is happening, causing the process's user to be
3041 * brought to the foreground. This is only sent to receivers registered
3042 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3043 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003044 * foreground. This is sent as a foreground
3045 * broadcast, since it is part of a visible user interaction; be as quick
3046 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003047 */
3048 public static final String ACTION_USER_FOREGROUND =
3049 "android.intent.action.USER_FOREGROUND";
3050
3051 /**
3052 * Sent when a user switch is happening, causing the process's user to be
3053 * sent to the background. This is only sent to receivers registered
3054 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3055 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003056 * background. This is sent as a foreground
3057 * broadcast, since it is part of a visible user interaction; be as quick
3058 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003059 */
3060 public static final String ACTION_USER_BACKGROUND =
3061 "android.intent.action.USER_BACKGROUND";
3062
3063 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003064 * Broadcast sent to the system when a user is added. Carries an extra
3065 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3066 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003067 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003068 * @hide
3069 */
3070 public static final String ACTION_USER_ADDED =
3071 "android.intent.action.USER_ADDED";
3072
3073 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003074 * Broadcast sent by the system when a user is started. Carries an extra
3075 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003076 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003077 * that has been started. This is sent as a foreground
3078 * broadcast, since it is part of a visible user interaction; be as quick
3079 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003080 * @hide
3081 */
3082 public static final String ACTION_USER_STARTED =
3083 "android.intent.action.USER_STARTED";
3084
3085 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003086 * Broadcast sent when a user is in the process of starting. Carries an extra
3087 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3088 * sent to registered receivers, not manifest receivers. It is sent to all
3089 * users (including the one that is being started). You must hold
3090 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3091 * this broadcast. This is sent as a background broadcast, since
3092 * its result is not part of the primary UX flow; to safely keep track of
3093 * started/stopped state of a user you can use this in conjunction with
3094 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3095 * other user state broadcasts since those are foreground broadcasts so can
3096 * execute in a different order.
3097 * @hide
3098 */
3099 public static final String ACTION_USER_STARTING =
3100 "android.intent.action.USER_STARTING";
3101
3102 /**
3103 * Broadcast sent when a user is going to be stopped. Carries an extra
3104 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3105 * sent to registered receivers, not manifest receivers. It is sent to all
3106 * users (including the one that is being stopped). You must hold
3107 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3108 * this broadcast. The user will not stop until all receivers have
3109 * handled the broadcast. This is sent as a background broadcast, since
3110 * its result is not part of the primary UX flow; to safely keep track of
3111 * started/stopped state of a user you can use this in conjunction with
3112 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3113 * other user state broadcasts since those are foreground broadcasts so can
3114 * execute in a different order.
3115 * @hide
3116 */
3117 public static final String ACTION_USER_STOPPING =
3118 "android.intent.action.USER_STOPPING";
3119
3120 /**
3121 * Broadcast sent to the system when a user is stopped. Carries an extra
3122 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3123 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3124 * specific package. This is only sent to registered receivers, not manifest
3125 * receivers. It is sent to all running users <em>except</em> the one that
3126 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003127 * @hide
3128 */
3129 public static final String ACTION_USER_STOPPED =
3130 "android.intent.action.USER_STOPPED";
3131
3132 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003133 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003134 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003135 * one that has been removed. The user will not be completely removed until all receivers have
3136 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003137 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003138 * @hide
3139 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003140 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003141 public static final String ACTION_USER_REMOVED =
3142 "android.intent.action.USER_REMOVED";
3143
3144 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003145 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003146 * the userHandle of the user to become the current one. This is only sent to
3147 * registered receivers, not manifest receivers. It is sent to all running users.
3148 * You must hold
3149 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003150 * @hide
3151 */
3152 public static final String ACTION_USER_SWITCHED =
3153 "android.intent.action.USER_SWITCHED";
3154
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003155 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003156 * Broadcast Action: Sent when the credential-encrypted private storage has
3157 * become unlocked for the target user. This is only sent to registered
3158 * receivers, not manifest receivers.
3159 */
3160 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3161 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3162
3163 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003164 * Broadcast sent to the system when a user's information changes. Carries an extra
3165 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003166 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003167 * @hide
3168 */
3169 public static final String ACTION_USER_INFO_CHANGED =
3170 "android.intent.action.USER_INFO_CHANGED";
3171
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003172 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003173 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3174 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003175 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3176 * that need to display merged content across both primary and managed profiles need to
3177 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003178 * not manifest receivers.
3179 */
3180 public static final String ACTION_MANAGED_PROFILE_ADDED =
3181 "android.intent.action.MANAGED_PROFILE_ADDED";
3182
3183 /**
3184 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003185 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3186 * Only applications (for example Launchers) that need to display merged content across both
3187 * primary and managed profiles need to worry about this broadcast. This is only sent to
3188 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003189 */
3190 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3191 "android.intent.action.MANAGED_PROFILE_REMOVED";
3192
3193 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003194 * Broadcast sent to the primary user when the credential-encrypted private storage for
3195 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3196 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3197 * Launchers) that need to display merged content across both primary and managed profiles
3198 * need to worry about this broadcast. This is only sent to registered receivers,
3199 * not manifest receivers.
3200 */
3201 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3202 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3203
3204 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003205 * Broadcast sent to the primary user when an associated managed profile has become available.
3206 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003207 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3208 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3209 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003210 */
Rubin Xue95057a2016-04-01 16:49:25 +01003211 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3212 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3213
3214 /**
3215 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3216 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3217 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3218 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3219 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3220 */
3221 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3222 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003223
3224 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003225 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3226 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3227 * the device was locked or unlocked.
3228 *
3229 * This is only sent to registered receivers.
3230 *
3231 * @hide
3232 */
3233 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3234 "android.intent.action.DEVICE_LOCKED_CHANGED";
3235
3236 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003237 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3238 */
3239 public static final String ACTION_QUICK_CLOCK =
3240 "android.intent.action.QUICK_CLOCK";
3241
Michael Wright0087a142013-02-05 16:29:39 -08003242 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003243 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003244 * @hide
3245 */
3246 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003247 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003248
Justin Kohd378ad72013-04-01 12:18:26 -07003249 /**
3250 * Broadcast Action: A global button was pressed. Includes a single
3251 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3252 * caused the broadcast.
3253 * @hide
3254 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003255 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003256 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3257
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003258 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003259 * Broadcast Action: Sent when media resource is granted.
3260 * <p>
3261 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3262 * granted.
3263 * </p>
3264 * <p class="note">
3265 * This is a protected intent that can only be sent by the system.
3266 * </p>
3267 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003268 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003269 * </p>
3270 *
3271 * @hide
3272 */
3273 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3274 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3275
3276 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003277 * Broadcast Action: An overlay package has changed. The data contains the
3278 * name of the overlay package which has changed. This is broadcast on all
3279 * changes to the OverlayInfo returned by {@link
3280 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3281 * most common change is a state change that will change whether the
3282 * overlay is enabled or not.
3283 * @hide
3284 */
3285 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3286
3287 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003288 * Activity Action: Allow the user to select and return one or more existing
3289 * documents. When invoked, the system will display the various
3290 * {@link DocumentsProvider} instances installed on the device, letting the
3291 * user interactively navigate through them. These documents include local
3292 * media, such as photos and video, and documents provided by installed
3293 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003294 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003295 * Each document is represented as a {@code content://} URI backed by a
3296 * {@link DocumentsProvider}, which can be opened as a stream with
3297 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3298 * {@link android.provider.DocumentsContract.Document} metadata.
3299 * <p>
3300 * All selected documents are returned to the calling application with
3301 * persistable read and write permission grants. If you want to maintain
3302 * access to the documents across device reboots, you need to explicitly
3303 * take the persistable permissions using
3304 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3305 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003306 * Callers must indicate the acceptable document MIME types through
3307 * {@link #setType(String)}. For example, to select photos, use
3308 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3309 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3310 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003311 * <p>
3312 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003313 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3314 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003315 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003316 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3317 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003318 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003319 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003320 * Callers can set a document URI through
3321 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3322 * location of documents navigator. System will do its best to launch the
3323 * navigator in the specified document if it's a folder, or the folder that
3324 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003325 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003326 * Output: The URI of the item that was picked, returned in
3327 * {@link #getData()}. This must be a {@code content://} URI so that any
3328 * receiver can access it. If multiple documents were selected, they are
3329 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003330 *
3331 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003332 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003333 * @see #ACTION_CREATE_DOCUMENT
3334 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003335 */
3336 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3337 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3338
3339 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003340 * Activity Action: Allow the user to create a new document. When invoked,
3341 * the system will display the various {@link DocumentsProvider} instances
3342 * installed on the device, letting the user navigate through them. The
3343 * returned document may be a newly created document with no content, or it
3344 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003345 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003346 * Each document is represented as a {@code content://} URI backed by a
3347 * {@link DocumentsProvider}, which can be opened as a stream with
3348 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3349 * {@link android.provider.DocumentsContract.Document} metadata.
3350 * <p>
3351 * Callers must indicate the concrete MIME type of the document being
3352 * created by setting {@link #setType(String)}. This MIME type cannot be
3353 * changed after the document is created.
3354 * <p>
3355 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3356 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003357 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003358 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3359 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003360 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003361 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003362 * Callers can set a document URI through
3363 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3364 * location of documents navigator. System will do its best to launch the
3365 * navigator in the specified document if it's a folder, or the folder that
3366 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003367 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003368 * Output: The URI of the item that was created. This must be a
3369 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003370 *
3371 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003372 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003373 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003374 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003375 */
3376 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3377 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3378
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003379 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003380 * Activity Action: Allow the user to pick a directory subtree. When
3381 * invoked, the system will display the various {@link DocumentsProvider}
3382 * instances installed on the device, letting the user navigate through
3383 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003384 * <p>
3385 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003386 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3387 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3388 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003389 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003390 * Callers can set a document URI through
3391 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3392 * location of documents navigator. System will do its best to launch the
3393 * navigator in the specified document if it's a folder, or the folder that
3394 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003395 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003396 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003397 *
3398 * @see DocumentsContract
3399 */
3400 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003401 public static final String
3402 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003403
Felipe Lemec7b1f892016-01-15 15:02:31 -08003404 /**
Peng Xua35b5532016-01-20 00:05:45 -08003405 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3406 * exisiting sensor being disconnected.
3407 *
3408 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3409 *
3410 * {@hide}
3411 */
3412 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3413 public static final String
3414 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3415
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003416 /**
Sam Line707f832017-04-13 17:00:55 -07003417 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003418 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003419 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003420 */
3421 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003422 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003423 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3424
Christopher Tate6597e342015-02-17 12:15:25 -08003425 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003426 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3427 * is about to be performed.
3428 * @hide
3429 */
3430 @SystemApi
3431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3432 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3433 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3434
3435 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003436 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3437 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3438 *
3439 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3440 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003441 * @hide
3442 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003443 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003444 public static final String EXTRA_FORCE_MASTER_CLEAR =
3445 "android.intent.extra.FORCE_MASTER_CLEAR";
3446
3447 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003448 * A broadcast action to trigger a factory reset.
3449 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003450 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3451 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003452 *
3453 * <p>Not for use by third-party applications.
3454 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003455 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003456 *
3457 * {@hide}
3458 */
3459 @SystemApi
3460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3461 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3462
3463 /**
3464 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3465 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3466 *
3467 * <p>Not for use by third-party applications.
3468 *
3469 * @hide
3470 */
3471 @SystemApi
3472 public static final String EXTRA_FORCE_FACTORY_RESET =
3473 "android.intent.extra.FORCE_FACTORY_RESET";
3474
3475 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003476 * Broadcast action: report that a settings element is being restored from backup. The intent
3477 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3478 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3479 * is the value of that settings entry prior to the restore operation, and
3480 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3481 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3482 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003483 *
3484 * <p>This broadcast is sent only for settings provider entries known to require special handling
3485 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3486 * the provider's backup agent implementation.
3487 *
3488 * @see #EXTRA_SETTING_NAME
3489 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3490 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003491 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003492 * {@hide}
3493 */
3494 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3495
3496 /** {@hide} */
3497 public static final String EXTRA_SETTING_NAME = "setting_name";
3498 /** {@hide} */
3499 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3500 /** {@hide} */
3501 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003502 /** {@hide} */
3503 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003504
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003505 /**
3506 * Activity Action: Process a piece of text.
3507 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3508 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3509 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3510 */
3511 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3512 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003513
3514 /**
3515 * Broadcast Action: The sim card state has changed.
3516 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3517 * because TelephonyIntents is an internal class.
3518 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003519 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3520 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003521 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003522 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003523 @SystemApi
3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3525 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3526
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003527 /**
fionaxu90fee272017-03-31 12:45:12 -07003528 * Broadcast Action: indicate that the phone service state has changed.
3529 * The intent will have the following extra values:</p>
3530 * <p>
3531 * @see #EXTRA_VOICE_REG_STATE
3532 * @see #EXTRA_DATA_REG_STATE
3533 * @see #EXTRA_VOICE_ROAMING_TYPE
3534 * @see #EXTRA_DATA_ROAMING_TYPE
3535 * @see #EXTRA_OPERATOR_ALPHA_LONG
3536 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3537 * @see #EXTRA_OPERATOR_NUMERIC
3538 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3539 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3540 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3541 * @see #EXTRA_MANUAL
3542 * @see #EXTRA_VOICE_RADIO_TECH
3543 * @see #EXTRA_DATA_RADIO_TECH
3544 * @see #EXTRA_CSS_INDICATOR
3545 * @see #EXTRA_NETWORK_ID
3546 * @see #EXTRA_SYSTEM_ID
3547 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3548 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3549 * @see #EXTRA_EMERGENCY_ONLY
3550 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3551 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3552 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3553 *
3554 * <p class="note">
3555 * Requires the READ_PHONE_STATE permission.
3556 *
3557 * <p class="note">This is a protected intent that can only be sent by the system.
3558 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003559 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003560 */
3561 @Deprecated
3562 @SystemApi
3563 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3564 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3565
3566 /**
3567 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3568 * state.
3569 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3570 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3571 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3572 * @see android.telephony.ServiceState#STATE_POWER_OFF
3573 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003574 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003575 */
3576 @Deprecated
3577 @SystemApi
3578 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3579
3580 /**
3581 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3582 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3583 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3584 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3585 * @see android.telephony.ServiceState#STATE_POWER_OFF
3586 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003587 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003588 */
3589 @Deprecated
3590 @SystemApi
3591 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3592
3593 /**
3594 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3595 * type.
3596 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003597 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003598 */
3599 @Deprecated
3600 @SystemApi
3601 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3602
3603 /**
3604 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3605 * type.
3606 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003607 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003608 */
3609 @Deprecated
3610 @SystemApi
3611 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3612
3613 /**
3614 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3615 * registered voice operator name in long alphanumeric format.
3616 * {@code null} if the operator name is not known or unregistered.
3617 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003618 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003619 */
3620 @Deprecated
3621 @SystemApi
3622 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3623
3624 /**
3625 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3626 * registered voice operator name in short alphanumeric format.
3627 * {@code null} if the operator name is not known or unregistered.
3628 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003629 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003630 */
3631 @Deprecated
3632 @SystemApi
3633 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3634
3635 /**
3636 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3637 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3638 * network.
3639 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003640 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003641 */
3642 @Deprecated
3643 @SystemApi
3644 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3645
3646 /**
3647 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3648 * registered data operator name in long alphanumeric format.
3649 * {@code null} if the operator name is not known or unregistered.
3650 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003651 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003652 */
3653 @Deprecated
3654 @SystemApi
3655 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3656
3657 /**
3658 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3659 * registered data operator name in short alphanumeric format.
3660 * {@code null} if the operator name is not known or unregistered.
3661 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003662 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003663 */
3664 @Deprecated
3665 @SystemApi
3666 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3667
3668 /**
3669 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3670 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3671 * data operator.
3672 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003673 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003674 */
3675 @Deprecated
3676 @SystemApi
3677 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3678
3679 /**
3680 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3681 * network selection mode is manual.
3682 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3683 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003684 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003685 */
3686 @Deprecated
3687 @SystemApi
3688 public static final String EXTRA_MANUAL = "manual";
3689
3690 /**
3691 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3692 * radio technology.
3693 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003694 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003695 */
3696 @Deprecated
3697 @SystemApi
3698 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3699
3700 /**
3701 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3702 * radio technology.
3703 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003704 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003705 */
3706 @Deprecated
3707 @SystemApi
3708 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3709
3710 /**
3711 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3712 * support on CDMA network.
3713 * Will be {@code true} if support, {@code false} otherwise.
3714 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003715 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003716 */
3717 @Deprecated
3718 @SystemApi
3719 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3720
3721 /**
3722 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3723 * id. {@code Integer.MAX_VALUE} if unknown.
3724 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003725 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003726 */
3727 @Deprecated
3728 @SystemApi
3729 public static final String EXTRA_NETWORK_ID = "networkId";
3730
3731 /**
3732 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3733 * {@code Integer.MAX_VALUE} if unknown.
3734 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003735 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003736 */
3737 @Deprecated
3738 @SystemApi
3739 public static final String EXTRA_SYSTEM_ID = "systemId";
3740
3741 /**
3742 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3743 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3744 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003745 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003746 */
3747 @Deprecated
3748 @SystemApi
3749 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3750
3751 /**
3752 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3753 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3754 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003755 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003756 */
3757 @Deprecated
3758 @SystemApi
3759 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3760
3761 /**
3762 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3763 * only mode.
3764 * {@code true} if in emergency only mode, {@code false} otherwise.
3765 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003766 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003767 */
3768 @Deprecated
3769 @SystemApi
3770 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3771
3772 /**
3773 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3774 * registration state is roaming.
3775 * {@code true} if registration indicates roaming, {@code false} otherwise
3776 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003777 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003778 */
3779 @Deprecated
3780 @SystemApi
3781 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3782 "isDataRoamingFromRegistration";
3783
3784 /**
3785 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3786 * aggregation is in use.
3787 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3788 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003789 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003790 */
3791 @Deprecated
3792 @SystemApi
3793 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3794
3795 /**
3796 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3797 * is reduced from the rsrp threshold while calculating signal strength level.
3798 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003799 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003800 */
3801 @Deprecated
3802 @SystemApi
3803 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3804
3805 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003806 * The name of the extra used to define the text to be processed, as a
3807 * CharSequence. Note that this may be a styled CharSequence, so you must use
3808 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003809 */
3810 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3811 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003812 * 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 +00003813 */
3814 public static final String EXTRA_PROCESS_TEXT_READONLY =
3815 "android.intent.extra.PROCESS_TEXT_READONLY";
3816
Bryce Leebc58f592015-09-25 16:43:01 -07003817 /**
3818 * Broadcast action: reports when a new thermal event has been reached. When the device
3819 * is reaching its maximum temperatue, the thermal level reported
3820 * {@hide}
3821 */
3822 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3823 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3824
3825 /** {@hide} */
3826 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3827
3828 /**
3829 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003830 * {@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_NORMAL = 0;
3834
3835 /**
3836 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003837 * the {@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_WARNING = 1;
3841
3842 /**
3843 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003844 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003845 * {@hide}
3846 */
3847 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3848
3849
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003850 // ---------------------------------------------------------------------
3851 // ---------------------------------------------------------------------
3852 // Standard intent categories (see addCategory()).
3853
3854 /**
3855 * Set if the activity should be an option for the default action
3856 * (center press) to perform on a piece of data. Setting this will
3857 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003858 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003859 * Intent when initiating an action -- it is for use in intent filters
3860 * specified in packages.
3861 */
3862 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3863 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3864 /**
3865 * Activities that can be safely invoked from a browser must support this
3866 * category. For example, if the user is viewing a web page or an e-mail
3867 * and clicks on a link in the text, the Intent generated execute that
3868 * link will require the BROWSABLE category, so that only activities
3869 * supporting this category will be considered as possible actions. By
3870 * supporting this category, you are promising that there is nothing
3871 * damaging (without user intervention) that can happen by invoking any
3872 * matching Intent.
3873 */
3874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3875 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3876 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003877 * Categories for activities that can participate in voice interaction.
3878 * An activity that supports this category must be prepared to run with
3879 * no UI shown at all (though in some case it may have a UI shown), and
3880 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3881 */
3882 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3883 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3884 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003885 * Set if the activity should be considered as an alternative action to
3886 * the data the user is currently viewing. See also
3887 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3888 * applies to the selection in a list of items.
3889 *
3890 * <p>Supporting this category means that you would like your activity to be
3891 * displayed in the set of alternative things the user can do, usually as
3892 * part of the current activity's options menu. You will usually want to
3893 * include a specific label in the &lt;intent-filter&gt; of this action
3894 * describing to the user what it does.
3895 *
3896 * <p>The action of IntentFilter with this category is important in that it
3897 * describes the specific action the target will perform. This generally
3898 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3899 * a specific name such as "com.android.camera.action.CROP. Only one
3900 * alternative of any particular action will be shown to the user, so using
3901 * a specific action like this makes sure that your alternative will be
3902 * displayed while also allowing other applications to provide their own
3903 * overrides of that particular action.
3904 */
3905 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3906 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3907 /**
3908 * Set if the activity should be considered as an alternative selection
3909 * action to the data the user has currently selected. This is like
3910 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3911 * of items from which the user can select, giving them alternatives to the
3912 * default action that will be performed on it.
3913 */
3914 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3915 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3916 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003917 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003918 */
3919 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3920 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3921 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003922 * Should be displayed in the top-level launcher.
3923 */
3924 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3925 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3926 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003927 * Indicates an activity optimized for Leanback mode, and that should
3928 * be displayed in the Leanback launcher.
3929 */
3930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3931 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3932 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08003933 * Indicates the preferred entry-point activity when an application is launched from a Car
3934 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
3935 * fallback, or exclude the application entirely.
3936 * @hide
3937 */
3938 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3939 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
3940 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003941 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3942 * @hide
3943 */
3944 @SystemApi
3945 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3946 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003947 * Provides information about the package it is in; typically used if
3948 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3949 * a front-door to the user without having to be shown in the all apps list.
3950 */
3951 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3952 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3953 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003954 * This is the home activity, that is the first activity that is displayed
3955 * when the device boots.
3956 */
3957 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3958 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3959 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003960 * This is the home activity that is displayed when the device is finished setting up and ready
3961 * for use.
3962 * @hide
3963 */
3964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3965 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3966 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003967 * This is the setup wizard activity, that is the first activity that is displayed
3968 * when the user sets up the device for the first time.
3969 * @hide
3970 */
3971 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3972 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3973 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07003974 * This is the home activity, that is the activity that serves as the launcher app
3975 * from there the user can start other apps. Often components with lower/higher
3976 * priority intent filters handle the home intent, for example SetupWizard, to
3977 * setup the device and we need to be able to distinguish the home app from these
3978 * setup helpers.
3979 * @hide
3980 */
3981 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3982 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
3983 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003984 * This activity is a preference panel.
3985 */
3986 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3987 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3988 /**
3989 * This activity is a development preference panel.
3990 */
3991 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3992 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3993 /**
3994 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003995 */
3996 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3997 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3998 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003999 * This activity allows the user to browse and download new applications.
4000 */
4001 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4002 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4003 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004004 * This activity may be exercised by the monkey or other automated test tools.
4005 */
4006 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4007 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4008 /**
4009 * To be used as a test (not part of the normal user experience).
4010 */
4011 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4012 /**
4013 * To be used as a unit test (run through the Test Harness).
4014 */
4015 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4016 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004017 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004018 * experience).
4019 */
4020 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004021
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004022 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004023 * Used to indicate that an intent only wants URIs that can be opened with
4024 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4025 * must support at least the columns defined in {@link OpenableColumns} when
4026 * queried.
4027 *
4028 * @see #ACTION_GET_CONTENT
4029 * @see #ACTION_OPEN_DOCUMENT
4030 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004031 */
4032 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4033 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4034
4035 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004036 * Used to indicate that an intent filter can accept files which are not necessarily
4037 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4038 * at least streamable via
4039 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4040 * using one of the stream types exposed via
4041 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4042 *
4043 * @see #ACTION_SEND
4044 * @see #ACTION_SEND_MULTIPLE
4045 */
4046 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4047 public static final String CATEGORY_TYPED_OPENABLE =
4048 "android.intent.category.TYPED_OPENABLE";
4049
4050 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004051 * To be used as code under test for framework instrumentation tests.
4052 */
4053 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4054 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004055 /**
4056 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004057 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4058 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004059 */
4060 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4061 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4062 /**
4063 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004064 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4065 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004066 */
4067 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4068 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004069 /**
4070 * An activity to run when device is inserted into a analog (low end) dock.
4071 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4072 * information, see {@link android.app.UiModeManager}.
4073 */
4074 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4075 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4076
4077 /**
4078 * An activity to run when device is inserted into a digital (high end) dock.
4079 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4080 * information, see {@link android.app.UiModeManager}.
4081 */
4082 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4083 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004084
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004085 /**
4086 * Used to indicate that the activity can be used in a car environment.
4087 */
4088 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4089 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4090
Zak Cohendb6ca492017-01-26 14:09:00 -08004091 /**
4092 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4093 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4094 * information, see {@link android.app.UiModeManager}.
4095 */
4096 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4097 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004098 // ---------------------------------------------------------------------
4099 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004100 // Application launch intent categories (see addCategory()).
4101
4102 /**
4103 * Used with {@link #ACTION_MAIN} to launch the browser application.
4104 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004105 * <p>NOTE: This should not be used as the primary key of an Intent,
4106 * since it will not result in the app launching with the correct
4107 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004108 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004109 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004110 */
4111 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4112 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4113
4114 /**
4115 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4116 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004117 * <p>NOTE: This should not be used as the primary key of an Intent,
4118 * since it will not result in the app launching with the correct
4119 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004120 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004121 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004122 */
4123 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4124 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4125
4126 /**
4127 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4128 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004129 * <p>NOTE: This should not be used as the primary key of an Intent,
4130 * since it will not result in the app launching with the correct
4131 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004132 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004133 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004134 */
4135 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4136 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4137
4138 /**
4139 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4140 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004141 * <p>NOTE: This should not be used as the primary key of an Intent,
4142 * since it will not result in the app launching with the correct
4143 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004144 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004145 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004146 */
4147 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4148 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4149
4150 /**
4151 * Used with {@link #ACTION_MAIN} to launch the email application.
4152 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004153 * <p>NOTE: This should not be used as the primary key of an Intent,
4154 * since it will not result in the app launching with the correct
4155 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004156 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004157 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004158 */
4159 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4160 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4161
4162 /**
4163 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4164 * The activity should be able to view and manipulate image and video files
4165 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004166 * <p>NOTE: This should not be used as the primary key of an Intent,
4167 * since it will not result in the app launching with the correct
4168 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004169 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004170 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004171 */
4172 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4173 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4174
4175 /**
4176 * Used with {@link #ACTION_MAIN} to launch the maps application.
4177 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004178 * <p>NOTE: This should not be used as the primary key of an Intent,
4179 * since it will not result in the app launching with the correct
4180 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004181 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004182 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004183 */
4184 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4185 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4186
4187 /**
4188 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4189 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004190 * <p>NOTE: This should not be used as the primary key of an Intent,
4191 * since it will not result in the app launching with the correct
4192 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004193 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004194 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004195 */
4196 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4197 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4198
4199 /**
4200 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004201 * The activity should be able to play, browse, or manipulate music files
4202 * stored on the device.
4203 * <p>NOTE: This should not be used as the primary key of an Intent,
4204 * since it will not result in the app launching with the correct
4205 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004206 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004207 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004208 */
4209 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4210 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4211
4212 // ---------------------------------------------------------------------
4213 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004214 // Standard extra data keys.
4215
4216 /**
4217 * The initial data to place in a newly created record. Use with
4218 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4219 * fields as would be given to the underlying ContentProvider.insert()
4220 * call.
4221 */
4222 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4223
4224 /**
4225 * A constant CharSequence that is associated with the Intent, used with
4226 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4227 * this may be a styled CharSequence, so you must use
4228 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4229 * retrieve it.
4230 */
4231 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4232
4233 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004234 * A constant String that is associated with the Intent, used with
4235 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4236 * as HTML formatted text. Note that you <em>must</em> also supply
4237 * {@link #EXTRA_TEXT}.
4238 */
4239 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4240
4241 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004242 * A content: URI holding a stream of data associated with the Intent,
4243 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004244 */
4245 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4246
4247 /**
4248 * A String[] holding e-mail addresses that should be delivered to.
4249 */
4250 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4251
4252 /**
4253 * A String[] holding e-mail addresses that should be carbon copied.
4254 */
4255 public static final String EXTRA_CC = "android.intent.extra.CC";
4256
4257 /**
4258 * A String[] holding e-mail addresses that should be blind carbon copied.
4259 */
4260 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4261
4262 /**
4263 * A constant string holding the desired subject line of a message.
4264 */
4265 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4266
4267 /**
4268 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004269 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004270 */
4271 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4272
4273 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004274 * An int representing the user id to be used.
4275 *
4276 * @hide
4277 */
4278 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4279
4280 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004281 * An int representing the task id to be retrieved. This is used when a launch from recents is
4282 * intercepted by another action such as credentials confirmation to remember which task should
4283 * be resumed when complete.
4284 *
4285 * @hide
4286 */
4287 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4288
4289 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004290 * An Intent[] describing additional, alternate choices you would like shown with
4291 * {@link #ACTION_CHOOSER}.
4292 *
4293 * <p>An app may be capable of providing several different payload types to complete a
4294 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4295 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4296 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4297 * photo data or a hosted link where the photos can be viewed.</p>
4298 *
4299 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4300 * first/primary/preferred intent in the set. Additional intents specified in
4301 * this extra are ordered; by default intents that appear earlier in the array will be
4302 * preferred over intents that appear later in the array as matches for the same
4303 * target component. To alter this preference, a calling app may also supply
4304 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4305 */
4306 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4307
4308 /**
Adam Powell52c39212016-04-07 15:14:18 -07004309 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4310 * and omitted from a list of components presented to the user.
4311 *
4312 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4313 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4314 * from your own package or other apps from your organization if the idea of sending to those
4315 * targets would be redundant with other app functionality. Filtered components will not
4316 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4317 */
4318 public static final String EXTRA_EXCLUDE_COMPONENTS
4319 = "android.intent.extra.EXCLUDE_COMPONENTS";
4320
4321 /**
4322 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4323 * describing additional high-priority deep-link targets for the chooser to present to the user.
4324 *
4325 * <p>Targets provided in this way will be presented inline with all other targets provided
4326 * by services from other apps. They will be prioritized before other service targets, but
4327 * after those targets provided by sources that the user has manually pinned to the front.</p>
4328 *
4329 * @see #ACTION_CHOOSER
4330 */
4331 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4332
4333 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004334 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4335 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4336 *
4337 * <p>An app preparing an action for another app to complete may wish to allow the user to
4338 * disambiguate between several options for completing the action based on the chosen target
4339 * or otherwise refine the action before it is invoked.
4340 * </p>
4341 *
4342 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4343 * <ul>
4344 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4345 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4346 * chosen target beyond the first</li>
4347 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4348 * should fill in and send once the disambiguation is complete</li>
4349 * </ul>
4350 */
4351 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4352 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4353
4354 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004355 * An {@code ArrayList} of {@code String} annotations describing content for
4356 * {@link #ACTION_CHOOSER}.
4357 *
4358 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4359 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4360 *
4361 * <p>Annotations should describe the major components or topics of the content. It is up to
4362 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4363 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004364 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4365 * character. Performance on customized annotations can suffer, if they are rarely used for
4366 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4367 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004368 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004369 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004370 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004371 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004372 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004373 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004374 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004375 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004376 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004377 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4378 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4379 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4380 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4381 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004382 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004383 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4384 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004385 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004386 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004387 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004388 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004389 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004390 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004391 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004392 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004393 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004394 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004395 * Christmas and Thanksgiving.</li>
4396 * </ul>
4397 */
4398 public static final String EXTRA_CONTENT_ANNOTATIONS
4399 = "android.intent.extra.CONTENT_ANNOTATIONS";
4400
4401 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004402 * A {@link ResultReceiver} used to return data back to the sender.
4403 *
4404 * <p>Used to complete an app-specific
4405 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4406 *
4407 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4408 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4409 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4410 * when the user selects a target component from the chooser. It is up to the recipient
4411 * to send a result to this ResultReceiver to signal that disambiguation is complete
4412 * and that the chooser should invoke the user's choice.</p>
4413 *
4414 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4415 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4416 * to match and fill in the final Intent or ChooserTarget before starting it.
4417 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4418 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4419 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4420 *
4421 * <p>The result code passed to the ResultReceiver should be
4422 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4423 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4424 * the chooser should finish without starting a target.</p>
4425 */
4426 public static final String EXTRA_RESULT_RECEIVER
4427 = "android.intent.extra.RESULT_RECEIVER";
4428
4429 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004430 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004431 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004432 */
4433 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4434
4435 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004436 * A Parcelable[] of {@link Intent} or
4437 * {@link android.content.pm.LabeledIntent} objects as set with
4438 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4439 * a the front of the list of choices, when shown to the user with a
4440 * {@link #ACTION_CHOOSER}.
4441 */
4442 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4443
4444 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004445 * A {@link IntentSender} to start after ephemeral installation success.
4446 * @hide
4447 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004448 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4449
4450 /**
4451 * A {@link IntentSender} to start after ephemeral installation failure.
4452 * @hide
4453 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004454 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4455
4456 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004457 * The host name that triggered an ephemeral resolution.
4458 * @hide
4459 */
4460 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4461
4462 /**
4463 * An opaque token to track ephemeral resolution.
4464 * @hide
4465 */
4466 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4467
4468 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004469 * The action that triggered an instant application resolution.
4470 * @hide
4471 */
4472 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4473
4474 /**
Patrick Baumann709ee152017-12-04 16:12:52 -08004475 * A {@link Bundle} of metadata that describes the instanta application that needs to be
4476 * installed. This data is populated from the response to
4477 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4478 * instant application resolver.
4479 * @hide
4480 */
4481 public static final String EXTRA_INSTANT_APP_EXTRAS =
4482 "android.intent.extra.INSTANT_APP_EXTRAS";
4483
4484 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004485 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004486 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004487 * @hide
4488 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004489 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004490 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4491
4492 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004493 * The version code of the app to install components from.
4494 * @hide
4495 */
4496 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4497
4498 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004499 * The app that triggered the ephemeral installation.
4500 * @hide
4501 */
4502 public static final String EXTRA_CALLING_PACKAGE
4503 = "android.intent.extra.CALLING_PACKAGE";
4504
4505 /**
4506 * Optional calling app provided bundle containing additional launch information the
4507 * installer may use.
4508 * @hide
4509 */
4510 public static final String EXTRA_VERIFICATION_BUNDLE
4511 = "android.intent.extra.VERIFICATION_BUNDLE";
4512
4513 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004514 * A Bundle forming a mapping of potential target package names to different extras Bundles
4515 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4516 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4517 * be currently installed on the device.
4518 *
4519 * <p>An application may choose to provide alternate extras for the case where a user
4520 * selects an activity from a predetermined set of target packages. If the activity
4521 * the user selects from the chooser belongs to a package with its package name as
4522 * a key in this bundle, the corresponding extras for that package will be merged with
4523 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4524 * extra has the same key as an extra already present in the intent it will overwrite
4525 * the extra from the intent.</p>
4526 *
4527 * <p><em>Examples:</em>
4528 * <ul>
4529 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4530 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4531 * parameters for that target.</li>
4532 * <li>An application may offer additional metadata for known targets of a given intent
4533 * to pass along information only relevant to that target such as account or content
4534 * identifiers already known to that application.</li>
4535 * </ul></p>
4536 */
4537 public static final String EXTRA_REPLACEMENT_EXTRAS =
4538 "android.intent.extra.REPLACEMENT_EXTRAS";
4539
4540 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004541 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4542 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4543 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4544 * {@link ComponentName} of the chosen component.
4545 *
4546 * <p>In some situations this callback may never come, for example if the user abandons
4547 * the chooser, switches to another task or any number of other reasons. Apps should not
4548 * be written assuming that this callback will always occur.</p>
4549 */
4550 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4551 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4552
4553 /**
4554 * The {@link ComponentName} chosen by the user to complete an action.
4555 *
4556 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4557 */
4558 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4559
4560 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004561 * A {@link android.view.KeyEvent} object containing the event that
4562 * triggered the creation of the Intent it is in.
4563 */
4564 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4565
4566 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004567 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4568 * before shutting down.
4569 *
4570 * {@hide}
4571 */
4572 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4573
4574 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004575 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4576 * requested by the user.
4577 *
4578 * {@hide}
4579 */
4580 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4581 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4582
4583 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004584 * 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 -07004585 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4586 * of restarting the application.
4587 */
4588 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4589
4590 /**
4591 * A String holding the phone number originally entered in
4592 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4593 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4594 */
4595 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004596
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004597 /**
4598 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4599 * intents to supply the uid the package had been assigned. Also an optional
4600 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4601 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4602 * purpose.
4603 */
4604 public static final String EXTRA_UID = "android.intent.extra.UID";
4605
4606 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004607 * @hide String array of package names.
4608 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004609 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004610 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4611
4612 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004613 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4614 * intents to indicate whether this represents a full uninstall (removing
4615 * both the code and its data) or a partial uninstall (leaving its data,
4616 * implying that this is an update).
4617 */
4618 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004619
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004620 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004621 * @hide
4622 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4623 * intents to indicate that at this point the package has been removed for
4624 * all users on the device.
4625 */
4626 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4627 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4628
4629 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004630 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4631 * intents to indicate that this is a replacement of the package, so this
4632 * broadcast will immediately be followed by an add broadcast for a
4633 * different version of the same package.
4634 */
4635 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004636
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004637 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004638 * Used as an int extra field in {@link android.app.AlarmManager} intents
4639 * to tell the application being invoked how many pending alarms are being
4640 * delievered with the intent. For one-shot alarms this will always be 1.
4641 * For recurring alarms, this might be greater than 1 if the device was
4642 * asleep or powered off at the time an earlier alarm would have been
4643 * delivered.
4644 */
4645 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004646
Jacek Surazski86b6c532009-05-13 14:38:28 +02004647 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004648 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4649 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004650 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4651 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004652 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4653 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4654 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004655 */
4656 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4657
4658 /**
4659 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4660 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004661 */
4662 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4663
4664 /**
4665 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4666 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004667 */
4668 public static final int EXTRA_DOCK_STATE_DESK = 1;
4669
4670 /**
4671 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4672 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004673 */
4674 public static final int EXTRA_DOCK_STATE_CAR = 2;
4675
4676 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004677 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4678 * to represent that the phone is in a analog (low end) dock.
4679 */
4680 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4681
4682 /**
4683 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4684 * to represent that the phone is in a digital (high end) dock.
4685 */
4686 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4687
4688 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004689 * Boolean that can be supplied as meta-data with a dock activity, to
4690 * indicate that the dock should take over the home key when it is active.
4691 */
4692 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004693
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004694 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004695 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4696 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004697 */
4698 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4699
4700 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004701 * Used in the extra field in the remote intent. It's astring token passed with the
4702 * remote intent.
4703 */
4704 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4705 "android.intent.extra.remote_intent_token";
4706
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004707 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004708 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004709 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004710 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004711 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004712 "android.intent.extra.changed_component_name";
4713
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004714 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004715 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004716 * and contains a string array of all of the components that have changed. If
4717 * the state of the overall package has changed, then it will contain an entry
4718 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004719 */
4720 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4721 "android.intent.extra.changed_component_name_list";
4722
4723 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004724 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004725 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004726 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4727 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4728 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004729 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004730 */
4731 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4732 "android.intent.extra.changed_package_list";
4733
4734 /**
4735 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004736 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4737 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004738 * and contains an integer array of uids of all of the components
4739 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004740 */
4741 public static final String EXTRA_CHANGED_UID_LIST =
4742 "android.intent.extra.changed_uid_list";
4743
4744 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004745 * @hide
4746 * Magic extra system code can use when binding, to give a label for
4747 * who it is that has bound to a service. This is an integer giving
4748 * a framework string resource that can be displayed to the user.
4749 */
4750 public static final String EXTRA_CLIENT_LABEL =
4751 "android.intent.extra.client_label";
4752
4753 /**
4754 * @hide
4755 * Magic extra system code can use when binding, to give a PendingIntent object
4756 * that can be launched for the user to disable the system's use of this
4757 * service.
4758 */
4759 public static final String EXTRA_CLIENT_INTENT =
4760 "android.intent.extra.client_intent";
4761
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004762 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004763 * Extra used to indicate that an intent should only return data that is on
4764 * the local device. This is a boolean extra; the default is false. If true,
4765 * an implementation should only allow the user to select data that is
4766 * already on the device, not requiring it be downloaded from a remote
4767 * service when opened.
4768 *
4769 * @see #ACTION_GET_CONTENT
4770 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004771 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004772 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004773 */
4774 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004775 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004776
Amith Yamasani13593602012-03-22 16:16:17 -07004777 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004778 * Extra used to indicate that an intent can allow the user to select and
4779 * return multiple items. This is a boolean extra; the default is false. If
4780 * true, an implementation is allowed to present the user with a UI where
4781 * they can pick multiple items that are all returned to the caller. When
4782 * this happens, they should be returned as the {@link #getClipData()} part
4783 * of the result Intent.
4784 *
4785 * @see #ACTION_GET_CONTENT
4786 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004787 */
4788 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004789 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004790
4791 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004792 * The integer userHandle carried with broadcast intents related to addition, removal and
4793 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4794 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4795 *
Amith Yamasani13593602012-03-22 16:16:17 -07004796 * @hide
4797 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004798 public static final String EXTRA_USER_HANDLE =
4799 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004800
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004801 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004802 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4803 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4804 */
4805 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004806 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004807
4808 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004809 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004810 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4811 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004812 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004813 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4814
4815 /**
4816 * Extra sent in the intent to the BroadcastReceiver that handles
4817 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4818 * the restrictions as key/value pairs.
4819 */
4820 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4821 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004822
Amith Yamasani86118ba2013-03-28 14:33:16 -07004823 /**
4824 * Extra used in the response from a BroadcastReceiver that handles
4825 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4826 */
4827 public static final String EXTRA_RESTRICTIONS_INTENT =
4828 "android.intent.extra.restrictions_intent";
4829
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004830 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004831 * Extra used to communicate a set of acceptable MIME types. The type of the
4832 * extra is {@code String[]}. Values may be a combination of concrete MIME
4833 * types (such as "image/png") and/or partial MIME types (such as
4834 * "audio/*").
4835 *
4836 * @see #ACTION_GET_CONTENT
4837 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004838 */
4839 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4840
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004841 /**
4842 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4843 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004844 * When this is true, hardware devices can use this information to determine that
4845 * they shouldn't do a complete shutdown of their device since this is not a
4846 * complete shutdown down to the kernel, but only user space restarting.
4847 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004848 */
4849 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4850 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4851
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004852 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004853 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4854 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4855 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4856 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004857 *
4858 * @hide for internal use only.
4859 */
4860 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4861 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004862 /** @hide */
4863 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4864 /** @hide */
4865 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4866 /** @hide */
4867 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004868
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07004869 /**
4870 * Intent extra: the reason that the operation associated with this intent is being performed.
4871 *
4872 * <p>Type: String
4873 * @hide
4874 */
4875 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004876 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4877
qingxi240c2bb2017-04-12 17:31:18 -07004878 /**
4879 * {@hide}
4880 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4881 */
Rubin Xue8490f12015-06-25 12:17:48 +01004882 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4883
Santos Cordon15a13782015-03-31 18:32:31 -07004884 /**
qingxi240c2bb2017-04-12 17:31:18 -07004885 * {@hide}
4886 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4887 * reset for the device with eSIM. This extra will be sent together with
4888 * {@link #ACTION_FACTORY_RESET}
4889 */
4890 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4891
4892 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004893 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4894 * activation request.
4895 * TODO: Add information about the structure and response data used with the pending intent.
4896 * @hide
4897 */
4898 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4899 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4900
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004901 /**
4902 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004903 *
4904 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004905 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004906 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004907 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4908
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004909 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004910 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4911 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4912 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004913 *
4914 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004915 * @see #ACTION_QUICK_VIEW
4916 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004917 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004918 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004919 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4920 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004921
4922 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004923 * An optional extra of {@code String[]} indicating which quick view features should be made
4924 * available to the user in the quick view UI while handing a
4925 * {@link Intent#ACTION_QUICK_VIEW} intent.
4926 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4927 * Quick viewer can implement features not listed below.
4928 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05004929 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
4930 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
4931 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07004932 * <p>
4933 * Requirements:
4934 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4935 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4936 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4937 * internal policies.
4938 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4939 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4940 * disable or hide features.
4941 *
4942 * @see #ACTION_QUICK_VIEW
4943 */
4944 public static final String EXTRA_QUICK_VIEW_FEATURES =
4945 "android.intent.extra.QUICK_VIEW_FEATURES";
4946
4947 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004948 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004949 * When a profile goes into quiet mode, all apps in the profile are killed and the
4950 * profile user is stopped. Widgets originating from the profile are masked, and app
4951 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004952 */
4953 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004954
4955 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004956 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004957 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004958 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4959 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004960 *
4961 * @hide
4962 */
4963 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4964 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4965
4966 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004967 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4968 * whether to show the chooser or not when there is only one application available
4969 * to choose from.
4970 *
4971 * @hide
4972 */
4973 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4974 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4975
4976 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004977 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004978 * to represent that a video codec is allowed to use.
4979 *
4980 * @hide
4981 */
4982 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4983
4984 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004985 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004986 * to represent that a audio codec is allowed to use.
4987 *
4988 * @hide
4989 */
4990 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4991
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004992 // ---------------------------------------------------------------------
4993 // ---------------------------------------------------------------------
4994 // Intent flags (see mFlags variable).
4995
Tor Norbyed9273d62013-05-30 15:59:53 -07004996 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004997 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004998 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4999 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005000 @Retention(RetentionPolicy.SOURCE)
5001 public @interface GrantUriMode {}
5002
Jeff Sharkey846318a2014-04-04 12:12:41 -07005003 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005004 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005005 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5006 @Retention(RetentionPolicy.SOURCE)
5007 public @interface AccessUriMode {}
5008
5009 /**
5010 * Test if given mode flags specify an access mode, which must be at least
5011 * read and/or write.
5012 *
5013 * @hide
5014 */
5015 public static boolean isAccessUriMode(int modeFlags) {
5016 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5017 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5018 }
5019
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005020 /** @hide */
5021 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5022 FLAG_GRANT_READ_URI_PERMISSION,
5023 FLAG_GRANT_WRITE_URI_PERMISSION,
5024 FLAG_FROM_BACKGROUND,
5025 FLAG_DEBUG_LOG_RESOLUTION,
5026 FLAG_EXCLUDE_STOPPED_PACKAGES,
5027 FLAG_INCLUDE_STOPPED_PACKAGES,
5028 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5029 FLAG_GRANT_PREFIX_URI_PERMISSION,
5030 FLAG_DEBUG_TRIAGED_MISSING,
5031 FLAG_IGNORE_EPHEMERAL,
5032 FLAG_ACTIVITY_NO_HISTORY,
5033 FLAG_ACTIVITY_SINGLE_TOP,
5034 FLAG_ACTIVITY_NEW_TASK,
5035 FLAG_ACTIVITY_MULTIPLE_TASK,
5036 FLAG_ACTIVITY_CLEAR_TOP,
5037 FLAG_ACTIVITY_FORWARD_RESULT,
5038 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5039 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5040 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5041 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5042 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5043 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5044 FLAG_ACTIVITY_NEW_DOCUMENT,
5045 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5046 FLAG_ACTIVITY_NO_USER_ACTION,
5047 FLAG_ACTIVITY_REORDER_TO_FRONT,
5048 FLAG_ACTIVITY_NO_ANIMATION,
5049 FLAG_ACTIVITY_CLEAR_TASK,
5050 FLAG_ACTIVITY_TASK_ON_HOME,
5051 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5052 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5053 FLAG_RECEIVER_REGISTERED_ONLY,
5054 FLAG_RECEIVER_REPLACE_PENDING,
5055 FLAG_RECEIVER_FOREGROUND,
5056 FLAG_RECEIVER_NO_ABORT,
5057 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5058 FLAG_RECEIVER_BOOT_UPGRADE,
5059 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5060 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5061 FLAG_RECEIVER_FROM_SHELL,
5062 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5063 })
5064 @Retention(RetentionPolicy.SOURCE)
5065 public @interface Flags {}
5066
5067 /** @hide */
5068 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5069 FLAG_FROM_BACKGROUND,
5070 FLAG_DEBUG_LOG_RESOLUTION,
5071 FLAG_EXCLUDE_STOPPED_PACKAGES,
5072 FLAG_INCLUDE_STOPPED_PACKAGES,
5073 FLAG_DEBUG_TRIAGED_MISSING,
5074 FLAG_IGNORE_EPHEMERAL,
5075 FLAG_ACTIVITY_NO_HISTORY,
5076 FLAG_ACTIVITY_SINGLE_TOP,
5077 FLAG_ACTIVITY_NEW_TASK,
5078 FLAG_ACTIVITY_MULTIPLE_TASK,
5079 FLAG_ACTIVITY_CLEAR_TOP,
5080 FLAG_ACTIVITY_FORWARD_RESULT,
5081 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5082 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5083 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5084 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5085 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5086 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5087 FLAG_ACTIVITY_NEW_DOCUMENT,
5088 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5089 FLAG_ACTIVITY_NO_USER_ACTION,
5090 FLAG_ACTIVITY_REORDER_TO_FRONT,
5091 FLAG_ACTIVITY_NO_ANIMATION,
5092 FLAG_ACTIVITY_CLEAR_TASK,
5093 FLAG_ACTIVITY_TASK_ON_HOME,
5094 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5095 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5096 FLAG_RECEIVER_REGISTERED_ONLY,
5097 FLAG_RECEIVER_REPLACE_PENDING,
5098 FLAG_RECEIVER_FOREGROUND,
5099 FLAG_RECEIVER_NO_ABORT,
5100 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5101 FLAG_RECEIVER_BOOT_UPGRADE,
5102 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5103 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5104 FLAG_RECEIVER_FROM_SHELL,
5105 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5106 })
5107 @Retention(RetentionPolicy.SOURCE)
5108 public @interface MutableFlags {}
5109
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005110 /**
5111 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005112 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005113 * specified in its ClipData. When applying to an Intent's ClipData,
5114 * all URIs as well as recursive traversals through data or other ClipData
5115 * in Intent items will be granted; only the grant flags of the top-level
5116 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005117 */
5118 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5119 /**
5120 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005121 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005122 * specified in its ClipData. When applying to an Intent's ClipData,
5123 * all URIs as well as recursive traversals through data or other ClipData
5124 * in Intent items will be granted; only the grant flags of the top-level
5125 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005126 */
5127 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5128 /**
5129 * Can be set by the caller to indicate that this Intent is coming from
5130 * a background operation, not from direct user interaction.
5131 */
5132 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5133 /**
5134 * A flag you can enable for debugging: when set, log messages will be
5135 * printed during the resolution of this intent to show you what has
5136 * been found to create the final resolved list.
5137 */
5138 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005139 /**
5140 * If set, this intent will not match any components in packages that
5141 * are currently stopped. If this is not set, then the default behavior
5142 * is to include such applications in the result.
5143 */
5144 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5145 /**
5146 * If set, this intent will always match any components in packages that
5147 * are currently stopped. This is the default behavior when
5148 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5149 * flags are set, this one wins (it allows overriding of exclude for
5150 * places where the framework may automatically set the exclude flag).
5151 */
5152 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005153
5154 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005155 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005156 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005157 * persisted across device reboots until explicitly revoked with
5158 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5159 * grant for possible persisting; the receiving application must call
5160 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5161 * actually persist.
5162 *
5163 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5164 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5165 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005166 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005167 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005168 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005169
5170 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005171 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5172 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5173 * applies to any URI that is a prefix match against the original granted
5174 * URI. (Without this flag, the URI must match exactly for access to be
5175 * granted.) Another URI is considered a prefix match only when scheme,
5176 * authority, and all path segments defined by the prefix are an exact
5177 * match.
5178 */
5179 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5180
5181 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005182 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005183 * homework and verified that they correctly handle packages and components
5184 * that come and go over time. In particular:
5185 * <ul>
5186 * <li>Apps installed on external storage, which will appear to be
5187 * uninstalled while the the device is ejected.
5188 * <li>Apps with encryption unaware components, which will appear to not
5189 * exist while the device is locked.
5190 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005191 *
5192 * @hide
5193 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005194 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005195
5196 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005197 * Internal flag used to indicate ephemeral applications should not be
5198 * considered when resolving the intent.
5199 *
5200 * @hide
5201 */
5202 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5203
5204 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005205 * If set, the new activity is not kept in the history stack. As soon as
5206 * the user navigates away from it, the activity is finished. This may also
5207 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5208 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005209 *
5210 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5211 * is never invoked when the current activity starts a new activity which
5212 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005213 */
5214 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5215 /**
5216 * If set, the activity will not be launched if it is already running
5217 * at the top of the history stack.
5218 */
5219 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5220 /**
5221 * If set, this activity will become the start of a new task on this
5222 * history stack. A task (from the activity that started it to the
5223 * next task activity) defines an atomic group of activities that the
5224 * user can move to. Tasks can be moved to the foreground and background;
5225 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005226 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005227 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5228 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005229 *
5230 * <p>This flag is generally used by activities that want
5231 * to present a "launcher" style behavior: they give the user a list of
5232 * separate things that can be done, which otherwise run completely
5233 * independently of the activity launching them.
5234 *
5235 * <p>When using this flag, if a task is already running for the activity
5236 * you are now starting, then a new activity will not be started; instead,
5237 * the current task will simply be brought to the front of the screen with
5238 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5239 * to disable this behavior.
5240 *
5241 * <p>This flag can not be used when the caller is requesting a result from
5242 * the activity being launched.
5243 */
5244 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5245 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005246 * This flag is used to create a new task and launch an activity into it.
5247 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5248 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5249 * search through existing tasks for ones matching this Intent. Only if no such
5250 * task is found would a new task be created. When paired with
5251 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5252 * the search for a matching task and unconditionally start a new task.
5253 *
5254 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5255 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005256 * top-level application launcher.</strong> Used in conjunction with
5257 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5258 * behavior of bringing an existing task to the foreground. When set,
5259 * a new task is <em>always</em> started to host the Activity for the
5260 * Intent, regardless of whether there is already an existing task running
5261 * the same thing.
5262 *
5263 * <p><strong>Because the default system does not include graphical task management,
5264 * you should not use this flag unless you provide some way for a user to
5265 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005266 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005267 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5268 * creating new document tasks.
5269 *
5270 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005271 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005272 *
Scott Main7aee61f2011-02-08 11:25:01 -08005273 * <p>See
5274 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5275 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005276 *
5277 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5278 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005279 */
5280 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5281 /**
5282 * If set, and the activity being launched is already running in the
5283 * current task, then instead of launching a new instance of that activity,
5284 * all of the other activities on top of it will be closed and this Intent
5285 * will be delivered to the (now on top) old activity as a new Intent.
5286 *
5287 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5288 * If D calls startActivity() with an Intent that resolves to the component
5289 * of activity B, then C and D will be finished and B receive the given
5290 * Intent, resulting in the stack now being: A, B.
5291 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005292 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005293 * either receive the new intent you are starting here in its
5294 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005295 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005296 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5297 * the same intent, then it will be finished and re-created; for all other
5298 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5299 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005300 *
5301 * <p>This launch mode can also be used to good effect in conjunction with
5302 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5303 * of a task, it will bring any currently running instance of that task
5304 * to the foreground, and then clear it to its root state. This is
5305 * especially useful, for example, when launching an activity from the
5306 * notification manager.
5307 *
Scott Main7aee61f2011-02-08 11:25:01 -08005308 * <p>See
5309 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5310 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005311 */
5312 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5313 /**
5314 * If set and this intent is being used to launch a new activity from an
5315 * existing one, then the reply target of the existing activity will be
5316 * transfered to the new activity. This way the new activity can call
5317 * {@link android.app.Activity#setResult} and have that result sent back to
5318 * the reply target of the original activity.
5319 */
5320 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5321 /**
5322 * If set and this intent is being used to launch a new activity from an
5323 * existing one, the current activity will not be counted as the top
5324 * activity for deciding whether the new intent should be delivered to
5325 * the top instead of starting a new one. The previous activity will
5326 * be used as the top, with the assumption being that the current activity
5327 * will finish itself immediately.
5328 */
5329 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5330 /**
5331 * If set, the new activity is not kept in the list of recently launched
5332 * activities.
5333 */
5334 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5335 /**
5336 * This flag is not normally set by application code, but set for you by
5337 * the system as described in the
5338 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5339 * launchMode} documentation for the singleTask mode.
5340 */
5341 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5342 /**
5343 * If set, and this activity is either being started in a new task or
5344 * bringing to the top an existing task, then it will be launched as
5345 * the front door of the task. This will result in the application of
5346 * any affinities needed to have that task in the proper state (either
5347 * moving activities to or from it), or simply resetting that task to
5348 * its initial state if needed.
5349 */
5350 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5351 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005352 * This flag is not normally set by application code, but set for you by
5353 * the system if this activity is being launched from history
5354 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005355 */
5356 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005357 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005358 * @deprecated As of API 21 this performs identically to
5359 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005360 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005361 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005362 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005363 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005364 * This flag is used to open a document into a new task rooted at the activity launched
5365 * by this Intent. Through the use of this flag, or its equivalent attribute,
5366 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005367 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005368 *
Craig Mautner026596b2014-05-21 15:35:44 -07005369 * <p>The use of the activity attribute form of this,
5370 * {@link android.R.attr#documentLaunchMode}, is
5371 * preferred over the Intent flag described here. The attribute form allows the
5372 * Activity to specify multiple document behavior for all launchers of the Activity
5373 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005374 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005375 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5376 * it is kept after the activity is finished is different than the use of
5377 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5378 * this flag is being used to create a new recents entry, then by default that entry
5379 * will be removed once the activity is finished. You can modify this behavior with
5380 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5381 *
Craig Mautner026596b2014-05-21 15:35:44 -07005382 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5383 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5384 * equivalent of the Activity manifest specifying {@link
5385 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5386 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5387 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005388 *
Craig Mautner026596b2014-05-21 15:35:44 -07005389 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005390 *
Craig Mautner026596b2014-05-21 15:35:44 -07005391 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005392 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5393 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005394 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005395 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005396 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005397 * callback from occurring on the current frontmost activity before it is
5398 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005399 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005400 * <p>Typically, an activity can rely on that callback to indicate that an
5401 * explicit user action has caused their activity to be moved out of the
5402 * foreground. The callback marks an appropriate point in the activity's
5403 * lifecycle for it to dismiss any notifications that it intends to display
5404 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005405 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005406 * <p>If an activity is ever started via any non-user-driven events such as
5407 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5408 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005409 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005410 */
5411 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005412 /**
5413 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5414 * this flag will cause the launched activity to be brought to the front of its
5415 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005416 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005417 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5418 * If D calls startActivity() with an Intent that resolves to the component
5419 * of activity B, then B will be brought to the front of the history stack,
5420 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005421 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005422 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005423 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005424 */
5425 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005426 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005427 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5428 * this flag will prevent the system from applying an activity transition
5429 * animation to go to the next activity state. This doesn't mean an
5430 * animation will never run -- if another activity change happens that doesn't
5431 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005432 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005433 * when you are going to do a series of activity operations but the
5434 * animation seen by the user shouldn't be driven by the first activity
5435 * change but rather a later one.
5436 */
5437 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5438 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005439 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5440 * this flag will cause any existing task that would be associated with the
5441 * activity to be cleared before the activity is started. That is, the activity
5442 * becomes the new root of an otherwise empty task, and any old activities
5443 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5444 */
5445 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5446 /**
5447 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5448 * this flag will cause a newly launching task to be placed on top of the current
5449 * home activity task (if there is one). That is, pressing back from the task
5450 * will always return the user to home even if that was not the last activity they
5451 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5452 */
5453 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5454 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005455 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5456 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005457 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005458 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005459 * this flag. When set and the task's activity is finished, the recents
5460 * entry will remain in the interface for the user to re-launch it, like a
5461 * recents entry for a top-level application.
5462 * <p>
5463 * The receiving activity can override this request with
5464 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5465 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005466 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005467 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005468 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005469
5470 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005471 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5472 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005473 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5474 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005475 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005476 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005477
5478 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005479 * If set, when sending a broadcast only registered receivers will be
5480 * called -- no BroadcastReceiver components will be launched.
5481 */
5482 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005483 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005484 * If set, when sending a broadcast the new broadcast will replace
5485 * any existing pending broadcast that matches it. Matching is defined
5486 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5487 * true for the intents of the two broadcasts. When a match is found,
5488 * the new broadcast (and receivers associated with it) will replace the
5489 * existing one in the pending broadcast list, remaining at the same
5490 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005491 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005492 * <p>This flag is most typically used with sticky broadcasts, which
5493 * only care about delivering the most recent values of the broadcast
5494 * to their receivers.
5495 */
5496 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5497 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005498 * If set, when sending a broadcast the recipient is allowed to run at
5499 * foreground priority, with a shorter timeout interval. During normal
5500 * broadcasts the receivers are not automatically hoisted out of the
5501 * background priority class.
5502 */
5503 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5504 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005505 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5506 * They can still propagate results through to later receivers, but they can not prevent
5507 * later receivers from seeing the broadcast.
5508 */
5509 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5510 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005511 * If set, when sending a broadcast <i>before boot has completed</i> only
5512 * registered receivers will be called -- no BroadcastReceiver components
5513 * will be launched. Sticky intent state will be recorded properly even
5514 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5515 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005516 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005517 * <p>This flag is only for use by system sevices as a convenience to
5518 * avoid having to implement a more complex mechanism around detection
5519 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005520 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005521 * @hide
5522 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005523 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005524 /**
5525 * Set when this broadcast is for a boot upgrade, a special mode that
5526 * allows the broadcast to be sent before the system is ready and launches
5527 * the app process with no providers running in it.
5528 * @hide
5529 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005530 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005531 /**
5532 * If set, the broadcast will always go to manifest receivers in background (cached
5533 * or not running) apps, regardless of whether that would be done by default. By
5534 * default they will only receive broadcasts if the broadcast has specified an
5535 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005536 *
5537 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5538 * the broadcast code there must also be changed to match.
5539 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005540 * @hide
5541 */
5542 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5543 /**
5544 * If set, the broadcast will never go to manifest receivers in background (cached
5545 * or not running) apps, regardless of whether that would be done by default. By
5546 * default they will receive broadcasts if the broadcast has specified an
5547 * explicit component or package name.
5548 * @hide
5549 */
5550 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005551 /**
5552 * If set, this broadcast is being sent from the shell.
5553 * @hide
5554 */
5555 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005556
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005557 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005558 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5559 * will not receive broadcasts.
5560 *
5561 * <em>This flag has no effect when used by an Instant App.</em>
5562 */
5563 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5564
5565 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005566 * @hide Flags that can't be changed with PendingIntent.
5567 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005568 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5569 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5570 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005571
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005572 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005573 // ---------------------------------------------------------------------
5574 // toUri() and parseUri() options.
5575
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005576 /** @hide */
5577 @IntDef(flag = true, prefix = { "URI_" }, value = {
5578 URI_ALLOW_UNSAFE,
5579 URI_ANDROID_APP_SCHEME,
5580 URI_INTENT_SCHEME,
5581 })
5582 @Retention(RetentionPolicy.SOURCE)
5583 public @interface UriFlags {}
5584
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005585 /**
5586 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5587 * always has the "intent:" scheme. This syntax can be used when you want
5588 * to later disambiguate between URIs that are intended to describe an
5589 * Intent vs. all others that should be treated as raw URIs. When used
5590 * with {@link #parseUri}, any other scheme will result in a generic
5591 * VIEW action for that raw URI.
5592 */
5593 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005594
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005595 /**
5596 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5597 * always has the "android-app:" scheme. This is a variation of
5598 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5599 * http/https URI being delivered to a specific package name. The format
5600 * is:
5601 *
5602 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005603 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005604 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005605 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5606 * you must also include a scheme; including a path also requires both a host and a scheme.
5607 * The final #Intent; fragment can be used without a scheme, host, or path.
5608 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005609 * used with intents that have a {@link #setSelector}, since the base intent
5610 * will always have an explicit package name.</p>
5611 *
5612 * <p>Some examples of how this scheme maps to Intent objects:</p>
5613 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5614 * <colgroup align="left" />
5615 * <colgroup align="left" />
5616 * <thead>
5617 * <tr><th>URI</th> <th>Intent</th></tr>
5618 * </thead>
5619 *
5620 * <tbody>
5621 * <tr><td><code>android-app://com.example.app</code></td>
5622 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5623 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5624 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5625 * </table></td>
5626 * </tr>
5627 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5628 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5629 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5630 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5631 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5632 * </table></td>
5633 * </tr>
5634 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5635 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5636 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5637 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5638 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5639 * </table></td>
5640 * </tr>
5641 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5642 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5643 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5644 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5645 * </table></td>
5646 * </tr>
5647 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5648 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5649 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5650 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5651 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5652 * </table></td>
5653 * </tr>
5654 * <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>
5655 * <td><table border="" style="margin:0" >
5656 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5657 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5658 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5659 * </table></td>
5660 * </tr>
5661 * </tbody>
5662 * </table>
5663 */
5664 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5665
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005666 /**
5667 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5668 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5669 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5670 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5671 * generated Intent can not cause unexpected data access to happen.
5672 *
5673 * <p>If you do not trust the source of the URI being parsed, you should still do further
5674 * processing to protect yourself from it. In particular, when using it to start an
5675 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5676 * that can handle it.</p>
5677 */
5678 public static final int URI_ALLOW_UNSAFE = 1<<2;
5679
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005680 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005681
5682 private String mAction;
5683 private Uri mData;
5684 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005685 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005686 private ComponentName mComponent;
5687 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005688 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005689 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005690 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005691 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005692 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005693 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005694 /** Token to track instant app launches. Local only; do not copy cross-process. */
5695 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005696
5697 // ---------------------------------------------------------------------
5698
Makoto Onuki97f82f22017-05-31 16:20:21 -07005699 private static final int COPY_MODE_ALL = 0;
5700 private static final int COPY_MODE_FILTER = 1;
5701 private static final int COPY_MODE_HISTORY = 2;
5702
5703 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005704 @IntDef(prefix = { "COPY_MODE_" }, value = {
5705 COPY_MODE_ALL,
5706 COPY_MODE_FILTER,
5707 COPY_MODE_HISTORY
5708 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005709 @Retention(RetentionPolicy.SOURCE)
5710 public @interface CopyMode {}
5711
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005712 /**
5713 * Create an empty intent.
5714 */
5715 public Intent() {
5716 }
5717
5718 /**
5719 * Copy constructor.
5720 */
5721 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005722 this(o, COPY_MODE_ALL);
5723 }
5724
5725 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005726 this.mAction = o.mAction;
5727 this.mData = o.mData;
5728 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005729 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005730 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005731
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005733 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005734 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005735
5736 if (copyMode != COPY_MODE_FILTER) {
5737 this.mFlags = o.mFlags;
5738 this.mContentUserHint = o.mContentUserHint;
5739 this.mLaunchToken = o.mLaunchToken;
5740 if (o.mSourceBounds != null) {
5741 this.mSourceBounds = new Rect(o.mSourceBounds);
5742 }
5743 if (o.mSelector != null) {
5744 this.mSelector = new Intent(o.mSelector);
5745 }
5746
5747 if (copyMode != COPY_MODE_HISTORY) {
5748 if (o.mExtras != null) {
5749 this.mExtras = new Bundle(o.mExtras);
5750 }
5751 if (o.mClipData != null) {
5752 this.mClipData = new ClipData(o.mClipData);
5753 }
5754 } else {
5755 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5756 this.mExtras = Bundle.STRIPPED;
5757 }
5758
5759 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5760 // history.
5761 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005762 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 }
5764
5765 @Override
5766 public Object clone() {
5767 return new Intent(this);
5768 }
5769
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005770 /**
5771 * Make a clone of only the parts of the Intent that are relevant for
5772 * filter matching: the action, data, type, component, and categories.
5773 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005774 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005775 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005776 }
5777
5778 /**
5779 * Create an intent with a given action. All other fields (data, type,
5780 * class) are null. Note that the action <em>must</em> be in a
5781 * namespace because Intents are used globally in the system -- for
5782 * example the system VIEW action is android.intent.action.VIEW; an
5783 * application's custom action would be something like
5784 * com.google.app.myapp.CUSTOM_ACTION.
5785 *
5786 * @param action The Intent action, such as ACTION_VIEW.
5787 */
5788 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005789 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790 }
5791
5792 /**
5793 * Create an intent with a given action and for a given data url. Note
5794 * that the action <em>must</em> be in a namespace because Intents are
5795 * used globally in the system -- for example the system VIEW action is
5796 * android.intent.action.VIEW; an application's custom action would be
5797 * something like com.google.app.myapp.CUSTOM_ACTION.
5798 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005799 * <p><em>Note: scheme and host name matching in the Android framework is
5800 * case-sensitive, unlike the formal RFC. As a result,
5801 * you should always ensure that you write your Uri with these elements
5802 * using lower case letters, and normalize any Uris you receive from
5803 * outside of Android to ensure the scheme and host is lower case.</em></p>
5804 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005805 * @param action The Intent action, such as ACTION_VIEW.
5806 * @param uri The Intent data URI.
5807 */
5808 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005809 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005810 mData = uri;
5811 }
5812
5813 /**
5814 * Create an intent for a specific component. All other fields (action, data,
5815 * type, class) are null, though they can be modified later with explicit
5816 * calls. This provides a convenient way to create an intent that is
5817 * intended to execute a hard-coded class name, rather than relying on the
5818 * system to find an appropriate class for you; see {@link #setComponent}
5819 * for more information on the repercussions of this.
5820 *
5821 * @param packageContext A Context of the application package implementing
5822 * this class.
5823 * @param cls The component class that is to be used for the intent.
5824 *
5825 * @see #setClass
5826 * @see #setComponent
5827 * @see #Intent(String, android.net.Uri , Context, Class)
5828 */
5829 public Intent(Context packageContext, Class<?> cls) {
5830 mComponent = new ComponentName(packageContext, cls);
5831 }
5832
5833 /**
5834 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005835 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005836 * construct the Intent and then calling {@link #setClass} to set its
5837 * class.
5838 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005839 * <p><em>Note: scheme and host name matching in the Android framework is
5840 * case-sensitive, unlike the formal RFC. As a result,
5841 * you should always ensure that you write your Uri with these elements
5842 * using lower case letters, and normalize any Uris you receive from
5843 * outside of Android to ensure the scheme and host is lower case.</em></p>
5844 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005845 * @param action The Intent action, such as ACTION_VIEW.
5846 * @param uri The Intent data URI.
5847 * @param packageContext A Context of the application package implementing
5848 * this class.
5849 * @param cls The component class that is to be used for the intent.
5850 *
5851 * @see #Intent(String, android.net.Uri)
5852 * @see #Intent(Context, Class)
5853 * @see #setClass
5854 * @see #setComponent
5855 */
5856 public Intent(String action, Uri uri,
5857 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005858 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005859 mData = uri;
5860 mComponent = new ComponentName(packageContext, cls);
5861 }
5862
5863 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005864 * Create an intent to launch the main (root) activity of a task. This
5865 * is the Intent that is started when the application's is launched from
5866 * Home. For anything else that wants to launch an application in the
5867 * same way, it is important that they use an Intent structured the same
5868 * way, and can use this function to ensure this is the case.
5869 *
5870 * <p>The returned Intent has the given Activity component as its explicit
5871 * component, {@link #ACTION_MAIN} as its action, and includes the
5872 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5873 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5874 * to do that through {@link #addFlags(int)} on the returned Intent.
5875 *
5876 * @param mainActivity The main activity component that this Intent will
5877 * launch.
5878 * @return Returns a newly created Intent that can be used to launch the
5879 * activity as a main application entry.
5880 *
5881 * @see #setClass
5882 * @see #setComponent
5883 */
5884 public static Intent makeMainActivity(ComponentName mainActivity) {
5885 Intent intent = new Intent(ACTION_MAIN);
5886 intent.setComponent(mainActivity);
5887 intent.addCategory(CATEGORY_LAUNCHER);
5888 return intent;
5889 }
5890
5891 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005892 * Make an Intent for the main activity of an application, without
5893 * specifying a specific activity to run but giving a selector to find
5894 * the activity. This results in a final Intent that is structured
5895 * the same as when the application is launched from
5896 * Home. For anything else that wants to launch an application in the
5897 * same way, it is important that they use an Intent structured the same
5898 * way, and can use this function to ensure this is the case.
5899 *
5900 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5901 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5902 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5903 * to do that through {@link #addFlags(int)} on the returned Intent.
5904 *
5905 * @param selectorAction The action name of the Intent's selector.
5906 * @param selectorCategory The name of a category to add to the Intent's
5907 * selector.
5908 * @return Returns a newly created Intent that can be used to launch the
5909 * activity as a main application entry.
5910 *
5911 * @see #setSelector(Intent)
5912 */
5913 public static Intent makeMainSelectorActivity(String selectorAction,
5914 String selectorCategory) {
5915 Intent intent = new Intent(ACTION_MAIN);
5916 intent.addCategory(CATEGORY_LAUNCHER);
5917 Intent selector = new Intent();
5918 selector.setAction(selectorAction);
5919 selector.addCategory(selectorCategory);
5920 intent.setSelector(selector);
5921 return intent;
5922 }
5923
5924 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005925 * Make an Intent that can be used to re-launch an application's task
5926 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5927 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5928 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5929 *
5930 * @param mainActivity The activity component that is the root of the
5931 * task; this is the activity that has been published in the application's
5932 * manifest as the main launcher icon.
5933 *
5934 * @return Returns a newly created Intent that can be used to relaunch the
5935 * activity's task in its root state.
5936 */
5937 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5938 Intent intent = makeMainActivity(mainActivity);
5939 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5940 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5941 return intent;
5942 }
5943
5944 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005945 * Call {@link #parseUri} with 0 flags.
5946 * @deprecated Use {@link #parseUri} instead.
5947 */
5948 @Deprecated
5949 public static Intent getIntent(String uri) throws URISyntaxException {
5950 return parseUri(uri, 0);
5951 }
Tom Taylord4a47292009-12-21 13:59:18 -08005952
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005953 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005954 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005955 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005956 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005957 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 *
5959 * <p>The URI given here must not be relative -- that is, it must include
5960 * the scheme and full path.
5961 *
5962 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005963 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005964 *
5965 * @return Intent The newly created Intent object.
5966 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005967 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5968 * it bad (as parsed by the Uri class) or the Intent data within the
5969 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005970 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005971 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005972 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005973 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005974 int i = 0;
5975 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005976 final boolean androidApp = uri.startsWith("android-app:");
5977
5978 // Validate intent scheme if requested.
5979 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5980 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005981 Intent intent = new Intent(ACTION_VIEW);
5982 try {
5983 intent.setData(Uri.parse(uri));
5984 } catch (IllegalArgumentException e) {
5985 throw new URISyntaxException(uri, e.getMessage());
5986 }
5987 return intent;
5988 }
5989 }
Tom Taylord4a47292009-12-21 13:59:18 -08005990
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005992 // simple case
5993 if (i == -1) {
5994 if (!androidApp) {
5995 return new Intent(ACTION_VIEW, Uri.parse(uri));
5996 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005997
5998 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005999 } else if (!uri.startsWith("#Intent;", i)) {
6000 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006001 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006002 } else {
6003 i = -1;
6004 }
6005 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006006
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006007 // new format
6008 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006009 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006010 boolean explicitAction = false;
6011 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006012
6013 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006014 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006015 String data;
6016 if (i >= 0) {
6017 data = uri.substring(0, i);
6018 i += 8; // length of "#Intent;"
6019 } else {
6020 data = uri;
6021 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006023 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006024 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006025 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006026 if (eq < 0) eq = i-1;
6027 int semi = uri.indexOf(';', i);
6028 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006029
6030 // action
6031 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006032 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006033 if (!inSelector) {
6034 explicitAction = true;
6035 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006036 }
6037
6038 // categories
6039 else if (uri.startsWith("category=", i)) {
6040 intent.addCategory(value);
6041 }
6042
6043 // type
6044 else if (uri.startsWith("type=", i)) {
6045 intent.mType = value;
6046 }
6047
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006048 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006049 else if (uri.startsWith("launchFlags=", i)) {
6050 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006051 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6052 intent.mFlags &= ~IMMUTABLE_FLAGS;
6053 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006054 }
6055
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006056 // package
6057 else if (uri.startsWith("package=", i)) {
6058 intent.mPackage = value;
6059 }
6060
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006061 // component
6062 else if (uri.startsWith("component=", i)) {
6063 intent.mComponent = ComponentName.unflattenFromString(value);
6064 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006065
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006066 // scheme
6067 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006068 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006069 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006070 } else {
6071 scheme = value;
6072 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006073 }
6074
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006075 // source bounds
6076 else if (uri.startsWith("sourceBounds=", i)) {
6077 intent.mSourceBounds = Rect.unflattenFromString(value);
6078 }
6079
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006080 // selector
6081 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6082 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006083 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006084 }
6085
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006086 // extra
6087 else {
6088 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006089 // create Bundle if it doesn't already exist
6090 if (intent.mExtras == null) intent.mExtras = new Bundle();
6091 Bundle b = intent.mExtras;
6092 // add EXTRA
6093 if (uri.startsWith("S.", i)) b.putString(key, value);
6094 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6095 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6096 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6097 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6098 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6099 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6100 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6101 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6102 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6103 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006104
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006105 // move to the next item
6106 i = semi + 1;
6107 }
6108
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006109 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006110 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006111 if (baseIntent.mPackage == null) {
6112 baseIntent.setSelector(intent);
6113 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006114 intent = baseIntent;
6115 }
6116
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006117 if (data != null) {
6118 if (data.startsWith("intent:")) {
6119 data = data.substring(7);
6120 if (scheme != null) {
6121 data = scheme + ':' + data;
6122 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006123 } else if (data.startsWith("android-app:")) {
6124 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6125 // Correctly formed android-app, first part is package name.
6126 int end = data.indexOf('/', 14);
6127 if (end < 0) {
6128 // All we have is a package name.
6129 intent.mPackage = data.substring(14);
6130 if (!explicitAction) {
6131 intent.setAction(ACTION_MAIN);
6132 }
6133 data = "";
6134 } else {
6135 // Target the Intent at the given package name always.
6136 String authority = null;
6137 intent.mPackage = data.substring(14, end);
6138 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006139 if ((end+1) < data.length()) {
6140 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6141 // Found a scheme, remember it.
6142 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006143 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006144 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6145 // Found a authority, remember it.
6146 authority = data.substring(end+1, newEnd);
6147 end = newEnd;
6148 }
6149 } else {
6150 // All we have is a scheme.
6151 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006152 }
6153 }
6154 if (scheme == null) {
6155 // If there was no scheme, then this just targets the package.
6156 if (!explicitAction) {
6157 intent.setAction(ACTION_MAIN);
6158 }
6159 data = "";
6160 } else if (authority == null) {
6161 data = scheme + ":";
6162 } else {
6163 data = scheme + "://" + authority + data.substring(end);
6164 }
6165 }
6166 } else {
6167 data = "";
6168 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006169 }
Tom Taylord4a47292009-12-21 13:59:18 -08006170
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006171 if (data.length() > 0) {
6172 try {
6173 intent.mData = Uri.parse(data);
6174 } catch (IllegalArgumentException e) {
6175 throw new URISyntaxException(uri, e.getMessage());
6176 }
6177 }
6178 }
Tom Taylord4a47292009-12-21 13:59:18 -08006179
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006180 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006181
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006182 } catch (IndexOutOfBoundsException e) {
6183 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6184 }
6185 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006186
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006187 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006188 return getIntentOld(uri, 0);
6189 }
6190
6191 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006192 Intent intent;
6193
6194 int i = uri.lastIndexOf('#');
6195 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006196 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006197 final int intentFragmentStart = i;
6198 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006199
6200 i++;
6201
6202 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006203 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006204 i += 7;
6205 int j = uri.indexOf(')', i);
6206 action = uri.substring(i, j);
6207 i = j + 1;
6208 }
6209
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006210 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006211
6212 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006213 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006214 i += 11;
6215 int j = uri.indexOf(')', i);
6216 while (i < j) {
6217 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006218 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006219 if (i < sep) {
6220 intent.addCategory(uri.substring(i, sep));
6221 }
6222 i = sep + 1;
6223 }
6224 i = j + 1;
6225 }
6226
6227 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006228 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006229 i += 5;
6230 int j = uri.indexOf(')', i);
6231 intent.mType = uri.substring(i, j);
6232 i = j + 1;
6233 }
6234
6235 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006236 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006237 i += 12;
6238 int j = uri.indexOf(')', i);
6239 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006240 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6241 intent.mFlags &= ~IMMUTABLE_FLAGS;
6242 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006243 i = j + 1;
6244 }
6245
6246 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006247 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006248 i += 10;
6249 int j = uri.indexOf(')', i);
6250 int sep = uri.indexOf('!', i);
6251 if (sep >= 0 && sep < j) {
6252 String pkg = uri.substring(i, sep);
6253 String cls = uri.substring(sep + 1, j);
6254 intent.mComponent = new ComponentName(pkg, cls);
6255 }
6256 i = j + 1;
6257 }
6258
6259 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006260 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006261 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006262
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006263 final int closeParen = uri.indexOf(')', i);
6264 if (closeParen == -1) throw new URISyntaxException(uri,
6265 "EXTRA missing trailing ')'", i);
6266
6267 while (i < closeParen) {
6268 // fetch the key value
6269 int j = uri.indexOf('=', i);
6270 if (j <= i + 1 || i >= closeParen) {
6271 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6272 }
6273 char type = uri.charAt(i);
6274 i++;
6275 String key = uri.substring(i, j);
6276 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006277
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006278 // get type-value
6279 j = uri.indexOf('!', i);
6280 if (j == -1 || j >= closeParen) j = closeParen;
6281 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6282 String value = uri.substring(i, j);
6283 i = j;
6284
6285 // create Bundle if it doesn't already exist
6286 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006287
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006288 // add item to bundle
6289 try {
6290 switch (type) {
6291 case 'S':
6292 intent.mExtras.putString(key, Uri.decode(value));
6293 break;
6294 case 'B':
6295 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6296 break;
6297 case 'b':
6298 intent.mExtras.putByte(key, Byte.parseByte(value));
6299 break;
6300 case 'c':
6301 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6302 break;
6303 case 'd':
6304 intent.mExtras.putDouble(key, Double.parseDouble(value));
6305 break;
6306 case 'f':
6307 intent.mExtras.putFloat(key, Float.parseFloat(value));
6308 break;
6309 case 'i':
6310 intent.mExtras.putInt(key, Integer.parseInt(value));
6311 break;
6312 case 'l':
6313 intent.mExtras.putLong(key, Long.parseLong(value));
6314 break;
6315 case 's':
6316 intent.mExtras.putShort(key, Short.parseShort(value));
6317 break;
6318 default:
6319 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6320 }
6321 } catch (NumberFormatException e) {
6322 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6323 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006324
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006325 char ch = uri.charAt(i);
6326 if (ch == ')') break;
6327 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6328 i++;
6329 }
6330 }
6331
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006332 if (isIntentFragment) {
6333 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6334 } else {
6335 intent.mData = Uri.parse(uri);
6336 }
Tom Taylord4a47292009-12-21 13:59:18 -08006337
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006338 if (intent.mAction == null) {
6339 // By default, if no action is specified, then use VIEW.
6340 intent.mAction = ACTION_VIEW;
6341 }
6342
6343 } else {
6344 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6345 }
6346
6347 return intent;
6348 }
6349
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006350 /** @hide */
6351 public interface CommandOptionHandler {
6352 boolean handleOption(String opt, ShellCommand cmd);
6353 }
6354
6355 /** @hide */
6356 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6357 throws URISyntaxException {
6358 Intent intent = new Intent();
6359 Intent baseIntent = intent;
6360 boolean hasIntentInfo = false;
6361
6362 Uri data = null;
6363 String type = null;
6364
6365 String opt;
6366 while ((opt=cmd.getNextOption()) != null) {
6367 switch (opt) {
6368 case "-a":
6369 intent.setAction(cmd.getNextArgRequired());
6370 if (intent == baseIntent) {
6371 hasIntentInfo = true;
6372 }
6373 break;
6374 case "-d":
6375 data = Uri.parse(cmd.getNextArgRequired());
6376 if (intent == baseIntent) {
6377 hasIntentInfo = true;
6378 }
6379 break;
6380 case "-t":
6381 type = cmd.getNextArgRequired();
6382 if (intent == baseIntent) {
6383 hasIntentInfo = true;
6384 }
6385 break;
6386 case "-c":
6387 intent.addCategory(cmd.getNextArgRequired());
6388 if (intent == baseIntent) {
6389 hasIntentInfo = true;
6390 }
6391 break;
6392 case "-e":
6393 case "--es": {
6394 String key = cmd.getNextArgRequired();
6395 String value = cmd.getNextArgRequired();
6396 intent.putExtra(key, value);
6397 }
6398 break;
6399 case "--esn": {
6400 String key = cmd.getNextArgRequired();
6401 intent.putExtra(key, (String) null);
6402 }
6403 break;
6404 case "--ei": {
6405 String key = cmd.getNextArgRequired();
6406 String value = cmd.getNextArgRequired();
6407 intent.putExtra(key, Integer.decode(value));
6408 }
6409 break;
6410 case "--eu": {
6411 String key = cmd.getNextArgRequired();
6412 String value = cmd.getNextArgRequired();
6413 intent.putExtra(key, Uri.parse(value));
6414 }
6415 break;
6416 case "--ecn": {
6417 String key = cmd.getNextArgRequired();
6418 String value = cmd.getNextArgRequired();
6419 ComponentName cn = ComponentName.unflattenFromString(value);
6420 if (cn == null)
6421 throw new IllegalArgumentException("Bad component name: " + value);
6422 intent.putExtra(key, cn);
6423 }
6424 break;
6425 case "--eia": {
6426 String key = cmd.getNextArgRequired();
6427 String value = cmd.getNextArgRequired();
6428 String[] strings = value.split(",");
6429 int[] list = new int[strings.length];
6430 for (int i = 0; i < strings.length; i++) {
6431 list[i] = Integer.decode(strings[i]);
6432 }
6433 intent.putExtra(key, list);
6434 }
6435 break;
6436 case "--eial": {
6437 String key = cmd.getNextArgRequired();
6438 String value = cmd.getNextArgRequired();
6439 String[] strings = value.split(",");
6440 ArrayList<Integer> list = new ArrayList<>(strings.length);
6441 for (int i = 0; i < strings.length; i++) {
6442 list.add(Integer.decode(strings[i]));
6443 }
6444 intent.putExtra(key, list);
6445 }
6446 break;
6447 case "--el": {
6448 String key = cmd.getNextArgRequired();
6449 String value = cmd.getNextArgRequired();
6450 intent.putExtra(key, Long.valueOf(value));
6451 }
6452 break;
6453 case "--ela": {
6454 String key = cmd.getNextArgRequired();
6455 String value = cmd.getNextArgRequired();
6456 String[] strings = value.split(",");
6457 long[] list = new long[strings.length];
6458 for (int i = 0; i < strings.length; i++) {
6459 list[i] = Long.valueOf(strings[i]);
6460 }
6461 intent.putExtra(key, list);
6462 hasIntentInfo = true;
6463 }
6464 break;
6465 case "--elal": {
6466 String key = cmd.getNextArgRequired();
6467 String value = cmd.getNextArgRequired();
6468 String[] strings = value.split(",");
6469 ArrayList<Long> list = new ArrayList<>(strings.length);
6470 for (int i = 0; i < strings.length; i++) {
6471 list.add(Long.valueOf(strings[i]));
6472 }
6473 intent.putExtra(key, list);
6474 hasIntentInfo = true;
6475 }
6476 break;
6477 case "--ef": {
6478 String key = cmd.getNextArgRequired();
6479 String value = cmd.getNextArgRequired();
6480 intent.putExtra(key, Float.valueOf(value));
6481 hasIntentInfo = true;
6482 }
6483 break;
6484 case "--efa": {
6485 String key = cmd.getNextArgRequired();
6486 String value = cmd.getNextArgRequired();
6487 String[] strings = value.split(",");
6488 float[] list = new float[strings.length];
6489 for (int i = 0; i < strings.length; i++) {
6490 list[i] = Float.valueOf(strings[i]);
6491 }
6492 intent.putExtra(key, list);
6493 hasIntentInfo = true;
6494 }
6495 break;
6496 case "--efal": {
6497 String key = cmd.getNextArgRequired();
6498 String value = cmd.getNextArgRequired();
6499 String[] strings = value.split(",");
6500 ArrayList<Float> list = new ArrayList<>(strings.length);
6501 for (int i = 0; i < strings.length; i++) {
6502 list.add(Float.valueOf(strings[i]));
6503 }
6504 intent.putExtra(key, list);
6505 hasIntentInfo = true;
6506 }
6507 break;
6508 case "--esa": {
6509 String key = cmd.getNextArgRequired();
6510 String value = cmd.getNextArgRequired();
6511 // Split on commas unless they are preceeded by an escape.
6512 // The escape character must be escaped for the string and
6513 // again for the regex, thus four escape characters become one.
6514 String[] strings = value.split("(?<!\\\\),");
6515 intent.putExtra(key, strings);
6516 hasIntentInfo = true;
6517 }
6518 break;
6519 case "--esal": {
6520 String key = cmd.getNextArgRequired();
6521 String value = cmd.getNextArgRequired();
6522 // Split on commas unless they are preceeded by an escape.
6523 // The escape character must be escaped for the string and
6524 // again for the regex, thus four escape characters become one.
6525 String[] strings = value.split("(?<!\\\\),");
6526 ArrayList<String> list = new ArrayList<>(strings.length);
6527 for (int i = 0; i < strings.length; i++) {
6528 list.add(strings[i]);
6529 }
6530 intent.putExtra(key, list);
6531 hasIntentInfo = true;
6532 }
6533 break;
6534 case "--ez": {
6535 String key = cmd.getNextArgRequired();
6536 String value = cmd.getNextArgRequired().toLowerCase();
6537 // Boolean.valueOf() results in false for anything that is not "true", which is
6538 // error-prone in shell commands
6539 boolean arg;
6540 if ("true".equals(value) || "t".equals(value)) {
6541 arg = true;
6542 } else if ("false".equals(value) || "f".equals(value)) {
6543 arg = false;
6544 } else {
6545 try {
6546 arg = Integer.decode(value) != 0;
6547 } catch (NumberFormatException ex) {
6548 throw new IllegalArgumentException("Invalid boolean value: " + value);
6549 }
6550 }
6551
6552 intent.putExtra(key, arg);
6553 }
6554 break;
6555 case "-n": {
6556 String str = cmd.getNextArgRequired();
6557 ComponentName cn = ComponentName.unflattenFromString(str);
6558 if (cn == null)
6559 throw new IllegalArgumentException("Bad component name: " + str);
6560 intent.setComponent(cn);
6561 if (intent == baseIntent) {
6562 hasIntentInfo = true;
6563 }
6564 }
6565 break;
6566 case "-p": {
6567 String str = cmd.getNextArgRequired();
6568 intent.setPackage(str);
6569 if (intent == baseIntent) {
6570 hasIntentInfo = true;
6571 }
6572 }
6573 break;
6574 case "-f":
6575 String str = cmd.getNextArgRequired();
6576 intent.setFlags(Integer.decode(str).intValue());
6577 break;
6578 case "--grant-read-uri-permission":
6579 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6580 break;
6581 case "--grant-write-uri-permission":
6582 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6583 break;
6584 case "--grant-persistable-uri-permission":
6585 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6586 break;
6587 case "--grant-prefix-uri-permission":
6588 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6589 break;
6590 case "--exclude-stopped-packages":
6591 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6592 break;
6593 case "--include-stopped-packages":
6594 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6595 break;
6596 case "--debug-log-resolution":
6597 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6598 break;
6599 case "--activity-brought-to-front":
6600 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6601 break;
6602 case "--activity-clear-top":
6603 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6604 break;
6605 case "--activity-clear-when-task-reset":
6606 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6607 break;
6608 case "--activity-exclude-from-recents":
6609 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6610 break;
6611 case "--activity-launched-from-history":
6612 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6613 break;
6614 case "--activity-multiple-task":
6615 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6616 break;
6617 case "--activity-no-animation":
6618 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6619 break;
6620 case "--activity-no-history":
6621 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6622 break;
6623 case "--activity-no-user-action":
6624 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6625 break;
6626 case "--activity-previous-is-top":
6627 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6628 break;
6629 case "--activity-reorder-to-front":
6630 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6631 break;
6632 case "--activity-reset-task-if-needed":
6633 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6634 break;
6635 case "--activity-single-top":
6636 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6637 break;
6638 case "--activity-clear-task":
6639 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6640 break;
6641 case "--activity-task-on-home":
6642 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6643 break;
6644 case "--receiver-registered-only":
6645 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6646 break;
6647 case "--receiver-replace-pending":
6648 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6649 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006650 case "--receiver-foreground":
6651 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6652 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006653 case "--receiver-no-abort":
6654 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6655 break;
6656 case "--receiver-include-background":
6657 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6658 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006659 case "--selector":
6660 intent.setDataAndType(data, type);
6661 intent = new Intent();
6662 break;
6663 default:
6664 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6665 // Okay, caller handled this option.
6666 } else {
6667 throw new IllegalArgumentException("Unknown option: " + opt);
6668 }
6669 break;
6670 }
6671 }
6672 intent.setDataAndType(data, type);
6673
6674 final boolean hasSelector = intent != baseIntent;
6675 if (hasSelector) {
6676 // A selector was specified; fix up.
6677 baseIntent.setSelector(intent);
6678 intent = baseIntent;
6679 }
6680
6681 String arg = cmd.getNextArg();
6682 baseIntent = null;
6683 if (arg == null) {
6684 if (hasSelector) {
6685 // If a selector has been specified, and no arguments
6686 // have been supplied for the main Intent, then we can
6687 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6688 // need to have a component name specified yet, the
6689 // selector will take care of that.
6690 baseIntent = new Intent(Intent.ACTION_MAIN);
6691 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6692 }
6693 } else if (arg.indexOf(':') >= 0) {
6694 // The argument is a URI. Fully parse it, and use that result
6695 // to fill in any data not specified so far.
6696 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6697 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6698 } else if (arg.indexOf('/') >= 0) {
6699 // The argument is a component name. Build an Intent to launch
6700 // it.
6701 baseIntent = new Intent(Intent.ACTION_MAIN);
6702 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6703 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6704 } else {
6705 // Assume the argument is a package name.
6706 baseIntent = new Intent(Intent.ACTION_MAIN);
6707 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6708 baseIntent.setPackage(arg);
6709 }
6710 if (baseIntent != null) {
6711 Bundle extras = intent.getExtras();
6712 intent.replaceExtras((Bundle)null);
6713 Bundle uriExtras = baseIntent.getExtras();
6714 baseIntent.replaceExtras((Bundle)null);
6715 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6716 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6717 for (String c : cats) {
6718 baseIntent.removeCategory(c);
6719 }
6720 }
6721 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6722 if (extras == null) {
6723 extras = uriExtras;
6724 } else if (uriExtras != null) {
6725 uriExtras.putAll(extras);
6726 extras = uriExtras;
6727 }
6728 intent.replaceExtras(extras);
6729 hasIntentInfo = true;
6730 }
6731
6732 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6733 return intent;
6734 }
6735
6736 /** @hide */
6737 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6738 final String[] lines = new String[] {
6739 "<INTENT> specifications include these flags and arguments:",
6740 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6741 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6742 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6743 " [--esn <EXTRA_KEY> ...]",
6744 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6745 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6746 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6747 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6748 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6749 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6750 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6751 " (mutiple extras passed as Integer[])",
6752 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6753 " (mutiple extras passed as List<Integer>)",
6754 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6755 " (mutiple extras passed as Long[])",
6756 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6757 " (mutiple extras passed as List<Long>)",
6758 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6759 " (mutiple extras passed as Float[])",
6760 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6761 " (mutiple extras passed as List<Float>)",
6762 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6763 " (mutiple extras passed as String[]; to embed a comma into a string,",
6764 " escape it using \"\\,\")",
6765 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6766 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6767 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006768 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006769 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6770 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6771 " [--debug-log-resolution] [--exclude-stopped-packages]",
6772 " [--include-stopped-packages]",
6773 " [--activity-brought-to-front] [--activity-clear-top]",
6774 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6775 " [--activity-launched-from-history] [--activity-multiple-task]",
6776 " [--activity-no-animation] [--activity-no-history]",
6777 " [--activity-no-user-action] [--activity-previous-is-top]",
6778 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6779 " [--activity-single-top] [--activity-clear-task]",
6780 " [--activity-task-on-home]",
6781 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006782 " [--receiver-foreground] [--receiver-no-abort]",
6783 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006784 " [--selector]",
6785 " [<URI> | <PACKAGE> | <COMPONENT>]"
6786 };
6787 for (String line : lines) {
6788 pw.print(prefix);
6789 pw.println(line);
6790 }
6791 }
6792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 /**
6794 * Retrieve the general action to be performed, such as
6795 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6796 * the information in the intent should be interpreted -- most importantly,
6797 * what to do with the data returned by {@link #getData}.
6798 *
6799 * @return The action of this intent or null if none is specified.
6800 *
6801 * @see #setAction
6802 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006803 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006804 return mAction;
6805 }
6806
6807 /**
6808 * Retrieve data this intent is operating on. This URI specifies the name
6809 * of the data; often it uses the content: scheme, specifying data in a
6810 * content provider. Other schemes may be handled by specific activities,
6811 * such as http: by the web browser.
6812 *
6813 * @return The URI of the data this intent is targeting or null.
6814 *
6815 * @see #getScheme
6816 * @see #setData
6817 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006818 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006819 return mData;
6820 }
6821
6822 /**
6823 * The same as {@link #getData()}, but returns the URI as an encoded
6824 * String.
6825 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006826 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006827 return mData != null ? mData.toString() : null;
6828 }
6829
6830 /**
6831 * Return the scheme portion of the intent's data. If the data is null or
6832 * does not include a scheme, null is returned. Otherwise, the scheme
6833 * prefix without the final ':' is returned, i.e. "http".
6834 *
6835 * <p>This is the same as calling getData().getScheme() (and checking for
6836 * null data).
6837 *
6838 * @return The scheme of this intent.
6839 *
6840 * @see #getData
6841 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006842 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006843 return mData != null ? mData.getScheme() : null;
6844 }
6845
6846 /**
6847 * Retrieve any explicit MIME type included in the intent. This is usually
6848 * null, as the type is determined by the intent data.
6849 *
6850 * @return If a type was manually set, it is returned; else null is
6851 * returned.
6852 *
6853 * @see #resolveType(ContentResolver)
6854 * @see #setType
6855 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006856 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006857 return mType;
6858 }
6859
6860 /**
6861 * Return the MIME data type of this intent. If the type field is
6862 * explicitly set, that is simply returned. Otherwise, if the data is set,
6863 * the type of that data is returned. If neither fields are set, a null is
6864 * returned.
6865 *
6866 * @return The MIME type of this intent.
6867 *
6868 * @see #getType
6869 * @see #resolveType(ContentResolver)
6870 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006871 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006872 return resolveType(context.getContentResolver());
6873 }
6874
6875 /**
6876 * Return the MIME data type of this intent. If the type field is
6877 * explicitly set, that is simply returned. Otherwise, if the data is set,
6878 * the type of that data is returned. If neither fields are set, a null is
6879 * returned.
6880 *
6881 * @param resolver A ContentResolver that can be used to determine the MIME
6882 * type of the intent's data.
6883 *
6884 * @return The MIME type of this intent.
6885 *
6886 * @see #getType
6887 * @see #resolveType(Context)
6888 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006889 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006890 if (mType != null) {
6891 return mType;
6892 }
6893 if (mData != null) {
6894 if ("content".equals(mData.getScheme())) {
6895 return resolver.getType(mData);
6896 }
6897 }
6898 return null;
6899 }
6900
6901 /**
6902 * Return the MIME data type of this intent, only if it will be needed for
6903 * intent resolution. This is not generally useful for application code;
6904 * it is used by the frameworks for communicating with back-end system
6905 * services.
6906 *
6907 * @param resolver A ContentResolver that can be used to determine the MIME
6908 * type of the intent's data.
6909 *
6910 * @return The MIME type of this intent, or null if it is unknown or not
6911 * needed.
6912 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006913 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006914 if (mComponent != null) {
6915 return mType;
6916 }
6917 return resolveType(resolver);
6918 }
6919
6920 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006921 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006922 *
6923 * @param category The category to check.
6924 *
6925 * @return boolean True if the intent contains the category, else false.
6926 *
6927 * @see #getCategories
6928 * @see #addCategory
6929 */
6930 public boolean hasCategory(String category) {
6931 return mCategories != null && mCategories.contains(category);
6932 }
6933
6934 /**
6935 * Return the set of all categories in the intent. If there are no categories,
6936 * returns NULL.
6937 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006938 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006939 *
6940 * @see #hasCategory
6941 * @see #addCategory
6942 */
6943 public Set<String> getCategories() {
6944 return mCategories;
6945 }
6946
6947 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006948 * Return the specific selector associated with this Intent. If there is
6949 * none, returns null. See {@link #setSelector} for more information.
6950 *
6951 * @see #setSelector
6952 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006953 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006954 return mSelector;
6955 }
6956
6957 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006958 * Return the {@link ClipData} associated with this Intent. If there is
6959 * none, returns null. See {@link #setClipData} for more information.
6960 *
John Spurlock125d1332013-11-25 11:58:37 -05006961 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006962 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006963 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006964 return mClipData;
6965 }
6966
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006967 /** @hide */
6968 public int getContentUserHint() {
6969 return mContentUserHint;
6970 }
6971
Todd Kennedyb3b431302017-03-20 16:05:48 -07006972 /** @hide */
6973 public String getLaunchToken() {
6974 return mLaunchToken;
6975 }
6976
6977 /** @hide */
6978 public void setLaunchToken(String launchToken) {
6979 mLaunchToken = launchToken;
6980 }
6981
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006982 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006983 * Sets the ClassLoader that will be used when unmarshalling
6984 * any Parcelable values from the extras of this Intent.
6985 *
6986 * @param loader a ClassLoader, or null to use the default loader
6987 * at the time of unmarshalling.
6988 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006989 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006990 if (mExtras != null) {
6991 mExtras.setClassLoader(loader);
6992 }
6993 }
6994
6995 /**
6996 * Returns true if an extra value is associated with the given name.
6997 * @param name the extra's name
6998 * @return true if the given extra is present.
6999 */
7000 public boolean hasExtra(String name) {
7001 return mExtras != null && mExtras.containsKey(name);
7002 }
7003
7004 /**
7005 * Returns true if the Intent's extras contain a parcelled file descriptor.
7006 * @return true if the Intent contains a parcelled file descriptor.
7007 */
7008 public boolean hasFileDescriptors() {
7009 return mExtras != null && mExtras.hasFileDescriptors();
7010 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007011
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007012 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007013 public void setAllowFds(boolean allowFds) {
7014 if (mExtras != null) {
7015 mExtras.setAllowFds(allowFds);
7016 }
7017 }
7018
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007019 /** {@hide} */
7020 public void setDefusable(boolean defusable) {
7021 if (mExtras != null) {
7022 mExtras.setDefusable(defusable);
7023 }
7024 }
7025
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007026 /**
7027 * Retrieve extended data from the intent.
7028 *
7029 * @param name The name of the desired item.
7030 *
7031 * @return the value of an item that previously added with putExtra()
7032 * or null if none was found.
7033 *
7034 * @deprecated
7035 * @hide
7036 */
7037 @Deprecated
7038 public Object getExtra(String name) {
7039 return getExtra(name, null);
7040 }
7041
7042 /**
7043 * Retrieve extended data from the intent.
7044 *
7045 * @param name The name of the desired item.
7046 * @param defaultValue the value to be returned if no value of the desired
7047 * type is stored with the given name.
7048 *
7049 * @return the value of an item that previously added with putExtra()
7050 * or the default value if none was found.
7051 *
7052 * @see #putExtra(String, boolean)
7053 */
7054 public boolean getBooleanExtra(String name, boolean defaultValue) {
7055 return mExtras == null ? defaultValue :
7056 mExtras.getBoolean(name, defaultValue);
7057 }
7058
7059 /**
7060 * Retrieve extended data from the intent.
7061 *
7062 * @param name The name of the desired item.
7063 * @param defaultValue the value to be returned if no value of the desired
7064 * type is stored with the given name.
7065 *
7066 * @return the value of an item that previously added with putExtra()
7067 * or the default value if none was found.
7068 *
7069 * @see #putExtra(String, byte)
7070 */
7071 public byte getByteExtra(String name, byte defaultValue) {
7072 return mExtras == null ? defaultValue :
7073 mExtras.getByte(name, defaultValue);
7074 }
7075
7076 /**
7077 * Retrieve extended data from the intent.
7078 *
7079 * @param name The name of the desired item.
7080 * @param defaultValue the value to be returned if no value of the desired
7081 * type is stored with the given name.
7082 *
7083 * @return the value of an item that previously added with putExtra()
7084 * or the default value if none was found.
7085 *
7086 * @see #putExtra(String, short)
7087 */
7088 public short getShortExtra(String name, short defaultValue) {
7089 return mExtras == null ? defaultValue :
7090 mExtras.getShort(name, defaultValue);
7091 }
7092
7093 /**
7094 * Retrieve extended data from the intent.
7095 *
7096 * @param name The name of the desired item.
7097 * @param defaultValue the value to be returned if no value of the desired
7098 * type is stored with the given name.
7099 *
7100 * @return the value of an item that previously added with putExtra()
7101 * or the default value if none was found.
7102 *
7103 * @see #putExtra(String, char)
7104 */
7105 public char getCharExtra(String name, char defaultValue) {
7106 return mExtras == null ? defaultValue :
7107 mExtras.getChar(name, defaultValue);
7108 }
7109
7110 /**
7111 * Retrieve extended data from the intent.
7112 *
7113 * @param name The name of the desired item.
7114 * @param defaultValue the value to be returned if no value of the desired
7115 * type is stored with the given name.
7116 *
7117 * @return the value of an item that previously added with putExtra()
7118 * or the default value if none was found.
7119 *
7120 * @see #putExtra(String, int)
7121 */
7122 public int getIntExtra(String name, int defaultValue) {
7123 return mExtras == null ? defaultValue :
7124 mExtras.getInt(name, defaultValue);
7125 }
7126
7127 /**
7128 * Retrieve extended data from the intent.
7129 *
7130 * @param name The name of the desired item.
7131 * @param defaultValue the value to be returned if no value of the desired
7132 * type is stored with the given name.
7133 *
7134 * @return the value of an item that previously added with putExtra()
7135 * or the default value if none was found.
7136 *
7137 * @see #putExtra(String, long)
7138 */
7139 public long getLongExtra(String name, long defaultValue) {
7140 return mExtras == null ? defaultValue :
7141 mExtras.getLong(name, defaultValue);
7142 }
7143
7144 /**
7145 * Retrieve extended data from the intent.
7146 *
7147 * @param name The name of the desired item.
7148 * @param defaultValue the value to be returned if no value of the desired
7149 * type is stored with the given name.
7150 *
7151 * @return the value of an item that previously added with putExtra(),
7152 * or the default value if no such item is present
7153 *
7154 * @see #putExtra(String, float)
7155 */
7156 public float getFloatExtra(String name, float defaultValue) {
7157 return mExtras == null ? defaultValue :
7158 mExtras.getFloat(name, defaultValue);
7159 }
7160
7161 /**
7162 * Retrieve extended data from the intent.
7163 *
7164 * @param name The name of the desired item.
7165 * @param defaultValue the value to be returned if no value of the desired
7166 * type is stored with the given name.
7167 *
7168 * @return the value of an item that previously added with putExtra()
7169 * or the default value if none was found.
7170 *
7171 * @see #putExtra(String, double)
7172 */
7173 public double getDoubleExtra(String name, double defaultValue) {
7174 return mExtras == null ? defaultValue :
7175 mExtras.getDouble(name, defaultValue);
7176 }
7177
7178 /**
7179 * Retrieve extended data from the intent.
7180 *
7181 * @param name The name of the desired item.
7182 *
7183 * @return the value of an item that previously added with putExtra()
7184 * or null if no String value was found.
7185 *
7186 * @see #putExtra(String, String)
7187 */
7188 public String getStringExtra(String name) {
7189 return mExtras == null ? null : mExtras.getString(name);
7190 }
7191
7192 /**
7193 * Retrieve extended data from the intent.
7194 *
7195 * @param name The name of the desired item.
7196 *
7197 * @return the value of an item that previously added with putExtra()
7198 * or null if no CharSequence value was found.
7199 *
7200 * @see #putExtra(String, CharSequence)
7201 */
7202 public CharSequence getCharSequenceExtra(String name) {
7203 return mExtras == null ? null : mExtras.getCharSequence(name);
7204 }
7205
7206 /**
7207 * Retrieve extended data from the intent.
7208 *
7209 * @param name The name of the desired item.
7210 *
7211 * @return the value of an item that previously added with putExtra()
7212 * or null if no Parcelable value was found.
7213 *
7214 * @see #putExtra(String, Parcelable)
7215 */
7216 public <T extends Parcelable> T getParcelableExtra(String name) {
7217 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7218 }
7219
7220 /**
7221 * Retrieve extended data from the intent.
7222 *
7223 * @param name The name of the desired item.
7224 *
7225 * @return the value of an item that previously added with putExtra()
7226 * or null if no Parcelable[] value was found.
7227 *
7228 * @see #putExtra(String, Parcelable[])
7229 */
7230 public Parcelable[] getParcelableArrayExtra(String name) {
7231 return mExtras == null ? null : mExtras.getParcelableArray(name);
7232 }
7233
7234 /**
7235 * Retrieve extended data from the intent.
7236 *
7237 * @param name The name of the desired item.
7238 *
7239 * @return the value of an item that previously added with putExtra()
7240 * or null if no ArrayList<Parcelable> value was found.
7241 *
7242 * @see #putParcelableArrayListExtra(String, ArrayList)
7243 */
7244 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7245 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7246 }
7247
7248 /**
7249 * Retrieve extended data from the intent.
7250 *
7251 * @param name The name of the desired item.
7252 *
7253 * @return the value of an item that previously added with putExtra()
7254 * or null if no Serializable value was found.
7255 *
7256 * @see #putExtra(String, Serializable)
7257 */
7258 public Serializable getSerializableExtra(String name) {
7259 return mExtras == null ? null : mExtras.getSerializable(name);
7260 }
7261
7262 /**
7263 * Retrieve extended data from the intent.
7264 *
7265 * @param name The name of the desired item.
7266 *
7267 * @return the value of an item that previously added with putExtra()
7268 * or null if no ArrayList<Integer> value was found.
7269 *
7270 * @see #putIntegerArrayListExtra(String, ArrayList)
7271 */
7272 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7273 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7274 }
7275
7276 /**
7277 * Retrieve extended data from the intent.
7278 *
7279 * @param name The name of the desired item.
7280 *
7281 * @return the value of an item that previously added with putExtra()
7282 * or null if no ArrayList<String> value was found.
7283 *
7284 * @see #putStringArrayListExtra(String, ArrayList)
7285 */
7286 public ArrayList<String> getStringArrayListExtra(String name) {
7287 return mExtras == null ? null : mExtras.getStringArrayList(name);
7288 }
7289
7290 /**
7291 * Retrieve extended data from the intent.
7292 *
7293 * @param name The name of the desired item.
7294 *
7295 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007296 * or null if no ArrayList<CharSequence> value was found.
7297 *
7298 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7299 */
7300 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7301 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7302 }
7303
7304 /**
7305 * Retrieve extended data from the intent.
7306 *
7307 * @param name The name of the desired item.
7308 *
7309 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007310 * or null if no boolean array value was found.
7311 *
7312 * @see #putExtra(String, boolean[])
7313 */
7314 public boolean[] getBooleanArrayExtra(String name) {
7315 return mExtras == null ? null : mExtras.getBooleanArray(name);
7316 }
7317
7318 /**
7319 * Retrieve extended data from the intent.
7320 *
7321 * @param name The name of the desired item.
7322 *
7323 * @return the value of an item that previously added with putExtra()
7324 * or null if no byte array value was found.
7325 *
7326 * @see #putExtra(String, byte[])
7327 */
7328 public byte[] getByteArrayExtra(String name) {
7329 return mExtras == null ? null : mExtras.getByteArray(name);
7330 }
7331
7332 /**
7333 * Retrieve extended data from the intent.
7334 *
7335 * @param name The name of the desired item.
7336 *
7337 * @return the value of an item that previously added with putExtra()
7338 * or null if no short array value was found.
7339 *
7340 * @see #putExtra(String, short[])
7341 */
7342 public short[] getShortArrayExtra(String name) {
7343 return mExtras == null ? null : mExtras.getShortArray(name);
7344 }
7345
7346 /**
7347 * Retrieve extended data from the intent.
7348 *
7349 * @param name The name of the desired item.
7350 *
7351 * @return the value of an item that previously added with putExtra()
7352 * or null if no char array value was found.
7353 *
7354 * @see #putExtra(String, char[])
7355 */
7356 public char[] getCharArrayExtra(String name) {
7357 return mExtras == null ? null : mExtras.getCharArray(name);
7358 }
7359
7360 /**
7361 * Retrieve extended data from the intent.
7362 *
7363 * @param name The name of the desired item.
7364 *
7365 * @return the value of an item that previously added with putExtra()
7366 * or null if no int array value was found.
7367 *
7368 * @see #putExtra(String, int[])
7369 */
7370 public int[] getIntArrayExtra(String name) {
7371 return mExtras == null ? null : mExtras.getIntArray(name);
7372 }
7373
7374 /**
7375 * Retrieve extended data from the intent.
7376 *
7377 * @param name The name of the desired item.
7378 *
7379 * @return the value of an item that previously added with putExtra()
7380 * or null if no long array value was found.
7381 *
7382 * @see #putExtra(String, long[])
7383 */
7384 public long[] getLongArrayExtra(String name) {
7385 return mExtras == null ? null : mExtras.getLongArray(name);
7386 }
7387
7388 /**
7389 * Retrieve extended data from the intent.
7390 *
7391 * @param name The name of the desired item.
7392 *
7393 * @return the value of an item that previously added with putExtra()
7394 * or null if no float array value was found.
7395 *
7396 * @see #putExtra(String, float[])
7397 */
7398 public float[] getFloatArrayExtra(String name) {
7399 return mExtras == null ? null : mExtras.getFloatArray(name);
7400 }
7401
7402 /**
7403 * Retrieve extended data from the intent.
7404 *
7405 * @param name The name of the desired item.
7406 *
7407 * @return the value of an item that previously added with putExtra()
7408 * or null if no double array value was found.
7409 *
7410 * @see #putExtra(String, double[])
7411 */
7412 public double[] getDoubleArrayExtra(String name) {
7413 return mExtras == null ? null : mExtras.getDoubleArray(name);
7414 }
7415
7416 /**
7417 * Retrieve extended data from the intent.
7418 *
7419 * @param name The name of the desired item.
7420 *
7421 * @return the value of an item that previously added with putExtra()
7422 * or null if no String array value was found.
7423 *
7424 * @see #putExtra(String, String[])
7425 */
7426 public String[] getStringArrayExtra(String name) {
7427 return mExtras == null ? null : mExtras.getStringArray(name);
7428 }
7429
7430 /**
7431 * Retrieve extended data from the intent.
7432 *
7433 * @param name The name of the desired item.
7434 *
7435 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007436 * or null if no CharSequence array value was found.
7437 *
7438 * @see #putExtra(String, CharSequence[])
7439 */
7440 public CharSequence[] getCharSequenceArrayExtra(String name) {
7441 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7442 }
7443
7444 /**
7445 * Retrieve extended data from the intent.
7446 *
7447 * @param name The name of the desired item.
7448 *
7449 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007450 * or null if no Bundle value was found.
7451 *
7452 * @see #putExtra(String, Bundle)
7453 */
7454 public Bundle getBundleExtra(String name) {
7455 return mExtras == null ? null : mExtras.getBundle(name);
7456 }
7457
7458 /**
7459 * Retrieve extended data from the intent.
7460 *
7461 * @param name The name of the desired item.
7462 *
7463 * @return the value of an item that previously added with putExtra()
7464 * or null if no IBinder value was found.
7465 *
7466 * @see #putExtra(String, IBinder)
7467 *
7468 * @deprecated
7469 * @hide
7470 */
7471 @Deprecated
7472 public IBinder getIBinderExtra(String name) {
7473 return mExtras == null ? null : mExtras.getIBinder(name);
7474 }
7475
7476 /**
7477 * Retrieve extended data from the intent.
7478 *
7479 * @param name The name of the desired item.
7480 * @param defaultValue The default value to return in case no item is
7481 * associated with the key 'name'
7482 *
7483 * @return the value of an item that previously added with putExtra()
7484 * or defaultValue if none was found.
7485 *
7486 * @see #putExtra
7487 *
7488 * @deprecated
7489 * @hide
7490 */
7491 @Deprecated
7492 public Object getExtra(String name, Object defaultValue) {
7493 Object result = defaultValue;
7494 if (mExtras != null) {
7495 Object result2 = mExtras.get(name);
7496 if (result2 != null) {
7497 result = result2;
7498 }
7499 }
7500
7501 return result;
7502 }
7503
7504 /**
7505 * Retrieves a map of extended data from the intent.
7506 *
7507 * @return the map of all extras previously added with putExtra(),
7508 * or null if none have been added.
7509 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007510 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007511 return (mExtras != null)
7512 ? new Bundle(mExtras)
7513 : null;
7514 }
7515
7516 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007517 * Filter extras to only basic types.
7518 * @hide
7519 */
7520 public void removeUnsafeExtras() {
7521 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007522 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007523 }
7524 }
7525
7526 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007527 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7528 * return itself as-is.
7529 * @hide
7530 */
7531 public boolean canStripForHistory() {
7532 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7533 }
7534
7535 /**
7536 * Call it when the system needs to keep an intent for logging purposes to remove fields
7537 * that are not needed for logging.
7538 * @hide
7539 */
7540 public Intent maybeStripForHistory() {
7541 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7542
7543 if (!canStripForHistory()) {
7544 return this;
7545 }
7546 return new Intent(this, COPY_MODE_HISTORY);
7547 }
7548
7549 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007550 * Retrieve any special flags associated with this intent. You will
7551 * normally just set them with {@link #setFlags} and let the system
7552 * take the appropriate action with them.
7553 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007554 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007555 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007556 * @see #addFlags
7557 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007558 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007559 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007560 return mFlags;
7561 }
7562
Dianne Hackborne7f97212011-02-24 14:40:20 -08007563 /** @hide */
7564 public boolean isExcludingStopped() {
7565 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7566 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7567 }
7568
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007569 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007570 * Retrieve the application package name this Intent is limited to. When
7571 * resolving an Intent, if non-null this limits the resolution to only
7572 * components in the given application package.
7573 *
7574 * @return The name of the application package for the Intent.
7575 *
7576 * @see #resolveActivity
7577 * @see #setPackage
7578 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007579 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007580 return mPackage;
7581 }
7582
7583 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007584 * Retrieve the concrete component associated with the intent. When receiving
7585 * an intent, this is the component that was found to best handle it (that is,
7586 * yourself) and will always be non-null; in all other cases it will be
7587 * null unless explicitly set.
7588 *
7589 * @return The name of the application component to handle the intent.
7590 *
7591 * @see #resolveActivity
7592 * @see #setComponent
7593 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007594 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007595 return mComponent;
7596 }
7597
7598 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007599 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7600 * used as a hint to the receiver for animations and the like. Null means that there
7601 * is no source bounds.
7602 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007603 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007604 return mSourceBounds;
7605 }
7606
7607 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007608 * Return the Activity component that should be used to handle this intent.
7609 * The appropriate component is determined based on the information in the
7610 * intent, evaluated as follows:
7611 *
7612 * <p>If {@link #getComponent} returns an explicit class, that is returned
7613 * without any further consideration.
7614 *
7615 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7616 * category to be considered.
7617 *
7618 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7619 * action.
7620 *
7621 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7622 * this type.
7623 *
7624 * <p>If {@link #addCategory} has added any categories, the activity must
7625 * handle ALL of the categories specified.
7626 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007627 * <p>If {@link #getPackage} is non-NULL, only activity components in
7628 * that application package will be considered.
7629 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007630 * <p>If there are no activities that satisfy all of these conditions, a
7631 * null string is returned.
7632 *
7633 * <p>If multiple activities are found to satisfy the intent, the one with
7634 * the highest priority will be used. If there are multiple activities
7635 * with the same priority, the system will either pick the best activity
7636 * based on user preference, or resolve to a system class that will allow
7637 * the user to pick an activity and forward from there.
7638 *
7639 * <p>This method is implemented simply by calling
7640 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7641 * true.</p>
7642 * <p> This API is called for you as part of starting an activity from an
7643 * intent. You do not normally need to call it yourself.</p>
7644 *
7645 * @param pm The package manager with which to resolve the Intent.
7646 *
7647 * @return Name of the component implementing an activity that can
7648 * display the intent.
7649 *
7650 * @see #setComponent
7651 * @see #getComponent
7652 * @see #resolveActivityInfo
7653 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007654 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007655 if (mComponent != null) {
7656 return mComponent;
7657 }
7658
7659 ResolveInfo info = pm.resolveActivity(
7660 this, PackageManager.MATCH_DEFAULT_ONLY);
7661 if (info != null) {
7662 return new ComponentName(
7663 info.activityInfo.applicationInfo.packageName,
7664 info.activityInfo.name);
7665 }
7666
7667 return null;
7668 }
7669
7670 /**
7671 * Resolve the Intent into an {@link ActivityInfo}
7672 * describing the activity that should execute the intent. Resolution
7673 * follows the same rules as described for {@link #resolveActivity}, but
7674 * you get back the completely information about the resolved activity
7675 * instead of just its class name.
7676 *
7677 * @param pm The package manager with which to resolve the Intent.
7678 * @param flags Addition information to retrieve as per
7679 * {@link PackageManager#getActivityInfo(ComponentName, int)
7680 * PackageManager.getActivityInfo()}.
7681 *
7682 * @return PackageManager.ActivityInfo
7683 *
7684 * @see #resolveActivity
7685 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007686 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7687 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007688 ActivityInfo ai = null;
7689 if (mComponent != null) {
7690 try {
7691 ai = pm.getActivityInfo(mComponent, flags);
7692 } catch (PackageManager.NameNotFoundException e) {
7693 // ignore
7694 }
7695 } else {
7696 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007697 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007698 if (info != null) {
7699 ai = info.activityInfo;
7700 }
7701 }
7702
7703 return ai;
7704 }
7705
7706 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007707 * Special function for use by the system to resolve service
7708 * intents to system apps. Throws an exception if there are
7709 * multiple potential matches to the Intent. Returns null if
7710 * there are no matches.
7711 * @hide
7712 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007713 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7714 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007715 if (mComponent != null) {
7716 return mComponent;
7717 }
7718
7719 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7720 if (results == null) {
7721 return null;
7722 }
7723 ComponentName comp = null;
7724 for (int i=0; i<results.size(); i++) {
7725 ResolveInfo ri = results.get(i);
7726 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7727 continue;
7728 }
7729 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7730 ri.serviceInfo.name);
7731 if (comp != null) {
7732 throw new IllegalStateException("Multiple system services handle " + this
7733 + ": " + comp + ", " + foundComp);
7734 }
7735 comp = foundComp;
7736 }
7737 return comp;
7738 }
7739
7740 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007741 * Set the general action to be performed.
7742 *
7743 * @param action An action name, such as ACTION_VIEW. Application-specific
7744 * actions should be prefixed with the vendor's package name.
7745 *
7746 * @return Returns the same Intent object, for chaining multiple calls
7747 * into a single statement.
7748 *
7749 * @see #getAction
7750 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007751 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007752 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007753 return this;
7754 }
7755
7756 /**
7757 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007758 * clears any type that was previously set by {@link #setType} or
7759 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007760 *
Nick Pellyccae4122012-01-09 14:12:58 -08007761 * <p><em>Note: scheme matching in the Android framework is
7762 * case-sensitive, unlike the formal RFC. As a result,
7763 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007764 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007765 * {@link #setDataAndNormalize}
7766 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007767 *
Nick Pellyccae4122012-01-09 14:12:58 -08007768 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007769 *
7770 * @return Returns the same Intent object, for chaining multiple calls
7771 * into a single statement.
7772 *
7773 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007774 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007775 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007776 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007777 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007778 mData = data;
7779 mType = null;
7780 return this;
7781 }
7782
7783 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007784 * Normalize and set the data this intent is operating on.
7785 *
7786 * <p>This method automatically clears any type that was
7787 * previously set (for example, by {@link #setType}).
7788 *
7789 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007790 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007791 * so really this is just a convenience method for
7792 * <pre>
7793 * setData(data.normalize())
7794 * </pre>
7795 *
7796 * @param data The Uri of the data this intent is now targeting.
7797 *
7798 * @return Returns the same Intent object, for chaining multiple calls
7799 * into a single statement.
7800 *
7801 * @see #getData
7802 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007803 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007804 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007805 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007806 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007807 }
7808
7809 /**
7810 * Set an explicit MIME data type.
7811 *
7812 * <p>This is used to create intents that only specify a type and not data,
7813 * for example to indicate the type of data to return.
7814 *
7815 * <p>This method automatically clears any data that was
7816 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007817 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007818 * <p><em>Note: MIME type matching in the Android framework is
7819 * case-sensitive, unlike formal RFC MIME types. As a result,
7820 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007821 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7822 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007823 *
7824 * @param type The MIME type of the data being handled by this intent.
7825 *
7826 * @return Returns the same Intent object, for chaining multiple calls
7827 * into a single statement.
7828 *
7829 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007830 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007831 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007832 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007833 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007834 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007835 mData = null;
7836 mType = type;
7837 return this;
7838 }
7839
7840 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007841 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007842 *
Nick Pellyccae4122012-01-09 14:12:58 -08007843 * <p>This is used to create intents that only specify a type and not data,
7844 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007845 *
Nick Pellyccae4122012-01-09 14:12:58 -08007846 * <p>This method automatically clears any data that was
7847 * previously set (for example by {@link #setData}).
7848 *
7849 * <p>The MIME type is normalized using
7850 * {@link #normalizeMimeType} before it is set,
7851 * so really this is just a convenience method for
7852 * <pre>
7853 * setType(Intent.normalizeMimeType(type))
7854 * </pre>
7855 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007856 * @param type The MIME type of the data being handled by this intent.
7857 *
7858 * @return Returns the same Intent object, for chaining multiple calls
7859 * into a single statement.
7860 *
Nick Pellyccae4122012-01-09 14:12:58 -08007861 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007862 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007863 * @see #normalizeMimeType
7864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007865 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007866 return setType(normalizeMimeType(type));
7867 }
7868
7869 /**
7870 * (Usually optional) Set the data for the intent along with an explicit
7871 * MIME data type. This method should very rarely be used -- it allows you
7872 * to override the MIME type that would ordinarily be inferred from the
7873 * data with your own type given here.
7874 *
7875 * <p><em>Note: MIME type and Uri scheme matching in the
7876 * Android framework is case-sensitive, unlike the formal RFC definitions.
7877 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007878 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007879 * {@link #setDataAndTypeAndNormalize}
7880 * to ensure that they are converted to lower case.</em>
7881 *
7882 * @param data The Uri of the data this intent is now targeting.
7883 * @param type The MIME type of the data being handled by this intent.
7884 *
7885 * @return Returns the same Intent object, for chaining multiple calls
7886 * into a single statement.
7887 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007888 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007889 * @see #setData
7890 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007891 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007892 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007893 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007894 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007895 mData = data;
7896 mType = type;
7897 return this;
7898 }
7899
7900 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007901 * (Usually optional) Normalize and set both the data Uri and an explicit
7902 * MIME data type. This method should very rarely be used -- it allows you
7903 * to override the MIME type that would ordinarily be inferred from the
7904 * data with your own type given here.
7905 *
7906 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007907 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007908 * before they are set, so really this is just a convenience method for
7909 * <pre>
7910 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7911 * </pre>
7912 *
7913 * @param data The Uri of the data this intent is now targeting.
7914 * @param type The MIME type of the data being handled by this intent.
7915 *
7916 * @return Returns the same Intent object, for chaining multiple calls
7917 * into a single statement.
7918 *
7919 * @see #setType
7920 * @see #setData
7921 * @see #setDataAndType
7922 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007923 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007924 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007925 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007926 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007927 }
7928
7929 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007930 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007931 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007932 * activities that provide <em>all</em> of the requested categories will be
7933 * used.
7934 *
7935 * @param category The desired category. This can be either one of the
7936 * predefined Intent categories, or a custom category in your own
7937 * namespace.
7938 *
7939 * @return Returns the same Intent object, for chaining multiple calls
7940 * into a single statement.
7941 *
7942 * @see #hasCategory
7943 * @see #removeCategory
7944 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007945 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007946 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007947 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007948 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007949 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007950 return this;
7951 }
7952
7953 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007954 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007955 *
7956 * @param category The category to remove.
7957 *
7958 * @see #addCategory
7959 */
7960 public void removeCategory(String category) {
7961 if (mCategories != null) {
7962 mCategories.remove(category);
7963 if (mCategories.size() == 0) {
7964 mCategories = null;
7965 }
7966 }
7967 }
7968
7969 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007970 * Set a selector for this Intent. This is a modification to the kinds of
7971 * things the Intent will match. If the selector is set, it will be used
7972 * when trying to find entities that can handle the Intent, instead of the
7973 * main contents of the Intent. This allows you build an Intent containing
7974 * a generic protocol while targeting it more specifically.
7975 *
7976 * <p>An example of where this may be used is with things like
7977 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7978 * Intent that will launch the Browser application. However, the correct
7979 * main entry point of an application is actually {@link #ACTION_MAIN}
7980 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7981 * used to specify the actual Activity to launch. If you launch the browser
7982 * with something different, undesired behavior may happen if the user has
7983 * previously or later launches it the normal way, since they do not match.
7984 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7985 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7986 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7987 *
7988 * <p>Setting a selector does not impact the behavior of
7989 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7990 * desired behavior of a selector -- it does not impact the base meaning
7991 * of the Intent, just what kinds of things will be matched against it
7992 * when determining who can handle it.</p>
7993 *
7994 * <p>You can not use both a selector and {@link #setPackage(String)} on
7995 * the same base Intent.</p>
7996 *
7997 * @param selector The desired selector Intent; set to null to not use
7998 * a special selector.
7999 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008000 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008001 if (selector == this) {
8002 throw new IllegalArgumentException(
8003 "Intent being set as a selector of itself");
8004 }
8005 if (selector != null && mPackage != null) {
8006 throw new IllegalArgumentException(
8007 "Can't set selector when package name is already set");
8008 }
8009 mSelector = selector;
8010 }
8011
8012 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008013 * Set a {@link ClipData} associated with this Intent. This replaces any
8014 * previously set ClipData.
8015 *
8016 * <p>The ClipData in an intent is not used for Intent matching or other
8017 * such operations. Semantically it is like extras, used to transmit
8018 * additional data with the Intent. The main feature of using this over
8019 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8020 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8021 * items included in the clip data. This is useful, in particular, if
8022 * you want to transmit an Intent containing multiple <code>content:</code>
8023 * URIs for which the recipient may not have global permission to access the
8024 * content provider.
8025 *
8026 * <p>If the ClipData contains items that are themselves Intents, any
8027 * grant flags in those Intents will be ignored. Only the top-level flags
8028 * of the main Intent are respected, and will be applied to all Uri or
8029 * Intent items in the clip (or sub-items of the clip).
8030 *
8031 * <p>The MIME type, label, and icon in the ClipData object are not
8032 * directly used by Intent. Applications should generally rely on the
8033 * MIME type of the Intent itself, not what it may find in the ClipData.
8034 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008035 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008036 *
8037 * @param clip The new clip to set. May be null to clear the current clip.
8038 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008039 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008040 mClipData = clip;
8041 }
8042
8043 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008044 * This is NOT a secure mechanism to identify the user who sent the intent.
8045 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8046 * who sent the intent.
8047 * @hide
8048 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008049 public void prepareToLeaveUser(int userId) {
8050 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8051 // We want mContentUserHint to refer to the original user, so don't do anything.
8052 if (mContentUserHint == UserHandle.USER_CURRENT) {
8053 mContentUserHint = userId;
8054 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008055 }
8056
8057 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008058 * Add extended data to the intent. The name must include a package
8059 * prefix, for example the app com.android.contacts would use names
8060 * like "com.android.contacts.ShowAll".
8061 *
8062 * @param name The name of the extra data, with package prefix.
8063 * @param value The boolean data value.
8064 *
8065 * @return Returns the same Intent object, for chaining multiple calls
8066 * into a single statement.
8067 *
8068 * @see #putExtras
8069 * @see #removeExtra
8070 * @see #getBooleanExtra(String, boolean)
8071 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008072 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008073 if (mExtras == null) {
8074 mExtras = new Bundle();
8075 }
8076 mExtras.putBoolean(name, value);
8077 return this;
8078 }
8079
8080 /**
8081 * Add extended data to the intent. The name must include a package
8082 * prefix, for example the app com.android.contacts would use names
8083 * like "com.android.contacts.ShowAll".
8084 *
8085 * @param name The name of the extra data, with package prefix.
8086 * @param value The byte data value.
8087 *
8088 * @return Returns the same Intent object, for chaining multiple calls
8089 * into a single statement.
8090 *
8091 * @see #putExtras
8092 * @see #removeExtra
8093 * @see #getByteExtra(String, byte)
8094 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008095 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008096 if (mExtras == null) {
8097 mExtras = new Bundle();
8098 }
8099 mExtras.putByte(name, value);
8100 return this;
8101 }
8102
8103 /**
8104 * Add extended data to the intent. The name must include a package
8105 * prefix, for example the app com.android.contacts would use names
8106 * like "com.android.contacts.ShowAll".
8107 *
8108 * @param name The name of the extra data, with package prefix.
8109 * @param value The char data value.
8110 *
8111 * @return Returns the same Intent object, for chaining multiple calls
8112 * into a single statement.
8113 *
8114 * @see #putExtras
8115 * @see #removeExtra
8116 * @see #getCharExtra(String, char)
8117 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008118 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008119 if (mExtras == null) {
8120 mExtras = new Bundle();
8121 }
8122 mExtras.putChar(name, value);
8123 return this;
8124 }
8125
8126 /**
8127 * Add extended data to the intent. The name must include a package
8128 * prefix, for example the app com.android.contacts would use names
8129 * like "com.android.contacts.ShowAll".
8130 *
8131 * @param name The name of the extra data, with package prefix.
8132 * @param value The short data value.
8133 *
8134 * @return Returns the same Intent object, for chaining multiple calls
8135 * into a single statement.
8136 *
8137 * @see #putExtras
8138 * @see #removeExtra
8139 * @see #getShortExtra(String, short)
8140 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008141 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008142 if (mExtras == null) {
8143 mExtras = new Bundle();
8144 }
8145 mExtras.putShort(name, value);
8146 return this;
8147 }
8148
8149 /**
8150 * Add extended data to the intent. The name must include a package
8151 * prefix, for example the app com.android.contacts would use names
8152 * like "com.android.contacts.ShowAll".
8153 *
8154 * @param name The name of the extra data, with package prefix.
8155 * @param value The integer data value.
8156 *
8157 * @return Returns the same Intent object, for chaining multiple calls
8158 * into a single statement.
8159 *
8160 * @see #putExtras
8161 * @see #removeExtra
8162 * @see #getIntExtra(String, int)
8163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008164 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008165 if (mExtras == null) {
8166 mExtras = new Bundle();
8167 }
8168 mExtras.putInt(name, value);
8169 return this;
8170 }
8171
8172 /**
8173 * Add extended data to the intent. The name must include a package
8174 * prefix, for example the app com.android.contacts would use names
8175 * like "com.android.contacts.ShowAll".
8176 *
8177 * @param name The name of the extra data, with package prefix.
8178 * @param value The long data value.
8179 *
8180 * @return Returns the same Intent object, for chaining multiple calls
8181 * into a single statement.
8182 *
8183 * @see #putExtras
8184 * @see #removeExtra
8185 * @see #getLongExtra(String, long)
8186 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008187 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 if (mExtras == null) {
8189 mExtras = new Bundle();
8190 }
8191 mExtras.putLong(name, value);
8192 return this;
8193 }
8194
8195 /**
8196 * Add extended data to the intent. The name must include a package
8197 * prefix, for example the app com.android.contacts would use names
8198 * like "com.android.contacts.ShowAll".
8199 *
8200 * @param name The name of the extra data, with package prefix.
8201 * @param value The float data value.
8202 *
8203 * @return Returns the same Intent object, for chaining multiple calls
8204 * into a single statement.
8205 *
8206 * @see #putExtras
8207 * @see #removeExtra
8208 * @see #getFloatExtra(String, float)
8209 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008210 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008211 if (mExtras == null) {
8212 mExtras = new Bundle();
8213 }
8214 mExtras.putFloat(name, value);
8215 return this;
8216 }
8217
8218 /**
8219 * Add extended data to the intent. The name must include a package
8220 * prefix, for example the app com.android.contacts would use names
8221 * like "com.android.contacts.ShowAll".
8222 *
8223 * @param name The name of the extra data, with package prefix.
8224 * @param value The double data value.
8225 *
8226 * @return Returns the same Intent object, for chaining multiple calls
8227 * into a single statement.
8228 *
8229 * @see #putExtras
8230 * @see #removeExtra
8231 * @see #getDoubleExtra(String, double)
8232 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008233 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008234 if (mExtras == null) {
8235 mExtras = new Bundle();
8236 }
8237 mExtras.putDouble(name, value);
8238 return this;
8239 }
8240
8241 /**
8242 * Add extended data to the intent. The name must include a package
8243 * prefix, for example the app com.android.contacts would use names
8244 * like "com.android.contacts.ShowAll".
8245 *
8246 * @param name The name of the extra data, with package prefix.
8247 * @param value The String data value.
8248 *
8249 * @return Returns the same Intent object, for chaining multiple calls
8250 * into a single statement.
8251 *
8252 * @see #putExtras
8253 * @see #removeExtra
8254 * @see #getStringExtra(String)
8255 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008256 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008257 if (mExtras == null) {
8258 mExtras = new Bundle();
8259 }
8260 mExtras.putString(name, value);
8261 return this;
8262 }
8263
8264 /**
8265 * Add extended data to the intent. The name must include a package
8266 * prefix, for example the app com.android.contacts would use names
8267 * like "com.android.contacts.ShowAll".
8268 *
8269 * @param name The name of the extra data, with package prefix.
8270 * @param value The CharSequence data value.
8271 *
8272 * @return Returns the same Intent object, for chaining multiple calls
8273 * into a single statement.
8274 *
8275 * @see #putExtras
8276 * @see #removeExtra
8277 * @see #getCharSequenceExtra(String)
8278 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008279 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 if (mExtras == null) {
8281 mExtras = new Bundle();
8282 }
8283 mExtras.putCharSequence(name, value);
8284 return this;
8285 }
8286
8287 /**
8288 * Add extended data to the intent. The name must include a package
8289 * prefix, for example the app com.android.contacts would use names
8290 * like "com.android.contacts.ShowAll".
8291 *
8292 * @param name The name of the extra data, with package prefix.
8293 * @param value The Parcelable data value.
8294 *
8295 * @return Returns the same Intent object, for chaining multiple calls
8296 * into a single statement.
8297 *
8298 * @see #putExtras
8299 * @see #removeExtra
8300 * @see #getParcelableExtra(String)
8301 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008302 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008303 if (mExtras == null) {
8304 mExtras = new Bundle();
8305 }
8306 mExtras.putParcelable(name, value);
8307 return this;
8308 }
8309
8310 /**
8311 * Add extended data to the intent. The name must include a package
8312 * prefix, for example the app com.android.contacts would use names
8313 * like "com.android.contacts.ShowAll".
8314 *
8315 * @param name The name of the extra data, with package prefix.
8316 * @param value The Parcelable[] data value.
8317 *
8318 * @return Returns the same Intent object, for chaining multiple calls
8319 * into a single statement.
8320 *
8321 * @see #putExtras
8322 * @see #removeExtra
8323 * @see #getParcelableArrayExtra(String)
8324 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008325 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008326 if (mExtras == null) {
8327 mExtras = new Bundle();
8328 }
8329 mExtras.putParcelableArray(name, value);
8330 return this;
8331 }
8332
8333 /**
8334 * Add extended data to the intent. The name must include a package
8335 * prefix, for example the app com.android.contacts would use names
8336 * like "com.android.contacts.ShowAll".
8337 *
8338 * @param name The name of the extra data, with package prefix.
8339 * @param value The ArrayList<Parcelable> data value.
8340 *
8341 * @return Returns the same Intent object, for chaining multiple calls
8342 * into a single statement.
8343 *
8344 * @see #putExtras
8345 * @see #removeExtra
8346 * @see #getParcelableArrayListExtra(String)
8347 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008348 public @NonNull Intent putParcelableArrayListExtra(String name,
8349 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008350 if (mExtras == null) {
8351 mExtras = new Bundle();
8352 }
8353 mExtras.putParcelableArrayList(name, value);
8354 return this;
8355 }
8356
8357 /**
8358 * Add extended data to the intent. The name must include a package
8359 * prefix, for example the app com.android.contacts would use names
8360 * like "com.android.contacts.ShowAll".
8361 *
8362 * @param name The name of the extra data, with package prefix.
8363 * @param value The ArrayList<Integer> data value.
8364 *
8365 * @return Returns the same Intent object, for chaining multiple calls
8366 * into a single statement.
8367 *
8368 * @see #putExtras
8369 * @see #removeExtra
8370 * @see #getIntegerArrayListExtra(String)
8371 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008372 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008373 if (mExtras == null) {
8374 mExtras = new Bundle();
8375 }
8376 mExtras.putIntegerArrayList(name, value);
8377 return this;
8378 }
8379
8380 /**
8381 * Add extended data to the intent. The name must include a package
8382 * prefix, for example the app com.android.contacts would use names
8383 * like "com.android.contacts.ShowAll".
8384 *
8385 * @param name The name of the extra data, with package prefix.
8386 * @param value The ArrayList<String> data value.
8387 *
8388 * @return Returns the same Intent object, for chaining multiple calls
8389 * into a single statement.
8390 *
8391 * @see #putExtras
8392 * @see #removeExtra
8393 * @see #getStringArrayListExtra(String)
8394 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008395 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008396 if (mExtras == null) {
8397 mExtras = new Bundle();
8398 }
8399 mExtras.putStringArrayList(name, value);
8400 return this;
8401 }
8402
8403 /**
8404 * Add extended data to the intent. The name must include a package
8405 * prefix, for example the app com.android.contacts would use names
8406 * like "com.android.contacts.ShowAll".
8407 *
8408 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008409 * @param value The ArrayList<CharSequence> data value.
8410 *
8411 * @return Returns the same Intent object, for chaining multiple calls
8412 * into a single statement.
8413 *
8414 * @see #putExtras
8415 * @see #removeExtra
8416 * @see #getCharSequenceArrayListExtra(String)
8417 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008418 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8419 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008420 if (mExtras == null) {
8421 mExtras = new Bundle();
8422 }
8423 mExtras.putCharSequenceArrayList(name, value);
8424 return this;
8425 }
8426
8427 /**
8428 * Add extended data to the intent. The name must include a package
8429 * prefix, for example the app com.android.contacts would use names
8430 * like "com.android.contacts.ShowAll".
8431 *
8432 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008433 * @param value The Serializable data value.
8434 *
8435 * @return Returns the same Intent object, for chaining multiple calls
8436 * into a single statement.
8437 *
8438 * @see #putExtras
8439 * @see #removeExtra
8440 * @see #getSerializableExtra(String)
8441 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008442 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008443 if (mExtras == null) {
8444 mExtras = new Bundle();
8445 }
8446 mExtras.putSerializable(name, value);
8447 return this;
8448 }
8449
8450 /**
8451 * Add extended data to the intent. The name must include a package
8452 * prefix, for example the app com.android.contacts would use names
8453 * like "com.android.contacts.ShowAll".
8454 *
8455 * @param name The name of the extra data, with package prefix.
8456 * @param value The boolean array data value.
8457 *
8458 * @return Returns the same Intent object, for chaining multiple calls
8459 * into a single statement.
8460 *
8461 * @see #putExtras
8462 * @see #removeExtra
8463 * @see #getBooleanArrayExtra(String)
8464 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008465 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 if (mExtras == null) {
8467 mExtras = new Bundle();
8468 }
8469 mExtras.putBooleanArray(name, value);
8470 return this;
8471 }
8472
8473 /**
8474 * Add extended data to the intent. The name must include a package
8475 * prefix, for example the app com.android.contacts would use names
8476 * like "com.android.contacts.ShowAll".
8477 *
8478 * @param name The name of the extra data, with package prefix.
8479 * @param value The byte array data value.
8480 *
8481 * @return Returns the same Intent object, for chaining multiple calls
8482 * into a single statement.
8483 *
8484 * @see #putExtras
8485 * @see #removeExtra
8486 * @see #getByteArrayExtra(String)
8487 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008488 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008489 if (mExtras == null) {
8490 mExtras = new Bundle();
8491 }
8492 mExtras.putByteArray(name, value);
8493 return this;
8494 }
8495
8496 /**
8497 * Add extended data to the intent. The name must include a package
8498 * prefix, for example the app com.android.contacts would use names
8499 * like "com.android.contacts.ShowAll".
8500 *
8501 * @param name The name of the extra data, with package prefix.
8502 * @param value The short array data value.
8503 *
8504 * @return Returns the same Intent object, for chaining multiple calls
8505 * into a single statement.
8506 *
8507 * @see #putExtras
8508 * @see #removeExtra
8509 * @see #getShortArrayExtra(String)
8510 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008511 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008512 if (mExtras == null) {
8513 mExtras = new Bundle();
8514 }
8515 mExtras.putShortArray(name, value);
8516 return this;
8517 }
8518
8519 /**
8520 * Add extended data to the intent. The name must include a package
8521 * prefix, for example the app com.android.contacts would use names
8522 * like "com.android.contacts.ShowAll".
8523 *
8524 * @param name The name of the extra data, with package prefix.
8525 * @param value The char array data value.
8526 *
8527 * @return Returns the same Intent object, for chaining multiple calls
8528 * into a single statement.
8529 *
8530 * @see #putExtras
8531 * @see #removeExtra
8532 * @see #getCharArrayExtra(String)
8533 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008534 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008535 if (mExtras == null) {
8536 mExtras = new Bundle();
8537 }
8538 mExtras.putCharArray(name, value);
8539 return this;
8540 }
8541
8542 /**
8543 * Add extended data to the intent. The name must include a package
8544 * prefix, for example the app com.android.contacts would use names
8545 * like "com.android.contacts.ShowAll".
8546 *
8547 * @param name The name of the extra data, with package prefix.
8548 * @param value The int array data value.
8549 *
8550 * @return Returns the same Intent object, for chaining multiple calls
8551 * into a single statement.
8552 *
8553 * @see #putExtras
8554 * @see #removeExtra
8555 * @see #getIntArrayExtra(String)
8556 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008557 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 if (mExtras == null) {
8559 mExtras = new Bundle();
8560 }
8561 mExtras.putIntArray(name, value);
8562 return this;
8563 }
8564
8565 /**
8566 * Add extended data to the intent. The name must include a package
8567 * prefix, for example the app com.android.contacts would use names
8568 * like "com.android.contacts.ShowAll".
8569 *
8570 * @param name The name of the extra data, with package prefix.
8571 * @param value The byte array data value.
8572 *
8573 * @return Returns the same Intent object, for chaining multiple calls
8574 * into a single statement.
8575 *
8576 * @see #putExtras
8577 * @see #removeExtra
8578 * @see #getLongArrayExtra(String)
8579 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008580 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 if (mExtras == null) {
8582 mExtras = new Bundle();
8583 }
8584 mExtras.putLongArray(name, value);
8585 return this;
8586 }
8587
8588 /**
8589 * Add extended data to the intent. The name must include a package
8590 * prefix, for example the app com.android.contacts would use names
8591 * like "com.android.contacts.ShowAll".
8592 *
8593 * @param name The name of the extra data, with package prefix.
8594 * @param value The float array data value.
8595 *
8596 * @return Returns the same Intent object, for chaining multiple calls
8597 * into a single statement.
8598 *
8599 * @see #putExtras
8600 * @see #removeExtra
8601 * @see #getFloatArrayExtra(String)
8602 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008603 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 if (mExtras == null) {
8605 mExtras = new Bundle();
8606 }
8607 mExtras.putFloatArray(name, value);
8608 return this;
8609 }
8610
8611 /**
8612 * Add extended data to the intent. The name must include a package
8613 * prefix, for example the app com.android.contacts would use names
8614 * like "com.android.contacts.ShowAll".
8615 *
8616 * @param name The name of the extra data, with package prefix.
8617 * @param value The double array data value.
8618 *
8619 * @return Returns the same Intent object, for chaining multiple calls
8620 * into a single statement.
8621 *
8622 * @see #putExtras
8623 * @see #removeExtra
8624 * @see #getDoubleArrayExtra(String)
8625 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008626 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008627 if (mExtras == null) {
8628 mExtras = new Bundle();
8629 }
8630 mExtras.putDoubleArray(name, value);
8631 return this;
8632 }
8633
8634 /**
8635 * Add extended data to the intent. The name must include a package
8636 * prefix, for example the app com.android.contacts would use names
8637 * like "com.android.contacts.ShowAll".
8638 *
8639 * @param name The name of the extra data, with package prefix.
8640 * @param value The String array data value.
8641 *
8642 * @return Returns the same Intent object, for chaining multiple calls
8643 * into a single statement.
8644 *
8645 * @see #putExtras
8646 * @see #removeExtra
8647 * @see #getStringArrayExtra(String)
8648 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008649 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650 if (mExtras == null) {
8651 mExtras = new Bundle();
8652 }
8653 mExtras.putStringArray(name, value);
8654 return this;
8655 }
8656
8657 /**
8658 * Add extended data to the intent. The name must include a package
8659 * prefix, for example the app com.android.contacts would use names
8660 * like "com.android.contacts.ShowAll".
8661 *
8662 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008663 * @param value The CharSequence array data value.
8664 *
8665 * @return Returns the same Intent object, for chaining multiple calls
8666 * into a single statement.
8667 *
8668 * @see #putExtras
8669 * @see #removeExtra
8670 * @see #getCharSequenceArrayExtra(String)
8671 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008672 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008673 if (mExtras == null) {
8674 mExtras = new Bundle();
8675 }
8676 mExtras.putCharSequenceArray(name, value);
8677 return this;
8678 }
8679
8680 /**
8681 * Add extended data to the intent. The name must include a package
8682 * prefix, for example the app com.android.contacts would use names
8683 * like "com.android.contacts.ShowAll".
8684 *
8685 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008686 * @param value The Bundle data value.
8687 *
8688 * @return Returns the same Intent object, for chaining multiple calls
8689 * into a single statement.
8690 *
8691 * @see #putExtras
8692 * @see #removeExtra
8693 * @see #getBundleExtra(String)
8694 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008695 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008696 if (mExtras == null) {
8697 mExtras = new Bundle();
8698 }
8699 mExtras.putBundle(name, value);
8700 return this;
8701 }
8702
8703 /**
8704 * Add extended data to the intent. The name must include a package
8705 * prefix, for example the app com.android.contacts would use names
8706 * like "com.android.contacts.ShowAll".
8707 *
8708 * @param name The name of the extra data, with package prefix.
8709 * @param value The IBinder data value.
8710 *
8711 * @return Returns the same Intent object, for chaining multiple calls
8712 * into a single statement.
8713 *
8714 * @see #putExtras
8715 * @see #removeExtra
8716 * @see #getIBinderExtra(String)
8717 *
8718 * @deprecated
8719 * @hide
8720 */
8721 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008722 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008723 if (mExtras == null) {
8724 mExtras = new Bundle();
8725 }
8726 mExtras.putIBinder(name, value);
8727 return this;
8728 }
8729
8730 /**
8731 * Copy all extras in 'src' in to this intent.
8732 *
8733 * @param src Contains the extras to copy.
8734 *
8735 * @see #putExtra
8736 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008737 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008738 if (src.mExtras != null) {
8739 if (mExtras == null) {
8740 mExtras = new Bundle(src.mExtras);
8741 } else {
8742 mExtras.putAll(src.mExtras);
8743 }
8744 }
8745 return this;
8746 }
8747
8748 /**
8749 * Add a set of extended data to the intent. The keys must include a package
8750 * prefix, for example the app com.android.contacts would use names
8751 * like "com.android.contacts.ShowAll".
8752 *
8753 * @param extras The Bundle of extras to add to this intent.
8754 *
8755 * @see #putExtra
8756 * @see #removeExtra
8757 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008758 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008759 if (mExtras == null) {
8760 mExtras = new Bundle();
8761 }
8762 mExtras.putAll(extras);
8763 return this;
8764 }
8765
8766 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008767 * Completely replace the extras in the Intent with the extras in the
8768 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008769 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008770 * @param src The exact extras contained in this Intent are copied
8771 * into the target intent, replacing any that were previously there.
8772 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008773 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008774 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8775 return this;
8776 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008777
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008778 /**
8779 * Completely replace the extras in the Intent with the given Bundle of
8780 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008781 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008782 * @param extras The new set of extras in the Intent, or null to erase
8783 * all extras.
8784 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008785 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008786 mExtras = extras != null ? new Bundle(extras) : null;
8787 return this;
8788 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008789
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008790 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008791 * Remove extended data from the intent.
8792 *
8793 * @see #putExtra
8794 */
8795 public void removeExtra(String name) {
8796 if (mExtras != null) {
8797 mExtras.remove(name);
8798 if (mExtras.size() == 0) {
8799 mExtras = null;
8800 }
8801 }
8802 }
8803
8804 /**
8805 * Set special flags controlling how this intent is handled. Most values
8806 * here depend on the type of component being executed by the Intent,
8807 * specifically the FLAG_ACTIVITY_* flags are all for use with
8808 * {@link Context#startActivity Context.startActivity()} and the
8809 * FLAG_RECEIVER_* flags are all for use with
8810 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8811 *
Scott Main7aee61f2011-02-08 11:25:01 -08008812 * <p>See the
8813 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8814 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008815 * the behavior of your application.
8816 *
8817 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008818 * @return Returns the same Intent object, for chaining multiple calls
8819 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008820 * @see #getFlags
8821 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008822 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008823 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008824 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008825 mFlags = flags;
8826 return this;
8827 }
8828
8829 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008830 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008831 *
8832 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008833 * @return Returns the same Intent object, for chaining multiple calls into
8834 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008835 * @see #setFlags
8836 * @see #getFlags
8837 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008838 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008839 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008840 mFlags |= flags;
8841 return this;
8842 }
8843
8844 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008845 * Remove these flags from the intent.
8846 *
8847 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008848 * @see #setFlags
8849 * @see #getFlags
8850 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008851 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008852 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008853 mFlags &= ~flags;
8854 }
8855
8856 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008857 * (Usually optional) Set an explicit application package name that limits
8858 * the components this Intent will resolve to. If left to the default
8859 * value of null, all components in all applications will considered.
8860 * If non-null, the Intent can only match the components in the given
8861 * application package.
8862 *
8863 * @param packageName The name of the application package to handle the
8864 * intent, or null to allow any application package.
8865 *
8866 * @return Returns the same Intent object, for chaining multiple calls
8867 * into a single statement.
8868 *
8869 * @see #getPackage
8870 * @see #resolveActivity
8871 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008872 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008873 if (packageName != null && mSelector != null) {
8874 throw new IllegalArgumentException(
8875 "Can't set package name when selector is already set");
8876 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008877 mPackage = packageName;
8878 return this;
8879 }
8880
8881 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008882 * (Usually optional) Explicitly set the component to handle the intent.
8883 * If left with the default value of null, the system will determine the
8884 * appropriate class to use based on the other fields (action, data,
8885 * type, categories) in the Intent. If this class is defined, the
8886 * specified class will always be used regardless of the other fields. You
8887 * should only set this value when you know you absolutely want a specific
8888 * class to be used; otherwise it is better to let the system find the
8889 * appropriate class so that you will respect the installed applications
8890 * and user preferences.
8891 *
8892 * @param component The name of the application component to handle the
8893 * intent, or null to let the system find one for you.
8894 *
8895 * @return Returns the same Intent object, for chaining multiple calls
8896 * into a single statement.
8897 *
8898 * @see #setClass
8899 * @see #setClassName(Context, String)
8900 * @see #setClassName(String, String)
8901 * @see #getComponent
8902 * @see #resolveActivity
8903 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008904 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008905 mComponent = component;
8906 return this;
8907 }
8908
8909 /**
8910 * Convenience for calling {@link #setComponent} with an
8911 * explicit class name.
8912 *
8913 * @param packageContext A Context of the application package implementing
8914 * this class.
8915 * @param className The name of a class inside of the application package
8916 * that will be used as the component for this Intent.
8917 *
8918 * @return Returns the same Intent object, for chaining multiple calls
8919 * into a single statement.
8920 *
8921 * @see #setComponent
8922 * @see #setClass
8923 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008924 public @NonNull Intent setClassName(@NonNull Context packageContext,
8925 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008926 mComponent = new ComponentName(packageContext, className);
8927 return this;
8928 }
8929
8930 /**
8931 * Convenience for calling {@link #setComponent} with an
8932 * explicit application package name and class name.
8933 *
8934 * @param packageName The name of the package implementing the desired
8935 * component.
8936 * @param className The name of a class inside of the application package
8937 * that will be used as the component for this Intent.
8938 *
8939 * @return Returns the same Intent object, for chaining multiple calls
8940 * into a single statement.
8941 *
8942 * @see #setComponent
8943 * @see #setClass
8944 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008945 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008946 mComponent = new ComponentName(packageName, className);
8947 return this;
8948 }
8949
8950 /**
8951 * Convenience for calling {@link #setComponent(ComponentName)} with the
8952 * name returned by a {@link Class} object.
8953 *
8954 * @param packageContext A Context of the application package implementing
8955 * this class.
8956 * @param cls The class name to set, equivalent to
8957 * <code>setClassName(context, cls.getName())</code>.
8958 *
8959 * @return Returns the same Intent object, for chaining multiple calls
8960 * into a single statement.
8961 *
8962 * @see #setComponent
8963 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008964 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008965 mComponent = new ComponentName(packageContext, cls);
8966 return this;
8967 }
8968
8969 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008970 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8971 * used as a hint to the receiver for animations and the like. Null means that there
8972 * is no source bounds.
8973 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008974 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008975 if (r != null) {
8976 mSourceBounds = new Rect(r);
8977 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008978 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008979 }
8980 }
8981
Tor Norbyed9273d62013-05-30 15:59:53 -07008982 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07008983 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
8984 FILL_IN_ACTION,
8985 FILL_IN_DATA,
8986 FILL_IN_CATEGORIES,
8987 FILL_IN_COMPONENT,
8988 FILL_IN_PACKAGE,
8989 FILL_IN_SOURCE_BOUNDS,
8990 FILL_IN_SELECTOR,
8991 FILL_IN_CLIP_DATA
8992 })
Tor Norbyed9273d62013-05-30 15:59:53 -07008993 @Retention(RetentionPolicy.SOURCE)
8994 public @interface FillInFlags {}
8995
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008996 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008997 * Use with {@link #fillIn} to allow the current action value to be
8998 * overwritten, even if it is already set.
8999 */
9000 public static final int FILL_IN_ACTION = 1<<0;
9001
9002 /**
9003 * Use with {@link #fillIn} to allow the current data or type value
9004 * overwritten, even if it is already set.
9005 */
9006 public static final int FILL_IN_DATA = 1<<1;
9007
9008 /**
9009 * Use with {@link #fillIn} to allow the current categories to be
9010 * overwritten, even if they are already set.
9011 */
9012 public static final int FILL_IN_CATEGORIES = 1<<2;
9013
9014 /**
9015 * Use with {@link #fillIn} to allow the current component value to be
9016 * overwritten, even if it is already set.
9017 */
9018 public static final int FILL_IN_COMPONENT = 1<<3;
9019
9020 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009021 * Use with {@link #fillIn} to allow the current package value to be
9022 * overwritten, even if it is already set.
9023 */
9024 public static final int FILL_IN_PACKAGE = 1<<4;
9025
9026 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009027 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009028 * overwritten, even if it is already set.
9029 */
9030 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9031
9032 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009033 * Use with {@link #fillIn} to allow the current selector to be
9034 * overwritten, even if it is already set.
9035 */
9036 public static final int FILL_IN_SELECTOR = 1<<6;
9037
9038 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009039 * Use with {@link #fillIn} to allow the current ClipData to be
9040 * overwritten, even if it is already set.
9041 */
9042 public static final int FILL_IN_CLIP_DATA = 1<<7;
9043
9044 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009045 * Copy the contents of <var>other</var> in to this object, but only
9046 * where fields are not defined by this object. For purposes of a field
9047 * being defined, the following pieces of data in the Intent are
9048 * considered to be separate fields:
9049 *
9050 * <ul>
9051 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009052 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009053 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9054 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009055 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009056 * <li> component, as set by {@link #setComponent(ComponentName)} or
9057 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009058 * <li> source bounds, as set by {@link #setSourceBounds}.
9059 * <li> selector, as set by {@link #setSelector(Intent)}.
9060 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009061 * <li> each top-level name in the associated extras.
9062 * </ul>
9063 *
9064 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009065 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009066 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9067 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9068 * the restriction where the corresponding field will not be replaced if
9069 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009070 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009071 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9072 * is explicitly specified. The selector will only be copied if
9073 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009074 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009075 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9076 * and Intent B with {action="gotit", data-type="some/thing",
9077 * categories="one","two"}.
9078 *
9079 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9080 * containing: {action="gotit", data-type="some/thing",
9081 * categories="bar"}.
9082 *
9083 * @param other Another Intent whose values are to be used to fill in
9084 * the current one.
9085 * @param flags Options to control which fields can be filled in.
9086 *
9087 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009088 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009089 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009090 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009091 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009092 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009093 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009094 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009095 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009096 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009097 if (other.mAction != null
9098 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009099 mAction = other.mAction;
9100 changes |= FILL_IN_ACTION;
9101 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009102 if ((other.mData != null || other.mType != null)
9103 && ((mData == null && mType == null)
9104 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009105 mData = other.mData;
9106 mType = other.mType;
9107 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009108 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009109 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009110 if (other.mCategories != null
9111 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009112 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009113 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 }
9115 changes |= FILL_IN_CATEGORIES;
9116 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009117 if (other.mPackage != null
9118 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009119 // Only do this if mSelector is not set.
9120 if (mSelector == null) {
9121 mPackage = other.mPackage;
9122 changes |= FILL_IN_PACKAGE;
9123 }
9124 }
9125 // Selector is special: it can only be set if explicitly allowed,
9126 // for the same reason as the component name.
9127 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9128 if (mPackage == null) {
9129 mSelector = new Intent(other.mSelector);
9130 mPackage = null;
9131 changes |= FILL_IN_SELECTOR;
9132 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009133 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009134 if (other.mClipData != null
9135 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9136 mClipData = other.mClipData;
9137 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009138 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009139 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009140 // Component is special: it can -only- be set if explicitly allowed,
9141 // since otherwise the sender could force the intent somewhere the
9142 // originator didn't intend.
9143 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009144 mComponent = other.mComponent;
9145 changes |= FILL_IN_COMPONENT;
9146 }
9147 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009148 if (other.mSourceBounds != null
9149 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9150 mSourceBounds = new Rect(other.mSourceBounds);
9151 changes |= FILL_IN_SOURCE_BOUNDS;
9152 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009153 if (mExtras == null) {
9154 if (other.mExtras != null) {
9155 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009156 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009157 }
9158 } else if (other.mExtras != null) {
9159 try {
9160 Bundle newb = new Bundle(other.mExtras);
9161 newb.putAll(mExtras);
9162 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009163 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009164 } catch (RuntimeException e) {
9165 // Modifying the extras can cause us to unparcel the contents
9166 // of the bundle, and if we do this in the system process that
9167 // may fail. We really should handle this (i.e., the Bundle
9168 // impl shouldn't be on top of a plain map), but for now just
9169 // ignore it and keep the original contents. :(
9170 Log.w("Intent", "Failure filling in extras", e);
9171 }
9172 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009173 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9174 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9175 mContentUserHint = other.mContentUserHint;
9176 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009177 return changes;
9178 }
9179
9180 /**
9181 * Wrapper class holding an Intent and implementing comparisons on it for
9182 * the purpose of filtering. The class implements its
9183 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9184 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9185 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9186 * on the wrapped Intent.
9187 */
9188 public static final class FilterComparison {
9189 private final Intent mIntent;
9190 private final int mHashCode;
9191
9192 public FilterComparison(Intent intent) {
9193 mIntent = intent;
9194 mHashCode = intent.filterHashCode();
9195 }
9196
9197 /**
9198 * Return the Intent that this FilterComparison represents.
9199 * @return Returns the Intent held by the FilterComparison. Do
9200 * not modify!
9201 */
9202 public Intent getIntent() {
9203 return mIntent;
9204 }
9205
9206 @Override
9207 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009208 if (obj instanceof FilterComparison) {
9209 Intent other = ((FilterComparison)obj).mIntent;
9210 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009211 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009212 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009213 }
9214
9215 @Override
9216 public int hashCode() {
9217 return mHashCode;
9218 }
9219 }
9220
9221 /**
9222 * Determine if two intents are the same for the purposes of intent
9223 * resolution (filtering). That is, if their action, data, type,
9224 * class, and categories are the same. This does <em>not</em> compare
9225 * any extra data included in the intents.
9226 *
9227 * @param other The other Intent to compare against.
9228 *
9229 * @return Returns true if action, data, type, class, and categories
9230 * are the same.
9231 */
9232 public boolean filterEquals(Intent other) {
9233 if (other == null) {
9234 return false;
9235 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009236 if (!Objects.equals(this.mAction, other.mAction)) return false;
9237 if (!Objects.equals(this.mData, other.mData)) return false;
9238 if (!Objects.equals(this.mType, other.mType)) return false;
9239 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9240 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9241 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009242
9243 return true;
9244 }
9245
9246 /**
9247 * Generate hash code that matches semantics of filterEquals().
9248 *
9249 * @return Returns the hash value of the action, data, type, class, and
9250 * categories.
9251 *
9252 * @see #filterEquals
9253 */
9254 public int filterHashCode() {
9255 int code = 0;
9256 if (mAction != null) {
9257 code += mAction.hashCode();
9258 }
9259 if (mData != null) {
9260 code += mData.hashCode();
9261 }
9262 if (mType != null) {
9263 code += mType.hashCode();
9264 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009265 if (mPackage != null) {
9266 code += mPackage.hashCode();
9267 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009268 if (mComponent != null) {
9269 code += mComponent.hashCode();
9270 }
9271 if (mCategories != null) {
9272 code += mCategories.hashCode();
9273 }
9274 return code;
9275 }
9276
9277 @Override
9278 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009279 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009280
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009281 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009282 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009283 b.append(" }");
9284
9285 return b.toString();
9286 }
9287
9288 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009289 public String toInsecureString() {
9290 StringBuilder b = new StringBuilder(128);
9291
9292 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009293 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009294 b.append(" }");
9295
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009296 return b.toString();
9297 }
Romain Guy4969af72009-06-17 10:53:19 -07009298
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009299 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009300 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009301 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009302
9303 b.append("Intent { ");
9304 toShortString(b, false, true, true, true);
9305 b.append(" }");
9306
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009307 return b.toString();
9308 }
9309
9310 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009311 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9312 StringBuilder b = new StringBuilder(128);
9313 toShortString(b, secure, comp, extras, clip);
9314 return b.toString();
9315 }
9316
9317 /** @hide */
9318 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9319 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009320 boolean first = true;
9321 if (mAction != null) {
9322 b.append("act=").append(mAction);
9323 first = false;
9324 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009325 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009326 if (!first) {
9327 b.append(' ');
9328 }
9329 first = false;
9330 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009331 for (int i=0; i<mCategories.size(); i++) {
9332 if (i > 0) b.append(',');
9333 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009334 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009335 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009336 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009337 if (mData != null) {
9338 if (!first) {
9339 b.append(' ');
9340 }
9341 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009342 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009343 if (secure) {
9344 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009345 } else {
9346 b.append(mData);
9347 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009348 }
9349 if (mType != null) {
9350 if (!first) {
9351 b.append(' ');
9352 }
9353 first = false;
9354 b.append("typ=").append(mType);
9355 }
9356 if (mFlags != 0) {
9357 if (!first) {
9358 b.append(' ');
9359 }
9360 first = false;
9361 b.append("flg=0x").append(Integer.toHexString(mFlags));
9362 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009363 if (mPackage != null) {
9364 if (!first) {
9365 b.append(' ');
9366 }
9367 first = false;
9368 b.append("pkg=").append(mPackage);
9369 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009370 if (comp && mComponent != null) {
9371 if (!first) {
9372 b.append(' ');
9373 }
9374 first = false;
9375 b.append("cmp=").append(mComponent.flattenToShortString());
9376 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009377 if (mSourceBounds != null) {
9378 if (!first) {
9379 b.append(' ');
9380 }
9381 first = false;
9382 b.append("bnds=").append(mSourceBounds.toShortString());
9383 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009384 if (mClipData != null) {
9385 if (!first) {
9386 b.append(' ');
9387 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009388 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009389 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009390 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009391 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009392 if (mClipData.getDescription() != null) {
9393 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9394 } else {
9395 first = true;
9396 }
9397 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009398 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009399 first = false;
9400 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009401 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009402 if (extras && mExtras != null) {
9403 if (!first) {
9404 b.append(' ');
9405 }
9406 first = false;
9407 b.append("(has extras)");
9408 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009409 if (mContentUserHint != UserHandle.USER_CURRENT) {
9410 if (!first) {
9411 b.append(' ');
9412 }
9413 first = false;
9414 b.append("u=").append(mContentUserHint);
9415 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009416 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009417 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009418 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009419 b.append("}");
9420 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009421 }
9422
Yi Jin129fc6c2017-09-28 15:48:38 -07009423 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009424 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9425 // Same input parameters that toString() gives to toShortString().
9426 writeToProto(proto, fieldId, true, true, true, false);
9427 }
9428
9429 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009430 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9431 boolean extras, boolean clip) {
9432 long token = proto.start(fieldId);
9433 if (mAction != null) {
9434 proto.write(IntentProto.ACTION, mAction);
9435 }
9436 if (mCategories != null) {
9437 for (String category : mCategories) {
9438 proto.write(IntentProto.CATEGORIES, category);
9439 }
9440 }
9441 if (mData != null) {
9442 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9443 }
9444 if (mType != null) {
9445 proto.write(IntentProto.TYPE, mType);
9446 }
9447 if (mFlags != 0) {
9448 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9449 }
9450 if (mPackage != null) {
9451 proto.write(IntentProto.PACKAGE, mPackage);
9452 }
9453 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009454 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009455 }
9456 if (mSourceBounds != null) {
9457 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9458 }
9459 if (mClipData != null) {
9460 StringBuilder b = new StringBuilder();
9461 if (clip) {
9462 mClipData.toShortString(b);
9463 } else {
9464 mClipData.toShortStringShortItems(b, false);
9465 }
9466 proto.write(IntentProto.CLIP_DATA, b.toString());
9467 }
9468 if (extras && mExtras != null) {
9469 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9470 }
9471 if (mContentUserHint != 0) {
9472 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9473 }
9474 if (mSelector != null) {
9475 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9476 }
9477 proto.end(token);
9478 }
9479
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009480 /**
9481 * Call {@link #toUri} with 0 flags.
9482 * @deprecated Use {@link #toUri} instead.
9483 */
9484 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009485 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009486 return toUri(0);
9487 }
9488
9489 /**
9490 * Convert this Intent into a String holding a URI representation of it.
9491 * The returned URI string has been properly URI encoded, so it can be
9492 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9493 * Intent's data as the base URI, with an additional fragment describing
9494 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009495 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009496 * <p>You can convert the returned string back to an Intent with
9497 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009498 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009499 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009500 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009501 * @return Returns a URI encoding URI string describing the entire contents
9502 * of the Intent.
9503 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009504 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009505 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009506 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9507 if (mPackage == null) {
9508 throw new IllegalArgumentException(
9509 "Intent must include an explicit package name to build an android-app: "
9510 + this);
9511 }
9512 uri.append("android-app://");
9513 uri.append(mPackage);
9514 String scheme = null;
9515 if (mData != null) {
9516 scheme = mData.getScheme();
9517 if (scheme != null) {
9518 uri.append('/');
9519 uri.append(scheme);
9520 String authority = mData.getEncodedAuthority();
9521 if (authority != null) {
9522 uri.append('/');
9523 uri.append(authority);
9524 String path = mData.getEncodedPath();
9525 if (path != null) {
9526 uri.append(path);
9527 }
9528 String queryParams = mData.getEncodedQuery();
9529 if (queryParams != null) {
9530 uri.append('?');
9531 uri.append(queryParams);
9532 }
9533 String fragment = mData.getEncodedFragment();
9534 if (fragment != null) {
9535 uri.append('#');
9536 uri.append(fragment);
9537 }
9538 }
9539 }
9540 }
9541 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9542 mPackage, flags);
9543 return uri.toString();
9544 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009545 String scheme = null;
9546 if (mData != null) {
9547 String data = mData.toString();
9548 if ((flags&URI_INTENT_SCHEME) != 0) {
9549 final int N = data.length();
9550 for (int i=0; i<N; i++) {
9551 char c = data.charAt(i);
9552 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009553 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009554 continue;
9555 }
9556 if (c == ':' && i > 0) {
9557 // Valid scheme.
9558 scheme = data.substring(0, i);
9559 uri.append("intent:");
9560 data = data.substring(i+1);
9561 break;
9562 }
Tom Taylord4a47292009-12-21 13:59:18 -08009563
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009564 // No scheme.
9565 break;
9566 }
9567 }
9568 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009569
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009570 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9571 uri.append("intent:");
9572 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009573
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009574 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009575
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009576 return uri.toString();
9577 }
9578
9579 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9580 String defPackage, int flags) {
9581 StringBuilder frag = new StringBuilder(128);
9582
9583 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009584 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009585 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009586 // Note that for now we are not going to try to handle the
9587 // data part; not clear how to represent this as a URI, and
9588 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009589 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9590 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009591 }
9592
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009593 if (frag.length() > 0) {
9594 uri.append("#Intent;");
9595 uri.append(frag);
9596 uri.append("end");
9597 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009598 }
9599
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009600 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9601 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009602 if (scheme != null) {
9603 uri.append("scheme=").append(scheme).append(';');
9604 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009605 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009606 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009607 }
9608 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009609 for (int i=0; i<mCategories.size(); i++) {
9610 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009611 }
9612 }
9613 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009614 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009615 }
9616 if (mFlags != 0) {
9617 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9618 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009619 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009620 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9621 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009622 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009623 uri.append("component=").append(Uri.encode(
9624 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009625 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009626 if (mSourceBounds != null) {
9627 uri.append("sourceBounds=")
9628 .append(Uri.encode(mSourceBounds.flattenToString()))
9629 .append(';');
9630 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009631 if (mExtras != null) {
9632 for (String key : mExtras.keySet()) {
9633 final Object value = mExtras.get(key);
9634 char entryType =
9635 value instanceof String ? 'S' :
9636 value instanceof Boolean ? 'B' :
9637 value instanceof Byte ? 'b' :
9638 value instanceof Character ? 'c' :
9639 value instanceof Double ? 'd' :
9640 value instanceof Float ? 'f' :
9641 value instanceof Integer ? 'i' :
9642 value instanceof Long ? 'l' :
9643 value instanceof Short ? 's' :
9644 '\0';
9645
9646 if (entryType != '\0') {
9647 uri.append(entryType);
9648 uri.append('.');
9649 uri.append(Uri.encode(key));
9650 uri.append('=');
9651 uri.append(Uri.encode(value.toString()));
9652 uri.append(';');
9653 }
9654 }
9655 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009656 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009658 public int describeContents() {
9659 return (mExtras != null) ? mExtras.describeContents() : 0;
9660 }
9661
9662 public void writeToParcel(Parcel out, int flags) {
9663 out.writeString(mAction);
9664 Uri.writeToParcel(out, mData);
9665 out.writeString(mType);
9666 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009667 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009668 ComponentName.writeToParcel(mComponent, out);
9669
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009670 if (mSourceBounds != null) {
9671 out.writeInt(1);
9672 mSourceBounds.writeToParcel(out, flags);
9673 } else {
9674 out.writeInt(0);
9675 }
9676
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009677 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009678 final int N = mCategories.size();
9679 out.writeInt(N);
9680 for (int i=0; i<N; i++) {
9681 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009682 }
9683 } else {
9684 out.writeInt(0);
9685 }
9686
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009687 if (mSelector != null) {
9688 out.writeInt(1);
9689 mSelector.writeToParcel(out, flags);
9690 } else {
9691 out.writeInt(0);
9692 }
9693
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009694 if (mClipData != null) {
9695 out.writeInt(1);
9696 mClipData.writeToParcel(out, flags);
9697 } else {
9698 out.writeInt(0);
9699 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009700 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009701 out.writeBundle(mExtras);
9702 }
9703
9704 public static final Parcelable.Creator<Intent> CREATOR
9705 = new Parcelable.Creator<Intent>() {
9706 public Intent createFromParcel(Parcel in) {
9707 return new Intent(in);
9708 }
9709 public Intent[] newArray(int size) {
9710 return new Intent[size];
9711 }
9712 };
9713
Dianne Hackborneb034652009-09-07 00:49:58 -07009714 /** @hide */
9715 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009716 readFromParcel(in);
9717 }
9718
9719 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009720 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009721 mData = Uri.CREATOR.createFromParcel(in);
9722 mType = in.readString();
9723 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009724 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009725 mComponent = ComponentName.readFromParcel(in);
9726
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009727 if (in.readInt() != 0) {
9728 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9729 }
9730
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009731 int N = in.readInt();
9732 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009733 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009734 int i;
9735 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009736 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009737 }
9738 } else {
9739 mCategories = null;
9740 }
9741
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009742 if (in.readInt() != 0) {
9743 mSelector = new Intent(in);
9744 }
9745
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009746 if (in.readInt() != 0) {
9747 mClipData = new ClipData(in);
9748 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009749 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009750 mExtras = in.readBundle();
9751 }
9752
9753 /**
9754 * Parses the "intent" element (and its children) from XML and instantiates
9755 * an Intent object. The given XML parser should be located at the tag
9756 * where parsing should start (often named "intent"), from which the
9757 * basic action, data, type, and package and class name will be
9758 * retrieved. The function will then parse in to any child elements,
9759 * looking for <category android:name="xxx"> tags to add categories and
9760 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9761 * to the intent.
9762 *
9763 * @param resources The Resources to use when inflating resources.
9764 * @param parser The XML parser pointing at an "intent" tag.
9765 * @param attrs The AttributeSet interface for retrieving extended
9766 * attribute data at the current <var>parser</var> location.
9767 * @return An Intent object matching the XML data.
9768 * @throws XmlPullParserException If there was an XML parsing error.
9769 * @throws IOException If there was an I/O error.
9770 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009771 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9772 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009773 throws XmlPullParserException, IOException {
9774 Intent intent = new Intent();
9775
9776 TypedArray sa = resources.obtainAttributes(attrs,
9777 com.android.internal.R.styleable.Intent);
9778
9779 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9780
9781 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9782 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9783 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9784
9785 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9786 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9787 if (packageName != null && className != null) {
9788 intent.setComponent(new ComponentName(packageName, className));
9789 }
9790
9791 sa.recycle();
9792
9793 int outerDepth = parser.getDepth();
9794 int type;
9795 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9796 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9797 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9798 continue;
9799 }
9800
9801 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009802 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009803 sa = resources.obtainAttributes(attrs,
9804 com.android.internal.R.styleable.IntentCategory);
9805 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9806 sa.recycle();
9807
9808 if (cat != null) {
9809 intent.addCategory(cat);
9810 }
9811 XmlUtils.skipCurrentTag(parser);
9812
Craig Mautner21d24a22014-04-23 11:45:37 -07009813 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009814 if (intent.mExtras == null) {
9815 intent.mExtras = new Bundle();
9816 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009817 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009818 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009819
9820 } else {
9821 XmlUtils.skipCurrentTag(parser);
9822 }
9823 }
9824
9825 return intent;
9826 }
Nick Pellyccae4122012-01-09 14:12:58 -08009827
Craig Mautner21d24a22014-04-23 11:45:37 -07009828 /** @hide */
9829 public void saveToXml(XmlSerializer out) throws IOException {
9830 if (mAction != null) {
9831 out.attribute(null, ATTR_ACTION, mAction);
9832 }
9833 if (mData != null) {
9834 out.attribute(null, ATTR_DATA, mData.toString());
9835 }
9836 if (mType != null) {
9837 out.attribute(null, ATTR_TYPE, mType);
9838 }
9839 if (mComponent != null) {
9840 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9841 }
9842 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9843
9844 if (mCategories != null) {
9845 out.startTag(null, TAG_CATEGORIES);
9846 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9847 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9848 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009849 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009850 }
9851 }
9852
9853 /** @hide */
9854 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9855 XmlPullParserException {
9856 Intent intent = new Intent();
9857 final int outerDepth = in.getDepth();
9858
9859 int attrCount = in.getAttributeCount();
9860 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9861 final String attrName = in.getAttributeName(attrNdx);
9862 final String attrValue = in.getAttributeValue(attrNdx);
9863 if (ATTR_ACTION.equals(attrName)) {
9864 intent.setAction(attrValue);
9865 } else if (ATTR_DATA.equals(attrName)) {
9866 intent.setData(Uri.parse(attrValue));
9867 } else if (ATTR_TYPE.equals(attrName)) {
9868 intent.setType(attrValue);
9869 } else if (ATTR_COMPONENT.equals(attrName)) {
9870 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9871 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009872 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009873 } else {
9874 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9875 }
9876 }
9877
9878 int event;
9879 String name;
9880 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9881 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9882 if (event == XmlPullParser.START_TAG) {
9883 name = in.getName();
9884 if (TAG_CATEGORIES.equals(name)) {
9885 attrCount = in.getAttributeCount();
9886 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9887 intent.addCategory(in.getAttributeValue(attrNdx));
9888 }
9889 } else {
9890 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9891 XmlUtils.skipCurrentTag(in);
9892 }
9893 }
9894 }
9895
9896 return intent;
9897 }
9898
Nick Pellyccae4122012-01-09 14:12:58 -08009899 /**
9900 * Normalize a MIME data type.
9901 *
9902 * <p>A normalized MIME type has white-space trimmed,
9903 * content-type parameters removed, and is lower-case.
9904 * This aligns the type with Android best practices for
9905 * intent filtering.
9906 *
9907 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9908 * "text/x-vCard" becomes "text/x-vcard".
9909 *
9910 * <p>All MIME types received from outside Android (such as user input,
9911 * or external sources like Bluetooth, NFC, or the Internet) should
9912 * be normalized before they are used to create an Intent.
9913 *
9914 * @param type MIME data type to normalize
9915 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009916 * @see #setType
9917 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009918 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009919 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009920 if (type == null) {
9921 return null;
9922 }
9923
Elliott Hughescb64d432013-08-02 10:00:44 -07009924 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009925
9926 final int semicolonIndex = type.indexOf(';');
9927 if (semicolonIndex != -1) {
9928 type = type.substring(0, semicolonIndex);
9929 }
9930 return type;
9931 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009932
9933 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009934 * Prepare this {@link Intent} to leave an app process.
9935 *
9936 * @hide
9937 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009938 public void prepareToLeaveProcess(Context context) {
9939 final boolean leavingPackage = (mComponent == null)
9940 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9941 prepareToLeaveProcess(leavingPackage);
9942 }
9943
9944 /**
9945 * Prepare this {@link Intent} to leave an app process.
9946 *
9947 * @hide
9948 */
9949 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009950 setAllowFds(false);
9951
9952 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009953 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009954 }
9955 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009956 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009957 }
9958
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009959 if (mExtras != null && !mExtras.isParcelled()) {
9960 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9961 if (intent instanceof Intent) {
9962 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9963 }
9964 }
9965
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009966 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9967 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009968 switch (mAction) {
9969 case ACTION_MEDIA_REMOVED:
9970 case ACTION_MEDIA_UNMOUNTED:
9971 case ACTION_MEDIA_CHECKING:
9972 case ACTION_MEDIA_NOFS:
9973 case ACTION_MEDIA_MOUNTED:
9974 case ACTION_MEDIA_SHARED:
9975 case ACTION_MEDIA_UNSHARED:
9976 case ACTION_MEDIA_BAD_REMOVAL:
9977 case ACTION_MEDIA_UNMOUNTABLE:
9978 case ACTION_MEDIA_EJECT:
9979 case ACTION_MEDIA_SCANNER_STARTED:
9980 case ACTION_MEDIA_SCANNER_FINISHED:
9981 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009982 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9983 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009984 // Ignore legacy actions
9985 break;
9986 default:
9987 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009988 }
9989 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009990
9991 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9992 && leavingPackage) {
9993 switch (mAction) {
9994 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -07009995 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009996 // Ignore actions that don't need to grant
9997 break;
9998 default:
9999 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10000 }
10001 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010002 }
10003
10004 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010005 * @hide
10006 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010007 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010008 // We just entered destination process, so we should be able to read all
10009 // parcelables inside.
10010 setDefusable(true);
10011
10012 if (mSelector != null) {
10013 mSelector.prepareToEnterProcess();
10014 }
10015 if (mClipData != null) {
10016 mClipData.prepareToEnterProcess();
10017 }
10018
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010019 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010020 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10021 fixUris(mContentUserHint);
10022 mContentUserHint = UserHandle.USER_CURRENT;
10023 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010024 }
10025 }
10026
10027 /**
10028 * @hide
10029 */
10030 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010031 Uri data = getData();
10032 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010033 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010034 }
10035 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010036 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010037 }
10038 String action = getAction();
10039 if (ACTION_SEND.equals(action)) {
10040 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10041 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010042 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010043 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010044 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010045 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10046 if (streams != null) {
10047 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10048 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010049 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010050 }
10051 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10052 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010053 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10054 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10055 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10056 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10057 if (output != null) {
10058 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10059 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010060 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010061 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010062
10063 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010064 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010065 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10066 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010067 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010068 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010069 * @hide
10070 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010071 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010072 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010073 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010074
10075 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010076 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010077
10078 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010079 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010080 // Inspect contained intents to see if we need to migrate extras. We
10081 // don't promote ClipData to the parent, since ChooserActivity will
10082 // already start the picked item as the caller, and we can't combine
10083 // the flags in a safe way.
10084
10085 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010086 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010087 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10088 if (intent != null) {
10089 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010090 }
10091 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010092 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010093 try {
10094 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10095 if (intents != null) {
10096 for (int i = 0; i < intents.length; i++) {
10097 final Intent intent = (Intent) intents[i];
10098 if (intent != null) {
10099 migrated |= intent.migrateExtraStreamToClipData();
10100 }
10101 }
10102 }
10103 } catch (ClassCastException e) {
10104 }
10105 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010106
10107 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010108 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010109 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10110 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10111 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10112 if (stream != null || text != null || htmlText != null) {
10113 final ClipData clipData = new ClipData(
10114 null, new String[] { getType() },
10115 new ClipData.Item(text, htmlText, null, stream));
10116 setClipData(clipData);
10117 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010118 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010119 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010120 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010121 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010122
10123 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010124 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010125 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10126 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10127 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10128 int num = -1;
10129 if (streams != null) {
10130 num = streams.size();
10131 }
10132 if (texts != null) {
10133 if (num >= 0 && num != texts.size()) {
10134 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010135 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010136 }
10137 num = texts.size();
10138 }
10139 if (htmlTexts != null) {
10140 if (num >= 0 && num != htmlTexts.size()) {
10141 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010142 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010143 }
10144 num = htmlTexts.size();
10145 }
10146 if (num > 0) {
10147 final ClipData clipData = new ClipData(
10148 null, new String[] { getType() },
10149 makeClipItem(streams, texts, htmlTexts, 0));
10150
10151 for (int i = 1; i < num; i++) {
10152 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10153 }
10154
10155 setClipData(clipData);
10156 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010157 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010158 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010159 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010160 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010161 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10162 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10163 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10164 final Uri output;
10165 try {
10166 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10167 } catch (ClassCastException e) {
10168 return false;
10169 }
10170 if (output != null) {
10171 setClipData(ClipData.newRawUri("", output));
10172 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10173 return true;
10174 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010175 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010176
10177 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010178 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010179
Michael Wright19859762017-09-18 20:57:58 +010010180 /**
10181 * Convert the dock state to a human readable format.
10182 * @hide
10183 */
10184 public static String dockStateToString(int dock) {
10185 switch (dock) {
10186 case EXTRA_DOCK_STATE_HE_DESK:
10187 return "EXTRA_DOCK_STATE_HE_DESK";
10188 case EXTRA_DOCK_STATE_LE_DESK:
10189 return "EXTRA_DOCK_STATE_LE_DESK";
10190 case EXTRA_DOCK_STATE_CAR:
10191 return "EXTRA_DOCK_STATE_CAR";
10192 case EXTRA_DOCK_STATE_DESK:
10193 return "EXTRA_DOCK_STATE_DESK";
10194 case EXTRA_DOCK_STATE_UNDOCKED:
10195 return "EXTRA_DOCK_STATE_UNDOCKED";
10196 default:
10197 return Integer.toString(dock);
10198 }
10199 }
10200
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010201 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10202 ArrayList<String> htmlTexts, int which) {
10203 Uri uri = streams != null ? streams.get(which) : null;
10204 CharSequence text = texts != null ? texts.get(which) : null;
10205 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10206 return new ClipData.Item(text, htmlText, null, uri);
10207 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010208
10209 /** @hide */
10210 public boolean isDocument() {
10211 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10212 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010213}