blob: c863fe0cff1f2865fc5a1047e0fbe50cfb20f743 [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;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070056
Dianne Hackborn2269d1572010-02-24 19:54:22 -080057import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070058
Jason Monk2f68e8a2016-02-23 17:57:28 -050059import org.xmlpull.v1.XmlPullParser;
60import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070061import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062
63import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080064import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070066import java.lang.annotation.Retention;
67import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.net.URISyntaxException;
69import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080070import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070071import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080072import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070073import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070074import java.util.Set;
75
76/**
77 * An intent is an abstract description of an operation to be performed. It
78 * can be used with {@link Context#startActivity(Intent) startActivity} to
79 * launch an {@link android.app.Activity},
80 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
81 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
82 * and {@link android.content.Context#startService} or
83 * {@link android.content.Context#bindService} to communicate with a
84 * background {@link android.app.Service}.
85 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 * <p>An Intent provides a facility for performing late runtime binding between the code in
87 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070088 * can be thought of as the glue between activities. It is basically a passive data structure
89 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070090 *
91 * <div class="special reference">
92 * <h3>Developer Guides</h3>
93 * <p>For information about how to create and resolve intents, read the
94 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
95 * developer guide.</p>
96 * </div>
97 *
98 * <a name="IntentStructure"></a>
99 * <h3>Intent Structure</h3>
100 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700101 *
102 * <ul>
103 * <li> <p><b>action</b> -- The general action to be performed, such as
104 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
105 * etc.</p>
106 * </li>
107 * <li> <p><b>data</b> -- The data to operate on, such as a person record
108 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
109 * </li>
110 * </ul>
111 *
112 *
113 * <p>Some examples of action/data pairs are:</p>
114 *
115 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700116 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700117 * information about the person whose identifier is "1".</p>
118 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700119 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700120 * the phone dialer with the person filled in.</p>
121 * </li>
122 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
123 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700124 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * a particular URI.</p>
126 * </li>
127 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
128 * the phone dialer with the given number filled in.</p>
129 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700130 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * information about the person whose identifier is "1".</p>
132 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700133 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * a list of people, which the user can browse through. This example is a
135 * typical top-level entry into the Contacts application, showing you the
136 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700137 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700138 * being used to start an activity to display that person.</p>
139 * </li>
140 * </ul>
141 *
142 * <p>In addition to these primary attributes, there are a number of secondary
143 * attributes that you can also include with an intent:</p>
144 *
145 * <ul>
146 * <li> <p><b>category</b> -- Gives additional information about the action
147 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
148 * appear in the Launcher as a top-level application, while
149 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
150 * of alternative actions the user can perform on a piece of data.</p>
151 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
152 * intent data. Normally the type is inferred from the data itself.
153 * By setting this attribute, you disable that evaluation and force
154 * an explicit type.</p>
155 * <li> <p><b>component</b> -- Specifies an explicit name of a component
156 * class to use for the intent. Normally this is determined by looking
157 * at the other information in the intent (the action, data/type, and
158 * categories) and matching that with a component that can handle it.
159 * If this attribute is set then none of the evaluation is performed,
160 * and this component is used exactly as is. By specifying this attribute,
161 * all of the other Intent attributes become optional.</p>
162 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
163 * This can be used to provide extended information to the component.
164 * For example, if we have a action to send an e-mail message, we could
165 * also include extra pieces of data here to supply a subject, body,
166 * etc.</p>
167 * </ul>
168 *
169 * <p>Here are some examples of other operations you can specify as intents
170 * using these additional parameters:</p>
171 *
172 * <ul>
173 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
174 * Launch the home screen.</p>
175 * </li>
176 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
177 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
178 * vnd.android.cursor.item/phone}</i></b>
179 * -- Display the list of people's phone numbers, allowing the user to
180 * browse through them and pick one and return it to the parent activity.</p>
181 * </li>
182 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
183 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
184 * -- Display all pickers for data that can be opened with
185 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
186 * allowing the user to pick one of them and then some data inside of it
187 * and returning the resulting URI to the caller. This can be used,
188 * for example, in an e-mail application to allow the user to pick some
189 * data to include as an attachment.</p>
190 * </li>
191 * </ul>
192 *
193 * <p>There are a variety of standard Intent action and category constants
194 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700195 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700196 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700197 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700198 *
199 * <p>Put together, the set of actions, data types, categories, and extra data
200 * defines a language for the system allowing for the expression of phrases
201 * such as "call john smith's cell". As applications are added to the system,
202 * they can extend this language by adding new actions, types, and categories, or
203 * they can modify the behavior of existing phrases by supplying their own
204 * activities that handle them.</p>
205 *
206 * <a name="IntentResolution"></a>
207 * <h3>Intent Resolution</h3>
208 *
209 * <p>There are two primary forms of intents you will use.
210 *
211 * <ul>
212 * <li> <p><b>Explicit Intents</b> have specified a component (via
213 * {@link #setComponent} or {@link #setClass}), which provides the exact
214 * class to be run. Often these will not include any other information,
215 * simply being a way for an application to launch various internal
216 * activities it has as the user interacts with the application.
217 *
218 * <li> <p><b>Implicit Intents</b> have not specified a component;
219 * instead, they must include enough information for the system to
220 * determine which of the available components is best to run for that
221 * intent.
222 * </ul>
223 *
224 * <p>When using implicit intents, given such an arbitrary intent we need to
225 * know what to do with it. This is handled by the process of <em>Intent
226 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
227 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
228 * more activities/receivers) that can handle it.</p>
229 *
230 * <p>The intent resolution mechanism basically revolves around matching an
231 * Intent against all of the &lt;intent-filter&gt; descriptions in the
232 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
233 * objects explicitly registered with {@link Context#registerReceiver}.) More
234 * details on this can be found in the documentation on the {@link
235 * IntentFilter} class.</p>
236 *
237 * <p>There are three pieces of information in the Intent that are used for
238 * resolution: the action, type, and category. Using this information, a query
239 * is done on the {@link PackageManager} for a component that can handle the
240 * intent. The appropriate component is determined based on the intent
241 * information supplied in the <code>AndroidManifest.xml</code> file as
242 * follows:</p>
243 *
244 * <ul>
245 * <li> <p>The <b>action</b>, if given, must be listed by the component as
246 * one it handles.</p>
247 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
248 * already supplied in the Intent. Like the action, if a type is
249 * included in the intent (either explicitly or implicitly in its
250 * data), then this must be listed by the component as one it handles.</p>
251 * <li> For data that is not a <code>content:</code> URI and where no explicit
252 * type is included in the Intent, instead the <b>scheme</b> of the
253 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
254 * considered. Again like the action, if we are matching a scheme it
255 * must be listed by the component as one it can handle.
256 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
257 * by the activity as categories it handles. That is, if you include
258 * the categories {@link #CATEGORY_LAUNCHER} and
259 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
260 * with an intent that lists <em>both</em> of those categories.
261 * Activities will very often need to support the
262 * {@link #CATEGORY_DEFAULT} so that they can be found by
263 * {@link Context#startActivity Context.startActivity()}.</p>
264 * </ul>
265 *
266 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700267 * allows a user to browse through a list of notes data and view details about
268 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700269 * name with one specific to your own package.</p>
270 *
271 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
272 * package="<i>com.android.notepad</i>"&gt;
273 * &lt;application android:icon="@drawable/app_notes"
274 * android:label="@string/app_name"&gt;
275 *
276 * &lt;provider class=".NotePadProvider"
277 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
278 *
279 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.MAIN" /&gt;
282 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700283 * &lt;/intent-filter&gt;
284 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700285 * &lt;action android:name="android.intent.action.VIEW" /&gt;
286 * &lt;action android:name="android.intent.action.EDIT" /&gt;
287 * &lt;action android:name="android.intent.action.PICK" /&gt;
288 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
289 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700290 * &lt;/intent-filter&gt;
291 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700292 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
293 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
294 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700295 * &lt;/intent-filter&gt;
296 * &lt;/activity&gt;
297 *
298 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
299 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700300 * &lt;action android:name="android.intent.action.VIEW" /&gt;
301 * &lt;action android:name="android.intent.action.EDIT" /&gt;
302 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
303 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700304 * &lt;/intent-filter&gt;
305 *
306 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700307 * &lt;action android:name="android.intent.action.INSERT" /&gt;
308 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
309 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700310 * &lt;/intent-filter&gt;
311 *
312 * &lt;/activity&gt;
313 *
314 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
315 * android:theme="@android:style/Theme.Dialog"&gt;
316 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700317 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
318 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
319 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
320 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
321 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700322 * &lt;/intent-filter&gt;
323 * &lt;/activity&gt;
324 *
325 * &lt;/application&gt;
326 * &lt;/manifest&gt;</pre>
327 *
328 * <p>The first activity,
329 * <code>com.android.notepad.NotesList</code>, serves as our main
330 * entry into the app. It can do three things as described by its three intent
331 * templates:
332 * <ol>
333 * <li><pre>
334 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700335 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
336 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700337 * &lt;/intent-filter&gt;</pre>
338 * <p>This provides a top-level entry into the NotePad application: the standard
339 * MAIN action is a main entry point (not requiring any other information in
340 * the Intent), and the LAUNCHER category says that this entry point should be
341 * listed in the application launcher.</p>
342 * <li><pre>
343 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700344 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
345 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
346 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
347 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700348 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700349 * &lt;/intent-filter&gt;</pre>
350 * <p>This declares the things that the activity can do on a directory of
351 * notes. The type being supported is given with the &lt;type&gt; tag, where
352 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
353 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
354 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
355 * The activity allows the user to view or edit the directory of data (via
356 * the VIEW and EDIT actions), or to pick a particular note and return it
357 * to the caller (via the PICK action). Note also the DEFAULT category
358 * supplied here: this is <em>required</em> for the
359 * {@link Context#startActivity Context.startActivity} method to resolve your
360 * activity when its component name is not explicitly specified.</p>
361 * <li><pre>
362 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700363 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
364 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
365 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700366 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700367 * <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 -0700368 * the user without needing to know where it came from. The data type
369 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
370 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
371 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
372 * The GET_CONTENT action is similar to the PICK action, where the activity
373 * will return to its caller a piece of data selected by the user. Here,
374 * however, the caller specifies the type of data they desire instead of
375 * the type of data the user will be picking from.</p>
376 * </ol>
377 *
378 * <p>Given these capabilities, the following intents will resolve to the
379 * NotesList activity:</p>
380 *
381 * <ul>
382 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
383 * activities that can be used as top-level entry points into an
384 * application.</p>
385 * <li> <p><b>{ action=android.app.action.MAIN,
386 * category=android.app.category.LAUNCHER }</b> is the actual intent
387 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700388 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700389 * data=content://com.google.provider.NotePad/notes }</b>
390 * displays a list of all the notes under
391 * "content://com.google.provider.NotePad/notes", which
392 * the user can browse through and see the details on.</p>
393 * <li> <p><b>{ action=android.app.action.PICK
394 * data=content://com.google.provider.NotePad/notes }</b>
395 * provides a list of the notes under
396 * "content://com.google.provider.NotePad/notes", from which
397 * the user can pick a note whose data URL is returned back to the caller.</p>
398 * <li> <p><b>{ action=android.app.action.GET_CONTENT
399 * type=vnd.android.cursor.item/vnd.google.note }</b>
400 * is similar to the pick action, but allows the caller to specify the
401 * kind of data they want back so that the system can find the appropriate
402 * activity to pick something of that data type.</p>
403 * </ul>
404 *
405 * <p>The second activity,
406 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
407 * note entry and allows them to edit it. It can do two things as described
408 * by its two intent templates:
409 * <ol>
410 * <li><pre>
411 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700412 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
413 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
414 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
415 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700416 * &lt;/intent-filter&gt;</pre>
417 * <p>The first, primary, purpose of this activity is to let the user interact
418 * with a single note, as decribed by the MIME type
419 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
420 * either VIEW a note or allow the user to EDIT it. Again we support the
421 * DEFAULT category to allow the activity to be launched without explicitly
422 * specifying its component.</p>
423 * <li><pre>
424 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700425 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
426 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
427 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700428 * &lt;/intent-filter&gt;</pre>
429 * <p>The secondary use of this activity is to insert a new note entry into
430 * an existing directory of notes. This is used when the user creates a new
431 * note: the INSERT action is executed on the directory of notes, causing
432 * this activity to run and have the user create the new note data which
433 * it then adds to the content provider.</p>
434 * </ol>
435 *
436 * <p>Given these capabilities, the following intents will resolve to the
437 * NoteEditor activity:</p>
438 *
439 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700440 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700441 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
442 * shows the user the content of note <var>{ID}</var>.</p>
443 * <li> <p><b>{ action=android.app.action.EDIT
444 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
445 * allows the user to edit the content of note <var>{ID}</var>.</p>
446 * <li> <p><b>{ action=android.app.action.INSERT
447 * data=content://com.google.provider.NotePad/notes }</b>
448 * creates a new, empty note in the notes list at
449 * "content://com.google.provider.NotePad/notes"
450 * and allows the user to edit it. If they keep their changes, the URI
451 * of the newly created note is returned to the caller.</p>
452 * </ul>
453 *
454 * <p>The last activity,
455 * <code>com.android.notepad.TitleEditor</code>, allows the user to
456 * edit the title of a note. This could be implemented as a class that the
457 * application directly invokes (by explicitly setting its component in
458 * the Intent), but here we show a way you can publish alternative
459 * operations on existing data:</p>
460 *
461 * <pre>
462 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700463 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
464 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
465 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
466 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
467 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700468 * &lt;/intent-filter&gt;</pre>
469 *
470 * <p>In the single intent template here, we
471 * have created our own private action called
472 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
473 * edit the title of a note. It must be invoked on a specific note
474 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
475 * view and edit actions, but here displays and edits the title contained
476 * in the note data.
477 *
478 * <p>In addition to supporting the default category as usual, our title editor
479 * also supports two other standard categories: ALTERNATIVE and
480 * SELECTED_ALTERNATIVE. Implementing
481 * these categories allows others to find the special action it provides
482 * without directly knowing about it, through the
483 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
484 * more often to build dynamic menu items with
485 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
486 * template here was also supply an explicit name for the template
487 * (via <code>android:label="@string/resolve_title"</code>) to better control
488 * what the user sees when presented with this activity as an alternative
489 * action to the data they are viewing.
490 *
491 * <p>Given these capabilities, the following intent will resolve to the
492 * TitleEditor activity:</p>
493 *
494 * <ul>
495 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
496 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
497 * displays and allows the user to edit the title associated
498 * with note <var>{ID}</var>.</p>
499 * </ul>
500 *
501 * <h3>Standard Activity Actions</h3>
502 *
503 * <p>These are the current standard actions that Intent defines for launching
504 * activities (usually through {@link Context#startActivity}. The most
505 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
506 * {@link #ACTION_EDIT}.
507 *
508 * <ul>
509 * <li> {@link #ACTION_MAIN}
510 * <li> {@link #ACTION_VIEW}
511 * <li> {@link #ACTION_ATTACH_DATA}
512 * <li> {@link #ACTION_EDIT}
513 * <li> {@link #ACTION_PICK}
514 * <li> {@link #ACTION_CHOOSER}
515 * <li> {@link #ACTION_GET_CONTENT}
516 * <li> {@link #ACTION_DIAL}
517 * <li> {@link #ACTION_CALL}
518 * <li> {@link #ACTION_SEND}
519 * <li> {@link #ACTION_SENDTO}
520 * <li> {@link #ACTION_ANSWER}
521 * <li> {@link #ACTION_INSERT}
522 * <li> {@link #ACTION_DELETE}
523 * <li> {@link #ACTION_RUN}
524 * <li> {@link #ACTION_SYNC}
525 * <li> {@link #ACTION_PICK_ACTIVITY}
526 * <li> {@link #ACTION_SEARCH}
527 * <li> {@link #ACTION_WEB_SEARCH}
528 * <li> {@link #ACTION_FACTORY_TEST}
529 * </ul>
530 *
531 * <h3>Standard Broadcast Actions</h3>
532 *
533 * <p>These are the current standard actions that Intent defines for receiving
534 * broadcasts (usually through {@link Context#registerReceiver} or a
535 * &lt;receiver&gt; tag in a manifest).
536 *
537 * <ul>
538 * <li> {@link #ACTION_TIME_TICK}
539 * <li> {@link #ACTION_TIME_CHANGED}
540 * <li> {@link #ACTION_TIMEZONE_CHANGED}
541 * <li> {@link #ACTION_BOOT_COMPLETED}
542 * <li> {@link #ACTION_PACKAGE_ADDED}
543 * <li> {@link #ACTION_PACKAGE_CHANGED}
544 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800545 * <li> {@link #ACTION_PACKAGE_RESTARTED}
546 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000547 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
548 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700549 * <li> {@link #ACTION_UID_REMOVED}
550 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700551 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700552 * <li> {@link #ACTION_POWER_DISCONNECTED}
553 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700554 * </ul>
555 *
556 * <h3>Standard Categories</h3>
557 *
558 * <p>These are the current standard categories that can be used to further
559 * clarify an Intent via {@link #addCategory}.
560 *
561 * <ul>
562 * <li> {@link #CATEGORY_DEFAULT}
563 * <li> {@link #CATEGORY_BROWSABLE}
564 * <li> {@link #CATEGORY_TAB}
565 * <li> {@link #CATEGORY_ALTERNATIVE}
566 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
567 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800568 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 * <li> {@link #CATEGORY_HOME}
570 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700571 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400572 * <li> {@link #CATEGORY_CAR_DOCK}
573 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500574 * <li> {@link #CATEGORY_LE_DESK_DOCK}
575 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200576 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700577 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800578 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700579 * </ul>
580 *
581 * <h3>Standard Extra Data</h3>
582 *
583 * <p>These are the current standard fields that can be used as extra data via
584 * {@link #putExtra}.
585 *
586 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800587 * <li> {@link #EXTRA_ALARM_COUNT}
588 * <li> {@link #EXTRA_BCC}
589 * <li> {@link #EXTRA_CC}
590 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
591 * <li> {@link #EXTRA_DATA_REMOVED}
592 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500593 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
594 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_DOCK_STATE_CAR}
596 * <li> {@link #EXTRA_DOCK_STATE_DESK}
597 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
598 * <li> {@link #EXTRA_DONT_KILL_APP}
599 * <li> {@link #EXTRA_EMAIL}
600 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700601 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700603 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800604 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700605 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
607 * <li> {@link #EXTRA_REPLACING}
608 * <li> {@link #EXTRA_SHORTCUT_ICON}
609 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
610 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_SHORTCUT_NAME}
613 * <li> {@link #EXTRA_SUBJECT}
614 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800616 * <li> {@link #EXTRA_TITLE}
617 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700618 * </ul>
619 *
620 * <h3>Flags</h3>
621 *
622 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800623 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
624 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700625 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800626public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700627 private static final String ATTR_ACTION = "action";
628 private static final String TAG_CATEGORIES = "categories";
629 private static final String ATTR_CATEGORY = "category";
630 private static final String TAG_EXTRA = "extra";
631 private static final String ATTR_TYPE = "type";
632 private static final String ATTR_COMPONENT = "component";
633 private static final String ATTR_DATA = "data";
634 private static final String ATTR_FLAGS = "flags";
635
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700636 // ---------------------------------------------------------------------
637 // ---------------------------------------------------------------------
638 // Standard intent activity actions (see action variable).
639
640 /**
641 * Activity Action: Start as a main entry point, does not expect to
642 * receive data.
643 * <p>Input: nothing
644 * <p>Output: nothing
645 */
646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
647 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800648
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700649 /**
650 * Activity Action: Display the data to the user. This is the most common
651 * action performed on data -- it is the generic action you can use on
652 * a piece of data to get the most reasonable thing to occur. For example,
653 * when used on a contacts entry it will view the entry; when used on a
654 * mailto: URI it will bring up a compose window filled with the information
655 * supplied by the URI; when used with a tel: URI it will invoke the
656 * dialer.
657 * <p>Input: {@link #getData} is URI from which to retrieve data.
658 * <p>Output: nothing.
659 */
660 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
661 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700663 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700664 * Extra that can be included on activity intents coming from the storage UI
665 * when it launches sub-activities to manage various types of storage. For example,
666 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
667 * the images on the device, and in that case also include this extra to tell the
668 * app it is coming from the storage UI so should help the user manage storage of
669 * this type.
670 */
671 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
672
673 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700674 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
675 * performed on a piece of data.
676 */
677 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900680 * Activity Action: Quick view the data. Launches a quick viewer for
681 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900682 * <p>Activities handling this intent action should handle the vast majority of
683 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700684 * <p>Quick viewers must render the quick view image locally, and must not send
685 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900686 * <p>Input: {@link #getData} is a mandatory content URI of the item to
687 * preview. {@link #getClipData} contains an optional list of content URIs
688 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
689 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700690 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
691 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700692 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900693 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700694 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700695 */
696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
697 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
698
699 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700700 * Used to indicate that some piece of data should be attached to some other
701 * place. For example, image data could be attached to a contact. It is up
702 * to the recipient to decide where the data should be attached; the intent
703 * does not specify the ultimate destination.
704 * <p>Input: {@link #getData} is URI of data to be attached.
705 * <p>Output: nothing.
706 */
707 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
708 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800709
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700710 /**
711 * Activity Action: Provide explicit editable access to the given data.
712 * <p>Input: {@link #getData} is URI of data to be edited.
713 * <p>Output: nothing.
714 */
715 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
716 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700718 /**
719 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
720 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
721 * The extras can contain type specific data to pass through to the editing/creating
722 * activity.
723 * <p>Output: The URI of the item that was picked. This must be a content:
724 * URI so that any receiver can access it.
725 */
726 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
727 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800728
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 /**
730 * Activity Action: Pick an item from the data, returning what was selected.
731 * <p>Input: {@link #getData} is URI containing a directory of data
732 * (vnd.android.cursor.dir/*) from which to pick an item.
733 * <p>Output: The URI of the item that was picked.
734 */
735 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
736 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800737
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700738 /**
739 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800740 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800741 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
742 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700743 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
744 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800745 * (value: ShortcutIconResource).</p>
746 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 * @see #EXTRA_SHORTCUT_INTENT
749 * @see #EXTRA_SHORTCUT_NAME
750 * @see #EXTRA_SHORTCUT_ICON
751 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
752 * @see android.content.Intent.ShortcutIconResource
753 */
754 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
755 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
756
757 /**
758 * The name of the extra used to define the Intent of a shortcut.
759 *
760 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800761 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700762 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
765 /**
766 * The name of the extra used to define the name of a shortcut.
767 *
768 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800769 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800771 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700772 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
773 /**
774 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
775 *
776 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800777 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800779 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700780 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
781 /**
782 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
783 *
784 * @see #ACTION_CREATE_SHORTCUT
785 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800786 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700787 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800788 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700789 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
790 "android.intent.extra.shortcut.ICON_RESOURCE";
791
792 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500793 * An activity that provides a user interface for adjusting application preferences.
794 * Optional but recommended settings for all applications which have settings.
795 */
796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
797 public static final String ACTION_APPLICATION_PREFERENCES
798 = "android.intent.action.APPLICATION_PREFERENCES";
799
800 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700801 * Activity Action: Launch an activity showing the app information.
802 * For applications which install other applications (such as app stores), it is recommended
803 * to handle this action for providing the app information to the user.
804 *
805 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
806 * to be displayed.
807 * <p>Output: Nothing.
808 */
809 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
810 public static final String ACTION_SHOW_APP_INFO
811 = "android.intent.action.SHOW_APP_INFO";
812
813 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800814 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700815 *
816 * @see Intent#ACTION_CREATE_SHORTCUT
817 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800818 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
819 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700820 */
821 public static class ShortcutIconResource implements Parcelable {
822 /**
823 * The package name of the application containing the icon.
824 */
825 public String packageName;
826
827 /**
828 * The resource name of the icon, including package, name and type.
829 */
830 public String resourceName;
831
832 /**
833 * Creates a new ShortcutIconResource for the specified context and resource
834 * identifier.
835 *
836 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700837 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700838 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700839 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700840 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700841 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700842 ShortcutIconResource icon = new ShortcutIconResource();
843 icon.packageName = context.getPackageName();
844 icon.resourceName = context.getResources().getResourceName(resourceId);
845 return icon;
846 }
847
848 /**
849 * Used to read a ShortcutIconResource from a Parcel.
850 */
851 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
852 new Parcelable.Creator<ShortcutIconResource>() {
853
854 public ShortcutIconResource createFromParcel(Parcel source) {
855 ShortcutIconResource icon = new ShortcutIconResource();
856 icon.packageName = source.readString();
857 icon.resourceName = source.readString();
858 return icon;
859 }
860
861 public ShortcutIconResource[] newArray(int size) {
862 return new ShortcutIconResource[size];
863 }
864 };
865
866 /**
867 * No special parcel contents.
868 */
869 public int describeContents() {
870 return 0;
871 }
872
873 public void writeToParcel(Parcel dest, int flags) {
874 dest.writeString(packageName);
875 dest.writeString(resourceName);
876 }
877
878 @Override
879 public String toString() {
880 return resourceName;
881 }
882 }
883
884 /**
885 * Activity Action: Display an activity chooser, allowing the user to pick
886 * what they want to before proceeding. This can be used as an alternative
887 * to the standard activity picker that is displayed by the system when
888 * you try to start an activity with multiple possible matches, with these
889 * differences in behavior:
890 * <ul>
891 * <li>You can specify the title that will appear in the activity chooser.
892 * <li>The user does not have the option to make one of the matching
893 * activities a preferred activity, and all possible activities will
894 * always be shown even if one of them is currently marked as the
895 * preferred activity.
896 * </ul>
897 * <p>
898 * This action should be used when the user will naturally expect to
899 * select an activity in order to proceed. An example if when not to use
900 * it is when the user clicks on a "mailto:" link. They would naturally
901 * expect to go directly to their mail app, so startActivity() should be
902 * called directly: it will
903 * either launch the current preferred app, or put up a dialog allowing the
904 * user to pick an app to use and optionally marking that as preferred.
905 * <p>
906 * In contrast, if the user is selecting a menu item to send a picture
907 * they are viewing to someone else, there are many different things they
908 * may want to do at this point: send it through e-mail, upload it to a
909 * web service, etc. In this case the CHOOSER action should be used, to
910 * always present to the user a list of the things they can do, with a
911 * nice title given by the caller such as "Send this photo with:".
912 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700913 * If you need to grant URI permissions through a chooser, you must specify
914 * the permissions to be granted on the ACTION_CHOOSER Intent
915 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
916 * {@link #setClipData} to specify the URIs to be granted as well as
917 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
918 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
919 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700920 * As a convenience, an Intent of this form can be created with the
921 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700922 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700923 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
925 * and can optionally have a {@link #EXTRA_TITLE} field containing the
926 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927 * <p>
928 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700929 */
930 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
931 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
932
933 /**
934 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
935 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700936 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
937 * target intent, also optionally supplying a title. If the target
938 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
939 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
940 * set in the returned chooser intent, with its ClipData set appropriately:
941 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500942 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700943 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700944 * @param target The Intent that the user will be selecting an activity
945 * to perform.
946 * @param title Optional title that will be displayed in the chooser.
947 * @return Return a new Intent object that you can hand to
948 * {@link Context#startActivity(Intent) Context.startActivity()} and
949 * related methods.
950 */
951 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700952 return createChooser(target, title, null);
953 }
954
955 /**
956 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
957 *
958 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
959 * target intent, also optionally supplying a title. If the target
960 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
961 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
962 * set in the returned chooser intent, with its ClipData set appropriately:
963 * either a direct reflection of {@link #getClipData()} if that is non-null,
964 * or a new ClipData built from {@link #getData()}.</p>
965 *
966 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
967 * when the user makes a choice. This can be useful if the calling application wants
968 * to remember the last chosen target and surface it as a more prominent or one-touch
969 * affordance elsewhere in the UI for next time.</p>
970 *
971 * @param target The Intent that the user will be selecting an activity
972 * to perform.
973 * @param title Optional title that will be displayed in the chooser.
974 * @param sender Optional IntentSender to be called when a choice is made.
975 * @return Return a new Intent object that you can hand to
976 * {@link Context#startActivity(Intent) Context.startActivity()} and
977 * related methods.
978 */
979 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700980 Intent intent = new Intent(ACTION_CHOOSER);
981 intent.putExtra(EXTRA_INTENT, target);
982 if (title != null) {
983 intent.putExtra(EXTRA_TITLE, title);
984 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700985
Adam Powell0b3c1122014-10-09 12:50:14 -0700986 if (sender != null) {
987 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
988 }
989
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700990 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700991 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
992 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
993 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700994 if (permFlags != 0) {
995 ClipData targetClipData = target.getClipData();
996 if (targetClipData == null && target.getData() != null) {
997 ClipData.Item item = new ClipData.Item(target.getData());
998 String[] mimeTypes;
999 if (target.getType() != null) {
1000 mimeTypes = new String[] { target.getType() };
1001 } else {
1002 mimeTypes = new String[] { };
1003 }
1004 targetClipData = new ClipData(null, mimeTypes, item);
1005 }
1006 if (targetClipData != null) {
1007 intent.setClipData(targetClipData);
1008 intent.addFlags(permFlags);
1009 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001010 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001011
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001012 return intent;
1013 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001014
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001015 /**
1016 * Activity Action: Allow the user to select a particular kind of data and
1017 * return it. This is different than {@link #ACTION_PICK} in that here we
1018 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001019 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001021 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001022 * etc.
1023 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001024 * 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 -07001025 * of data, such as a person contact, you set the MIME type to the kind of
1026 * data you want and launch it with {@link Context#startActivity(Intent)}.
1027 * The system will then launch the best application to select that kind
1028 * of data for you.
1029 * <p>
1030 * You may also be interested in any of a set of types of content the user
1031 * can pick. For example, an e-mail application that wants to allow the
1032 * user to add an attachment to an e-mail message can use this action to
1033 * bring up a list of all of the types of content the user can attach.
1034 * <p>
1035 * In this case, you should wrap the GET_CONTENT intent with a chooser
1036 * (through {@link #createChooser}), which will give the proper interface
1037 * for the user to pick how to send your data and allow you to specify
1038 * a prompt indicating what they are doing. You will usually specify a
1039 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1040 * broad range of content types the user can select from.
1041 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001042 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 * only pick from data that can be represented as a stream. This is
1044 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1045 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001046 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001047 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001048 * is locally available on the device. For example, if this extra is set
1049 * to true then an image picker should not show any pictures that are available
1050 * from a remote server but not already on the local device (thus requiring
1051 * they be downloaded when opened).
1052 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001053 * If the caller can handle multiple returned items (the user performing
1054 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1055 * to indicate this.
1056 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001057 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1058 * that no URI is supplied in the intent, as there are no constraints on
1059 * where the returned data originally comes from. You may also include the
1060 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001061 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001062 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1063 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001064 * <p>
1065 * Output: The URI of the item that was picked. This must be a content:
1066 * URI so that any receiver can access it.
1067 */
1068 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1069 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1070 /**
1071 * Activity Action: Dial a number as specified by the data. This shows a
1072 * UI with the number being dialed, allowing the user to explicitly
1073 * initiate the call.
1074 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1075 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1076 * number.
1077 * <p>Output: nothing.
1078 */
1079 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1080 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1081 /**
1082 * Activity Action: Perform a call to someone specified by the data.
1083 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1084 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1085 * number.
1086 * <p>Output: nothing.
1087 *
1088 * <p>Note: there will be restrictions on which applications can initiate a
1089 * call; most applications should use the {@link #ACTION_DIAL}.
1090 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1091 * numbers. Applications can <strong>dial</strong> emergency numbers using
1092 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001093 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001094 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001095 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001096 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001097 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001098 */
1099 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1100 public static final String ACTION_CALL = "android.intent.action.CALL";
1101 /**
1102 * Activity Action: Perform a call to an emergency number specified by the
1103 * data.
1104 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1105 * tel: URI of an explicit phone number.
1106 * <p>Output: nothing.
1107 * @hide
1108 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001109 @SystemApi
1110 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001111 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1112 /**
1113 * Activity action: Perform a call to any number (emergency or not)
1114 * specified by the data.
1115 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1116 * tel: URI of an explicit phone number.
1117 * <p>Output: nothing.
1118 * @hide
1119 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001120 @SystemApi
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001122 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001123
Santos Cordon15a13782015-03-31 18:32:31 -07001124 /**
fionaxuadfe7002017-02-17 17:20:46 -08001125 * Activity Action: Main entry point for carrier setup apps.
1126 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1127 * carrier service and typically require
1128 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1129 * fulfill their duties.
1130 */
1131 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1132 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1133 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001134 * Activity Action: Send a message to someone specified by the data.
1135 * <p>Input: {@link #getData} is URI describing the target.
1136 * <p>Output: nothing.
1137 */
1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1139 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1140 /**
1141 * Activity Action: Deliver some data to someone else. Who the data is
1142 * being delivered to is not specified; it is up to the receiver of this
1143 * action to ask the user where the data should be sent.
1144 * <p>
1145 * When launching a SEND intent, you should usually wrap it in a chooser
1146 * (through {@link #createChooser}), which will give the proper interface
1147 * for the user to pick how to send your data and allow you to specify
1148 * a prompt indicating what they are doing.
1149 * <p>
1150 * Input: {@link #getType} is the MIME type of the data being sent.
1151 * get*Extra can have either a {@link #EXTRA_TEXT}
1152 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1153 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1154 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1155 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001156 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1157 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1158 * your text with HTML formatting.
1159 * <p>
1160 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1161 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1162 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1163 * content: URIs and other advanced features of {@link ClipData}. If
1164 * using this approach, you still must supply the same data through the
1165 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1166 * for compatibility with old applications. If you don't set a ClipData,
1167 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001169 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1170 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1171 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1172 * be openable only as asset typed files using
1173 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1174 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001175 * Optional standard extras, which may be interpreted by some recipients as
1176 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1177 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1178 * <p>
1179 * Output: nothing.
1180 */
1181 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1182 public static final String ACTION_SEND = "android.intent.action.SEND";
1183 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001184 * Activity Action: Deliver multiple data to someone else.
1185 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001186 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001187 * <p>
1188 * Input: {@link #getType} is the MIME type of the data being sent.
1189 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001190 * #EXTRA_STREAM} field, containing the data to be sent. If using
1191 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1192 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001193 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001194 * Multiple types are supported, and receivers should handle mixed types
1195 * whenever possible. The right way for the receiver to check them is to
1196 * use the content resolver on each URI. The intent sender should try to
1197 * put the most concrete mime type in the intent type, but it can fall
1198 * back to {@literal <type>/*} or {@literal *}/* as needed.
1199 * <p>
1200 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1201 * be image/jpg, but if you are sending image/jpg and image/png, then the
1202 * intent's type should be image/*.
1203 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001204 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1205 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1206 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1207 * content: URIs and other advanced features of {@link ClipData}. If
1208 * using this approach, you still must supply the same data through the
1209 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1210 * for compatibility with old applications. If you don't set a ClipData,
1211 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1212 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001213 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1214 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1215 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1216 * be openable only as asset typed files using
1217 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1218 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001219 * Optional standard extras, which may be interpreted by some recipients as
1220 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1221 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1222 * <p>
1223 * Output: nothing.
1224 */
1225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1226 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1227 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001228 * Activity Action: Handle an incoming phone call.
1229 * <p>Input: nothing.
1230 * <p>Output: nothing.
1231 */
1232 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1233 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1234 /**
1235 * Activity Action: Insert an empty item into the given container.
1236 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1237 * in which to place the data.
1238 * <p>Output: URI of the new data that was created.
1239 */
1240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1241 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1242 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001243 * Activity Action: Create a new item in the given container, initializing it
1244 * from the current contents of the clipboard.
1245 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1246 * in which to place the data.
1247 * <p>Output: URI of the new data that was created.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1251 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001252 * Activity Action: Delete the given data from its container.
1253 * <p>Input: {@link #getData} is URI of data to be deleted.
1254 * <p>Output: nothing.
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1258 /**
1259 * Activity Action: Run the data, whatever that means.
1260 * <p>Input: ? (Note: this is currently specific to the test harness.)
1261 * <p>Output: nothing.
1262 */
1263 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264 public static final String ACTION_RUN = "android.intent.action.RUN";
1265 /**
1266 * Activity Action: Perform a data synchronization.
1267 * <p>Input: ?
1268 * <p>Output: ?
1269 */
1270 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1271 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1272 /**
1273 * Activity Action: Pick an activity given an intent, returning the class
1274 * selected.
1275 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1276 * used with {@link PackageManager#queryIntentActivities} to determine the
1277 * set of activities from which to pick.
1278 * <p>Output: Class name of the activity that was selected.
1279 */
1280 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1282 /**
1283 * Activity Action: Perform a search.
1284 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1285 * is the text to search for. If empty, simply
1286 * enter your search results Activity with the search UI activated.
1287 * <p>Output: nothing.
1288 */
1289 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1290 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1291 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001292 * Activity Action: Start the platform-defined tutorial
1293 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1294 * is the text to search for. If empty, simply
1295 * enter your search results Activity with the search UI activated.
1296 * <p>Output: nothing.
1297 */
1298 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1299 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1300 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001301 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001302 * <p>
1303 * Input: {@link android.app.SearchManager#QUERY
1304 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1305 * a url starts with http or https, the site will be opened. If it is plain
1306 * text, Google search will be applied.
1307 * <p>
1308 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001309 */
1310 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1311 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001312
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001313 /**
Jim Miller07994402012-05-02 14:22:27 -07001314 * Activity Action: Perform assist action.
1315 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001316 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1317 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001318 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1319 * information.
Jim Miller07994402012-05-02 14:22:27 -07001320 * Output: nothing.
1321 */
1322 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1323 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001324
1325 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001326 * Activity Action: Perform voice assist action.
1327 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001328 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1329 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001330 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001332 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001333 */
Amith Yamasani16452032017-03-03 10:15:57 -08001334 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1336 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1337
1338 /**
Adam Skory7140a252013-09-11 12:04:58 +01001339 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1340 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001341 */
1342 public static final String EXTRA_ASSIST_PACKAGE
1343 = "android.intent.extra.ASSIST_PACKAGE";
1344
1345 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001346 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1347 * application package at the time the assist was invoked.
1348 */
1349 public static final String EXTRA_ASSIST_UID
1350 = "android.intent.extra.ASSIST_UID";
1351
1352 /**
Adam Skory7140a252013-09-11 12:04:58 +01001353 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1354 * information supplied by the current foreground app at the time of the assist request.
1355 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001356 */
1357 public static final String EXTRA_ASSIST_CONTEXT
1358 = "android.intent.extra.ASSIST_CONTEXT";
1359
Jim Miller07994402012-05-02 14:22:27 -07001360 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001361 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1362 * keyboard as the primary input device for assistance.
1363 */
1364 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1365 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1366
1367 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001368 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1369 * that was used to invoke the assist.
1370 */
1371 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1372 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1373
1374 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001375 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001376 * <p>Input: Nothing.
1377 * <p>Output: nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1381 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001382 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001383 * <p>Input: Nothing.
1384 * <p>Output: Nothing.
1385 */
1386 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1387 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1388
1389 /**
1390 * Activity Action: Show activity for reporting a bug.
1391 * <p>Input: Nothing.
1392 * <p>Output: Nothing.
1393 */
1394 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1395 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1396
1397 /**
1398 * Activity Action: Main entry point for factory tests. Only used when
1399 * the device is booting in factory test node. The implementing package
1400 * must be installed in the system image.
1401 * <p>Input: nothing
1402 * <p>Output: nothing
1403 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001404 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001405 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1406
1407 /**
1408 * Activity Action: The user pressed the "call" button to go to the dialer
1409 * or other appropriate UI for placing a call.
1410 * <p>Input: Nothing.
1411 * <p>Output: Nothing.
1412 */
1413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1414 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1415
1416 /**
1417 * Activity Action: Start Voice Command.
1418 * <p>Input: Nothing.
1419 * <p>Output: Nothing.
1420 */
1421 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1422 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001423
1424 /**
1425 * Activity Action: Start action associated with long pressing on the
1426 * search key.
1427 * <p>Input: Nothing.
1428 * <p>Output: Nothing.
1429 */
1430 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1431 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001432
Jacek Surazski86b6c532009-05-13 14:38:28 +02001433 /**
1434 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1435 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001436 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001437 * <p>Input: No data is specified. The bug report is passed in using
1438 * an {@link #EXTRA_BUG_REPORT} field.
1439 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001440 *
1441 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001442 */
1443 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1444 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001445
1446 /**
1447 * Activity Action: Show power usage information to the user.
1448 * <p>Input: Nothing.
1449 * <p>Output: Nothing.
1450 */
1451 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1452 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001453
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001454 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001455 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1456 * to run.
1457 * <p>Input: Nothing.
1458 * <p>Output: Nothing.
1459 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1460 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1461 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001462 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001463 */
1464 @Deprecated
1465 @SystemApi
1466 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1467 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1468
1469 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001470 * Activity Action: Setup wizard to launch after a platform update. This
1471 * activity should have a string meta-data field associated with it,
1472 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1473 * the platform for setup. The activity will be launched only if
1474 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1475 * same value.
1476 * <p>Input: Nothing.
1477 * <p>Output: Nothing.
1478 * @hide
1479 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001480 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1482 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001483
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001484 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001485 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1486 * <p>Input: Nothing.
1487 * <p>Output: Nothing.
1488 * @hide
1489 */
1490 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1491 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001492 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001493
1494 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001495 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1496 * <p>Input: Nothing.
1497 * <p>Output: Nothing.
1498 * @hide
1499 */
1500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1501 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001502 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001503
1504 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001505 * Activity Action: Show settings for managing network data usage of a
1506 * specific application. Applications should define an activity that offers
1507 * options to control data usage.
1508 */
1509 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1510 public static final String ACTION_MANAGE_NETWORK_USAGE =
1511 "android.intent.action.MANAGE_NETWORK_USAGE";
1512
1513 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001514 * Activity Action: Launch application installer.
1515 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001516 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001517 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1518 * you can also use "package:<package-name>" to install an application for the
1519 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001520 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1521 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1522 * <p>
1523 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1524 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001525 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001526 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001527 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1528 * in order to launch the application installer.
1529 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001530 *
1531 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1532 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1533 * @see #EXTRA_RETURN_RESULT
1534 */
1535 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1536 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1537
1538 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001539 * Activity Action: Activity to handle split installation failures.
1540 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1541 * but the split that contains the application isn't installed. When a split is
1542 * installed in this manner, the containing package usually doesn't know this is
1543 * happening. However, if an error occurs during installation, the containing
1544 * package can define a single activity handling this action to deal with such
1545 * failures.
1546 * <p>The activity handling this action must be in the base package.
1547 * <p>
1548 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1549 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1550 */
1551 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1552 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1553
1554 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001555 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001556 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001557 * @deprecated Do not use. This will go away.
1558 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1559 */
1560 @SystemApi
1561 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1562 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1563 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1564 /**
1565 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001566 * <p class="note">
1567 * This is a protected intent that can only be sent by the system.
1568 * </p>
1569 *
1570 * @hide
1571 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1575 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576
1577 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001579 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001580 * @deprecated Do not use. This will go away.
1581 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1582 */
1583 @SystemApi
1584 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1585 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1586 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1587 /**
1588 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001589 * <p>
1590 * The system will have a persistent connection to this service.
1591 * This is a protected intent that can only be sent by the system.
1592 * </p>
1593 *
1594 * @hide
1595 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001596 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001597 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001598 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1599 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001600
1601 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001602 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001603 * @removed
Todd Kennedyd46a1602017-04-03 15:22:38 -07001604 * @deprecated Do not use. This will go away.
1605 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1606 */
1607 @SystemApi
1608 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1609 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1610 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1611 /**
1612 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001613 *
1614 * <p class="note">
1615 * This is a protected intent that can only be sent by the system.
1616 * </p>
1617 *
1618 * @hide
1619 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001620 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001621 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001622 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1623 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001624
1625 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001626 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1627 * package. Specifies the installer package name; this package will receive the
1628 * {@link #ACTION_APP_ERROR} intent.
1629 */
1630 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1631 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1632
1633 /**
1634 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1635 * package. Specifies that the application being installed should not be
1636 * treated as coming from an unknown source, but as coming from the app
1637 * invoking the Intent. For this to work you must start the installer with
1638 * startActivityForResult().
1639 */
1640 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1641 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1642
1643 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001644 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1645 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001646 * data field originated from.
1647 */
rich cannings706e8ba2012-08-20 13:20:14 -07001648 public static final String EXTRA_ORIGINATING_URI
1649 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001650
1651 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001652 * This extra can be used with any Intent used to launch an activity, supplying information
1653 * about who is launching that activity. This field contains a {@link android.net.Uri}
1654 * object, typically an http: or https: URI of the web site that the referral came from;
1655 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1656 * a native application that it came from.
1657 *
1658 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1659 * instead of directly retrieving the extra. It is also valid for applications to
1660 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1661 * a string, not a Uri; the field here, if supplied, will always take precedence,
1662 * however.</p>
1663 *
1664 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001665 */
1666 public static final String EXTRA_REFERRER
1667 = "android.intent.extra.REFERRER";
1668
1669 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001670 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1671 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1672 * not be created, in particular when Intent extras are supplied through the
1673 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1674 * schemes.
1675 *
1676 * @see #EXTRA_REFERRER
1677 */
1678 public static final String EXTRA_REFERRER_NAME
1679 = "android.intent.extra.REFERRER_NAME";
1680
1681 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001682 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001683 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001684 * Currently only a system app that hosts the provider authority "downloads" or holds the
1685 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001686 * @hide
1687 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001688 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001689 public static final String EXTRA_ORIGINATING_UID
1690 = "android.intent.extra.ORIGINATING_UID";
1691
1692 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001693 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1694 * package. Tells the installer UI to skip the confirmation with the user
1695 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001696 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1697 * will no longer show an interstitial message about updating existing
1698 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001699 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001700 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001701 public static final String EXTRA_ALLOW_REPLACE
1702 = "android.intent.extra.ALLOW_REPLACE";
1703
1704 /**
1705 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1706 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1707 * return to the application the result code of the install/uninstall. The returned result
1708 * code will be {@link android.app.Activity#RESULT_OK} on success or
1709 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1710 */
1711 public static final String EXTRA_RETURN_RESULT
1712 = "android.intent.extra.RETURN_RESULT";
1713
1714 /**
1715 * Package manager install result code. @hide because result codes are not
1716 * yet ready to be exposed.
1717 */
1718 public static final String EXTRA_INSTALL_RESULT
1719 = "android.intent.extra.INSTALL_RESULT";
1720
1721 /**
1722 * Activity Action: Launch application uninstaller.
1723 * <p>
1724 * Input: The data must be a package: URI whose scheme specific part is
1725 * the package name of the current installed package to be uninstalled.
1726 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1727 * <p>
1728 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1729 * succeeded.
1730 */
1731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1732 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1733
1734 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001735 * Specify whether the package should be uninstalled for all users.
1736 * @hide because these should not be part of normal application flow.
1737 */
1738 public static final String EXTRA_UNINSTALL_ALL_USERS
1739 = "android.intent.extra.UNINSTALL_ALL_USERS";
1740
1741 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001742 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1743 * describing the last run version of the platform that was setup.
1744 * @hide
1745 */
1746 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1747
Svet Ganov3695b8a2015-03-24 16:30:25 -07001748 /**
1749 * Activity action: Launch UI to manage the permissions of an app.
1750 * <p>
1751 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1752 * will be managed by the launched UI.
1753 * </p>
1754 * <p>
1755 * Output: Nothing.
1756 * </p>
1757 *
1758 * @see #EXTRA_PACKAGE_NAME
1759 *
1760 * @hide
1761 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001762 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001763 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1764 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1765 "android.intent.action.MANAGE_APP_PERMISSIONS";
1766
1767 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001768 * Activity action: Launch UI to manage permissions.
1769 * <p>
1770 * Input: Nothing.
1771 * </p>
1772 * <p>
1773 * Output: Nothing.
1774 * </p>
1775 *
1776 * @hide
1777 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001778 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001779 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1780 public static final String ACTION_MANAGE_PERMISSIONS =
1781 "android.intent.action.MANAGE_PERMISSIONS";
1782
1783 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001784 * Activity action: Launch UI to review permissions for an app.
1785 * The system uses this intent if permission review for apps not
1786 * supporting the new runtime permissions model is enabled. In
1787 * this mode a permission review is required before any of the
1788 * app components can run.
1789 * <p>
1790 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1791 * permissions will be reviewed (mandatory).
1792 * </p>
1793 * <p>
1794 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1795 * be fired after the permission review (optional).
1796 * </p>
1797 * <p>
1798 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1799 * be invoked after the permission review (optional).
1800 * </p>
1801 * <p>
1802 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1803 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1804 * </p>
1805 * <p>
1806 * Output: Nothing.
1807 * </p>
1808 *
1809 * @see #EXTRA_PACKAGE_NAME
1810 * @see #EXTRA_INTENT
1811 * @see #EXTRA_REMOTE_CALLBACK
1812 * @see #EXTRA_RESULT_NEEDED
1813 *
1814 * @hide
1815 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001816 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001817 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1818 public static final String ACTION_REVIEW_PERMISSIONS =
1819 "android.intent.action.REVIEW_PERMISSIONS";
1820
1821 /**
1822 * Intent extra: A callback for reporting remote result as a bundle.
1823 * <p>
1824 * Type: IRemoteCallback
1825 * </p>
1826 *
1827 * @hide
1828 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001829 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001830 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1831
1832 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001833 * Intent extra: An app package name.
1834 * <p>
1835 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001836 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001837 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001838 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001839 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1840
1841 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001842 * Intent extra: An app split name.
1843 * <p>
1844 * Type: String
1845 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001846 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001847 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1848
1849 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001850 * Intent extra: A {@link ComponentName} value.
1851 * <p>
1852 * Type: String
1853 * </p>
1854 */
1855 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1856
1857 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001858 * Intent extra: An extra for specifying whether a result is needed.
1859 * <p>
1860 * Type: boolean
1861 * </p>
1862 *
1863 * @hide
1864 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001865 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001866 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1867
1868 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001869 * Activity action: Launch UI to manage which apps have a given permission.
1870 * <p>
1871 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1872 * to which will be managed by the launched UI.
1873 * </p>
1874 * <p>
1875 * Output: Nothing.
1876 * </p>
1877 *
1878 * @see #EXTRA_PERMISSION_NAME
1879 *
1880 * @hide
1881 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001882 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001883 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1884 public static final String ACTION_MANAGE_PERMISSION_APPS =
1885 "android.intent.action.MANAGE_PERMISSION_APPS";
1886
1887 /**
1888 * Intent extra: The name of a permission.
1889 * <p>
1890 * Type: String
1891 * </p>
1892 *
1893 * @hide
1894 */
1895 @SystemApi
1896 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1897
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001898 // ---------------------------------------------------------------------
1899 // ---------------------------------------------------------------------
1900 // Standard intent broadcast actions (see action variable).
1901
1902 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001903 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1904 * <p>
1905 * For historical reasons, the name of this broadcast action refers to the power
1906 * state of the screen but it is actually sent in response to changes in the
1907 * overall interactive state of the device.
1908 * </p><p>
1909 * This broadcast is sent when the device becomes non-interactive which may have
1910 * nothing to do with the screen turning off. To determine the
1911 * actual state of the screen, use {@link android.view.Display#getState}.
1912 * </p><p>
1913 * See {@link android.os.PowerManager#isInteractive} for details.
1914 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001915 * You <em>cannot</em> receive this through components declared in
1916 * manifests, only by explicitly registering for it with
1917 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1918 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001919 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001920 * <p class="note">This is a protected intent that can only be sent
1921 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001922 */
1923 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1924 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001925
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001926 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001927 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1928 * <p>
1929 * For historical reasons, the name of this broadcast action refers to the power
1930 * state of the screen but it is actually sent in response to changes in the
1931 * overall interactive state of the device.
1932 * </p><p>
1933 * This broadcast is sent when the device becomes interactive which may have
1934 * nothing to do with the screen turning on. To determine the
1935 * actual state of the screen, use {@link android.view.Display#getState}.
1936 * </p><p>
1937 * See {@link android.os.PowerManager#isInteractive} for details.
1938 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001939 * You <em>cannot</em> receive this through components declared in
1940 * manifests, only by explicitly registering for it with
1941 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1942 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001943 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001944 * <p class="note">This is a protected intent that can only be sent
1945 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001946 */
1947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1948 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001949
1950 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001951 * Broadcast Action: Sent after the system stops dreaming.
1952 *
1953 * <p class="note">This is a protected intent that can only be sent by the system.
1954 * It is only sent to registered receivers.</p>
1955 */
1956 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1957 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1958
1959 /**
1960 * Broadcast Action: Sent after the system starts dreaming.
1961 *
1962 * <p class="note">This is a protected intent that can only be sent by the system.
1963 * It is only sent to registered receivers.</p>
1964 */
1965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1966 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1967
1968 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001969 * 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 -07001970 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001971 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001972 * <p class="note">This is a protected intent that can only be sent
1973 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001974 */
1975 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001976 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001977
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 /**
1979 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001980 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001981 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001982 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1983 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001984 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001985 * <p class="note">This is a protected intent that can only be sent
1986 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001987 */
1988 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1989 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1990 /**
1991 * Broadcast Action: The time was set.
1992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1995 /**
1996 * Broadcast Action: The date has changed.
1997 */
1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1999 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2000 /**
2001 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2002 * <ul>
2003 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2004 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002005 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002006 * <p class="note">This is a protected intent that can only be sent
2007 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2011 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002012 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2013 * DNS entries should be tossed.
2014 * @hide
2015 */
2016 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2017 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2018 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002019 * Alarm Changed Action: This is broadcast when the AlarmClock
2020 * application's alarm is set or unset. It is used by the
2021 * AlarmClock application and the StatusBar service.
2022 * @hide
2023 */
2024 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2025 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002026
2027 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002028 * Broadcast Action: This is broadcast once, after the user has finished
2029 * booting, but while still in the "locked" state. It can be used to perform
2030 * application-specific initialization, such as installing alarms. You must
2031 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2032 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002033 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002034 * This broadcast is sent immediately at boot by all devices (regardless of
2035 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2036 * higher. Upon receipt of this broadcast, the user is still locked and only
2037 * device-protected storage can be accessed safely. If you want to access
2038 * credential-protected storage, you need to wait for the user to be
2039 * unlocked (typically by entering their lock pattern or PIN for the first
2040 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2041 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2042 * <p>
2043 * To receive this broadcast, your receiver component must be marked as
2044 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002045 * <p class="note">
2046 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002047 *
2048 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002049 */
2050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2051 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2052
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002053 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002054 * Broadcast Action: This is broadcast once, after the user has finished
2055 * booting. It can be used to perform application-specific initialization,
2056 * such as installing alarms. You must hold the
2057 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2058 * order to receive this broadcast.
2059 * <p>
2060 * This broadcast is sent at boot by all devices (both with and without
2061 * direct boot support). Upon receipt of this broadcast, the user is
2062 * unlocked and both device-protected and credential-protected storage can
2063 * accessed safely.
2064 * <p>
2065 * If you need to run while the user is still locked (before they've entered
2066 * their lock pattern or PIN for the first time), you can listen for the
2067 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2068 * <p class="note">
2069 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002070 */
2071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002072 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002073 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002074
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002075 /**
2076 * Broadcast Action: This is broadcast when a user action should request a
2077 * temporary system dialog to dismiss. Some examples of temporary system
2078 * dialogs are the notification window-shade and the recent tasks dialog.
2079 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002081 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2082 /**
2083 * Broadcast Action: Trigger the download and eventual installation
2084 * of a package.
2085 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002086 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002087 * <p class="note">This is a protected intent that can only be sent
2088 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002089 *
2090 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002091 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002092 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002093 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2094 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2095 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002096 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002097 * device. The data contains the name of the package. Note that the
2098 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002099 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002100 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002101 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2102 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002103 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2104 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002105 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002106 * <p class="note">This is a protected intent that can only be sent
2107 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002108 */
2109 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2110 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2111 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002112 * Broadcast Action: A new version of an application package has been
2113 * installed, replacing an existing version that was previously installed.
2114 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002115 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002116 * <ul>
2117 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2118 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002119 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002120 * <p class="note">This is a protected intent that can only be sent
2121 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002122 */
2123 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2124 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2125 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002126 * Broadcast Action: A new version of your application has been installed
2127 * over an existing one. This is only sent to the application that was
2128 * replaced. It does not contain any additional data; to receive it, just
2129 * use an intent filter for this action.
2130 *
2131 * <p class="note">This is a protected intent that can only be sent
2132 * by the system.
2133 */
2134 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2135 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2136 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002137 * Broadcast Action: An existing application package has been removed from
2138 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002139 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002140 * <ul>
2141 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2142 * to the package.
2143 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2144 * application -- data and code -- is being removed.
2145 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2146 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2147 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002148 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002149 * <p class="note">This is a protected intent that can only be sent
2150 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002151 */
2152 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2153 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2154 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002155 * Broadcast Action: An existing application package has been completely
2156 * removed from the device. The data contains the name of the package.
2157 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2158 * {@link #EXTRA_DATA_REMOVED} is true and
2159 * {@link #EXTRA_REPLACING} is false of that broadcast.
2160 *
2161 * <ul>
2162 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2163 * to the package.
2164 * </ul>
2165 *
2166 * <p class="note">This is a protected intent that can only be sent
2167 * by the system.
2168 */
2169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2170 public static final String ACTION_PACKAGE_FULLY_REMOVED
2171 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2172 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002173 * Broadcast Action: An existing application package has been changed (for
2174 * example, a component has been enabled or disabled). The data contains
2175 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002176 * <ul>
2177 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002178 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002179 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002180 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2181 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002182 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002183 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002184 * <p class="note">This is a protected intent that can only be sent
2185 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2189 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002190 * @hide
2191 * Broadcast Action: Ask system services if there is any reason to
2192 * restart the given package. The data contains the name of the
2193 * package.
2194 * <ul>
2195 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2196 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2197 * </ul>
2198 *
2199 * <p class="note">This is a protected intent that can only be sent
2200 * by the system.
2201 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002202 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002203 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2204 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2205 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002206 * Broadcast Action: The user has restarted a package, and all of its
2207 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002208 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002209 * be removed. Note that the restarted package does <em>not</em>
2210 * receive this broadcast.
2211 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002212 * <ul>
2213 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2214 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002215 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002216 * <p class="note">This is a protected intent that can only be sent
2217 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002218 */
2219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2220 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2221 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002222 * Broadcast Action: The user has cleared the data of a package. This should
2223 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002224 * its persistent data is erased and this broadcast sent.
2225 * Note that the cleared package does <em>not</em>
2226 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002227 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002228 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2229 * package whose data was cleared is an uninstalled instant app, then the UID
2230 * will be -1. The platform keeps some meta-data associated with instant apps
2231 * after they are uninstalled.
2232 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2233 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002234 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002235 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002236 * <p class="note">This is a protected intent that can only be sent
2237 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2241 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002242 * Broadcast Action: Packages have been suspended.
2243 * <p>Includes the following extras:
2244 * <ul>
2245 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2246 * </ul>
2247 *
2248 * <p class="note">This is a protected intent that can only be sent
2249 * by the system. It is only sent to registered receivers.
2250 */
2251 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2252 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2253 /**
2254 * Broadcast Action: Packages have been unsuspended.
2255 * <p>Includes the following extras:
2256 * <ul>
2257 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2258 * </ul>
2259 *
2260 * <p class="note">This is a protected intent that can only be sent
2261 * by the system. It is only sent to registered receivers.
2262 */
2263 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2264 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2265 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002266 * Broadcast Action: A user ID has been removed from the system. The user
2267 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002268 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002269 * <p class="note">This is a protected intent that can only be sent
2270 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002271 */
2272 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2273 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002274
2275 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002276 * Broadcast Action: Sent to the installer package of an application when
2277 * that application is first launched (that is the first time it is moved
2278 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002279 *
2280 * <p class="note">This is a protected intent that can only be sent
2281 * by the system.
2282 */
2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2284 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2285
2286 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002287 * Broadcast Action: Sent to the system package verifier when a package
2288 * needs to be verified. The data contains the package URI.
2289 * <p class="note">
2290 * This is a protected intent that can only be sent by the system.
2291 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002292 */
2293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2294 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2295
2296 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002297 * Broadcast Action: Sent to the system package verifier when a package is
2298 * verified. The data contains the package URI.
2299 * <p class="note">
2300 * This is a protected intent that can only be sent by the system.
2301 */
2302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2303 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2304
2305 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002306 * Broadcast Action: Sent to the system intent filter verifier when an
2307 * intent filter needs to be verified. The data contains the filter data
2308 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002309 * <p class="note">
2310 * This is a protected intent that can only be sent by the system.
2311 * </p>
2312 *
2313 * @hide
2314 */
2315 @SystemApi
2316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2317 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2318
2319 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002320 * Broadcast Action: Resources for a set of packages (which were
2321 * previously unavailable) are currently
2322 * available since the media on which they exist is available.
2323 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2324 * list of packages whose availability changed.
2325 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2326 * list of uids of packages whose availability changed.
2327 * Note that the
2328 * packages in this list do <em>not</em> receive this broadcast.
2329 * The specified set of packages are now available on the system.
2330 * <p>Includes the following extras:
2331 * <ul>
2332 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2333 * whose resources(were previously unavailable) are currently available.
2334 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2335 * packages whose resources(were previously unavailable)
2336 * are currently available.
2337 * </ul>
2338 *
2339 * <p class="note">This is a protected intent that can only be sent
2340 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002341 */
2342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002343 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2344 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002345
2346 /**
2347 * Broadcast Action: Resources for a set of packages are currently
2348 * unavailable since the media on which they exist is unavailable.
2349 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2350 * list of packages whose availability changed.
2351 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2352 * list of uids of packages whose availability changed.
2353 * The specified set of packages can no longer be
2354 * launched and are practically unavailable on the system.
2355 * <p>Inclues the following extras:
2356 * <ul>
2357 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2358 * whose resources are no longer available.
2359 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2360 * whose resources are no longer available.
2361 * </ul>
2362 *
2363 * <p class="note">This is a protected intent that can only be sent
2364 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002365 */
2366 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002367 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002368 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002369
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002370 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002371 * Broadcast Action: preferred activities have changed *explicitly*.
2372 *
2373 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2374 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2375 * be sent.
2376 *
2377 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2378 *
2379 * @hide
2380 */
2381 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2382 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2383 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2384
2385
2386 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002387 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002388 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002389 * This should <em>only</em> be used to determine when the wallpaper
2390 * has changed to show the new wallpaper to the user. You should certainly
2391 * never, in response to this, change the wallpaper or other attributes of
2392 * it such as the suggested size. That would be crazy, right? You'd cause
2393 * all kinds of loops, especially if other apps are doing similar things,
2394 * right? Of course. So please don't do this.
2395 *
2396 * @deprecated Modern applications should use
2397 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2398 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2399 * shown behind their UI, rather than watching for this broadcast and
2400 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002401 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002402 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002403 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2404 /**
2405 * Broadcast Action: The current device {@link android.content.res.Configuration}
2406 * (orientation, locale, etc) has changed. When such a change happens, the
2407 * UIs (view hierarchy) will need to be rebuilt based on this new
2408 * information; for the most part, applications don't need to worry about
2409 * this, because the system will take care of stopping and restarting the
2410 * application to make sure it sees the new changes. Some system code that
2411 * can not be restarted will need to watch for this action and handle it
2412 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002413 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002414 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002415 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002416 * in manifests, only by explicitly registering for it with
2417 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2418 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002419 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002420 * <p class="note">This is a protected intent that can only be sent
2421 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 *
2423 * @see android.content.res.Configuration
2424 */
2425 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2426 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2427 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002428 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002429 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002430 * <p class="note">This is a protected intent that can only be sent
2431 * by the system.
2432 */
2433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2434 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2435 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002436 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2437 * charging state, level, and other information about the battery.
2438 * See {@link android.os.BatteryManager} for documentation on the
2439 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002440 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002441 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002442 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002443 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002444 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002445 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2446 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2447 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2448 * broadcasts that are sent and can be received through manifest
2449 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002450 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002451 * <p class="note">This is a protected intent that can only be sent
2452 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002453 */
2454 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2455 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2456 /**
2457 * Broadcast Action: Indicates low battery condition on the device.
2458 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002459 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002460 * <p class="note">This is a protected intent that can only be sent
2461 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002462 */
2463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2464 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2465 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002466 * Broadcast Action: Indicates the battery is now okay after being low.
2467 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2468 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002469 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002470 * <p class="note">This is a protected intent that can only be sent
2471 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002472 */
2473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2474 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2475 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002476 * Broadcast Action: External power has been connected to the device.
2477 * This is intended for applications that wish to register specifically to this notification.
2478 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2479 * stay active to receive this notification. This action can be used to implement actions
2480 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002481 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002482 * <p class="note">This is a protected intent that can only be sent
2483 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002486 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002487 /**
2488 * Broadcast Action: External power has been removed from the device.
2489 * This is intended for applications that wish to register specifically to this notification.
2490 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2491 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002492 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002493 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002494 * <p class="note">This is a protected intent that can only be sent
2495 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002498 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002499 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002500 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002501 * Broadcast Action: Device is shutting down.
2502 * This is broadcast when the device is being shut down (completely turned
2503 * off, not sleeping). Once the broadcast is complete, the final shutdown
2504 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002505 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002506 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002507 * <p class="note">This is a protected intent that can only be sent
2508 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002509 * <p>May include the following extras:
2510 * <ul>
2511 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2512 * shutdown is only for userspace processes. If not set, assumed to be false.
2513 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002514 */
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002516 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002517 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002518 * Activity Action: Start this activity to request system shutdown.
2519 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002520 * to request confirmation from the user before shutting down. The optional boolean
2521 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2522 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002523 *
2524 * <p class="note">This is a protected intent that can only be sent
2525 * by the system.
2526 *
2527 * {@hide}
2528 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002529 public static final String ACTION_REQUEST_SHUTDOWN
2530 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002531 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002532 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002533 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002534 * <p class="note">
2535 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002536 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002537 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2538 * or above, this broadcast will no longer be delivered to any
2539 * {@link BroadcastReceiver} defined in your manifest. Instead,
2540 * apps are strongly encouraged to use the improved
2541 * {@link Context#getCacheDir()} behavior so the system can
2542 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 */
2544 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002545 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002546 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2547 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002548 * Broadcast Action: Indicates low storage space condition on the device no
2549 * longer exists
2550 * <p class="note">
2551 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002552 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002553 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2554 * or above, this broadcast will no longer be delivered to any
2555 * {@link BroadcastReceiver} defined in your manifest. Instead,
2556 * apps are strongly encouraged to use the improved
2557 * {@link Context#getCacheDir()} behavior so the system can
2558 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002561 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002562 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2563 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002564 * Broadcast Action: A sticky broadcast that indicates a storage space full
2565 * condition on the device. This is intended for activities that want to be
2566 * able to fill the data partition completely, leaving only enough free
2567 * space to prevent system-wide SQLite failures.
2568 * <p class="note">
2569 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002570 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002571 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2572 * or above, this broadcast will no longer be delivered to any
2573 * {@link BroadcastReceiver} defined in your manifest. Instead,
2574 * apps are strongly encouraged to use the improved
2575 * {@link Context#getCacheDir()} behavior so the system can
2576 * automatically free up storage when needed.
2577 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002580 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002581 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2582 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002583 * Broadcast Action: Indicates storage space full condition on the device no
2584 * longer exists.
2585 * <p class="note">
2586 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002587 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002588 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2589 * or above, this broadcast will no longer be delivered to any
2590 * {@link BroadcastReceiver} defined in your manifest. Instead,
2591 * apps are strongly encouraged to use the improved
2592 * {@link Context#getCacheDir()} behavior so the system can
2593 * automatically free up storage when needed.
2594 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002597 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002598 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2599 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002600 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2601 * and package management should be started.
2602 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2603 * notification.
2604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2607 /**
2608 * Broadcast Action: The device has entered USB Mass Storage mode.
2609 * This is used mainly for the USB Settings panel.
2610 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2611 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002612 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002613 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002614 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002615 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002616 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2617
2618 /**
2619 * Broadcast Action: The device has exited USB Mass Storage mode.
2620 * This is used mainly for the USB Settings panel.
2621 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2622 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002623 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002624 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002625 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002627 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2628
2629 /**
2630 * Broadcast Action: External media has been removed.
2631 * The path to the mount point for the removed media is contained in the Intent.mData field.
2632 */
2633 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2634 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2635
2636 /**
2637 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002638 * 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 -07002639 */
2640 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2641 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2642
2643 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002644 * Broadcast Action: External media is present, and being disk-checked
2645 * 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 -08002646 */
2647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2648 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2649
2650 /**
2651 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2652 * 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 -08002653 */
2654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2655 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2656
2657 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002659 * 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 -07002660 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2661 * media was mounted read only.
2662 */
2663 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2664 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2665
2666 /**
2667 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002668 * 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 -07002669 */
2670 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2671 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2672
2673 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002674 * Broadcast Action: External media is no longer being shared via USB mass storage.
2675 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2676 *
2677 * @hide
2678 */
2679 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2680
2681 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002682 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2683 * The path to the mount point for the removed media is contained in the Intent.mData field.
2684 */
2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2686 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2687
2688 /**
2689 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002690 * 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 -07002691 */
2692 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2693 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2694
2695 /**
2696 * Broadcast Action: User has expressed the desire to remove the external storage media.
2697 * Applications should close all files they have open within the mount point when they receive this intent.
2698 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2699 */
2700 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2701 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2702
2703 /**
2704 * Broadcast Action: The media scanner has started scanning a directory.
2705 * The path to the directory being scanned is contained in the Intent.mData field.
2706 */
2707 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2708 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2709
2710 /**
2711 * Broadcast Action: The media scanner has finished scanning a directory.
2712 * The path to the scanned directory is contained in the Intent.mData field.
2713 */
2714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2715 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2716
2717 /**
2718 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2719 * The path to the file is contained in the Intent.mData field.
2720 */
2721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2722 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2723
2724 /**
2725 * Broadcast Action: The "Media Button" was pressed. Includes a single
2726 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2727 * caused the broadcast.
2728 */
2729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2730 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2731
2732 /**
2733 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2734 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2735 * caused the broadcast.
2736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2738 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2739
2740 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2741 // location; they are not general-purpose actions.
2742
2743 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002744 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002745 */
2746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2747 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2748 "android.intent.action.GTALK_CONNECTED";
2749
2750 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002751 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002752 */
2753 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2754 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2755 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002756
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002757 /**
2758 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002759 */
2760 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2761 public static final String ACTION_INPUT_METHOD_CHANGED =
2762 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002763
2764 /**
2765 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2766 * more radios have been turned off or on. The intent will have the following extra value:</p>
2767 * <ul>
2768 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2769 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2770 * turned off</li>
2771 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002772 *
Peng Xua35b5532016-01-20 00:05:45 -08002773 * <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 -07002774 */
2775 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2776 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2777
2778 /**
2779 * Broadcast Action: Some content providers have parts of their namespace
2780 * where they publish new events or items that the user may be especially
2781 * interested in. For these things, they may broadcast this action when the
2782 * set of interesting items change.
2783 *
2784 * For example, GmailProvider sends this notification when the set of unread
2785 * mail in the inbox changes.
2786 *
2787 * <p>The data of the intent identifies which part of which provider
2788 * changed. When queried through the content resolver, the data URI will
2789 * return the data set in question.
2790 *
2791 * <p>The intent will have the following extra values:
2792 * <ul>
2793 * <li><em>count</em> - The number of items in the data set. This is the
2794 * same as the number of items in the cursor returned by querying the
2795 * data URI. </li>
2796 * </ul>
2797 *
2798 * This intent will be sent at boot (if the count is non-zero) and when the
2799 * data set changes. It is possible for the data set to change without the
2800 * count changing (for example, if a new unread message arrives in the same
2801 * sync operation in which a message is archived). The phone should still
2802 * ring/vibrate/etc as normal in this case.
2803 */
2804 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2805 public static final String ACTION_PROVIDER_CHANGED =
2806 "android.intent.action.PROVIDER_CHANGED";
2807
2808 /**
2809 * Broadcast Action: Wired Headset plugged in or unplugged.
2810 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002811 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2812 * and documentation.
2813 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002814 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002815 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002816 */
2817 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002818 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002819
2820 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002821 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2822 * <ul>
2823 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2824 * </ul>
2825 *
2826 * <p class="note">This is a protected intent that can only be sent
2827 * by the system.
2828 *
2829 * @hide
2830 */
2831 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2833 = "android.intent.action.ADVANCED_SETTINGS";
2834
2835 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002836 * Broadcast Action: Sent after application restrictions are changed.
2837 *
2838 * <p class="note">This is a protected intent that can only be sent
2839 * by the system.</p>
2840 */
2841 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2842 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2843 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2844
2845 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002846 * Broadcast Action: An outgoing call is about to be placed.
2847 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002848 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002849 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002850 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002851 * the phone number originally intended to be dialed.</li>
2852 * </ul>
2853 * <p>Once the broadcast is finished, the resultData is used as the actual
2854 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002855 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002856 * outgoing call in turn: for example, a parental control application
2857 * might verify that the user is authorized to place the call at that
2858 * time, then a number-rewriting application might add an area code if
2859 * one was not specified.</p>
2860 * <p>For consistency, any receiver whose purpose is to prohibit phone
2861 * calls should have a priority of 0, to ensure it will see the final
2862 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002863 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002864 * should have a positive priority.
2865 * Negative priorities are reserved for the system for this broadcast;
2866 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002867 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2868 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002869 * <p>Emergency calls cannot be intercepted using this mechanism, and
2870 * other calls cannot be modified to call emergency numbers using this
2871 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002872 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2873 * call to use their own service instead. Those apps should first prevent
2874 * the call from being placed by setting resultData to <code>null</code>
2875 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002876 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002877 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2878 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002879 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002880 * <p class="note">This is a protected intent that can only be sent
2881 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002882 */
2883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2884 public static final String ACTION_NEW_OUTGOING_CALL =
2885 "android.intent.action.NEW_OUTGOING_CALL";
2886
2887 /**
2888 * Broadcast Action: Have the device reboot. This is only for use by
2889 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002890 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002891 * <p class="note">This is a protected intent that can only be sent
2892 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002893 */
2894 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2895 public static final String ACTION_REBOOT =
2896 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002897
Wei Huang97ecc9c2009-05-11 17:44:20 -07002898 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002899 * Broadcast Action: A sticky broadcast for changes in the physical
2900 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002901 *
2902 * <p>The intent will have the following extra values:
2903 * <ul>
2904 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002905 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002906 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002907 * <p>This is intended for monitoring the current physical dock state.
2908 * See {@link android.app.UiModeManager} for the normal API dealing with
2909 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002910 */
2911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2912 public static final String ACTION_DOCK_EVENT =
2913 "android.intent.action.DOCK_EVENT";
2914
2915 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002916 * Broadcast Action: A broadcast when idle maintenance can be started.
2917 * This means that the user is not interacting with the device and is
2918 * not expected to do so soon. Typical use of the idle maintenance is
2919 * to perform somehow expensive tasks that can be postponed at a moment
2920 * when they will not degrade user experience.
2921 * <p>
2922 * <p class="note">In order to keep the device responsive in case of an
2923 * unexpected user interaction, implementations of a maintenance task
2924 * should be interruptible. In such a scenario a broadcast with action
2925 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2926 * should not do the maintenance work in
2927 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2928 * maintenance service by {@link Context#startService(Intent)}. Also
2929 * you should hold a wake lock while your maintenance service is running
2930 * to prevent the device going to sleep.
2931 * </p>
2932 * <p>
2933 * <p class="note">This is a protected intent that can only be sent by
2934 * the system.
2935 * </p>
2936 *
2937 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002938 *
2939 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002940 */
2941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2942 public static final String ACTION_IDLE_MAINTENANCE_START =
2943 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2944
2945 /**
2946 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2947 * This means that the user was not interacting with the device as a result
2948 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2949 * was sent and now the user started interacting with the device. Typical
2950 * use of the idle maintenance is to perform somehow expensive tasks that
2951 * can be postponed at a moment when they will not degrade user experience.
2952 * <p>
2953 * <p class="note">In order to keep the device responsive in case of an
2954 * unexpected user interaction, implementations of a maintenance task
2955 * should be interruptible. Hence, on receiving a broadcast with this
2956 * action, the maintenance task should be interrupted as soon as possible.
2957 * In other words, you should not do the maintenance work in
2958 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2959 * maintenance service that was started on receiving of
2960 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2961 * lock you acquired when your maintenance service started.
2962 * </p>
2963 * <p class="note">This is a protected intent that can only be sent
2964 * by the system.
2965 *
2966 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002967 *
2968 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002969 */
2970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2971 public static final String ACTION_IDLE_MAINTENANCE_END =
2972 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2973
2974 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002975 * Broadcast Action: a remote intent is to be broadcasted.
2976 *
2977 * A remote intent is used for remote RPC between devices. The remote intent
2978 * is serialized and sent from one device to another device. The receiving
2979 * device parses the remote intent and broadcasts it. Note that anyone can
2980 * broadcast a remote intent. However, if the intent receiver of the remote intent
2981 * does not trust intent broadcasts from arbitrary intent senders, it should require
2982 * the sender to hold certain permissions so only trusted sender's broadcast will be
2983 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002984 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002985 */
2986 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002987 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002988
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002989 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002990 * Broadcast Action: This is broadcast once when the user is booting after a
2991 * system update. It can be used to perform cleanup or upgrades after a
2992 * system update.
2993 * <p>
2994 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2995 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2996 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2997 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002998 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002999 * @hide
3000 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003001 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003002 public static final String ACTION_PRE_BOOT_COMPLETED =
3003 "android.intent.action.PRE_BOOT_COMPLETED";
3004
Amith Yamasani13593602012-03-22 16:16:17 -07003005 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003006 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003007 * on restricted users. The broadcast intent contains an extra
3008 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3009 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3010 * String[] depending on the restriction type.<p/>
3011 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003012 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3013 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3014 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003015 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3016 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003017 * @see RestrictionEntry
3018 */
3019 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3020 "android.intent.action.GET_RESTRICTION_ENTRIES";
3021
3022 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003023 * Sent the first time a user is starting, to allow system apps to
3024 * perform one time initialization. (This will not be seen by third
3025 * party applications because a newly initialized user does not have any
3026 * third party applications installed for it.) This is sent early in
3027 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003028 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3029 * broadcast, since it is part of a visible user interaction; be as quick
3030 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003031 */
3032 public static final String ACTION_USER_INITIALIZE =
3033 "android.intent.action.USER_INITIALIZE";
3034
3035 /**
3036 * Sent when a user switch is happening, causing the process's user to be
3037 * brought to the foreground. This is only sent to receivers registered
3038 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3039 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003040 * foreground. This is sent as a foreground
3041 * broadcast, since it is part of a visible user interaction; be as quick
3042 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003043 */
3044 public static final String ACTION_USER_FOREGROUND =
3045 "android.intent.action.USER_FOREGROUND";
3046
3047 /**
3048 * Sent when a user switch is happening, causing the process's user to be
3049 * sent to the background. This is only sent to receivers registered
3050 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3051 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003052 * background. This is sent as a foreground
3053 * broadcast, since it is part of a visible user interaction; be as quick
3054 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003055 */
3056 public static final String ACTION_USER_BACKGROUND =
3057 "android.intent.action.USER_BACKGROUND";
3058
3059 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003060 * Broadcast sent to the system when a user is added. Carries an extra
3061 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3062 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003063 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003064 * @hide
3065 */
3066 public static final String ACTION_USER_ADDED =
3067 "android.intent.action.USER_ADDED";
3068
3069 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003070 * Broadcast sent by the system when a user is started. Carries an extra
3071 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003072 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003073 * that has been started. This is sent as a foreground
3074 * broadcast, since it is part of a visible user interaction; be as quick
3075 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003076 * @hide
3077 */
3078 public static final String ACTION_USER_STARTED =
3079 "android.intent.action.USER_STARTED";
3080
3081 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003082 * Broadcast sent when a user is in the process of starting. Carries an extra
3083 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3084 * sent to registered receivers, not manifest receivers. It is sent to all
3085 * users (including the one that is being started). You must hold
3086 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3087 * this broadcast. This is sent as a background broadcast, since
3088 * its result is not part of the primary UX flow; to safely keep track of
3089 * started/stopped state of a user you can use this in conjunction with
3090 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3091 * other user state broadcasts since those are foreground broadcasts so can
3092 * execute in a different order.
3093 * @hide
3094 */
3095 public static final String ACTION_USER_STARTING =
3096 "android.intent.action.USER_STARTING";
3097
3098 /**
3099 * Broadcast sent when a user is going to be stopped. Carries an extra
3100 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3101 * sent to registered receivers, not manifest receivers. It is sent to all
3102 * users (including the one that is being stopped). You must hold
3103 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3104 * this broadcast. The user will not stop until all receivers have
3105 * handled the broadcast. This is sent as a background broadcast, since
3106 * its result is not part of the primary UX flow; to safely keep track of
3107 * started/stopped state of a user you can use this in conjunction with
3108 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3109 * other user state broadcasts since those are foreground broadcasts so can
3110 * execute in a different order.
3111 * @hide
3112 */
3113 public static final String ACTION_USER_STOPPING =
3114 "android.intent.action.USER_STOPPING";
3115
3116 /**
3117 * Broadcast sent to the system when a user is stopped. Carries an extra
3118 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3119 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3120 * specific package. This is only sent to registered receivers, not manifest
3121 * receivers. It is sent to all running users <em>except</em> the one that
3122 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003123 * @hide
3124 */
3125 public static final String ACTION_USER_STOPPED =
3126 "android.intent.action.USER_STOPPED";
3127
3128 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003129 * 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 -07003130 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003131 * one that has been removed. The user will not be completely removed until all receivers have
3132 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003133 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003134 * @hide
3135 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003136 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003137 public static final String ACTION_USER_REMOVED =
3138 "android.intent.action.USER_REMOVED";
3139
3140 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003141 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003142 * the userHandle of the user to become the current one. This is only sent to
3143 * registered receivers, not manifest receivers. It is sent to all running users.
3144 * You must hold
3145 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003146 * @hide
3147 */
3148 public static final String ACTION_USER_SWITCHED =
3149 "android.intent.action.USER_SWITCHED";
3150
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003151 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003152 * Broadcast Action: Sent when the credential-encrypted private storage has
3153 * become unlocked for the target user. This is only sent to registered
3154 * receivers, not manifest receivers.
3155 */
3156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3157 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3158
3159 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003160 * Broadcast sent to the system when a user's information changes. Carries an extra
3161 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003162 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003163 * @hide
3164 */
3165 public static final String ACTION_USER_INFO_CHANGED =
3166 "android.intent.action.USER_INFO_CHANGED";
3167
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003168 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003169 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3170 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003171 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3172 * that need to display merged content across both primary and managed profiles need to
3173 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003174 * not manifest receivers.
3175 */
3176 public static final String ACTION_MANAGED_PROFILE_ADDED =
3177 "android.intent.action.MANAGED_PROFILE_ADDED";
3178
3179 /**
3180 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003181 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3182 * Only applications (for example Launchers) that need to display merged content across both
3183 * primary and managed profiles need to worry about this broadcast. This is only sent to
3184 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003185 */
3186 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3187 "android.intent.action.MANAGED_PROFILE_REMOVED";
3188
3189 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003190 * Broadcast sent to the primary user when the credential-encrypted private storage for
3191 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3192 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3193 * Launchers) that need to display merged content across both primary and managed profiles
3194 * need to worry about this broadcast. This is only sent to registered receivers,
3195 * not manifest receivers.
3196 */
3197 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3198 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3199
3200 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003201 * Broadcast sent to the primary user when an associated managed profile has become available.
3202 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003203 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3204 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3205 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003206 */
Rubin Xue95057a2016-04-01 16:49:25 +01003207 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3208 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3209
3210 /**
3211 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3212 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3213 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3214 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3215 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3216 */
3217 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3218 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003219
3220 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003221 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3222 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3223 * the device was locked or unlocked.
3224 *
3225 * This is only sent to registered receivers.
3226 *
3227 * @hide
3228 */
3229 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3230 "android.intent.action.DEVICE_LOCKED_CHANGED";
3231
3232 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003233 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3234 */
3235 public static final String ACTION_QUICK_CLOCK =
3236 "android.intent.action.QUICK_CLOCK";
3237
Michael Wright0087a142013-02-05 16:29:39 -08003238 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003239 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003240 * @hide
3241 */
3242 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003243 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003244
Justin Kohd378ad72013-04-01 12:18:26 -07003245 /**
3246 * Broadcast Action: A global button was pressed. Includes a single
3247 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3248 * caused the broadcast.
3249 * @hide
3250 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003251 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003252 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3253
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003254 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003255 * Broadcast Action: Sent when media resource is granted.
3256 * <p>
3257 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3258 * granted.
3259 * </p>
3260 * <p class="note">
3261 * This is a protected intent that can only be sent by the system.
3262 * </p>
3263 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003264 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003265 * </p>
3266 *
3267 * @hide
3268 */
3269 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3270 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3271
3272 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003273 * Broadcast Action: An overlay package has changed. The data contains the
3274 * name of the overlay package which has changed. This is broadcast on all
3275 * changes to the OverlayInfo returned by {@link
3276 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3277 * most common change is a state change that will change whether the
3278 * overlay is enabled or not.
3279 * @hide
3280 */
3281 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3282
3283 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003284 * Activity Action: Allow the user to select and return one or more existing
3285 * documents. When invoked, the system will display the various
3286 * {@link DocumentsProvider} instances installed on the device, letting the
3287 * user interactively navigate through them. These documents include local
3288 * media, such as photos and video, and documents provided by installed
3289 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003290 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003291 * Each document is represented as a {@code content://} URI backed by a
3292 * {@link DocumentsProvider}, which can be opened as a stream with
3293 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3294 * {@link android.provider.DocumentsContract.Document} metadata.
3295 * <p>
3296 * All selected documents are returned to the calling application with
3297 * persistable read and write permission grants. If you want to maintain
3298 * access to the documents across device reboots, you need to explicitly
3299 * take the persistable permissions using
3300 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3301 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003302 * Callers must indicate the acceptable document MIME types through
3303 * {@link #setType(String)}. For example, to select photos, use
3304 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3305 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3306 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003307 * <p>
3308 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003309 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3310 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003311 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003312 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3313 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003314 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003315 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003316 * Callers can set a document URI through
3317 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3318 * location of documents navigator. System will do its best to launch the
3319 * navigator in the specified document if it's a folder, or the folder that
3320 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003321 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003322 * Output: The URI of the item that was picked, returned in
3323 * {@link #getData()}. This must be a {@code content://} URI so that any
3324 * receiver can access it. If multiple documents were selected, they are
3325 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003326 *
3327 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003328 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003329 * @see #ACTION_CREATE_DOCUMENT
3330 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003331 */
3332 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3333 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3334
3335 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003336 * Activity Action: Allow the user to create a new document. When invoked,
3337 * the system will display the various {@link DocumentsProvider} instances
3338 * installed on the device, letting the user navigate through them. The
3339 * returned document may be a newly created document with no content, or it
3340 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003341 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003342 * Each document is represented as a {@code content://} URI backed by a
3343 * {@link DocumentsProvider}, which can be opened as a stream with
3344 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3345 * {@link android.provider.DocumentsContract.Document} metadata.
3346 * <p>
3347 * Callers must indicate the concrete MIME type of the document being
3348 * created by setting {@link #setType(String)}. This MIME type cannot be
3349 * changed after the document is created.
3350 * <p>
3351 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3352 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003353 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003354 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3355 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003356 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003357 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003358 * Callers can set a document URI through
3359 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3360 * location of documents navigator. System will do its best to launch the
3361 * navigator in the specified document if it's a folder, or the folder that
3362 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003363 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003364 * Output: The URI of the item that was created. This must be a
3365 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003366 *
3367 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003368 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003369 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003370 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003371 */
3372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3373 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3374
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003375 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003376 * Activity Action: Allow the user to pick a directory subtree. When
3377 * invoked, the system will display the various {@link DocumentsProvider}
3378 * instances installed on the device, letting the user navigate through
3379 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003380 * <p>
3381 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003382 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3383 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3384 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003385 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003386 * Callers can set a document URI through
3387 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3388 * location of documents navigator. System will do its best to launch the
3389 * navigator in the specified document if it's a folder, or the folder that
3390 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003391 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003392 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003393 *
3394 * @see DocumentsContract
3395 */
3396 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003397 public static final String
3398 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003399
Felipe Lemec7b1f892016-01-15 15:02:31 -08003400 /**
Peng Xua35b5532016-01-20 00:05:45 -08003401 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3402 * exisiting sensor being disconnected.
3403 *
3404 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3405 *
3406 * {@hide}
3407 */
3408 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3409 public static final String
3410 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3411
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003412 /**
Sam Line707f832017-04-13 17:00:55 -07003413 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003414 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003415 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003416 */
3417 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003418 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003419 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3420
Christopher Tate6597e342015-02-17 12:15:25 -08003421 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003422 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3423 * is about to be performed.
3424 * @hide
3425 */
3426 @SystemApi
3427 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3428 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3429 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3430
3431 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003432 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3433 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3434 *
3435 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3436 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003437 * @hide
3438 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003439 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003440 public static final String EXTRA_FORCE_MASTER_CLEAR =
3441 "android.intent.extra.FORCE_MASTER_CLEAR";
3442
3443 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003444 * A broadcast action to trigger a factory reset.
3445 *
3446 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3447 *
3448 * <p>Not for use by third-party applications.
3449 *
3450 * @see #EXTRA_FORCE_MASTER_CLEAR
3451 *
3452 * {@hide}
3453 */
3454 @SystemApi
3455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3456 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3457
3458 /**
3459 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3460 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3461 *
3462 * <p>Not for use by third-party applications.
3463 *
3464 * @hide
3465 */
3466 @SystemApi
3467 public static final String EXTRA_FORCE_FACTORY_RESET =
3468 "android.intent.extra.FORCE_FACTORY_RESET";
3469
3470 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003471 * Broadcast action: report that a settings element is being restored from backup. The intent
3472 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3473 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3474 * is the value of that settings entry prior to the restore operation, and
3475 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3476 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3477 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003478 *
3479 * <p>This broadcast is sent only for settings provider entries known to require special handling
3480 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3481 * the provider's backup agent implementation.
3482 *
3483 * @see #EXTRA_SETTING_NAME
3484 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3485 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003486 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003487 * {@hide}
3488 */
3489 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3490
3491 /** {@hide} */
3492 public static final String EXTRA_SETTING_NAME = "setting_name";
3493 /** {@hide} */
3494 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3495 /** {@hide} */
3496 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003497 /** {@hide} */
3498 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003499
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003500 /**
3501 * Activity Action: Process a piece of text.
3502 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3503 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3504 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3505 */
3506 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3507 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003508
3509 /**
3510 * Broadcast Action: The sim card state has changed.
3511 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3512 * because TelephonyIntents is an internal class.
3513 * @hide
3514 */
3515 @SystemApi
3516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3517 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3518
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003519 /**
fionaxu90fee272017-03-31 12:45:12 -07003520 * Broadcast Action: indicate that the phone service state has changed.
3521 * The intent will have the following extra values:</p>
3522 * <p>
3523 * @see #EXTRA_VOICE_REG_STATE
3524 * @see #EXTRA_DATA_REG_STATE
3525 * @see #EXTRA_VOICE_ROAMING_TYPE
3526 * @see #EXTRA_DATA_ROAMING_TYPE
3527 * @see #EXTRA_OPERATOR_ALPHA_LONG
3528 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3529 * @see #EXTRA_OPERATOR_NUMERIC
3530 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3531 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3532 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3533 * @see #EXTRA_MANUAL
3534 * @see #EXTRA_VOICE_RADIO_TECH
3535 * @see #EXTRA_DATA_RADIO_TECH
3536 * @see #EXTRA_CSS_INDICATOR
3537 * @see #EXTRA_NETWORK_ID
3538 * @see #EXTRA_SYSTEM_ID
3539 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3540 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3541 * @see #EXTRA_EMERGENCY_ONLY
3542 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3543 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3544 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3545 *
3546 * <p class="note">
3547 * Requires the READ_PHONE_STATE permission.
3548 *
3549 * <p class="note">This is a protected intent that can only be sent by the system.
3550 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003551 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003552 */
3553 @Deprecated
3554 @SystemApi
3555 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3556 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3557
3558 /**
3559 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3560 * state.
3561 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3562 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3563 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3564 * @see android.telephony.ServiceState#STATE_POWER_OFF
3565 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003566 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003567 */
3568 @Deprecated
3569 @SystemApi
3570 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3571
3572 /**
3573 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3574 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3575 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3576 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3577 * @see android.telephony.ServiceState#STATE_POWER_OFF
3578 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003579 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003580 */
3581 @Deprecated
3582 @SystemApi
3583 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3584
3585 /**
3586 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3587 * type.
3588 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003589 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003590 */
3591 @Deprecated
3592 @SystemApi
3593 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3594
3595 /**
3596 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3597 * type.
3598 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003599 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003600 */
3601 @Deprecated
3602 @SystemApi
3603 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3604
3605 /**
3606 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3607 * registered voice operator name in long alphanumeric format.
3608 * {@code null} if the operator name is not known or unregistered.
3609 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003610 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003611 */
3612 @Deprecated
3613 @SystemApi
3614 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3615
3616 /**
3617 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3618 * registered voice operator name in short alphanumeric format.
3619 * {@code null} if the operator name is not known or unregistered.
3620 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003621 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003622 */
3623 @Deprecated
3624 @SystemApi
3625 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3626
3627 /**
3628 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3629 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3630 * network.
3631 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003632 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003633 */
3634 @Deprecated
3635 @SystemApi
3636 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3637
3638 /**
3639 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3640 * registered data operator name in long alphanumeric format.
3641 * {@code null} if the operator name is not known or unregistered.
3642 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003643 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003644 */
3645 @Deprecated
3646 @SystemApi
3647 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3648
3649 /**
3650 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3651 * registered data operator name in short alphanumeric format.
3652 * {@code null} if the operator name is not known or unregistered.
3653 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003654 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003655 */
3656 @Deprecated
3657 @SystemApi
3658 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3659
3660 /**
3661 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3662 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3663 * data operator.
3664 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003665 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003666 */
3667 @Deprecated
3668 @SystemApi
3669 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3670
3671 /**
3672 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3673 * network selection mode is manual.
3674 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3675 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003676 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003677 */
3678 @Deprecated
3679 @SystemApi
3680 public static final String EXTRA_MANUAL = "manual";
3681
3682 /**
3683 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3684 * radio technology.
3685 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003686 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003687 */
3688 @Deprecated
3689 @SystemApi
3690 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3691
3692 /**
3693 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3694 * radio technology.
3695 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003696 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003697 */
3698 @Deprecated
3699 @SystemApi
3700 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3701
3702 /**
3703 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3704 * support on CDMA network.
3705 * Will be {@code true} if support, {@code false} otherwise.
3706 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003707 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003708 */
3709 @Deprecated
3710 @SystemApi
3711 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3712
3713 /**
3714 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3715 * id. {@code Integer.MAX_VALUE} if unknown.
3716 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003717 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003718 */
3719 @Deprecated
3720 @SystemApi
3721 public static final String EXTRA_NETWORK_ID = "networkId";
3722
3723 /**
3724 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3725 * {@code Integer.MAX_VALUE} if unknown.
3726 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003727 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003728 */
3729 @Deprecated
3730 @SystemApi
3731 public static final String EXTRA_SYSTEM_ID = "systemId";
3732
3733 /**
3734 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3735 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3736 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003737 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003738 */
3739 @Deprecated
3740 @SystemApi
3741 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3742
3743 /**
3744 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3745 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3746 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003747 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003748 */
3749 @Deprecated
3750 @SystemApi
3751 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3752
3753 /**
3754 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3755 * only mode.
3756 * {@code true} if in emergency only mode, {@code false} otherwise.
3757 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003758 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003759 */
3760 @Deprecated
3761 @SystemApi
3762 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3763
3764 /**
3765 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3766 * registration state is roaming.
3767 * {@code true} if registration indicates roaming, {@code false} otherwise
3768 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003769 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003770 */
3771 @Deprecated
3772 @SystemApi
3773 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3774 "isDataRoamingFromRegistration";
3775
3776 /**
3777 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3778 * aggregation is in use.
3779 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3780 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003781 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003782 */
3783 @Deprecated
3784 @SystemApi
3785 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3786
3787 /**
3788 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3789 * is reduced from the rsrp threshold while calculating signal strength level.
3790 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003791 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003792 */
3793 @Deprecated
3794 @SystemApi
3795 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3796
3797 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003798 * The name of the extra used to define the text to be processed, as a
3799 * CharSequence. Note that this may be a styled CharSequence, so you must use
3800 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003801 */
3802 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3803 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003804 * 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 +00003805 */
3806 public static final String EXTRA_PROCESS_TEXT_READONLY =
3807 "android.intent.extra.PROCESS_TEXT_READONLY";
3808
Bryce Leebc58f592015-09-25 16:43:01 -07003809 /**
3810 * Broadcast action: reports when a new thermal event has been reached. When the device
3811 * is reaching its maximum temperatue, the thermal level reported
3812 * {@hide}
3813 */
3814 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3815 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3816
3817 /** {@hide} */
3818 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3819
3820 /**
3821 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003822 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003823 * {@hide}
3824 */
3825 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3826
3827 /**
3828 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003829 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003830 * {@hide}
3831 */
3832 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3833
3834 /**
3835 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003836 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003837 * {@hide}
3838 */
3839 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3840
3841
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003842 // ---------------------------------------------------------------------
3843 // ---------------------------------------------------------------------
3844 // Standard intent categories (see addCategory()).
3845
3846 /**
3847 * Set if the activity should be an option for the default action
3848 * (center press) to perform on a piece of data. Setting this will
3849 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003850 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003851 * Intent when initiating an action -- it is for use in intent filters
3852 * specified in packages.
3853 */
3854 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3855 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3856 /**
3857 * Activities that can be safely invoked from a browser must support this
3858 * category. For example, if the user is viewing a web page or an e-mail
3859 * and clicks on a link in the text, the Intent generated execute that
3860 * link will require the BROWSABLE category, so that only activities
3861 * supporting this category will be considered as possible actions. By
3862 * supporting this category, you are promising that there is nothing
3863 * damaging (without user intervention) that can happen by invoking any
3864 * matching Intent.
3865 */
3866 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3867 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3868 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003869 * Categories for activities that can participate in voice interaction.
3870 * An activity that supports this category must be prepared to run with
3871 * no UI shown at all (though in some case it may have a UI shown), and
3872 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3873 */
3874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3875 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3876 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003877 * Set if the activity should be considered as an alternative action to
3878 * the data the user is currently viewing. See also
3879 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3880 * applies to the selection in a list of items.
3881 *
3882 * <p>Supporting this category means that you would like your activity to be
3883 * displayed in the set of alternative things the user can do, usually as
3884 * part of the current activity's options menu. You will usually want to
3885 * include a specific label in the &lt;intent-filter&gt; of this action
3886 * describing to the user what it does.
3887 *
3888 * <p>The action of IntentFilter with this category is important in that it
3889 * describes the specific action the target will perform. This generally
3890 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3891 * a specific name such as "com.android.camera.action.CROP. Only one
3892 * alternative of any particular action will be shown to the user, so using
3893 * a specific action like this makes sure that your alternative will be
3894 * displayed while also allowing other applications to provide their own
3895 * overrides of that particular action.
3896 */
3897 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3898 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3899 /**
3900 * Set if the activity should be considered as an alternative selection
3901 * action to the data the user has currently selected. This is like
3902 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3903 * of items from which the user can select, giving them alternatives to the
3904 * default action that will be performed on it.
3905 */
3906 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3907 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3908 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003909 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003910 */
3911 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3912 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3913 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003914 * Should be displayed in the top-level launcher.
3915 */
3916 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3917 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3918 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003919 * Indicates an activity optimized for Leanback mode, and that should
3920 * be displayed in the Leanback launcher.
3921 */
3922 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3923 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3924 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003925 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3926 * @hide
3927 */
3928 @SystemApi
3929 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3930 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003931 * Provides information about the package it is in; typically used if
3932 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3933 * a front-door to the user without having to be shown in the all apps list.
3934 */
3935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3936 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3937 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003938 * This is the home activity, that is the first activity that is displayed
3939 * when the device boots.
3940 */
3941 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3942 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3943 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003944 * This is the home activity that is displayed when the device is finished setting up and ready
3945 * for use.
3946 * @hide
3947 */
3948 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3949 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3950 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003951 * This is the setup wizard activity, that is the first activity that is displayed
3952 * when the user sets up the device for the first time.
3953 * @hide
3954 */
3955 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3956 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3957 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07003958 * This is the home activity, that is the activity that serves as the launcher app
3959 * from there the user can start other apps. Often components with lower/higher
3960 * priority intent filters handle the home intent, for example SetupWizard, to
3961 * setup the device and we need to be able to distinguish the home app from these
3962 * setup helpers.
3963 * @hide
3964 */
3965 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3966 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
3967 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003968 * This activity is a preference panel.
3969 */
3970 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3971 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3972 /**
3973 * This activity is a development preference panel.
3974 */
3975 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3976 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3977 /**
3978 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003979 */
3980 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3981 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3982 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003983 * This activity allows the user to browse and download new applications.
3984 */
3985 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3986 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3987 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003988 * This activity may be exercised by the monkey or other automated test tools.
3989 */
3990 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3991 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3992 /**
3993 * To be used as a test (not part of the normal user experience).
3994 */
3995 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3996 /**
3997 * To be used as a unit test (run through the Test Harness).
3998 */
3999 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4000 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004001 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004002 * experience).
4003 */
4004 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004005
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004006 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004007 * Used to indicate that an intent only wants URIs that can be opened with
4008 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4009 * must support at least the columns defined in {@link OpenableColumns} when
4010 * queried.
4011 *
4012 * @see #ACTION_GET_CONTENT
4013 * @see #ACTION_OPEN_DOCUMENT
4014 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004015 */
4016 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4017 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4018
4019 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004020 * Used to indicate that an intent filter can accept files which are not necessarily
4021 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4022 * at least streamable via
4023 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4024 * using one of the stream types exposed via
4025 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4026 *
4027 * @see #ACTION_SEND
4028 * @see #ACTION_SEND_MULTIPLE
4029 */
4030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4031 public static final String CATEGORY_TYPED_OPENABLE =
4032 "android.intent.category.TYPED_OPENABLE";
4033
4034 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004035 * To be used as code under test for framework instrumentation tests.
4036 */
4037 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4038 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004039 /**
4040 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004041 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4042 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004043 */
4044 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4045 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4046 /**
4047 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004048 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4049 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004050 */
4051 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4052 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004053 /**
4054 * An activity to run when device is inserted into a analog (low end) dock.
4055 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4056 * information, see {@link android.app.UiModeManager}.
4057 */
4058 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4059 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4060
4061 /**
4062 * An activity to run when device is inserted into a digital (high end) dock.
4063 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4064 * information, see {@link android.app.UiModeManager}.
4065 */
4066 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4067 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004068
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004069 /**
4070 * Used to indicate that the activity can be used in a car environment.
4071 */
4072 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4073 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4074
Zak Cohendb6ca492017-01-26 14:09:00 -08004075 /**
4076 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4077 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4078 * information, see {@link android.app.UiModeManager}.
4079 */
4080 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4081 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004082 // ---------------------------------------------------------------------
4083 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004084 // Application launch intent categories (see addCategory()).
4085
4086 /**
4087 * Used with {@link #ACTION_MAIN} to launch the browser application.
4088 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004089 * <p>NOTE: This should not be used as the primary key of an Intent,
4090 * since it will not result in the app launching with the correct
4091 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004092 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004093 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004094 */
4095 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4096 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4097
4098 /**
4099 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4100 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004101 * <p>NOTE: This should not be used as the primary key of an Intent,
4102 * since it will not result in the app launching with the correct
4103 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004104 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004105 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004106 */
4107 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4108 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4109
4110 /**
4111 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4112 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004113 * <p>NOTE: This should not be used as the primary key of an Intent,
4114 * since it will not result in the app launching with the correct
4115 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004116 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004117 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004118 */
4119 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4120 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4121
4122 /**
4123 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4124 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004125 * <p>NOTE: This should not be used as the primary key of an Intent,
4126 * since it will not result in the app launching with the correct
4127 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004128 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004129 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004130 */
4131 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4132 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4133
4134 /**
4135 * Used with {@link #ACTION_MAIN} to launch the email application.
4136 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004137 * <p>NOTE: This should not be used as the primary key of an Intent,
4138 * since it will not result in the app launching with the correct
4139 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004140 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004141 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004142 */
4143 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4144 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4145
4146 /**
4147 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4148 * The activity should be able to view and manipulate image and video files
4149 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004150 * <p>NOTE: This should not be used as the primary key of an Intent,
4151 * since it will not result in the app launching with the correct
4152 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004153 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004154 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004155 */
4156 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4157 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4158
4159 /**
4160 * Used with {@link #ACTION_MAIN} to launch the maps application.
4161 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004162 * <p>NOTE: This should not be used as the primary key of an Intent,
4163 * since it will not result in the app launching with the correct
4164 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004165 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004166 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004167 */
4168 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4169 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4170
4171 /**
4172 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4173 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004174 * <p>NOTE: This should not be used as the primary key of an Intent,
4175 * since it will not result in the app launching with the correct
4176 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004177 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004178 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004179 */
4180 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4181 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4182
4183 /**
4184 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004185 * The activity should be able to play, browse, or manipulate music files
4186 * stored on the device.
4187 * <p>NOTE: This should not be used as the primary key of an Intent,
4188 * since it will not result in the app launching with the correct
4189 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004190 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004191 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004192 */
4193 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4194 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4195
4196 // ---------------------------------------------------------------------
4197 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 // Standard extra data keys.
4199
4200 /**
4201 * The initial data to place in a newly created record. Use with
4202 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4203 * fields as would be given to the underlying ContentProvider.insert()
4204 * call.
4205 */
4206 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4207
4208 /**
4209 * A constant CharSequence that is associated with the Intent, used with
4210 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4211 * this may be a styled CharSequence, so you must use
4212 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4213 * retrieve it.
4214 */
4215 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4216
4217 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004218 * A constant String that is associated with the Intent, used with
4219 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4220 * as HTML formatted text. Note that you <em>must</em> also supply
4221 * {@link #EXTRA_TEXT}.
4222 */
4223 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4224
4225 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004226 * A content: URI holding a stream of data associated with the Intent,
4227 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004228 */
4229 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4230
4231 /**
4232 * A String[] holding e-mail addresses that should be delivered to.
4233 */
4234 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4235
4236 /**
4237 * A String[] holding e-mail addresses that should be carbon copied.
4238 */
4239 public static final String EXTRA_CC = "android.intent.extra.CC";
4240
4241 /**
4242 * A String[] holding e-mail addresses that should be blind carbon copied.
4243 */
4244 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4245
4246 /**
4247 * A constant string holding the desired subject line of a message.
4248 */
4249 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4250
4251 /**
4252 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004253 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004254 */
4255 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4256
4257 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004258 * An int representing the user id to be used.
4259 *
4260 * @hide
4261 */
4262 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4263
4264 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004265 * An int representing the task id to be retrieved. This is used when a launch from recents is
4266 * intercepted by another action such as credentials confirmation to remember which task should
4267 * be resumed when complete.
4268 *
4269 * @hide
4270 */
4271 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4272
4273 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004274 * An Intent[] describing additional, alternate choices you would like shown with
4275 * {@link #ACTION_CHOOSER}.
4276 *
4277 * <p>An app may be capable of providing several different payload types to complete a
4278 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4279 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4280 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4281 * photo data or a hosted link where the photos can be viewed.</p>
4282 *
4283 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4284 * first/primary/preferred intent in the set. Additional intents specified in
4285 * this extra are ordered; by default intents that appear earlier in the array will be
4286 * preferred over intents that appear later in the array as matches for the same
4287 * target component. To alter this preference, a calling app may also supply
4288 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4289 */
4290 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4291
4292 /**
Adam Powell52c39212016-04-07 15:14:18 -07004293 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4294 * and omitted from a list of components presented to the user.
4295 *
4296 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4297 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4298 * from your own package or other apps from your organization if the idea of sending to those
4299 * targets would be redundant with other app functionality. Filtered components will not
4300 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4301 */
4302 public static final String EXTRA_EXCLUDE_COMPONENTS
4303 = "android.intent.extra.EXCLUDE_COMPONENTS";
4304
4305 /**
4306 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4307 * describing additional high-priority deep-link targets for the chooser to present to the user.
4308 *
4309 * <p>Targets provided in this way will be presented inline with all other targets provided
4310 * by services from other apps. They will be prioritized before other service targets, but
4311 * after those targets provided by sources that the user has manually pinned to the front.</p>
4312 *
4313 * @see #ACTION_CHOOSER
4314 */
4315 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4316
4317 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004318 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4319 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4320 *
4321 * <p>An app preparing an action for another app to complete may wish to allow the user to
4322 * disambiguate between several options for completing the action based on the chosen target
4323 * or otherwise refine the action before it is invoked.
4324 * </p>
4325 *
4326 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4327 * <ul>
4328 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4329 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4330 * chosen target beyond the first</li>
4331 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4332 * should fill in and send once the disambiguation is complete</li>
4333 * </ul>
4334 */
4335 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4336 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4337
4338 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004339 * An {@code ArrayList} of {@code String} annotations describing content for
4340 * {@link #ACTION_CHOOSER}.
4341 *
4342 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4343 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4344 *
4345 * <p>Annotations should describe the major components or topics of the content. It is up to
4346 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4347 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004348 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4349 * character. Performance on customized annotations can suffer, if they are rarely used for
4350 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4351 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004352 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004353 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004354 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004355 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004356 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004357 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004358 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004359 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004360 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004361 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4362 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4363 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4364 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4365 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004366 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004367 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4368 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004369 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004370 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004371 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004372 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004373 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004374 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004375 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004376 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004377 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004378 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004379 * Christmas and Thanksgiving.</li>
4380 * </ul>
4381 */
4382 public static final String EXTRA_CONTENT_ANNOTATIONS
4383 = "android.intent.extra.CONTENT_ANNOTATIONS";
4384
4385 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004386 * A {@link ResultReceiver} used to return data back to the sender.
4387 *
4388 * <p>Used to complete an app-specific
4389 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4390 *
4391 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4392 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4393 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4394 * when the user selects a target component from the chooser. It is up to the recipient
4395 * to send a result to this ResultReceiver to signal that disambiguation is complete
4396 * and that the chooser should invoke the user's choice.</p>
4397 *
4398 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4399 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4400 * to match and fill in the final Intent or ChooserTarget before starting it.
4401 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4402 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4403 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4404 *
4405 * <p>The result code passed to the ResultReceiver should be
4406 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4407 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4408 * the chooser should finish without starting a target.</p>
4409 */
4410 public static final String EXTRA_RESULT_RECEIVER
4411 = "android.intent.extra.RESULT_RECEIVER";
4412
4413 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004414 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004415 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004416 */
4417 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4418
4419 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004420 * A Parcelable[] of {@link Intent} or
4421 * {@link android.content.pm.LabeledIntent} objects as set with
4422 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4423 * a the front of the list of choices, when shown to the user with a
4424 * {@link #ACTION_CHOOSER}.
4425 */
4426 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4427
4428 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004429 * A {@link IntentSender} to start after ephemeral installation success.
4430 * @hide
4431 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004432 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4433
4434 /**
4435 * A {@link IntentSender} to start after ephemeral installation failure.
4436 * @hide
4437 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004438 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4439
4440 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004441 * The host name that triggered an ephemeral resolution.
4442 * @hide
4443 */
4444 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4445
4446 /**
4447 * An opaque token to track ephemeral resolution.
4448 * @hide
4449 */
4450 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4451
4452 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004453 * The version code of the app to install components from.
4454 * @hide
4455 */
4456 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4457
4458 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004459 * The app that triggered the ephemeral installation.
4460 * @hide
4461 */
4462 public static final String EXTRA_CALLING_PACKAGE
4463 = "android.intent.extra.CALLING_PACKAGE";
4464
4465 /**
4466 * Optional calling app provided bundle containing additional launch information the
4467 * installer may use.
4468 * @hide
4469 */
4470 public static final String EXTRA_VERIFICATION_BUNDLE
4471 = "android.intent.extra.VERIFICATION_BUNDLE";
4472
4473 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004474 * A Bundle forming a mapping of potential target package names to different extras Bundles
4475 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4476 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4477 * be currently installed on the device.
4478 *
4479 * <p>An application may choose to provide alternate extras for the case where a user
4480 * selects an activity from a predetermined set of target packages. If the activity
4481 * the user selects from the chooser belongs to a package with its package name as
4482 * a key in this bundle, the corresponding extras for that package will be merged with
4483 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4484 * extra has the same key as an extra already present in the intent it will overwrite
4485 * the extra from the intent.</p>
4486 *
4487 * <p><em>Examples:</em>
4488 * <ul>
4489 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4490 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4491 * parameters for that target.</li>
4492 * <li>An application may offer additional metadata for known targets of a given intent
4493 * to pass along information only relevant to that target such as account or content
4494 * identifiers already known to that application.</li>
4495 * </ul></p>
4496 */
4497 public static final String EXTRA_REPLACEMENT_EXTRAS =
4498 "android.intent.extra.REPLACEMENT_EXTRAS";
4499
4500 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004501 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4502 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4503 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4504 * {@link ComponentName} of the chosen component.
4505 *
4506 * <p>In some situations this callback may never come, for example if the user abandons
4507 * the chooser, switches to another task or any number of other reasons. Apps should not
4508 * be written assuming that this callback will always occur.</p>
4509 */
4510 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4511 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4512
4513 /**
4514 * The {@link ComponentName} chosen by the user to complete an action.
4515 *
4516 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4517 */
4518 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4519
4520 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004521 * A {@link android.view.KeyEvent} object containing the event that
4522 * triggered the creation of the Intent it is in.
4523 */
4524 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4525
4526 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004527 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4528 * before shutting down.
4529 *
4530 * {@hide}
4531 */
4532 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4533
4534 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004535 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4536 * requested by the user.
4537 *
4538 * {@hide}
4539 */
4540 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4541 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4542
4543 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004544 * 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 -07004545 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4546 * of restarting the application.
4547 */
4548 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4549
4550 /**
4551 * A String holding the phone number originally entered in
4552 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4553 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4554 */
4555 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004556
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004557 /**
4558 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4559 * intents to supply the uid the package had been assigned. Also an optional
4560 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4561 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4562 * purpose.
4563 */
4564 public static final String EXTRA_UID = "android.intent.extra.UID";
4565
4566 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004567 * @hide String array of package names.
4568 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004569 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004570 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4571
4572 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004573 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4574 * intents to indicate whether this represents a full uninstall (removing
4575 * both the code and its data) or a partial uninstall (leaving its data,
4576 * implying that this is an update).
4577 */
4578 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004579
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004580 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004581 * @hide
4582 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4583 * intents to indicate that at this point the package has been removed for
4584 * all users on the device.
4585 */
4586 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4587 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4588
4589 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004590 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4591 * intents to indicate that this is a replacement of the package, so this
4592 * broadcast will immediately be followed by an add broadcast for a
4593 * different version of the same package.
4594 */
4595 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004596
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004597 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004598 * Used as an int extra field in {@link android.app.AlarmManager} intents
4599 * to tell the application being invoked how many pending alarms are being
4600 * delievered with the intent. For one-shot alarms this will always be 1.
4601 * For recurring alarms, this might be greater than 1 if the device was
4602 * asleep or powered off at the time an earlier alarm would have been
4603 * delivered.
4604 */
4605 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004606
Jacek Surazski86b6c532009-05-13 14:38:28 +02004607 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004608 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4609 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004610 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4611 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004612 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4613 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4614 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004615 */
4616 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4617
4618 /**
4619 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4620 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004621 */
4622 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4623
4624 /**
4625 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4626 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004627 */
4628 public static final int EXTRA_DOCK_STATE_DESK = 1;
4629
4630 /**
4631 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4632 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004633 */
4634 public static final int EXTRA_DOCK_STATE_CAR = 2;
4635
4636 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004637 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4638 * to represent that the phone is in a analog (low end) dock.
4639 */
4640 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4641
4642 /**
4643 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4644 * to represent that the phone is in a digital (high end) dock.
4645 */
4646 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4647
4648 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004649 * Boolean that can be supplied as meta-data with a dock activity, to
4650 * indicate that the dock should take over the home key when it is active.
4651 */
4652 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004653
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004654 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004655 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4656 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004657 */
4658 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4659
4660 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004661 * Used in the extra field in the remote intent. It's astring token passed with the
4662 * remote intent.
4663 */
4664 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4665 "android.intent.extra.remote_intent_token";
4666
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004667 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004668 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004669 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004670 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004671 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004672 "android.intent.extra.changed_component_name";
4673
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004674 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004675 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004676 * and contains a string array of all of the components that have changed. If
4677 * the state of the overall package has changed, then it will contain an entry
4678 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004679 */
4680 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4681 "android.intent.extra.changed_component_name_list";
4682
4683 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004684 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004685 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004686 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4687 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4688 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004689 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004690 */
4691 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4692 "android.intent.extra.changed_package_list";
4693
4694 /**
4695 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004696 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4697 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004698 * and contains an integer array of uids of all of the components
4699 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004700 */
4701 public static final String EXTRA_CHANGED_UID_LIST =
4702 "android.intent.extra.changed_uid_list";
4703
4704 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004705 * @hide
4706 * Magic extra system code can use when binding, to give a label for
4707 * who it is that has bound to a service. This is an integer giving
4708 * a framework string resource that can be displayed to the user.
4709 */
4710 public static final String EXTRA_CLIENT_LABEL =
4711 "android.intent.extra.client_label";
4712
4713 /**
4714 * @hide
4715 * Magic extra system code can use when binding, to give a PendingIntent object
4716 * that can be launched for the user to disable the system's use of this
4717 * service.
4718 */
4719 public static final String EXTRA_CLIENT_INTENT =
4720 "android.intent.extra.client_intent";
4721
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004722 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004723 * Extra used to indicate that an intent should only return data that is on
4724 * the local device. This is a boolean extra; the default is false. If true,
4725 * an implementation should only allow the user to select data that is
4726 * already on the device, not requiring it be downloaded from a remote
4727 * service when opened.
4728 *
4729 * @see #ACTION_GET_CONTENT
4730 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004731 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004732 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004733 */
4734 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004735 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004736
Amith Yamasani13593602012-03-22 16:16:17 -07004737 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004738 * Extra used to indicate that an intent can allow the user to select and
4739 * return multiple items. This is a boolean extra; the default is false. If
4740 * true, an implementation is allowed to present the user with a UI where
4741 * they can pick multiple items that are all returned to the caller. When
4742 * this happens, they should be returned as the {@link #getClipData()} part
4743 * of the result Intent.
4744 *
4745 * @see #ACTION_GET_CONTENT
4746 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004747 */
4748 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004749 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004750
4751 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004752 * The integer userHandle carried with broadcast intents related to addition, removal and
4753 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4754 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4755 *
Amith Yamasani13593602012-03-22 16:16:17 -07004756 * @hide
4757 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004758 public static final String EXTRA_USER_HANDLE =
4759 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004760
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004761 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004762 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4763 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4764 */
4765 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004766 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004767
4768 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004769 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004770 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4771 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004772 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004773 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4774
4775 /**
4776 * Extra sent in the intent to the BroadcastReceiver that handles
4777 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4778 * the restrictions as key/value pairs.
4779 */
4780 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4781 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004782
Amith Yamasani86118ba2013-03-28 14:33:16 -07004783 /**
4784 * Extra used in the response from a BroadcastReceiver that handles
4785 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4786 */
4787 public static final String EXTRA_RESTRICTIONS_INTENT =
4788 "android.intent.extra.restrictions_intent";
4789
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004790 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004791 * Extra used to communicate a set of acceptable MIME types. The type of the
4792 * extra is {@code String[]}. Values may be a combination of concrete MIME
4793 * types (such as "image/png") and/or partial MIME types (such as
4794 * "audio/*").
4795 *
4796 * @see #ACTION_GET_CONTENT
4797 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004798 */
4799 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4800
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004801 /**
4802 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4803 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004804 * When this is true, hardware devices can use this information to determine that
4805 * they shouldn't do a complete shutdown of their device since this is not a
4806 * complete shutdown down to the kernel, but only user space restarting.
4807 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004808 */
4809 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4810 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4811
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004812 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004813 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4814 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4815 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4816 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004817 *
4818 * @hide for internal use only.
4819 */
4820 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4821 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004822 /** @hide */
4823 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4824 /** @hide */
4825 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4826 /** @hide */
4827 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004828
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004829 /** {@hide} */
4830 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4831
qingxi240c2bb2017-04-12 17:31:18 -07004832 /**
4833 * {@hide}
4834 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4835 */
Rubin Xue8490f12015-06-25 12:17:48 +01004836 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4837
Santos Cordon15a13782015-03-31 18:32:31 -07004838 /**
qingxi240c2bb2017-04-12 17:31:18 -07004839 * {@hide}
4840 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4841 * reset for the device with eSIM. This extra will be sent together with
4842 * {@link #ACTION_FACTORY_RESET}
4843 */
4844 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4845
4846 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004847 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4848 * activation request.
4849 * TODO: Add information about the structure and response data used with the pending intent.
4850 * @hide
4851 */
4852 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4853 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4854
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004855 /**
4856 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004857 *
4858 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004859 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004860 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004861 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4862
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004863 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004864 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4865 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4866 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004867 *
4868 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004869 * @see #ACTION_QUICK_VIEW
4870 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004871 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004872 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004873 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4874 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004875
4876 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004877 * An optional extra of {@code String[]} indicating which quick view features should be made
4878 * available to the user in the quick view UI while handing a
4879 * {@link Intent#ACTION_QUICK_VIEW} intent.
4880 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4881 * Quick viewer can implement features not listed below.
4882 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4883 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4884 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4885 * <p>
4886 * Requirements:
4887 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4888 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4889 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4890 * internal policies.
4891 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4892 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4893 * disable or hide features.
4894 *
4895 * @see #ACTION_QUICK_VIEW
4896 */
4897 public static final String EXTRA_QUICK_VIEW_FEATURES =
4898 "android.intent.extra.QUICK_VIEW_FEATURES";
4899
4900 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004901 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004902 * When a profile goes into quiet mode, all apps in the profile are killed and the
4903 * profile user is stopped. Widgets originating from the profile are masked, and app
4904 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004905 */
4906 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004907
4908 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004909 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004910 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004911 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4912 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004913 *
4914 * @hide
4915 */
4916 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4917 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4918
4919 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004920 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4921 * whether to show the chooser or not when there is only one application available
4922 * to choose from.
4923 *
4924 * @hide
4925 */
4926 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4927 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4928
4929 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004930 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004931 * to represent that a video codec is allowed to use.
4932 *
4933 * @hide
4934 */
4935 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4936
4937 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004938 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004939 * to represent that a audio codec is allowed to use.
4940 *
4941 * @hide
4942 */
4943 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4944
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004945 // ---------------------------------------------------------------------
4946 // ---------------------------------------------------------------------
4947 // Intent flags (see mFlags variable).
4948
Tor Norbyed9273d62013-05-30 15:59:53 -07004949 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004950 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004951 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4952 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004953 @Retention(RetentionPolicy.SOURCE)
4954 public @interface GrantUriMode {}
4955
Jeff Sharkey846318a2014-04-04 12:12:41 -07004956 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004957 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004958 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4959 @Retention(RetentionPolicy.SOURCE)
4960 public @interface AccessUriMode {}
4961
4962 /**
4963 * Test if given mode flags specify an access mode, which must be at least
4964 * read and/or write.
4965 *
4966 * @hide
4967 */
4968 public static boolean isAccessUriMode(int modeFlags) {
4969 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4970 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4971 }
4972
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004973 /** @hide */
4974 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4975 FLAG_GRANT_READ_URI_PERMISSION,
4976 FLAG_GRANT_WRITE_URI_PERMISSION,
4977 FLAG_FROM_BACKGROUND,
4978 FLAG_DEBUG_LOG_RESOLUTION,
4979 FLAG_EXCLUDE_STOPPED_PACKAGES,
4980 FLAG_INCLUDE_STOPPED_PACKAGES,
4981 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
4982 FLAG_GRANT_PREFIX_URI_PERMISSION,
4983 FLAG_DEBUG_TRIAGED_MISSING,
4984 FLAG_IGNORE_EPHEMERAL,
4985 FLAG_ACTIVITY_NO_HISTORY,
4986 FLAG_ACTIVITY_SINGLE_TOP,
4987 FLAG_ACTIVITY_NEW_TASK,
4988 FLAG_ACTIVITY_MULTIPLE_TASK,
4989 FLAG_ACTIVITY_CLEAR_TOP,
4990 FLAG_ACTIVITY_FORWARD_RESULT,
4991 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4992 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4993 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4994 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4995 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4996 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4997 FLAG_ACTIVITY_NEW_DOCUMENT,
4998 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4999 FLAG_ACTIVITY_NO_USER_ACTION,
5000 FLAG_ACTIVITY_REORDER_TO_FRONT,
5001 FLAG_ACTIVITY_NO_ANIMATION,
5002 FLAG_ACTIVITY_CLEAR_TASK,
5003 FLAG_ACTIVITY_TASK_ON_HOME,
5004 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5005 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5006 FLAG_RECEIVER_REGISTERED_ONLY,
5007 FLAG_RECEIVER_REPLACE_PENDING,
5008 FLAG_RECEIVER_FOREGROUND,
5009 FLAG_RECEIVER_NO_ABORT,
5010 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5011 FLAG_RECEIVER_BOOT_UPGRADE,
5012 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5013 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5014 FLAG_RECEIVER_FROM_SHELL,
5015 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5016 })
5017 @Retention(RetentionPolicy.SOURCE)
5018 public @interface Flags {}
5019
5020 /** @hide */
5021 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5022 FLAG_FROM_BACKGROUND,
5023 FLAG_DEBUG_LOG_RESOLUTION,
5024 FLAG_EXCLUDE_STOPPED_PACKAGES,
5025 FLAG_INCLUDE_STOPPED_PACKAGES,
5026 FLAG_DEBUG_TRIAGED_MISSING,
5027 FLAG_IGNORE_EPHEMERAL,
5028 FLAG_ACTIVITY_NO_HISTORY,
5029 FLAG_ACTIVITY_SINGLE_TOP,
5030 FLAG_ACTIVITY_NEW_TASK,
5031 FLAG_ACTIVITY_MULTIPLE_TASK,
5032 FLAG_ACTIVITY_CLEAR_TOP,
5033 FLAG_ACTIVITY_FORWARD_RESULT,
5034 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5035 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5036 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5037 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5038 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5039 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5040 FLAG_ACTIVITY_NEW_DOCUMENT,
5041 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5042 FLAG_ACTIVITY_NO_USER_ACTION,
5043 FLAG_ACTIVITY_REORDER_TO_FRONT,
5044 FLAG_ACTIVITY_NO_ANIMATION,
5045 FLAG_ACTIVITY_CLEAR_TASK,
5046 FLAG_ACTIVITY_TASK_ON_HOME,
5047 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5048 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5049 FLAG_RECEIVER_REGISTERED_ONLY,
5050 FLAG_RECEIVER_REPLACE_PENDING,
5051 FLAG_RECEIVER_FOREGROUND,
5052 FLAG_RECEIVER_NO_ABORT,
5053 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5054 FLAG_RECEIVER_BOOT_UPGRADE,
5055 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5056 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5057 FLAG_RECEIVER_FROM_SHELL,
5058 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5059 })
5060 @Retention(RetentionPolicy.SOURCE)
5061 public @interface MutableFlags {}
5062
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005063 /**
5064 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005065 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005066 * specified in its ClipData. When applying to an Intent's ClipData,
5067 * all URIs as well as recursive traversals through data or other ClipData
5068 * in Intent items will be granted; only the grant flags of the top-level
5069 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005070 */
5071 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5072 /**
5073 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005074 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005075 * specified in its ClipData. When applying to an Intent's ClipData,
5076 * all URIs as well as recursive traversals through data or other ClipData
5077 * in Intent items will be granted; only the grant flags of the top-level
5078 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005079 */
5080 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5081 /**
5082 * Can be set by the caller to indicate that this Intent is coming from
5083 * a background operation, not from direct user interaction.
5084 */
5085 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5086 /**
5087 * A flag you can enable for debugging: when set, log messages will be
5088 * printed during the resolution of this intent to show you what has
5089 * been found to create the final resolved list.
5090 */
5091 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005092 /**
5093 * If set, this intent will not match any components in packages that
5094 * are currently stopped. If this is not set, then the default behavior
5095 * is to include such applications in the result.
5096 */
5097 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5098 /**
5099 * If set, this intent will always match any components in packages that
5100 * are currently stopped. This is the default behavior when
5101 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5102 * flags are set, this one wins (it allows overriding of exclude for
5103 * places where the framework may automatically set the exclude flag).
5104 */
5105 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005106
5107 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005108 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005109 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005110 * persisted across device reboots until explicitly revoked with
5111 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5112 * grant for possible persisting; the receiving application must call
5113 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5114 * actually persist.
5115 *
5116 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5117 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5118 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005119 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005120 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005121 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005122
5123 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005124 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5125 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5126 * applies to any URI that is a prefix match against the original granted
5127 * URI. (Without this flag, the URI must match exactly for access to be
5128 * granted.) Another URI is considered a prefix match only when scheme,
5129 * authority, and all path segments defined by the prefix are an exact
5130 * match.
5131 */
5132 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5133
5134 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005135 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005136 * homework and verified that they correctly handle packages and components
5137 * that come and go over time. In particular:
5138 * <ul>
5139 * <li>Apps installed on external storage, which will appear to be
5140 * uninstalled while the the device is ejected.
5141 * <li>Apps with encryption unaware components, which will appear to not
5142 * exist while the device is locked.
5143 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005144 *
5145 * @hide
5146 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005147 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005148
5149 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005150 * Internal flag used to indicate ephemeral applications should not be
5151 * considered when resolving the intent.
5152 *
5153 * @hide
5154 */
5155 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5156
5157 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005158 * If set, the new activity is not kept in the history stack. As soon as
5159 * the user navigates away from it, the activity is finished. This may also
5160 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5161 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005162 *
5163 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5164 * is never invoked when the current activity starts a new activity which
5165 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005166 */
5167 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5168 /**
5169 * If set, the activity will not be launched if it is already running
5170 * at the top of the history stack.
5171 */
5172 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5173 /**
5174 * If set, this activity will become the start of a new task on this
5175 * history stack. A task (from the activity that started it to the
5176 * next task activity) defines an atomic group of activities that the
5177 * user can move to. Tasks can be moved to the foreground and background;
5178 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005179 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005180 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5181 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005182 *
5183 * <p>This flag is generally used by activities that want
5184 * to present a "launcher" style behavior: they give the user a list of
5185 * separate things that can be done, which otherwise run completely
5186 * independently of the activity launching them.
5187 *
5188 * <p>When using this flag, if a task is already running for the activity
5189 * you are now starting, then a new activity will not be started; instead,
5190 * the current task will simply be brought to the front of the screen with
5191 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5192 * to disable this behavior.
5193 *
5194 * <p>This flag can not be used when the caller is requesting a result from
5195 * the activity being launched.
5196 */
5197 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5198 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005199 * This flag is used to create a new task and launch an activity into it.
5200 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5201 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5202 * search through existing tasks for ones matching this Intent. Only if no such
5203 * task is found would a new task be created. When paired with
5204 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5205 * the search for a matching task and unconditionally start a new task.
5206 *
5207 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5208 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005209 * top-level application launcher.</strong> Used in conjunction with
5210 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5211 * behavior of bringing an existing task to the foreground. When set,
5212 * a new task is <em>always</em> started to host the Activity for the
5213 * Intent, regardless of whether there is already an existing task running
5214 * the same thing.
5215 *
5216 * <p><strong>Because the default system does not include graphical task management,
5217 * you should not use this flag unless you provide some way for a user to
5218 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005219 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005220 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5221 * creating new document tasks.
5222 *
5223 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005224 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005225 *
Scott Main7aee61f2011-02-08 11:25:01 -08005226 * <p>See
5227 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5228 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005229 *
5230 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5231 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005232 */
5233 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5234 /**
5235 * If set, and the activity being launched is already running in the
5236 * current task, then instead of launching a new instance of that activity,
5237 * all of the other activities on top of it will be closed and this Intent
5238 * will be delivered to the (now on top) old activity as a new Intent.
5239 *
5240 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5241 * If D calls startActivity() with an Intent that resolves to the component
5242 * of activity B, then C and D will be finished and B receive the given
5243 * Intent, resulting in the stack now being: A, B.
5244 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005245 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005246 * either receive the new intent you are starting here in its
5247 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005248 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005249 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5250 * the same intent, then it will be finished and re-created; for all other
5251 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5252 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005253 *
5254 * <p>This launch mode can also be used to good effect in conjunction with
5255 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5256 * of a task, it will bring any currently running instance of that task
5257 * to the foreground, and then clear it to its root state. This is
5258 * especially useful, for example, when launching an activity from the
5259 * notification manager.
5260 *
Scott Main7aee61f2011-02-08 11:25:01 -08005261 * <p>See
5262 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5263 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005264 */
5265 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5266 /**
5267 * If set and this intent is being used to launch a new activity from an
5268 * existing one, then the reply target of the existing activity will be
5269 * transfered to the new activity. This way the new activity can call
5270 * {@link android.app.Activity#setResult} and have that result sent back to
5271 * the reply target of the original activity.
5272 */
5273 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5274 /**
5275 * If set and this intent is being used to launch a new activity from an
5276 * existing one, the current activity will not be counted as the top
5277 * activity for deciding whether the new intent should be delivered to
5278 * the top instead of starting a new one. The previous activity will
5279 * be used as the top, with the assumption being that the current activity
5280 * will finish itself immediately.
5281 */
5282 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5283 /**
5284 * If set, the new activity is not kept in the list of recently launched
5285 * activities.
5286 */
5287 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5288 /**
5289 * This flag is not normally set by application code, but set for you by
5290 * the system as described in the
5291 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5292 * launchMode} documentation for the singleTask mode.
5293 */
5294 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5295 /**
5296 * If set, and this activity is either being started in a new task or
5297 * bringing to the top an existing task, then it will be launched as
5298 * the front door of the task. This will result in the application of
5299 * any affinities needed to have that task in the proper state (either
5300 * moving activities to or from it), or simply resetting that task to
5301 * its initial state if needed.
5302 */
5303 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5304 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005305 * This flag is not normally set by application code, but set for you by
5306 * the system if this activity is being launched from history
5307 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005308 */
5309 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005310 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005311 * @deprecated As of API 21 this performs identically to
5312 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005313 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005314 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005315 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005316 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005317 * This flag is used to open a document into a new task rooted at the activity launched
5318 * by this Intent. Through the use of this flag, or its equivalent attribute,
5319 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005320 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005321 *
Craig Mautner026596b2014-05-21 15:35:44 -07005322 * <p>The use of the activity attribute form of this,
5323 * {@link android.R.attr#documentLaunchMode}, is
5324 * preferred over the Intent flag described here. The attribute form allows the
5325 * Activity to specify multiple document behavior for all launchers of the Activity
5326 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005327 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005328 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5329 * it is kept after the activity is finished is different than the use of
5330 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5331 * this flag is being used to create a new recents entry, then by default that entry
5332 * will be removed once the activity is finished. You can modify this behavior with
5333 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5334 *
Craig Mautner026596b2014-05-21 15:35:44 -07005335 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5336 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5337 * equivalent of the Activity manifest specifying {@link
5338 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5339 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5340 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005341 *
Craig Mautner026596b2014-05-21 15:35:44 -07005342 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005343 *
Craig Mautner026596b2014-05-21 15:35:44 -07005344 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005345 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5346 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005347 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005348 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005349 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005350 * callback from occurring on the current frontmost activity before it is
5351 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005352 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005353 * <p>Typically, an activity can rely on that callback to indicate that an
5354 * explicit user action has caused their activity to be moved out of the
5355 * foreground. The callback marks an appropriate point in the activity's
5356 * lifecycle for it to dismiss any notifications that it intends to display
5357 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005358 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005359 * <p>If an activity is ever started via any non-user-driven events such as
5360 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5361 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005362 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005363 */
5364 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005365 /**
5366 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5367 * this flag will cause the launched activity to be brought to the front of its
5368 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005369 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005370 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5371 * If D calls startActivity() with an Intent that resolves to the component
5372 * of activity B, then B will be brought to the front of the history stack,
5373 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005374 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005375 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005376 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005377 */
5378 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005379 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005380 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5381 * this flag will prevent the system from applying an activity transition
5382 * animation to go to the next activity state. This doesn't mean an
5383 * animation will never run -- if another activity change happens that doesn't
5384 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005385 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005386 * when you are going to do a series of activity operations but the
5387 * animation seen by the user shouldn't be driven by the first activity
5388 * change but rather a later one.
5389 */
5390 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5391 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005392 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5393 * this flag will cause any existing task that would be associated with the
5394 * activity to be cleared before the activity is started. That is, the activity
5395 * becomes the new root of an otherwise empty task, and any old activities
5396 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5397 */
5398 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5399 /**
5400 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5401 * this flag will cause a newly launching task to be placed on top of the current
5402 * home activity task (if there is one). That is, pressing back from the task
5403 * will always return the user to home even if that was not the last activity they
5404 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5405 */
5406 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5407 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005408 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5409 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005410 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005411 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005412 * this flag. When set and the task's activity is finished, the recents
5413 * entry will remain in the interface for the user to re-launch it, like a
5414 * recents entry for a top-level application.
5415 * <p>
5416 * The receiving activity can override this request with
5417 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5418 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005419 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005420 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005421 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005422
5423 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005424 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5425 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005426 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5427 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005428 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005429 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005430
5431 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005432 * If set, when sending a broadcast only registered receivers will be
5433 * called -- no BroadcastReceiver components will be launched.
5434 */
5435 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005436 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005437 * If set, when sending a broadcast the new broadcast will replace
5438 * any existing pending broadcast that matches it. Matching is defined
5439 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5440 * true for the intents of the two broadcasts. When a match is found,
5441 * the new broadcast (and receivers associated with it) will replace the
5442 * existing one in the pending broadcast list, remaining at the same
5443 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005444 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005445 * <p>This flag is most typically used with sticky broadcasts, which
5446 * only care about delivering the most recent values of the broadcast
5447 * to their receivers.
5448 */
5449 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5450 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005451 * If set, when sending a broadcast the recipient is allowed to run at
5452 * foreground priority, with a shorter timeout interval. During normal
5453 * broadcasts the receivers are not automatically hoisted out of the
5454 * background priority class.
5455 */
5456 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5457 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005458 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5459 * They can still propagate results through to later receivers, but they can not prevent
5460 * later receivers from seeing the broadcast.
5461 */
5462 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5463 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005464 * If set, when sending a broadcast <i>before boot has completed</i> only
5465 * registered receivers will be called -- no BroadcastReceiver components
5466 * will be launched. Sticky intent state will be recorded properly even
5467 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5468 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005469 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005470 * <p>This flag is only for use by system sevices as a convenience to
5471 * avoid having to implement a more complex mechanism around detection
5472 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005473 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005474 * @hide
5475 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005476 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005477 /**
5478 * Set when this broadcast is for a boot upgrade, a special mode that
5479 * allows the broadcast to be sent before the system is ready and launches
5480 * the app process with no providers running in it.
5481 * @hide
5482 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005483 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005484 /**
5485 * If set, the broadcast will always go to manifest receivers in background (cached
5486 * or not running) apps, regardless of whether that would be done by default. By
5487 * default they will only receive broadcasts if the broadcast has specified an
5488 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005489 *
5490 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5491 * the broadcast code there must also be changed to match.
5492 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005493 * @hide
5494 */
5495 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5496 /**
5497 * If set, the broadcast will never go to manifest receivers in background (cached
5498 * or not running) apps, regardless of whether that would be done by default. By
5499 * default they will receive broadcasts if the broadcast has specified an
5500 * explicit component or package name.
5501 * @hide
5502 */
5503 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005504 /**
5505 * If set, this broadcast is being sent from the shell.
5506 * @hide
5507 */
5508 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005510 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005511 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5512 * will not receive broadcasts.
5513 *
5514 * <em>This flag has no effect when used by an Instant App.</em>
5515 */
5516 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5517
5518 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005519 * @hide Flags that can't be changed with PendingIntent.
5520 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005521 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5522 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5523 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005524
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005525 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005526 // ---------------------------------------------------------------------
5527 // toUri() and parseUri() options.
5528
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005529 /** @hide */
5530 @IntDef(flag = true, prefix = { "URI_" }, value = {
5531 URI_ALLOW_UNSAFE,
5532 URI_ANDROID_APP_SCHEME,
5533 URI_INTENT_SCHEME,
5534 })
5535 @Retention(RetentionPolicy.SOURCE)
5536 public @interface UriFlags {}
5537
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005538 /**
5539 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5540 * always has the "intent:" scheme. This syntax can be used when you want
5541 * to later disambiguate between URIs that are intended to describe an
5542 * Intent vs. all others that should be treated as raw URIs. When used
5543 * with {@link #parseUri}, any other scheme will result in a generic
5544 * VIEW action for that raw URI.
5545 */
5546 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005547
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005548 /**
5549 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5550 * always has the "android-app:" scheme. This is a variation of
5551 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5552 * http/https URI being delivered to a specific package name. The format
5553 * is:
5554 *
5555 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005556 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005557 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005558 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5559 * you must also include a scheme; including a path also requires both a host and a scheme.
5560 * The final #Intent; fragment can be used without a scheme, host, or path.
5561 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005562 * used with intents that have a {@link #setSelector}, since the base intent
5563 * will always have an explicit package name.</p>
5564 *
5565 * <p>Some examples of how this scheme maps to Intent objects:</p>
5566 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5567 * <colgroup align="left" />
5568 * <colgroup align="left" />
5569 * <thead>
5570 * <tr><th>URI</th> <th>Intent</th></tr>
5571 * </thead>
5572 *
5573 * <tbody>
5574 * <tr><td><code>android-app://com.example.app</code></td>
5575 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5576 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5577 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5578 * </table></td>
5579 * </tr>
5580 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5581 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5582 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5583 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5584 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5585 * </table></td>
5586 * </tr>
5587 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5588 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5589 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5590 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5591 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5592 * </table></td>
5593 * </tr>
5594 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5595 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5596 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5597 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5598 * </table></td>
5599 * </tr>
5600 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5601 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5602 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5603 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5604 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5605 * </table></td>
5606 * </tr>
5607 * <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>
5608 * <td><table border="" style="margin:0" >
5609 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5610 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5611 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5612 * </table></td>
5613 * </tr>
5614 * </tbody>
5615 * </table>
5616 */
5617 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5618
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005619 /**
5620 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5621 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5622 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5623 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5624 * generated Intent can not cause unexpected data access to happen.
5625 *
5626 * <p>If you do not trust the source of the URI being parsed, you should still do further
5627 * processing to protect yourself from it. In particular, when using it to start an
5628 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5629 * that can handle it.</p>
5630 */
5631 public static final int URI_ALLOW_UNSAFE = 1<<2;
5632
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005633 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005634
5635 private String mAction;
5636 private Uri mData;
5637 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005638 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005639 private ComponentName mComponent;
5640 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005641 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005642 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005643 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005644 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005645 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005646 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005647 /** Token to track instant app launches. Local only; do not copy cross-process. */
5648 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005649
5650 // ---------------------------------------------------------------------
5651
Makoto Onuki97f82f22017-05-31 16:20:21 -07005652 private static final int COPY_MODE_ALL = 0;
5653 private static final int COPY_MODE_FILTER = 1;
5654 private static final int COPY_MODE_HISTORY = 2;
5655
5656 /** @hide */
5657 @IntDef(value = {COPY_MODE_ALL, COPY_MODE_FILTER, COPY_MODE_HISTORY})
5658 @Retention(RetentionPolicy.SOURCE)
5659 public @interface CopyMode {}
5660
5661
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005662 /**
5663 * Create an empty intent.
5664 */
5665 public Intent() {
5666 }
5667
5668 /**
5669 * Copy constructor.
5670 */
5671 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005672 this(o, COPY_MODE_ALL);
5673 }
5674
5675 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005676 this.mAction = o.mAction;
5677 this.mData = o.mData;
5678 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005679 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005680 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005681
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005682 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005683 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005684 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005685
5686 if (copyMode != COPY_MODE_FILTER) {
5687 this.mFlags = o.mFlags;
5688 this.mContentUserHint = o.mContentUserHint;
5689 this.mLaunchToken = o.mLaunchToken;
5690 if (o.mSourceBounds != null) {
5691 this.mSourceBounds = new Rect(o.mSourceBounds);
5692 }
5693 if (o.mSelector != null) {
5694 this.mSelector = new Intent(o.mSelector);
5695 }
5696
5697 if (copyMode != COPY_MODE_HISTORY) {
5698 if (o.mExtras != null) {
5699 this.mExtras = new Bundle(o.mExtras);
5700 }
5701 if (o.mClipData != null) {
5702 this.mClipData = new ClipData(o.mClipData);
5703 }
5704 } else {
5705 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5706 this.mExtras = Bundle.STRIPPED;
5707 }
5708
5709 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5710 // history.
5711 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005712 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005713 }
5714
5715 @Override
5716 public Object clone() {
5717 return new Intent(this);
5718 }
5719
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005720 /**
5721 * Make a clone of only the parts of the Intent that are relevant for
5722 * filter matching: the action, data, type, component, and categories.
5723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005724 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005725 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005726 }
5727
5728 /**
5729 * Create an intent with a given action. All other fields (data, type,
5730 * class) are null. Note that the action <em>must</em> be in a
5731 * namespace because Intents are used globally in the system -- for
5732 * example the system VIEW action is android.intent.action.VIEW; an
5733 * application's custom action would be something like
5734 * com.google.app.myapp.CUSTOM_ACTION.
5735 *
5736 * @param action The Intent action, such as ACTION_VIEW.
5737 */
5738 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005739 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005740 }
5741
5742 /**
5743 * Create an intent with a given action and for a given data url. Note
5744 * that the action <em>must</em> be in a namespace because Intents are
5745 * used globally in the system -- for example the system VIEW action is
5746 * android.intent.action.VIEW; an application's custom action would be
5747 * something like com.google.app.myapp.CUSTOM_ACTION.
5748 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005749 * <p><em>Note: scheme and host name matching in the Android framework is
5750 * case-sensitive, unlike the formal RFC. As a result,
5751 * you should always ensure that you write your Uri with these elements
5752 * using lower case letters, and normalize any Uris you receive from
5753 * outside of Android to ensure the scheme and host is lower case.</em></p>
5754 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005755 * @param action The Intent action, such as ACTION_VIEW.
5756 * @param uri The Intent data URI.
5757 */
5758 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005759 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005760 mData = uri;
5761 }
5762
5763 /**
5764 * Create an intent for a specific component. All other fields (action, data,
5765 * type, class) are null, though they can be modified later with explicit
5766 * calls. This provides a convenient way to create an intent that is
5767 * intended to execute a hard-coded class name, rather than relying on the
5768 * system to find an appropriate class for you; see {@link #setComponent}
5769 * for more information on the repercussions of this.
5770 *
5771 * @param packageContext A Context of the application package implementing
5772 * this class.
5773 * @param cls The component class that is to be used for the intent.
5774 *
5775 * @see #setClass
5776 * @see #setComponent
5777 * @see #Intent(String, android.net.Uri , Context, Class)
5778 */
5779 public Intent(Context packageContext, Class<?> cls) {
5780 mComponent = new ComponentName(packageContext, cls);
5781 }
5782
5783 /**
5784 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005785 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005786 * construct the Intent and then calling {@link #setClass} to set its
5787 * class.
5788 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005789 * <p><em>Note: scheme and host name matching in the Android framework is
5790 * case-sensitive, unlike the formal RFC. As a result,
5791 * you should always ensure that you write your Uri with these elements
5792 * using lower case letters, and normalize any Uris you receive from
5793 * outside of Android to ensure the scheme and host is lower case.</em></p>
5794 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005795 * @param action The Intent action, such as ACTION_VIEW.
5796 * @param uri The Intent data URI.
5797 * @param packageContext A Context of the application package implementing
5798 * this class.
5799 * @param cls The component class that is to be used for the intent.
5800 *
5801 * @see #Intent(String, android.net.Uri)
5802 * @see #Intent(Context, Class)
5803 * @see #setClass
5804 * @see #setComponent
5805 */
5806 public Intent(String action, Uri uri,
5807 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005808 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005809 mData = uri;
5810 mComponent = new ComponentName(packageContext, cls);
5811 }
5812
5813 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005814 * Create an intent to launch the main (root) activity of a task. This
5815 * is the Intent that is started when the application's is launched from
5816 * Home. For anything else that wants to launch an application in the
5817 * same way, it is important that they use an Intent structured the same
5818 * way, and can use this function to ensure this is the case.
5819 *
5820 * <p>The returned Intent has the given Activity component as its explicit
5821 * component, {@link #ACTION_MAIN} as its action, and includes the
5822 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5823 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5824 * to do that through {@link #addFlags(int)} on the returned Intent.
5825 *
5826 * @param mainActivity The main activity component that this Intent will
5827 * launch.
5828 * @return Returns a newly created Intent that can be used to launch the
5829 * activity as a main application entry.
5830 *
5831 * @see #setClass
5832 * @see #setComponent
5833 */
5834 public static Intent makeMainActivity(ComponentName mainActivity) {
5835 Intent intent = new Intent(ACTION_MAIN);
5836 intent.setComponent(mainActivity);
5837 intent.addCategory(CATEGORY_LAUNCHER);
5838 return intent;
5839 }
5840
5841 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005842 * Make an Intent for the main activity of an application, without
5843 * specifying a specific activity to run but giving a selector to find
5844 * the activity. This results in a final Intent that is structured
5845 * the same as when the application is launched from
5846 * Home. For anything else that wants to launch an application in the
5847 * same way, it is important that they use an Intent structured the same
5848 * way, and can use this function to ensure this is the case.
5849 *
5850 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5851 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5852 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5853 * to do that through {@link #addFlags(int)} on the returned Intent.
5854 *
5855 * @param selectorAction The action name of the Intent's selector.
5856 * @param selectorCategory The name of a category to add to the Intent's
5857 * selector.
5858 * @return Returns a newly created Intent that can be used to launch the
5859 * activity as a main application entry.
5860 *
5861 * @see #setSelector(Intent)
5862 */
5863 public static Intent makeMainSelectorActivity(String selectorAction,
5864 String selectorCategory) {
5865 Intent intent = new Intent(ACTION_MAIN);
5866 intent.addCategory(CATEGORY_LAUNCHER);
5867 Intent selector = new Intent();
5868 selector.setAction(selectorAction);
5869 selector.addCategory(selectorCategory);
5870 intent.setSelector(selector);
5871 return intent;
5872 }
5873
5874 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005875 * Make an Intent that can be used to re-launch an application's task
5876 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5877 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5878 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5879 *
5880 * @param mainActivity The activity component that is the root of the
5881 * task; this is the activity that has been published in the application's
5882 * manifest as the main launcher icon.
5883 *
5884 * @return Returns a newly created Intent that can be used to relaunch the
5885 * activity's task in its root state.
5886 */
5887 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5888 Intent intent = makeMainActivity(mainActivity);
5889 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5890 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5891 return intent;
5892 }
5893
5894 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005895 * Call {@link #parseUri} with 0 flags.
5896 * @deprecated Use {@link #parseUri} instead.
5897 */
5898 @Deprecated
5899 public static Intent getIntent(String uri) throws URISyntaxException {
5900 return parseUri(uri, 0);
5901 }
Tom Taylord4a47292009-12-21 13:59:18 -08005902
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005903 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005904 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005905 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005906 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005907 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005908 *
5909 * <p>The URI given here must not be relative -- that is, it must include
5910 * the scheme and full path.
5911 *
5912 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005913 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005914 *
5915 * @return Intent The newly created Intent object.
5916 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005917 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5918 * it bad (as parsed by the Uri class) or the Intent data within the
5919 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005920 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005921 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005923 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005924 int i = 0;
5925 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005926 final boolean androidApp = uri.startsWith("android-app:");
5927
5928 // Validate intent scheme if requested.
5929 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5930 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005931 Intent intent = new Intent(ACTION_VIEW);
5932 try {
5933 intent.setData(Uri.parse(uri));
5934 } catch (IllegalArgumentException e) {
5935 throw new URISyntaxException(uri, e.getMessage());
5936 }
5937 return intent;
5938 }
5939 }
Tom Taylord4a47292009-12-21 13:59:18 -08005940
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005941 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005942 // simple case
5943 if (i == -1) {
5944 if (!androidApp) {
5945 return new Intent(ACTION_VIEW, Uri.parse(uri));
5946 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005947
5948 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005949 } else if (!uri.startsWith("#Intent;", i)) {
5950 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005951 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005952 } else {
5953 i = -1;
5954 }
5955 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005956
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005957 // new format
5958 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005959 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005960 boolean explicitAction = false;
5961 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005962
5963 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005964 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005965 String data;
5966 if (i >= 0) {
5967 data = uri.substring(0, i);
5968 i += 8; // length of "#Intent;"
5969 } else {
5970 data = uri;
5971 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005972
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005973 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005974 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005975 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005976 if (eq < 0) eq = i-1;
5977 int semi = uri.indexOf(';', i);
5978 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005979
5980 // action
5981 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005982 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005983 if (!inSelector) {
5984 explicitAction = true;
5985 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005986 }
5987
5988 // categories
5989 else if (uri.startsWith("category=", i)) {
5990 intent.addCategory(value);
5991 }
5992
5993 // type
5994 else if (uri.startsWith("type=", i)) {
5995 intent.mType = value;
5996 }
5997
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005998 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005999 else if (uri.startsWith("launchFlags=", i)) {
6000 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006001 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6002 intent.mFlags &= ~IMMUTABLE_FLAGS;
6003 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006004 }
6005
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006006 // package
6007 else if (uri.startsWith("package=", i)) {
6008 intent.mPackage = value;
6009 }
6010
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006011 // component
6012 else if (uri.startsWith("component=", i)) {
6013 intent.mComponent = ComponentName.unflattenFromString(value);
6014 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006015
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006016 // scheme
6017 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006018 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006019 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006020 } else {
6021 scheme = value;
6022 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006023 }
6024
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006025 // source bounds
6026 else if (uri.startsWith("sourceBounds=", i)) {
6027 intent.mSourceBounds = Rect.unflattenFromString(value);
6028 }
6029
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006030 // selector
6031 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6032 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006033 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006034 }
6035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006036 // extra
6037 else {
6038 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006039 // create Bundle if it doesn't already exist
6040 if (intent.mExtras == null) intent.mExtras = new Bundle();
6041 Bundle b = intent.mExtras;
6042 // add EXTRA
6043 if (uri.startsWith("S.", i)) b.putString(key, value);
6044 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6045 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6046 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6047 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6048 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6049 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6050 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6051 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6052 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6053 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006055 // move to the next item
6056 i = semi + 1;
6057 }
6058
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006059 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006060 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006061 if (baseIntent.mPackage == null) {
6062 baseIntent.setSelector(intent);
6063 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006064 intent = baseIntent;
6065 }
6066
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006067 if (data != null) {
6068 if (data.startsWith("intent:")) {
6069 data = data.substring(7);
6070 if (scheme != null) {
6071 data = scheme + ':' + data;
6072 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006073 } else if (data.startsWith("android-app:")) {
6074 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6075 // Correctly formed android-app, first part is package name.
6076 int end = data.indexOf('/', 14);
6077 if (end < 0) {
6078 // All we have is a package name.
6079 intent.mPackage = data.substring(14);
6080 if (!explicitAction) {
6081 intent.setAction(ACTION_MAIN);
6082 }
6083 data = "";
6084 } else {
6085 // Target the Intent at the given package name always.
6086 String authority = null;
6087 intent.mPackage = data.substring(14, end);
6088 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006089 if ((end+1) < data.length()) {
6090 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6091 // Found a scheme, remember it.
6092 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006093 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006094 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6095 // Found a authority, remember it.
6096 authority = data.substring(end+1, newEnd);
6097 end = newEnd;
6098 }
6099 } else {
6100 // All we have is a scheme.
6101 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006102 }
6103 }
6104 if (scheme == null) {
6105 // If there was no scheme, then this just targets the package.
6106 if (!explicitAction) {
6107 intent.setAction(ACTION_MAIN);
6108 }
6109 data = "";
6110 } else if (authority == null) {
6111 data = scheme + ":";
6112 } else {
6113 data = scheme + "://" + authority + data.substring(end);
6114 }
6115 }
6116 } else {
6117 data = "";
6118 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006119 }
Tom Taylord4a47292009-12-21 13:59:18 -08006120
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006121 if (data.length() > 0) {
6122 try {
6123 intent.mData = Uri.parse(data);
6124 } catch (IllegalArgumentException e) {
6125 throw new URISyntaxException(uri, e.getMessage());
6126 }
6127 }
6128 }
Tom Taylord4a47292009-12-21 13:59:18 -08006129
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006130 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006131
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006132 } catch (IndexOutOfBoundsException e) {
6133 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6134 }
6135 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006136
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006137 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006138 return getIntentOld(uri, 0);
6139 }
6140
6141 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006142 Intent intent;
6143
6144 int i = uri.lastIndexOf('#');
6145 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006146 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006147 final int intentFragmentStart = i;
6148 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006149
6150 i++;
6151
6152 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006153 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006154 i += 7;
6155 int j = uri.indexOf(')', i);
6156 action = uri.substring(i, j);
6157 i = j + 1;
6158 }
6159
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006160 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006161
6162 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006163 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006164 i += 11;
6165 int j = uri.indexOf(')', i);
6166 while (i < j) {
6167 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006168 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006169 if (i < sep) {
6170 intent.addCategory(uri.substring(i, sep));
6171 }
6172 i = sep + 1;
6173 }
6174 i = j + 1;
6175 }
6176
6177 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006178 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006179 i += 5;
6180 int j = uri.indexOf(')', i);
6181 intent.mType = uri.substring(i, j);
6182 i = j + 1;
6183 }
6184
6185 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006186 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006187 i += 12;
6188 int j = uri.indexOf(')', i);
6189 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006190 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6191 intent.mFlags &= ~IMMUTABLE_FLAGS;
6192 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006193 i = j + 1;
6194 }
6195
6196 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006197 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006198 i += 10;
6199 int j = uri.indexOf(')', i);
6200 int sep = uri.indexOf('!', i);
6201 if (sep >= 0 && sep < j) {
6202 String pkg = uri.substring(i, sep);
6203 String cls = uri.substring(sep + 1, j);
6204 intent.mComponent = new ComponentName(pkg, cls);
6205 }
6206 i = j + 1;
6207 }
6208
6209 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006210 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006211 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006212
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006213 final int closeParen = uri.indexOf(')', i);
6214 if (closeParen == -1) throw new URISyntaxException(uri,
6215 "EXTRA missing trailing ')'", i);
6216
6217 while (i < closeParen) {
6218 // fetch the key value
6219 int j = uri.indexOf('=', i);
6220 if (j <= i + 1 || i >= closeParen) {
6221 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6222 }
6223 char type = uri.charAt(i);
6224 i++;
6225 String key = uri.substring(i, j);
6226 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006227
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006228 // get type-value
6229 j = uri.indexOf('!', i);
6230 if (j == -1 || j >= closeParen) j = closeParen;
6231 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6232 String value = uri.substring(i, j);
6233 i = j;
6234
6235 // create Bundle if it doesn't already exist
6236 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006237
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006238 // add item to bundle
6239 try {
6240 switch (type) {
6241 case 'S':
6242 intent.mExtras.putString(key, Uri.decode(value));
6243 break;
6244 case 'B':
6245 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6246 break;
6247 case 'b':
6248 intent.mExtras.putByte(key, Byte.parseByte(value));
6249 break;
6250 case 'c':
6251 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6252 break;
6253 case 'd':
6254 intent.mExtras.putDouble(key, Double.parseDouble(value));
6255 break;
6256 case 'f':
6257 intent.mExtras.putFloat(key, Float.parseFloat(value));
6258 break;
6259 case 'i':
6260 intent.mExtras.putInt(key, Integer.parseInt(value));
6261 break;
6262 case 'l':
6263 intent.mExtras.putLong(key, Long.parseLong(value));
6264 break;
6265 case 's':
6266 intent.mExtras.putShort(key, Short.parseShort(value));
6267 break;
6268 default:
6269 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6270 }
6271 } catch (NumberFormatException e) {
6272 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6273 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006274
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006275 char ch = uri.charAt(i);
6276 if (ch == ')') break;
6277 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6278 i++;
6279 }
6280 }
6281
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006282 if (isIntentFragment) {
6283 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6284 } else {
6285 intent.mData = Uri.parse(uri);
6286 }
Tom Taylord4a47292009-12-21 13:59:18 -08006287
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006288 if (intent.mAction == null) {
6289 // By default, if no action is specified, then use VIEW.
6290 intent.mAction = ACTION_VIEW;
6291 }
6292
6293 } else {
6294 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6295 }
6296
6297 return intent;
6298 }
6299
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006300 /** @hide */
6301 public interface CommandOptionHandler {
6302 boolean handleOption(String opt, ShellCommand cmd);
6303 }
6304
6305 /** @hide */
6306 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6307 throws URISyntaxException {
6308 Intent intent = new Intent();
6309 Intent baseIntent = intent;
6310 boolean hasIntentInfo = false;
6311
6312 Uri data = null;
6313 String type = null;
6314
6315 String opt;
6316 while ((opt=cmd.getNextOption()) != null) {
6317 switch (opt) {
6318 case "-a":
6319 intent.setAction(cmd.getNextArgRequired());
6320 if (intent == baseIntent) {
6321 hasIntentInfo = true;
6322 }
6323 break;
6324 case "-d":
6325 data = Uri.parse(cmd.getNextArgRequired());
6326 if (intent == baseIntent) {
6327 hasIntentInfo = true;
6328 }
6329 break;
6330 case "-t":
6331 type = cmd.getNextArgRequired();
6332 if (intent == baseIntent) {
6333 hasIntentInfo = true;
6334 }
6335 break;
6336 case "-c":
6337 intent.addCategory(cmd.getNextArgRequired());
6338 if (intent == baseIntent) {
6339 hasIntentInfo = true;
6340 }
6341 break;
6342 case "-e":
6343 case "--es": {
6344 String key = cmd.getNextArgRequired();
6345 String value = cmd.getNextArgRequired();
6346 intent.putExtra(key, value);
6347 }
6348 break;
6349 case "--esn": {
6350 String key = cmd.getNextArgRequired();
6351 intent.putExtra(key, (String) null);
6352 }
6353 break;
6354 case "--ei": {
6355 String key = cmd.getNextArgRequired();
6356 String value = cmd.getNextArgRequired();
6357 intent.putExtra(key, Integer.decode(value));
6358 }
6359 break;
6360 case "--eu": {
6361 String key = cmd.getNextArgRequired();
6362 String value = cmd.getNextArgRequired();
6363 intent.putExtra(key, Uri.parse(value));
6364 }
6365 break;
6366 case "--ecn": {
6367 String key = cmd.getNextArgRequired();
6368 String value = cmd.getNextArgRequired();
6369 ComponentName cn = ComponentName.unflattenFromString(value);
6370 if (cn == null)
6371 throw new IllegalArgumentException("Bad component name: " + value);
6372 intent.putExtra(key, cn);
6373 }
6374 break;
6375 case "--eia": {
6376 String key = cmd.getNextArgRequired();
6377 String value = cmd.getNextArgRequired();
6378 String[] strings = value.split(",");
6379 int[] list = new int[strings.length];
6380 for (int i = 0; i < strings.length; i++) {
6381 list[i] = Integer.decode(strings[i]);
6382 }
6383 intent.putExtra(key, list);
6384 }
6385 break;
6386 case "--eial": {
6387 String key = cmd.getNextArgRequired();
6388 String value = cmd.getNextArgRequired();
6389 String[] strings = value.split(",");
6390 ArrayList<Integer> list = new ArrayList<>(strings.length);
6391 for (int i = 0; i < strings.length; i++) {
6392 list.add(Integer.decode(strings[i]));
6393 }
6394 intent.putExtra(key, list);
6395 }
6396 break;
6397 case "--el": {
6398 String key = cmd.getNextArgRequired();
6399 String value = cmd.getNextArgRequired();
6400 intent.putExtra(key, Long.valueOf(value));
6401 }
6402 break;
6403 case "--ela": {
6404 String key = cmd.getNextArgRequired();
6405 String value = cmd.getNextArgRequired();
6406 String[] strings = value.split(",");
6407 long[] list = new long[strings.length];
6408 for (int i = 0; i < strings.length; i++) {
6409 list[i] = Long.valueOf(strings[i]);
6410 }
6411 intent.putExtra(key, list);
6412 hasIntentInfo = true;
6413 }
6414 break;
6415 case "--elal": {
6416 String key = cmd.getNextArgRequired();
6417 String value = cmd.getNextArgRequired();
6418 String[] strings = value.split(",");
6419 ArrayList<Long> list = new ArrayList<>(strings.length);
6420 for (int i = 0; i < strings.length; i++) {
6421 list.add(Long.valueOf(strings[i]));
6422 }
6423 intent.putExtra(key, list);
6424 hasIntentInfo = true;
6425 }
6426 break;
6427 case "--ef": {
6428 String key = cmd.getNextArgRequired();
6429 String value = cmd.getNextArgRequired();
6430 intent.putExtra(key, Float.valueOf(value));
6431 hasIntentInfo = true;
6432 }
6433 break;
6434 case "--efa": {
6435 String key = cmd.getNextArgRequired();
6436 String value = cmd.getNextArgRequired();
6437 String[] strings = value.split(",");
6438 float[] list = new float[strings.length];
6439 for (int i = 0; i < strings.length; i++) {
6440 list[i] = Float.valueOf(strings[i]);
6441 }
6442 intent.putExtra(key, list);
6443 hasIntentInfo = true;
6444 }
6445 break;
6446 case "--efal": {
6447 String key = cmd.getNextArgRequired();
6448 String value = cmd.getNextArgRequired();
6449 String[] strings = value.split(",");
6450 ArrayList<Float> list = new ArrayList<>(strings.length);
6451 for (int i = 0; i < strings.length; i++) {
6452 list.add(Float.valueOf(strings[i]));
6453 }
6454 intent.putExtra(key, list);
6455 hasIntentInfo = true;
6456 }
6457 break;
6458 case "--esa": {
6459 String key = cmd.getNextArgRequired();
6460 String value = cmd.getNextArgRequired();
6461 // Split on commas unless they are preceeded by an escape.
6462 // The escape character must be escaped for the string and
6463 // again for the regex, thus four escape characters become one.
6464 String[] strings = value.split("(?<!\\\\),");
6465 intent.putExtra(key, strings);
6466 hasIntentInfo = true;
6467 }
6468 break;
6469 case "--esal": {
6470 String key = cmd.getNextArgRequired();
6471 String value = cmd.getNextArgRequired();
6472 // Split on commas unless they are preceeded by an escape.
6473 // The escape character must be escaped for the string and
6474 // again for the regex, thus four escape characters become one.
6475 String[] strings = value.split("(?<!\\\\),");
6476 ArrayList<String> list = new ArrayList<>(strings.length);
6477 for (int i = 0; i < strings.length; i++) {
6478 list.add(strings[i]);
6479 }
6480 intent.putExtra(key, list);
6481 hasIntentInfo = true;
6482 }
6483 break;
6484 case "--ez": {
6485 String key = cmd.getNextArgRequired();
6486 String value = cmd.getNextArgRequired().toLowerCase();
6487 // Boolean.valueOf() results in false for anything that is not "true", which is
6488 // error-prone in shell commands
6489 boolean arg;
6490 if ("true".equals(value) || "t".equals(value)) {
6491 arg = true;
6492 } else if ("false".equals(value) || "f".equals(value)) {
6493 arg = false;
6494 } else {
6495 try {
6496 arg = Integer.decode(value) != 0;
6497 } catch (NumberFormatException ex) {
6498 throw new IllegalArgumentException("Invalid boolean value: " + value);
6499 }
6500 }
6501
6502 intent.putExtra(key, arg);
6503 }
6504 break;
6505 case "-n": {
6506 String str = cmd.getNextArgRequired();
6507 ComponentName cn = ComponentName.unflattenFromString(str);
6508 if (cn == null)
6509 throw new IllegalArgumentException("Bad component name: " + str);
6510 intent.setComponent(cn);
6511 if (intent == baseIntent) {
6512 hasIntentInfo = true;
6513 }
6514 }
6515 break;
6516 case "-p": {
6517 String str = cmd.getNextArgRequired();
6518 intent.setPackage(str);
6519 if (intent == baseIntent) {
6520 hasIntentInfo = true;
6521 }
6522 }
6523 break;
6524 case "-f":
6525 String str = cmd.getNextArgRequired();
6526 intent.setFlags(Integer.decode(str).intValue());
6527 break;
6528 case "--grant-read-uri-permission":
6529 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6530 break;
6531 case "--grant-write-uri-permission":
6532 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6533 break;
6534 case "--grant-persistable-uri-permission":
6535 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6536 break;
6537 case "--grant-prefix-uri-permission":
6538 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6539 break;
6540 case "--exclude-stopped-packages":
6541 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6542 break;
6543 case "--include-stopped-packages":
6544 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6545 break;
6546 case "--debug-log-resolution":
6547 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6548 break;
6549 case "--activity-brought-to-front":
6550 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6551 break;
6552 case "--activity-clear-top":
6553 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6554 break;
6555 case "--activity-clear-when-task-reset":
6556 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6557 break;
6558 case "--activity-exclude-from-recents":
6559 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6560 break;
6561 case "--activity-launched-from-history":
6562 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6563 break;
6564 case "--activity-multiple-task":
6565 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6566 break;
6567 case "--activity-no-animation":
6568 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6569 break;
6570 case "--activity-no-history":
6571 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6572 break;
6573 case "--activity-no-user-action":
6574 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6575 break;
6576 case "--activity-previous-is-top":
6577 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6578 break;
6579 case "--activity-reorder-to-front":
6580 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6581 break;
6582 case "--activity-reset-task-if-needed":
6583 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6584 break;
6585 case "--activity-single-top":
6586 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6587 break;
6588 case "--activity-clear-task":
6589 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6590 break;
6591 case "--activity-task-on-home":
6592 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6593 break;
6594 case "--receiver-registered-only":
6595 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6596 break;
6597 case "--receiver-replace-pending":
6598 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6599 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006600 case "--receiver-foreground":
6601 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6602 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006603 case "--receiver-no-abort":
6604 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6605 break;
6606 case "--receiver-include-background":
6607 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6608 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006609 case "--selector":
6610 intent.setDataAndType(data, type);
6611 intent = new Intent();
6612 break;
6613 default:
6614 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6615 // Okay, caller handled this option.
6616 } else {
6617 throw new IllegalArgumentException("Unknown option: " + opt);
6618 }
6619 break;
6620 }
6621 }
6622 intent.setDataAndType(data, type);
6623
6624 final boolean hasSelector = intent != baseIntent;
6625 if (hasSelector) {
6626 // A selector was specified; fix up.
6627 baseIntent.setSelector(intent);
6628 intent = baseIntent;
6629 }
6630
6631 String arg = cmd.getNextArg();
6632 baseIntent = null;
6633 if (arg == null) {
6634 if (hasSelector) {
6635 // If a selector has been specified, and no arguments
6636 // have been supplied for the main Intent, then we can
6637 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6638 // need to have a component name specified yet, the
6639 // selector will take care of that.
6640 baseIntent = new Intent(Intent.ACTION_MAIN);
6641 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6642 }
6643 } else if (arg.indexOf(':') >= 0) {
6644 // The argument is a URI. Fully parse it, and use that result
6645 // to fill in any data not specified so far.
6646 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6647 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6648 } else if (arg.indexOf('/') >= 0) {
6649 // The argument is a component name. Build an Intent to launch
6650 // it.
6651 baseIntent = new Intent(Intent.ACTION_MAIN);
6652 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6653 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6654 } else {
6655 // Assume the argument is a package name.
6656 baseIntent = new Intent(Intent.ACTION_MAIN);
6657 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6658 baseIntent.setPackage(arg);
6659 }
6660 if (baseIntent != null) {
6661 Bundle extras = intent.getExtras();
6662 intent.replaceExtras((Bundle)null);
6663 Bundle uriExtras = baseIntent.getExtras();
6664 baseIntent.replaceExtras((Bundle)null);
6665 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6666 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6667 for (String c : cats) {
6668 baseIntent.removeCategory(c);
6669 }
6670 }
6671 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6672 if (extras == null) {
6673 extras = uriExtras;
6674 } else if (uriExtras != null) {
6675 uriExtras.putAll(extras);
6676 extras = uriExtras;
6677 }
6678 intent.replaceExtras(extras);
6679 hasIntentInfo = true;
6680 }
6681
6682 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6683 return intent;
6684 }
6685
6686 /** @hide */
6687 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6688 final String[] lines = new String[] {
6689 "<INTENT> specifications include these flags and arguments:",
6690 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6691 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6692 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6693 " [--esn <EXTRA_KEY> ...]",
6694 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6695 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6696 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6697 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6698 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6699 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6700 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6701 " (mutiple extras passed as Integer[])",
6702 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6703 " (mutiple extras passed as List<Integer>)",
6704 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6705 " (mutiple extras passed as Long[])",
6706 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6707 " (mutiple extras passed as List<Long>)",
6708 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6709 " (mutiple extras passed as Float[])",
6710 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6711 " (mutiple extras passed as List<Float>)",
6712 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6713 " (mutiple extras passed as String[]; to embed a comma into a string,",
6714 " escape it using \"\\,\")",
6715 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6716 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6717 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006718 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006719 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6720 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6721 " [--debug-log-resolution] [--exclude-stopped-packages]",
6722 " [--include-stopped-packages]",
6723 " [--activity-brought-to-front] [--activity-clear-top]",
6724 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6725 " [--activity-launched-from-history] [--activity-multiple-task]",
6726 " [--activity-no-animation] [--activity-no-history]",
6727 " [--activity-no-user-action] [--activity-previous-is-top]",
6728 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6729 " [--activity-single-top] [--activity-clear-task]",
6730 " [--activity-task-on-home]",
6731 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006732 " [--receiver-foreground] [--receiver-no-abort]",
6733 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006734 " [--selector]",
6735 " [<URI> | <PACKAGE> | <COMPONENT>]"
6736 };
6737 for (String line : lines) {
6738 pw.print(prefix);
6739 pw.println(line);
6740 }
6741 }
6742
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006743 /**
6744 * Retrieve the general action to be performed, such as
6745 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6746 * the information in the intent should be interpreted -- most importantly,
6747 * what to do with the data returned by {@link #getData}.
6748 *
6749 * @return The action of this intent or null if none is specified.
6750 *
6751 * @see #setAction
6752 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006753 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006754 return mAction;
6755 }
6756
6757 /**
6758 * Retrieve data this intent is operating on. This URI specifies the name
6759 * of the data; often it uses the content: scheme, specifying data in a
6760 * content provider. Other schemes may be handled by specific activities,
6761 * such as http: by the web browser.
6762 *
6763 * @return The URI of the data this intent is targeting or null.
6764 *
6765 * @see #getScheme
6766 * @see #setData
6767 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006768 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006769 return mData;
6770 }
6771
6772 /**
6773 * The same as {@link #getData()}, but returns the URI as an encoded
6774 * String.
6775 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006776 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006777 return mData != null ? mData.toString() : null;
6778 }
6779
6780 /**
6781 * Return the scheme portion of the intent's data. If the data is null or
6782 * does not include a scheme, null is returned. Otherwise, the scheme
6783 * prefix without the final ':' is returned, i.e. "http".
6784 *
6785 * <p>This is the same as calling getData().getScheme() (and checking for
6786 * null data).
6787 *
6788 * @return The scheme of this intent.
6789 *
6790 * @see #getData
6791 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006792 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 return mData != null ? mData.getScheme() : null;
6794 }
6795
6796 /**
6797 * Retrieve any explicit MIME type included in the intent. This is usually
6798 * null, as the type is determined by the intent data.
6799 *
6800 * @return If a type was manually set, it is returned; else null is
6801 * returned.
6802 *
6803 * @see #resolveType(ContentResolver)
6804 * @see #setType
6805 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006806 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006807 return mType;
6808 }
6809
6810 /**
6811 * Return the MIME data type of this intent. If the type field is
6812 * explicitly set, that is simply returned. Otherwise, if the data is set,
6813 * the type of that data is returned. If neither fields are set, a null is
6814 * returned.
6815 *
6816 * @return The MIME type of this intent.
6817 *
6818 * @see #getType
6819 * @see #resolveType(ContentResolver)
6820 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006821 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006822 return resolveType(context.getContentResolver());
6823 }
6824
6825 /**
6826 * Return the MIME data type of this intent. If the type field is
6827 * explicitly set, that is simply returned. Otherwise, if the data is set,
6828 * the type of that data is returned. If neither fields are set, a null is
6829 * returned.
6830 *
6831 * @param resolver A ContentResolver that can be used to determine the MIME
6832 * type of the intent's data.
6833 *
6834 * @return The MIME type of this intent.
6835 *
6836 * @see #getType
6837 * @see #resolveType(Context)
6838 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006839 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006840 if (mType != null) {
6841 return mType;
6842 }
6843 if (mData != null) {
6844 if ("content".equals(mData.getScheme())) {
6845 return resolver.getType(mData);
6846 }
6847 }
6848 return null;
6849 }
6850
6851 /**
6852 * Return the MIME data type of this intent, only if it will be needed for
6853 * intent resolution. This is not generally useful for application code;
6854 * it is used by the frameworks for communicating with back-end system
6855 * services.
6856 *
6857 * @param resolver A ContentResolver that can be used to determine the MIME
6858 * type of the intent's data.
6859 *
6860 * @return The MIME type of this intent, or null if it is unknown or not
6861 * needed.
6862 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006863 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006864 if (mComponent != null) {
6865 return mType;
6866 }
6867 return resolveType(resolver);
6868 }
6869
6870 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006871 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006872 *
6873 * @param category The category to check.
6874 *
6875 * @return boolean True if the intent contains the category, else false.
6876 *
6877 * @see #getCategories
6878 * @see #addCategory
6879 */
6880 public boolean hasCategory(String category) {
6881 return mCategories != null && mCategories.contains(category);
6882 }
6883
6884 /**
6885 * Return the set of all categories in the intent. If there are no categories,
6886 * returns NULL.
6887 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006888 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006889 *
6890 * @see #hasCategory
6891 * @see #addCategory
6892 */
6893 public Set<String> getCategories() {
6894 return mCategories;
6895 }
6896
6897 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006898 * Return the specific selector associated with this Intent. If there is
6899 * none, returns null. See {@link #setSelector} for more information.
6900 *
6901 * @see #setSelector
6902 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006903 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006904 return mSelector;
6905 }
6906
6907 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006908 * Return the {@link ClipData} associated with this Intent. If there is
6909 * none, returns null. See {@link #setClipData} for more information.
6910 *
John Spurlock125d1332013-11-25 11:58:37 -05006911 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006912 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006913 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006914 return mClipData;
6915 }
6916
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006917 /** @hide */
6918 public int getContentUserHint() {
6919 return mContentUserHint;
6920 }
6921
Todd Kennedyb3b431302017-03-20 16:05:48 -07006922 /** @hide */
6923 public String getLaunchToken() {
6924 return mLaunchToken;
6925 }
6926
6927 /** @hide */
6928 public void setLaunchToken(String launchToken) {
6929 mLaunchToken = launchToken;
6930 }
6931
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006932 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006933 * Sets the ClassLoader that will be used when unmarshalling
6934 * any Parcelable values from the extras of this Intent.
6935 *
6936 * @param loader a ClassLoader, or null to use the default loader
6937 * at the time of unmarshalling.
6938 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006939 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 if (mExtras != null) {
6941 mExtras.setClassLoader(loader);
6942 }
6943 }
6944
6945 /**
6946 * Returns true if an extra value is associated with the given name.
6947 * @param name the extra's name
6948 * @return true if the given extra is present.
6949 */
6950 public boolean hasExtra(String name) {
6951 return mExtras != null && mExtras.containsKey(name);
6952 }
6953
6954 /**
6955 * Returns true if the Intent's extras contain a parcelled file descriptor.
6956 * @return true if the Intent contains a parcelled file descriptor.
6957 */
6958 public boolean hasFileDescriptors() {
6959 return mExtras != null && mExtras.hasFileDescriptors();
6960 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006961
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006962 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006963 public void setAllowFds(boolean allowFds) {
6964 if (mExtras != null) {
6965 mExtras.setAllowFds(allowFds);
6966 }
6967 }
6968
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006969 /** {@hide} */
6970 public void setDefusable(boolean defusable) {
6971 if (mExtras != null) {
6972 mExtras.setDefusable(defusable);
6973 }
6974 }
6975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006976 /**
6977 * Retrieve extended data from the intent.
6978 *
6979 * @param name The name of the desired item.
6980 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07006981 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006982 * or null if none was found.
6983 *
6984 * @deprecated
6985 * @hide
6986 */
6987 @Deprecated
6988 public Object getExtra(String name) {
6989 return getExtra(name, null);
6990 }
6991
6992 /**
6993 * Retrieve extended data from the intent.
6994 *
6995 * @param name The name of the desired item.
6996 * @param defaultValue the value to be returned if no value of the desired
6997 * type is stored with the given name.
6998 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07006999 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007000 * or the default value if none was found.
7001 *
7002 * @see #putExtra(String, boolean)
7003 */
7004 public boolean getBooleanExtra(String name, boolean defaultValue) {
7005 return mExtras == null ? defaultValue :
7006 mExtras.getBoolean(name, defaultValue);
7007 }
7008
7009 /**
7010 * Retrieve extended data from the intent.
7011 *
7012 * @param name The name of the desired item.
7013 * @param defaultValue the value to be returned if no value of the desired
7014 * type is stored with the given name.
7015 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007016 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007017 * or the default value if none was found.
7018 *
7019 * @see #putExtra(String, byte)
7020 */
7021 public byte getByteExtra(String name, byte defaultValue) {
7022 return mExtras == null ? defaultValue :
7023 mExtras.getByte(name, defaultValue);
7024 }
7025
7026 /**
7027 * Retrieve extended data from the intent.
7028 *
7029 * @param name The name of the desired item.
7030 * @param defaultValue the value to be returned if no value of the desired
7031 * type is stored with the given name.
7032 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007033 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007034 * or the default value if none was found.
7035 *
7036 * @see #putExtra(String, short)
7037 */
7038 public short getShortExtra(String name, short defaultValue) {
7039 return mExtras == null ? defaultValue :
7040 mExtras.getShort(name, defaultValue);
7041 }
7042
7043 /**
7044 * Retrieve extended data from the intent.
7045 *
7046 * @param name The name of the desired item.
7047 * @param defaultValue the value to be returned if no value of the desired
7048 * type is stored with the given name.
7049 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007050 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007051 * or the default value if none was found.
7052 *
7053 * @see #putExtra(String, char)
7054 */
7055 public char getCharExtra(String name, char defaultValue) {
7056 return mExtras == null ? defaultValue :
7057 mExtras.getChar(name, defaultValue);
7058 }
7059
7060 /**
7061 * Retrieve extended data from the intent.
7062 *
7063 * @param name The name of the desired item.
7064 * @param defaultValue the value to be returned if no value of the desired
7065 * type is stored with the given name.
7066 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007067 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007068 * or the default value if none was found.
7069 *
7070 * @see #putExtra(String, int)
7071 */
7072 public int getIntExtra(String name, int defaultValue) {
7073 return mExtras == null ? defaultValue :
7074 mExtras.getInt(name, defaultValue);
7075 }
7076
7077 /**
7078 * Retrieve extended data from the intent.
7079 *
7080 * @param name The name of the desired item.
7081 * @param defaultValue the value to be returned if no value of the desired
7082 * type is stored with the given name.
7083 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007084 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007085 * or the default value if none was found.
7086 *
7087 * @see #putExtra(String, long)
7088 */
7089 public long getLongExtra(String name, long defaultValue) {
7090 return mExtras == null ? defaultValue :
7091 mExtras.getLong(name, defaultValue);
7092 }
7093
7094 /**
7095 * Retrieve extended data from the intent.
7096 *
7097 * @param name The name of the desired item.
7098 * @param defaultValue the value to be returned if no value of the desired
7099 * type is stored with the given name.
7100 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007101 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007102 * or the default value if no such item is present
7103 *
7104 * @see #putExtra(String, float)
7105 */
7106 public float getFloatExtra(String name, float defaultValue) {
7107 return mExtras == null ? defaultValue :
7108 mExtras.getFloat(name, defaultValue);
7109 }
7110
7111 /**
7112 * Retrieve extended data from the intent.
7113 *
7114 * @param name The name of the desired item.
7115 * @param defaultValue the value to be returned if no value of the desired
7116 * type is stored with the given name.
7117 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007118 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007119 * or the default value if none was found.
7120 *
7121 * @see #putExtra(String, double)
7122 */
7123 public double getDoubleExtra(String name, double defaultValue) {
7124 return mExtras == null ? defaultValue :
7125 mExtras.getDouble(name, defaultValue);
7126 }
7127
7128 /**
7129 * Retrieve extended data from the intent.
7130 *
7131 * @param name The name of the desired item.
7132 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007133 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007134 * or null if no String value was found.
7135 *
7136 * @see #putExtra(String, String)
7137 */
7138 public String getStringExtra(String name) {
7139 return mExtras == null ? null : mExtras.getString(name);
7140 }
7141
7142 /**
7143 * Retrieve extended data from the intent.
7144 *
7145 * @param name The name of the desired item.
7146 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007147 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007148 * or null if no CharSequence value was found.
7149 *
7150 * @see #putExtra(String, CharSequence)
7151 */
7152 public CharSequence getCharSequenceExtra(String name) {
7153 return mExtras == null ? null : mExtras.getCharSequence(name);
7154 }
7155
7156 /**
7157 * Retrieve extended data from the intent.
7158 *
7159 * @param name The name of the desired item.
7160 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007161 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007162 * or null if no Parcelable value was found.
7163 *
7164 * @see #putExtra(String, Parcelable)
7165 */
7166 public <T extends Parcelable> T getParcelableExtra(String name) {
7167 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7168 }
7169
7170 /**
7171 * Retrieve extended data from the intent.
7172 *
7173 * @param name The name of the desired item.
7174 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007175 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007176 * or null if no Parcelable[] value was found.
7177 *
7178 * @see #putExtra(String, Parcelable[])
7179 */
7180 public Parcelable[] getParcelableArrayExtra(String name) {
7181 return mExtras == null ? null : mExtras.getParcelableArray(name);
7182 }
7183
7184 /**
7185 * Retrieve extended data from the intent.
7186 *
7187 * @param name The name of the desired item.
7188 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007189 * @return the value of an item previously added with
7190 * putParcelableArrayListExtra(), or null if no
7191 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007192 *
7193 * @see #putParcelableArrayListExtra(String, ArrayList)
7194 */
7195 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7196 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7197 }
7198
7199 /**
7200 * Retrieve extended data from the intent.
7201 *
7202 * @param name The name of the desired item.
7203 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007204 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007205 * or null if no Serializable value was found.
7206 *
7207 * @see #putExtra(String, Serializable)
7208 */
7209 public Serializable getSerializableExtra(String name) {
7210 return mExtras == null ? null : mExtras.getSerializable(name);
7211 }
7212
7213 /**
7214 * Retrieve extended data from the intent.
7215 *
7216 * @param name The name of the desired item.
7217 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007218 * @return the value of an item previously added with
7219 * putIntegerArrayListExtra(), or null if no
7220 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007221 *
7222 * @see #putIntegerArrayListExtra(String, ArrayList)
7223 */
7224 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7225 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7226 }
7227
7228 /**
7229 * Retrieve extended data from the intent.
7230 *
7231 * @param name The name of the desired item.
7232 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007233 * @return the value of an item previously added with
7234 * putStringArrayListExtra(), or null if no
7235 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007236 *
7237 * @see #putStringArrayListExtra(String, ArrayList)
7238 */
7239 public ArrayList<String> getStringArrayListExtra(String name) {
7240 return mExtras == null ? null : mExtras.getStringArrayList(name);
7241 }
7242
7243 /**
7244 * Retrieve extended data from the intent.
7245 *
7246 * @param name The name of the desired item.
7247 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007248 * @return the value of an item previously added with
7249 * putCharSequenceArrayListExtra, or null if no
7250 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007251 *
7252 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7253 */
7254 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7255 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7256 }
7257
7258 /**
7259 * Retrieve extended data from the intent.
7260 *
7261 * @param name The name of the desired item.
7262 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007263 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007264 * or null if no boolean array value was found.
7265 *
7266 * @see #putExtra(String, boolean[])
7267 */
7268 public boolean[] getBooleanArrayExtra(String name) {
7269 return mExtras == null ? null : mExtras.getBooleanArray(name);
7270 }
7271
7272 /**
7273 * Retrieve extended data from the intent.
7274 *
7275 * @param name The name of the desired item.
7276 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007277 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007278 * or null if no byte array value was found.
7279 *
7280 * @see #putExtra(String, byte[])
7281 */
7282 public byte[] getByteArrayExtra(String name) {
7283 return mExtras == null ? null : mExtras.getByteArray(name);
7284 }
7285
7286 /**
7287 * Retrieve extended data from the intent.
7288 *
7289 * @param name The name of the desired item.
7290 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007291 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007292 * or null if no short array value was found.
7293 *
7294 * @see #putExtra(String, short[])
7295 */
7296 public short[] getShortArrayExtra(String name) {
7297 return mExtras == null ? null : mExtras.getShortArray(name);
7298 }
7299
7300 /**
7301 * Retrieve extended data from the intent.
7302 *
7303 * @param name The name of the desired item.
7304 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007305 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007306 * or null if no char array value was found.
7307 *
7308 * @see #putExtra(String, char[])
7309 */
7310 public char[] getCharArrayExtra(String name) {
7311 return mExtras == null ? null : mExtras.getCharArray(name);
7312 }
7313
7314 /**
7315 * Retrieve extended data from the intent.
7316 *
7317 * @param name The name of the desired item.
7318 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007319 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007320 * or null if no int array value was found.
7321 *
7322 * @see #putExtra(String, int[])
7323 */
7324 public int[] getIntArrayExtra(String name) {
7325 return mExtras == null ? null : mExtras.getIntArray(name);
7326 }
7327
7328 /**
7329 * Retrieve extended data from the intent.
7330 *
7331 * @param name The name of the desired item.
7332 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007333 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007334 * or null if no long array value was found.
7335 *
7336 * @see #putExtra(String, long[])
7337 */
7338 public long[] getLongArrayExtra(String name) {
7339 return mExtras == null ? null : mExtras.getLongArray(name);
7340 }
7341
7342 /**
7343 * Retrieve extended data from the intent.
7344 *
7345 * @param name The name of the desired item.
7346 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007347 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007348 * or null if no float array value was found.
7349 *
7350 * @see #putExtra(String, float[])
7351 */
7352 public float[] getFloatArrayExtra(String name) {
7353 return mExtras == null ? null : mExtras.getFloatArray(name);
7354 }
7355
7356 /**
7357 * Retrieve extended data from the intent.
7358 *
7359 * @param name The name of the desired item.
7360 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007361 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007362 * or null if no double array value was found.
7363 *
7364 * @see #putExtra(String, double[])
7365 */
7366 public double[] getDoubleArrayExtra(String name) {
7367 return mExtras == null ? null : mExtras.getDoubleArray(name);
7368 }
7369
7370 /**
7371 * Retrieve extended data from the intent.
7372 *
7373 * @param name The name of the desired item.
7374 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007375 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007376 * or null if no String array value was found.
7377 *
7378 * @see #putExtra(String, String[])
7379 */
7380 public String[] getStringArrayExtra(String name) {
7381 return mExtras == null ? null : mExtras.getStringArray(name);
7382 }
7383
7384 /**
7385 * Retrieve extended data from the intent.
7386 *
7387 * @param name The name of the desired item.
7388 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007389 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007390 * or null if no CharSequence array value was found.
7391 *
7392 * @see #putExtra(String, CharSequence[])
7393 */
7394 public CharSequence[] getCharSequenceArrayExtra(String name) {
7395 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7396 }
7397
7398 /**
7399 * Retrieve extended data from the intent.
7400 *
7401 * @param name The name of the desired item.
7402 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007403 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007404 * or null if no Bundle value was found.
7405 *
7406 * @see #putExtra(String, Bundle)
7407 */
7408 public Bundle getBundleExtra(String name) {
7409 return mExtras == null ? null : mExtras.getBundle(name);
7410 }
7411
7412 /**
7413 * Retrieve extended data from the intent.
7414 *
7415 * @param name The name of the desired item.
7416 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007417 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007418 * or null if no IBinder value was found.
7419 *
7420 * @see #putExtra(String, IBinder)
7421 *
7422 * @deprecated
7423 * @hide
7424 */
7425 @Deprecated
7426 public IBinder getIBinderExtra(String name) {
7427 return mExtras == null ? null : mExtras.getIBinder(name);
7428 }
7429
7430 /**
7431 * Retrieve extended data from the intent.
7432 *
7433 * @param name The name of the desired item.
7434 * @param defaultValue The default value to return in case no item is
7435 * associated with the key 'name'
7436 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007437 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007438 * or defaultValue if none was found.
7439 *
7440 * @see #putExtra
7441 *
7442 * @deprecated
7443 * @hide
7444 */
7445 @Deprecated
7446 public Object getExtra(String name, Object defaultValue) {
7447 Object result = defaultValue;
7448 if (mExtras != null) {
7449 Object result2 = mExtras.get(name);
7450 if (result2 != null) {
7451 result = result2;
7452 }
7453 }
7454
7455 return result;
7456 }
7457
7458 /**
7459 * Retrieves a map of extended data from the intent.
7460 *
7461 * @return the map of all extras previously added with putExtra(),
7462 * or null if none have been added.
7463 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007464 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007465 return (mExtras != null)
7466 ? new Bundle(mExtras)
7467 : null;
7468 }
7469
7470 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007471 * Filter extras to only basic types.
7472 * @hide
7473 */
7474 public void removeUnsafeExtras() {
7475 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007476 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007477 }
7478 }
7479
7480 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007481 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7482 * return itself as-is.
7483 * @hide
7484 */
7485 public boolean canStripForHistory() {
7486 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7487 }
7488
7489 /**
7490 * Call it when the system needs to keep an intent for logging purposes to remove fields
7491 * that are not needed for logging.
7492 * @hide
7493 */
7494 public Intent maybeStripForHistory() {
7495 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7496
7497 if (!canStripForHistory()) {
7498 return this;
7499 }
7500 return new Intent(this, COPY_MODE_HISTORY);
7501 }
7502
7503 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007504 * Retrieve any special flags associated with this intent. You will
7505 * normally just set them with {@link #setFlags} and let the system
7506 * take the appropriate action with them.
7507 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007508 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007509 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007510 * @see #addFlags
7511 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007512 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007513 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007514 return mFlags;
7515 }
7516
Dianne Hackborne7f97212011-02-24 14:40:20 -08007517 /** @hide */
7518 public boolean isExcludingStopped() {
7519 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7520 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7521 }
7522
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007523 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007524 * Retrieve the application package name this Intent is limited to. When
7525 * resolving an Intent, if non-null this limits the resolution to only
7526 * components in the given application package.
7527 *
7528 * @return The name of the application package for the Intent.
7529 *
7530 * @see #resolveActivity
7531 * @see #setPackage
7532 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007533 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007534 return mPackage;
7535 }
7536
7537 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007538 * Retrieve the concrete component associated with the intent. When receiving
7539 * an intent, this is the component that was found to best handle it (that is,
7540 * yourself) and will always be non-null; in all other cases it will be
7541 * null unless explicitly set.
7542 *
7543 * @return The name of the application component to handle the intent.
7544 *
7545 * @see #resolveActivity
7546 * @see #setComponent
7547 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007548 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007549 return mComponent;
7550 }
7551
7552 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007553 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7554 * used as a hint to the receiver for animations and the like. Null means that there
7555 * is no source bounds.
7556 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007557 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007558 return mSourceBounds;
7559 }
7560
7561 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007562 * Return the Activity component that should be used to handle this intent.
7563 * The appropriate component is determined based on the information in the
7564 * intent, evaluated as follows:
7565 *
7566 * <p>If {@link #getComponent} returns an explicit class, that is returned
7567 * without any further consideration.
7568 *
7569 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7570 * category to be considered.
7571 *
7572 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7573 * action.
7574 *
7575 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7576 * this type.
7577 *
7578 * <p>If {@link #addCategory} has added any categories, the activity must
7579 * handle ALL of the categories specified.
7580 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007581 * <p>If {@link #getPackage} is non-NULL, only activity components in
7582 * that application package will be considered.
7583 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007584 * <p>If there are no activities that satisfy all of these conditions, a
7585 * null string is returned.
7586 *
7587 * <p>If multiple activities are found to satisfy the intent, the one with
7588 * the highest priority will be used. If there are multiple activities
7589 * with the same priority, the system will either pick the best activity
7590 * based on user preference, or resolve to a system class that will allow
7591 * the user to pick an activity and forward from there.
7592 *
7593 * <p>This method is implemented simply by calling
7594 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7595 * true.</p>
7596 * <p> This API is called for you as part of starting an activity from an
7597 * intent. You do not normally need to call it yourself.</p>
7598 *
7599 * @param pm The package manager with which to resolve the Intent.
7600 *
7601 * @return Name of the component implementing an activity that can
7602 * display the intent.
7603 *
7604 * @see #setComponent
7605 * @see #getComponent
7606 * @see #resolveActivityInfo
7607 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007608 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007609 if (mComponent != null) {
7610 return mComponent;
7611 }
7612
7613 ResolveInfo info = pm.resolveActivity(
7614 this, PackageManager.MATCH_DEFAULT_ONLY);
7615 if (info != null) {
7616 return new ComponentName(
7617 info.activityInfo.applicationInfo.packageName,
7618 info.activityInfo.name);
7619 }
7620
7621 return null;
7622 }
7623
7624 /**
7625 * Resolve the Intent into an {@link ActivityInfo}
7626 * describing the activity that should execute the intent. Resolution
7627 * follows the same rules as described for {@link #resolveActivity}, but
7628 * you get back the completely information about the resolved activity
7629 * instead of just its class name.
7630 *
7631 * @param pm The package manager with which to resolve the Intent.
7632 * @param flags Addition information to retrieve as per
7633 * {@link PackageManager#getActivityInfo(ComponentName, int)
7634 * PackageManager.getActivityInfo()}.
7635 *
7636 * @return PackageManager.ActivityInfo
7637 *
7638 * @see #resolveActivity
7639 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007640 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7641 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007642 ActivityInfo ai = null;
7643 if (mComponent != null) {
7644 try {
7645 ai = pm.getActivityInfo(mComponent, flags);
7646 } catch (PackageManager.NameNotFoundException e) {
7647 // ignore
7648 }
7649 } else {
7650 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007651 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007652 if (info != null) {
7653 ai = info.activityInfo;
7654 }
7655 }
7656
7657 return ai;
7658 }
7659
7660 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007661 * Special function for use by the system to resolve service
7662 * intents to system apps. Throws an exception if there are
7663 * multiple potential matches to the Intent. Returns null if
7664 * there are no matches.
7665 * @hide
7666 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007667 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7668 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007669 if (mComponent != null) {
7670 return mComponent;
7671 }
7672
7673 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7674 if (results == null) {
7675 return null;
7676 }
7677 ComponentName comp = null;
7678 for (int i=0; i<results.size(); i++) {
7679 ResolveInfo ri = results.get(i);
7680 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7681 continue;
7682 }
7683 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7684 ri.serviceInfo.name);
7685 if (comp != null) {
7686 throw new IllegalStateException("Multiple system services handle " + this
7687 + ": " + comp + ", " + foundComp);
7688 }
7689 comp = foundComp;
7690 }
7691 return comp;
7692 }
7693
7694 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 * Set the general action to be performed.
7696 *
7697 * @param action An action name, such as ACTION_VIEW. Application-specific
7698 * actions should be prefixed with the vendor's package name.
7699 *
7700 * @return Returns the same Intent object, for chaining multiple calls
7701 * into a single statement.
7702 *
7703 * @see #getAction
7704 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007705 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007706 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007707 return this;
7708 }
7709
7710 /**
7711 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007712 * clears any type that was previously set by {@link #setType} or
7713 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007714 *
Nick Pellyccae4122012-01-09 14:12:58 -08007715 * <p><em>Note: scheme matching in the Android framework is
7716 * case-sensitive, unlike the formal RFC. As a result,
7717 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007718 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007719 * {@link #setDataAndNormalize}
7720 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007721 *
Nick Pellyccae4122012-01-09 14:12:58 -08007722 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007723 *
7724 * @return Returns the same Intent object, for chaining multiple calls
7725 * into a single statement.
7726 *
7727 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007728 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007729 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007730 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007731 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007732 mData = data;
7733 mType = null;
7734 return this;
7735 }
7736
7737 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007738 * Normalize and set the data this intent is operating on.
7739 *
7740 * <p>This method automatically clears any type that was
7741 * previously set (for example, by {@link #setType}).
7742 *
7743 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007744 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007745 * so really this is just a convenience method for
7746 * <pre>
7747 * setData(data.normalize())
7748 * </pre>
7749 *
7750 * @param data The Uri of the data this intent is now targeting.
7751 *
7752 * @return Returns the same Intent object, for chaining multiple calls
7753 * into a single statement.
7754 *
7755 * @see #getData
7756 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007757 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007758 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007759 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007760 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007761 }
7762
7763 /**
7764 * Set an explicit MIME data type.
7765 *
7766 * <p>This is used to create intents that only specify a type and not data,
7767 * for example to indicate the type of data to return.
7768 *
7769 * <p>This method automatically clears any data that was
7770 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007771 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007772 * <p><em>Note: MIME type matching in the Android framework is
7773 * case-sensitive, unlike formal RFC MIME types. As a result,
7774 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007775 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7776 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007777 *
7778 * @param type The MIME type of the data being handled by this intent.
7779 *
7780 * @return Returns the same Intent object, for chaining multiple calls
7781 * into a single statement.
7782 *
7783 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007784 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007785 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007786 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007787 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007788 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007789 mData = null;
7790 mType = type;
7791 return this;
7792 }
7793
7794 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007795 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007796 *
Nick Pellyccae4122012-01-09 14:12:58 -08007797 * <p>This is used to create intents that only specify a type and not data,
7798 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007799 *
Nick Pellyccae4122012-01-09 14:12:58 -08007800 * <p>This method automatically clears any data that was
7801 * previously set (for example by {@link #setData}).
7802 *
7803 * <p>The MIME type is normalized using
7804 * {@link #normalizeMimeType} before it is set,
7805 * so really this is just a convenience method for
7806 * <pre>
7807 * setType(Intent.normalizeMimeType(type))
7808 * </pre>
7809 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007810 * @param type The MIME type of the data being handled by this intent.
7811 *
7812 * @return Returns the same Intent object, for chaining multiple calls
7813 * into a single statement.
7814 *
Nick Pellyccae4122012-01-09 14:12:58 -08007815 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007816 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007817 * @see #normalizeMimeType
7818 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007819 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007820 return setType(normalizeMimeType(type));
7821 }
7822
7823 /**
7824 * (Usually optional) Set the data for the intent along with an explicit
7825 * MIME data type. This method should very rarely be used -- it allows you
7826 * to override the MIME type that would ordinarily be inferred from the
7827 * data with your own type given here.
7828 *
7829 * <p><em>Note: MIME type and Uri scheme matching in the
7830 * Android framework is case-sensitive, unlike the formal RFC definitions.
7831 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007832 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007833 * {@link #setDataAndTypeAndNormalize}
7834 * to ensure that they are converted to lower case.</em>
7835 *
7836 * @param data The Uri of the data this intent is now targeting.
7837 * @param type The MIME type of the data being handled by this intent.
7838 *
7839 * @return Returns the same Intent object, for chaining multiple calls
7840 * into a single statement.
7841 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007842 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007843 * @see #setData
7844 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007845 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007846 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007848 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007849 mData = data;
7850 mType = type;
7851 return this;
7852 }
7853
7854 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007855 * (Usually optional) Normalize and set both the data Uri and an explicit
7856 * MIME data type. This method should very rarely be used -- it allows you
7857 * to override the MIME type that would ordinarily be inferred from the
7858 * data with your own type given here.
7859 *
7860 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007861 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007862 * before they are set, so really this is just a convenience method for
7863 * <pre>
7864 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7865 * </pre>
7866 *
7867 * @param data The Uri of the data this intent is now targeting.
7868 * @param type The MIME type of the data being handled by this intent.
7869 *
7870 * @return Returns the same Intent object, for chaining multiple calls
7871 * into a single statement.
7872 *
7873 * @see #setType
7874 * @see #setData
7875 * @see #setDataAndType
7876 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007877 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007878 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007879 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007880 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007881 }
7882
7883 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007884 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007885 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007886 * activities that provide <em>all</em> of the requested categories will be
7887 * used.
7888 *
7889 * @param category The desired category. This can be either one of the
7890 * predefined Intent categories, or a custom category in your own
7891 * namespace.
7892 *
7893 * @return Returns the same Intent object, for chaining multiple calls
7894 * into a single statement.
7895 *
7896 * @see #hasCategory
7897 * @see #removeCategory
7898 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007899 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007900 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007901 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007902 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007903 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007904 return this;
7905 }
7906
7907 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007908 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007909 *
7910 * @param category The category to remove.
7911 *
7912 * @see #addCategory
7913 */
7914 public void removeCategory(String category) {
7915 if (mCategories != null) {
7916 mCategories.remove(category);
7917 if (mCategories.size() == 0) {
7918 mCategories = null;
7919 }
7920 }
7921 }
7922
7923 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007924 * Set a selector for this Intent. This is a modification to the kinds of
7925 * things the Intent will match. If the selector is set, it will be used
7926 * when trying to find entities that can handle the Intent, instead of the
7927 * main contents of the Intent. This allows you build an Intent containing
7928 * a generic protocol while targeting it more specifically.
7929 *
7930 * <p>An example of where this may be used is with things like
7931 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7932 * Intent that will launch the Browser application. However, the correct
7933 * main entry point of an application is actually {@link #ACTION_MAIN}
7934 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7935 * used to specify the actual Activity to launch. If you launch the browser
7936 * with something different, undesired behavior may happen if the user has
7937 * previously or later launches it the normal way, since they do not match.
7938 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7939 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7940 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7941 *
7942 * <p>Setting a selector does not impact the behavior of
7943 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7944 * desired behavior of a selector -- it does not impact the base meaning
7945 * of the Intent, just what kinds of things will be matched against it
7946 * when determining who can handle it.</p>
7947 *
7948 * <p>You can not use both a selector and {@link #setPackage(String)} on
7949 * the same base Intent.</p>
7950 *
7951 * @param selector The desired selector Intent; set to null to not use
7952 * a special selector.
7953 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007954 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007955 if (selector == this) {
7956 throw new IllegalArgumentException(
7957 "Intent being set as a selector of itself");
7958 }
7959 if (selector != null && mPackage != null) {
7960 throw new IllegalArgumentException(
7961 "Can't set selector when package name is already set");
7962 }
7963 mSelector = selector;
7964 }
7965
7966 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007967 * Set a {@link ClipData} associated with this Intent. This replaces any
7968 * previously set ClipData.
7969 *
7970 * <p>The ClipData in an intent is not used for Intent matching or other
7971 * such operations. Semantically it is like extras, used to transmit
7972 * additional data with the Intent. The main feature of using this over
7973 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7974 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7975 * items included in the clip data. This is useful, in particular, if
7976 * you want to transmit an Intent containing multiple <code>content:</code>
7977 * URIs for which the recipient may not have global permission to access the
7978 * content provider.
7979 *
7980 * <p>If the ClipData contains items that are themselves Intents, any
7981 * grant flags in those Intents will be ignored. Only the top-level flags
7982 * of the main Intent are respected, and will be applied to all Uri or
7983 * Intent items in the clip (or sub-items of the clip).
7984 *
7985 * <p>The MIME type, label, and icon in the ClipData object are not
7986 * directly used by Intent. Applications should generally rely on the
7987 * MIME type of the Intent itself, not what it may find in the ClipData.
7988 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007989 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007990 *
7991 * @param clip The new clip to set. May be null to clear the current clip.
7992 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007993 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007994 mClipData = clip;
7995 }
7996
7997 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007998 * This is NOT a secure mechanism to identify the user who sent the intent.
7999 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8000 * who sent the intent.
8001 * @hide
8002 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008003 public void prepareToLeaveUser(int userId) {
8004 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8005 // We want mContentUserHint to refer to the original user, so don't do anything.
8006 if (mContentUserHint == UserHandle.USER_CURRENT) {
8007 mContentUserHint = userId;
8008 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008009 }
8010
8011 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008012 * Add extended data to the intent. The name must include a package
8013 * prefix, for example the app com.android.contacts would use names
8014 * like "com.android.contacts.ShowAll".
8015 *
8016 * @param name The name of the extra data, with package prefix.
8017 * @param value The boolean data value.
8018 *
8019 * @return Returns the same Intent object, for chaining multiple calls
8020 * into a single statement.
8021 *
8022 * @see #putExtras
8023 * @see #removeExtra
8024 * @see #getBooleanExtra(String, boolean)
8025 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008026 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008027 if (mExtras == null) {
8028 mExtras = new Bundle();
8029 }
8030 mExtras.putBoolean(name, value);
8031 return this;
8032 }
8033
8034 /**
8035 * Add extended data to the intent. The name must include a package
8036 * prefix, for example the app com.android.contacts would use names
8037 * like "com.android.contacts.ShowAll".
8038 *
8039 * @param name The name of the extra data, with package prefix.
8040 * @param value The byte data value.
8041 *
8042 * @return Returns the same Intent object, for chaining multiple calls
8043 * into a single statement.
8044 *
8045 * @see #putExtras
8046 * @see #removeExtra
8047 * @see #getByteExtra(String, byte)
8048 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008049 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008050 if (mExtras == null) {
8051 mExtras = new Bundle();
8052 }
8053 mExtras.putByte(name, value);
8054 return this;
8055 }
8056
8057 /**
8058 * 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 char 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 #getCharExtra(String, char)
8071 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008072 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008073 if (mExtras == null) {
8074 mExtras = new Bundle();
8075 }
8076 mExtras.putChar(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 short 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 #getShortExtra(String, short)
8094 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008095 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008096 if (mExtras == null) {
8097 mExtras = new Bundle();
8098 }
8099 mExtras.putShort(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 integer 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 #getIntExtra(String, int)
8117 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008118 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008119 if (mExtras == null) {
8120 mExtras = new Bundle();
8121 }
8122 mExtras.putInt(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 long 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 #getLongExtra(String, long)
8140 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008141 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008142 if (mExtras == null) {
8143 mExtras = new Bundle();
8144 }
8145 mExtras.putLong(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 float 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 #getFloatExtra(String, float)
8163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008164 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008165 if (mExtras == null) {
8166 mExtras = new Bundle();
8167 }
8168 mExtras.putFloat(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 double 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 #getDoubleExtra(String, double)
8186 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008187 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 if (mExtras == null) {
8189 mExtras = new Bundle();
8190 }
8191 mExtras.putDouble(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 String 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 #getStringExtra(String)
8209 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008210 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008211 if (mExtras == null) {
8212 mExtras = new Bundle();
8213 }
8214 mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
8232 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008233 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008234 if (mExtras == null) {
8235 mExtras = new Bundle();
8236 }
8237 mExtras.putCharSequence(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 Parcelable 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 #getParcelableExtra(String)
8255 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008256 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008257 if (mExtras == null) {
8258 mExtras = new Bundle();
8259 }
8260 mExtras.putParcelable(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 Parcelable[] 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 #getParcelableArrayExtra(String)
8278 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008279 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 if (mExtras == null) {
8281 mExtras = new Bundle();
8282 }
8283 mExtras.putParcelableArray(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 ArrayList<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 #getParcelableArrayListExtra(String)
8301 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008302 public @NonNull Intent putParcelableArrayListExtra(String name,
8303 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008304 if (mExtras == null) {
8305 mExtras = new Bundle();
8306 }
8307 mExtras.putParcelableArrayList(name, value);
8308 return this;
8309 }
8310
8311 /**
8312 * Add extended data to the intent. The name must include a package
8313 * prefix, for example the app com.android.contacts would use names
8314 * like "com.android.contacts.ShowAll".
8315 *
8316 * @param name The name of the extra data, with package prefix.
8317 * @param value The ArrayList<Integer> data value.
8318 *
8319 * @return Returns the same Intent object, for chaining multiple calls
8320 * into a single statement.
8321 *
8322 * @see #putExtras
8323 * @see #removeExtra
8324 * @see #getIntegerArrayListExtra(String)
8325 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008326 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008327 if (mExtras == null) {
8328 mExtras = new Bundle();
8329 }
8330 mExtras.putIntegerArrayList(name, value);
8331 return this;
8332 }
8333
8334 /**
8335 * Add extended data to the intent. The name must include a package
8336 * prefix, for example the app com.android.contacts would use names
8337 * like "com.android.contacts.ShowAll".
8338 *
8339 * @param name The name of the extra data, with package prefix.
8340 * @param value The ArrayList<String> data value.
8341 *
8342 * @return Returns the same Intent object, for chaining multiple calls
8343 * into a single statement.
8344 *
8345 * @see #putExtras
8346 * @see #removeExtra
8347 * @see #getStringArrayListExtra(String)
8348 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008349 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008350 if (mExtras == null) {
8351 mExtras = new Bundle();
8352 }
8353 mExtras.putStringArrayList(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.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008363 * @param value The ArrayList<CharSequence> 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 #getCharSequenceArrayListExtra(String)
8371 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008372 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8373 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008374 if (mExtras == null) {
8375 mExtras = new Bundle();
8376 }
8377 mExtras.putCharSequenceArrayList(name, value);
8378 return this;
8379 }
8380
8381 /**
8382 * Add extended data to the intent. The name must include a package
8383 * prefix, for example the app com.android.contacts would use names
8384 * like "com.android.contacts.ShowAll".
8385 *
8386 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008387 * @param value The Serializable data value.
8388 *
8389 * @return Returns the same Intent object, for chaining multiple calls
8390 * into a single statement.
8391 *
8392 * @see #putExtras
8393 * @see #removeExtra
8394 * @see #getSerializableExtra(String)
8395 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008396 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008397 if (mExtras == null) {
8398 mExtras = new Bundle();
8399 }
8400 mExtras.putSerializable(name, value);
8401 return this;
8402 }
8403
8404 /**
8405 * Add extended data to the intent. The name must include a package
8406 * prefix, for example the app com.android.contacts would use names
8407 * like "com.android.contacts.ShowAll".
8408 *
8409 * @param name The name of the extra data, with package prefix.
8410 * @param value The boolean array data value.
8411 *
8412 * @return Returns the same Intent object, for chaining multiple calls
8413 * into a single statement.
8414 *
8415 * @see #putExtras
8416 * @see #removeExtra
8417 * @see #getBooleanArrayExtra(String)
8418 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008419 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008420 if (mExtras == null) {
8421 mExtras = new Bundle();
8422 }
8423 mExtras.putBooleanArray(name, value);
8424 return this;
8425 }
8426
8427 /**
8428 * Add extended data to the intent. The name must include a package
8429 * prefix, for example the app com.android.contacts would use names
8430 * like "com.android.contacts.ShowAll".
8431 *
8432 * @param name The name of the extra data, with package prefix.
8433 * @param value The byte array 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 #getByteArrayExtra(String)
8441 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008442 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008443 if (mExtras == null) {
8444 mExtras = new Bundle();
8445 }
8446 mExtras.putByteArray(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 short 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 #getShortArrayExtra(String)
8464 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008465 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 if (mExtras == null) {
8467 mExtras = new Bundle();
8468 }
8469 mExtras.putShortArray(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 char 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 #getCharArrayExtra(String)
8487 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008488 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008489 if (mExtras == null) {
8490 mExtras = new Bundle();
8491 }
8492 mExtras.putCharArray(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 int 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 #getIntArrayExtra(String)
8510 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008511 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008512 if (mExtras == null) {
8513 mExtras = new Bundle();
8514 }
8515 mExtras.putIntArray(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 byte 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 #getLongArrayExtra(String)
8533 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008534 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008535 if (mExtras == null) {
8536 mExtras = new Bundle();
8537 }
8538 mExtras.putLongArray(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 float 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 #getFloatArrayExtra(String)
8556 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008557 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 if (mExtras == null) {
8559 mExtras = new Bundle();
8560 }
8561 mExtras.putFloatArray(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 double 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 #getDoubleArrayExtra(String)
8579 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008580 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 if (mExtras == null) {
8582 mExtras = new Bundle();
8583 }
8584 mExtras.putDoubleArray(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 String 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 #getStringArrayExtra(String)
8602 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008603 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 if (mExtras == null) {
8605 mExtras = new Bundle();
8606 }
8607 mExtras.putStringArray(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.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008617 * @param value The CharSequence 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 #getCharSequenceArrayExtra(String)
8625 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008626 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008627 if (mExtras == null) {
8628 mExtras = new Bundle();
8629 }
8630 mExtras.putCharSequenceArray(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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008640 * @param value The Bundle 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 #getBundleExtra(String)
8648 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008649 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650 if (mExtras == null) {
8651 mExtras = new Bundle();
8652 }
8653 mExtras.putBundle(name, value);
8654 return this;
8655 }
8656
8657 /**
8658 * Add extended data to the intent. The name must include a package
8659 * prefix, for example the app com.android.contacts would use names
8660 * like "com.android.contacts.ShowAll".
8661 *
8662 * @param name The name of the extra data, with package prefix.
8663 * @param value The IBinder 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 #getIBinderExtra(String)
8671 *
8672 * @deprecated
8673 * @hide
8674 */
8675 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008676 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008677 if (mExtras == null) {
8678 mExtras = new Bundle();
8679 }
8680 mExtras.putIBinder(name, value);
8681 return this;
8682 }
8683
8684 /**
8685 * Copy all extras in 'src' in to this intent.
8686 *
8687 * @param src Contains the extras to copy.
8688 *
8689 * @see #putExtra
8690 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008691 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008692 if (src.mExtras != null) {
8693 if (mExtras == null) {
8694 mExtras = new Bundle(src.mExtras);
8695 } else {
8696 mExtras.putAll(src.mExtras);
8697 }
8698 }
8699 return this;
8700 }
8701
8702 /**
8703 * Add a set of extended data to the intent. The keys must include a package
8704 * prefix, for example the app com.android.contacts would use names
8705 * like "com.android.contacts.ShowAll".
8706 *
8707 * @param extras The Bundle of extras to add to this intent.
8708 *
8709 * @see #putExtra
8710 * @see #removeExtra
8711 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008712 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008713 if (mExtras == null) {
8714 mExtras = new Bundle();
8715 }
8716 mExtras.putAll(extras);
8717 return this;
8718 }
8719
8720 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008721 * Completely replace the extras in the Intent with the extras in the
8722 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008723 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008724 * @param src The exact extras contained in this Intent are copied
8725 * into the target intent, replacing any that were previously there.
8726 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008727 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008728 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8729 return this;
8730 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008731
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008732 /**
8733 * Completely replace the extras in the Intent with the given Bundle of
8734 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008735 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008736 * @param extras The new set of extras in the Intent, or null to erase
8737 * all extras.
8738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008739 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008740 mExtras = extras != null ? new Bundle(extras) : null;
8741 return this;
8742 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008743
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008744 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008745 * Remove extended data from the intent.
8746 *
8747 * @see #putExtra
8748 */
8749 public void removeExtra(String name) {
8750 if (mExtras != null) {
8751 mExtras.remove(name);
8752 if (mExtras.size() == 0) {
8753 mExtras = null;
8754 }
8755 }
8756 }
8757
8758 /**
8759 * Set special flags controlling how this intent is handled. Most values
8760 * here depend on the type of component being executed by the Intent,
8761 * specifically the FLAG_ACTIVITY_* flags are all for use with
8762 * {@link Context#startActivity Context.startActivity()} and the
8763 * FLAG_RECEIVER_* flags are all for use with
8764 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8765 *
Scott Main7aee61f2011-02-08 11:25:01 -08008766 * <p>See the
8767 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8768 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008769 * the behavior of your application.
8770 *
8771 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008772 * @return Returns the same Intent object, for chaining multiple calls
8773 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008774 * @see #getFlags
8775 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008776 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008777 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008778 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008779 mFlags = flags;
8780 return this;
8781 }
8782
8783 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008784 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008785 *
8786 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008787 * @return Returns the same Intent object, for chaining multiple calls into
8788 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008789 * @see #setFlags
8790 * @see #getFlags
8791 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008792 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008793 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008794 mFlags |= flags;
8795 return this;
8796 }
8797
8798 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008799 * Remove these flags from the intent.
8800 *
8801 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008802 * @see #setFlags
8803 * @see #getFlags
8804 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008805 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008806 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008807 mFlags &= ~flags;
8808 }
8809
8810 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008811 * (Usually optional) Set an explicit application package name that limits
8812 * the components this Intent will resolve to. If left to the default
8813 * value of null, all components in all applications will considered.
8814 * If non-null, the Intent can only match the components in the given
8815 * application package.
8816 *
8817 * @param packageName The name of the application package to handle the
8818 * intent, or null to allow any application package.
8819 *
8820 * @return Returns the same Intent object, for chaining multiple calls
8821 * into a single statement.
8822 *
8823 * @see #getPackage
8824 * @see #resolveActivity
8825 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008826 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008827 if (packageName != null && mSelector != null) {
8828 throw new IllegalArgumentException(
8829 "Can't set package name when selector is already set");
8830 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008831 mPackage = packageName;
8832 return this;
8833 }
8834
8835 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008836 * (Usually optional) Explicitly set the component to handle the intent.
8837 * If left with the default value of null, the system will determine the
8838 * appropriate class to use based on the other fields (action, data,
8839 * type, categories) in the Intent. If this class is defined, the
8840 * specified class will always be used regardless of the other fields. You
8841 * should only set this value when you know you absolutely want a specific
8842 * class to be used; otherwise it is better to let the system find the
8843 * appropriate class so that you will respect the installed applications
8844 * and user preferences.
8845 *
8846 * @param component The name of the application component to handle the
8847 * intent, or null to let the system find one for you.
8848 *
8849 * @return Returns the same Intent object, for chaining multiple calls
8850 * into a single statement.
8851 *
8852 * @see #setClass
8853 * @see #setClassName(Context, String)
8854 * @see #setClassName(String, String)
8855 * @see #getComponent
8856 * @see #resolveActivity
8857 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008858 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008859 mComponent = component;
8860 return this;
8861 }
8862
8863 /**
8864 * Convenience for calling {@link #setComponent} with an
8865 * explicit class name.
8866 *
8867 * @param packageContext A Context of the application package implementing
8868 * this class.
8869 * @param className The name of a class inside of the application package
8870 * that will be used as the component for this Intent.
8871 *
8872 * @return Returns the same Intent object, for chaining multiple calls
8873 * into a single statement.
8874 *
8875 * @see #setComponent
8876 * @see #setClass
8877 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008878 public @NonNull Intent setClassName(@NonNull Context packageContext,
8879 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008880 mComponent = new ComponentName(packageContext, className);
8881 return this;
8882 }
8883
8884 /**
8885 * Convenience for calling {@link #setComponent} with an
8886 * explicit application package name and class name.
8887 *
8888 * @param packageName The name of the package implementing the desired
8889 * component.
8890 * @param className The name of a class inside of the application package
8891 * that will be used as the component for this Intent.
8892 *
8893 * @return Returns the same Intent object, for chaining multiple calls
8894 * into a single statement.
8895 *
8896 * @see #setComponent
8897 * @see #setClass
8898 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008899 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008900 mComponent = new ComponentName(packageName, className);
8901 return this;
8902 }
8903
8904 /**
8905 * Convenience for calling {@link #setComponent(ComponentName)} with the
8906 * name returned by a {@link Class} object.
8907 *
8908 * @param packageContext A Context of the application package implementing
8909 * this class.
8910 * @param cls The class name to set, equivalent to
8911 * <code>setClassName(context, cls.getName())</code>.
8912 *
8913 * @return Returns the same Intent object, for chaining multiple calls
8914 * into a single statement.
8915 *
8916 * @see #setComponent
8917 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008918 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008919 mComponent = new ComponentName(packageContext, cls);
8920 return this;
8921 }
8922
8923 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008924 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8925 * used as a hint to the receiver for animations and the like. Null means that there
8926 * is no source bounds.
8927 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008928 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008929 if (r != null) {
8930 mSourceBounds = new Rect(r);
8931 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008932 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008933 }
8934 }
8935
Tor Norbyed9273d62013-05-30 15:59:53 -07008936 /** @hide */
8937 @IntDef(flag = true,
8938 value = {
8939 FILL_IN_ACTION,
8940 FILL_IN_DATA,
8941 FILL_IN_CATEGORIES,
8942 FILL_IN_COMPONENT,
8943 FILL_IN_PACKAGE,
8944 FILL_IN_SOURCE_BOUNDS,
8945 FILL_IN_SELECTOR,
8946 FILL_IN_CLIP_DATA
8947 })
8948 @Retention(RetentionPolicy.SOURCE)
8949 public @interface FillInFlags {}
8950
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008951 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008952 * Use with {@link #fillIn} to allow the current action value to be
8953 * overwritten, even if it is already set.
8954 */
8955 public static final int FILL_IN_ACTION = 1<<0;
8956
8957 /**
8958 * Use with {@link #fillIn} to allow the current data or type value
8959 * overwritten, even if it is already set.
8960 */
8961 public static final int FILL_IN_DATA = 1<<1;
8962
8963 /**
8964 * Use with {@link #fillIn} to allow the current categories to be
8965 * overwritten, even if they are already set.
8966 */
8967 public static final int FILL_IN_CATEGORIES = 1<<2;
8968
8969 /**
8970 * Use with {@link #fillIn} to allow the current component value to be
8971 * overwritten, even if it is already set.
8972 */
8973 public static final int FILL_IN_COMPONENT = 1<<3;
8974
8975 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008976 * Use with {@link #fillIn} to allow the current package value to be
8977 * overwritten, even if it is already set.
8978 */
8979 public static final int FILL_IN_PACKAGE = 1<<4;
8980
8981 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008982 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008983 * overwritten, even if it is already set.
8984 */
8985 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8986
8987 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008988 * Use with {@link #fillIn} to allow the current selector to be
8989 * overwritten, even if it is already set.
8990 */
8991 public static final int FILL_IN_SELECTOR = 1<<6;
8992
8993 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008994 * Use with {@link #fillIn} to allow the current ClipData to be
8995 * overwritten, even if it is already set.
8996 */
8997 public static final int FILL_IN_CLIP_DATA = 1<<7;
8998
8999 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009000 * Copy the contents of <var>other</var> in to this object, but only
9001 * where fields are not defined by this object. For purposes of a field
9002 * being defined, the following pieces of data in the Intent are
9003 * considered to be separate fields:
9004 *
9005 * <ul>
9006 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009007 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009008 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9009 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009010 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009011 * <li> component, as set by {@link #setComponent(ComponentName)} or
9012 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009013 * <li> source bounds, as set by {@link #setSourceBounds}.
9014 * <li> selector, as set by {@link #setSelector(Intent)}.
9015 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009016 * <li> each top-level name in the associated extras.
9017 * </ul>
9018 *
9019 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009020 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009021 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9022 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9023 * the restriction where the corresponding field will not be replaced if
9024 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009025 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009026 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9027 * is explicitly specified. The selector will only be copied if
9028 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009029 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009030 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9031 * and Intent B with {action="gotit", data-type="some/thing",
9032 * categories="one","two"}.
9033 *
9034 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9035 * containing: {action="gotit", data-type="some/thing",
9036 * categories="bar"}.
9037 *
9038 * @param other Another Intent whose values are to be used to fill in
9039 * the current one.
9040 * @param flags Options to control which fields can be filled in.
9041 *
9042 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009043 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009044 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009045 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009046 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009047 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009048 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009049 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009050 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009051 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009052 if (other.mAction != null
9053 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009054 mAction = other.mAction;
9055 changes |= FILL_IN_ACTION;
9056 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009057 if ((other.mData != null || other.mType != null)
9058 && ((mData == null && mType == null)
9059 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009060 mData = other.mData;
9061 mType = other.mType;
9062 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009063 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009064 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009065 if (other.mCategories != null
9066 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009068 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009069 }
9070 changes |= FILL_IN_CATEGORIES;
9071 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009072 if (other.mPackage != null
9073 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009074 // Only do this if mSelector is not set.
9075 if (mSelector == null) {
9076 mPackage = other.mPackage;
9077 changes |= FILL_IN_PACKAGE;
9078 }
9079 }
9080 // Selector is special: it can only be set if explicitly allowed,
9081 // for the same reason as the component name.
9082 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9083 if (mPackage == null) {
9084 mSelector = new Intent(other.mSelector);
9085 mPackage = null;
9086 changes |= FILL_IN_SELECTOR;
9087 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009088 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009089 if (other.mClipData != null
9090 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9091 mClipData = other.mClipData;
9092 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009093 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009094 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009095 // Component is special: it can -only- be set if explicitly allowed,
9096 // since otherwise the sender could force the intent somewhere the
9097 // originator didn't intend.
9098 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009099 mComponent = other.mComponent;
9100 changes |= FILL_IN_COMPONENT;
9101 }
9102 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009103 if (other.mSourceBounds != null
9104 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9105 mSourceBounds = new Rect(other.mSourceBounds);
9106 changes |= FILL_IN_SOURCE_BOUNDS;
9107 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009108 if (mExtras == null) {
9109 if (other.mExtras != null) {
9110 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009111 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009112 }
9113 } else if (other.mExtras != null) {
9114 try {
9115 Bundle newb = new Bundle(other.mExtras);
9116 newb.putAll(mExtras);
9117 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009118 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 } catch (RuntimeException e) {
9120 // Modifying the extras can cause us to unparcel the contents
9121 // of the bundle, and if we do this in the system process that
9122 // may fail. We really should handle this (i.e., the Bundle
9123 // impl shouldn't be on top of a plain map), but for now just
9124 // ignore it and keep the original contents. :(
9125 Log.w("Intent", "Failure filling in extras", e);
9126 }
9127 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009128 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9129 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9130 mContentUserHint = other.mContentUserHint;
9131 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132 return changes;
9133 }
9134
9135 /**
9136 * Wrapper class holding an Intent and implementing comparisons on it for
9137 * the purpose of filtering. The class implements its
9138 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9139 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9140 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9141 * on the wrapped Intent.
9142 */
9143 public static final class FilterComparison {
9144 private final Intent mIntent;
9145 private final int mHashCode;
9146
9147 public FilterComparison(Intent intent) {
9148 mIntent = intent;
9149 mHashCode = intent.filterHashCode();
9150 }
9151
9152 /**
9153 * Return the Intent that this FilterComparison represents.
9154 * @return Returns the Intent held by the FilterComparison. Do
9155 * not modify!
9156 */
9157 public Intent getIntent() {
9158 return mIntent;
9159 }
9160
9161 @Override
9162 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009163 if (obj instanceof FilterComparison) {
9164 Intent other = ((FilterComparison)obj).mIntent;
9165 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009166 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009167 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009168 }
9169
9170 @Override
9171 public int hashCode() {
9172 return mHashCode;
9173 }
9174 }
9175
9176 /**
9177 * Determine if two intents are the same for the purposes of intent
9178 * resolution (filtering). That is, if their action, data, type,
9179 * class, and categories are the same. This does <em>not</em> compare
9180 * any extra data included in the intents.
9181 *
9182 * @param other The other Intent to compare against.
9183 *
9184 * @return Returns true if action, data, type, class, and categories
9185 * are the same.
9186 */
9187 public boolean filterEquals(Intent other) {
9188 if (other == null) {
9189 return false;
9190 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009191 if (!Objects.equals(this.mAction, other.mAction)) return false;
9192 if (!Objects.equals(this.mData, other.mData)) return false;
9193 if (!Objects.equals(this.mType, other.mType)) return false;
9194 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9195 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9196 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009197
9198 return true;
9199 }
9200
9201 /**
9202 * Generate hash code that matches semantics of filterEquals().
9203 *
9204 * @return Returns the hash value of the action, data, type, class, and
9205 * categories.
9206 *
9207 * @see #filterEquals
9208 */
9209 public int filterHashCode() {
9210 int code = 0;
9211 if (mAction != null) {
9212 code += mAction.hashCode();
9213 }
9214 if (mData != null) {
9215 code += mData.hashCode();
9216 }
9217 if (mType != null) {
9218 code += mType.hashCode();
9219 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009220 if (mPackage != null) {
9221 code += mPackage.hashCode();
9222 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009223 if (mComponent != null) {
9224 code += mComponent.hashCode();
9225 }
9226 if (mCategories != null) {
9227 code += mCategories.hashCode();
9228 }
9229 return code;
9230 }
9231
9232 @Override
9233 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009234 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009235
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009236 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009237 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009238 b.append(" }");
9239
9240 return b.toString();
9241 }
9242
9243 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009244 public String toInsecureString() {
9245 StringBuilder b = new StringBuilder(128);
9246
9247 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009248 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009249 b.append(" }");
9250
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009251 return b.toString();
9252 }
Romain Guy4969af72009-06-17 10:53:19 -07009253
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009254 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009255 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009256 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009257
9258 b.append("Intent { ");
9259 toShortString(b, false, true, true, true);
9260 b.append(" }");
9261
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009262 return b.toString();
9263 }
9264
9265 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009266 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9267 StringBuilder b = new StringBuilder(128);
9268 toShortString(b, secure, comp, extras, clip);
9269 return b.toString();
9270 }
9271
9272 /** @hide */
9273 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9274 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009275 boolean first = true;
9276 if (mAction != null) {
9277 b.append("act=").append(mAction);
9278 first = false;
9279 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009280 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009281 if (!first) {
9282 b.append(' ');
9283 }
9284 first = false;
9285 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009286 for (int i=0; i<mCategories.size(); i++) {
9287 if (i > 0) b.append(',');
9288 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009289 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009290 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009291 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009292 if (mData != null) {
9293 if (!first) {
9294 b.append(' ');
9295 }
9296 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009297 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009298 if (secure) {
9299 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009300 } else {
9301 b.append(mData);
9302 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009303 }
9304 if (mType != null) {
9305 if (!first) {
9306 b.append(' ');
9307 }
9308 first = false;
9309 b.append("typ=").append(mType);
9310 }
9311 if (mFlags != 0) {
9312 if (!first) {
9313 b.append(' ');
9314 }
9315 first = false;
9316 b.append("flg=0x").append(Integer.toHexString(mFlags));
9317 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009318 if (mPackage != null) {
9319 if (!first) {
9320 b.append(' ');
9321 }
9322 first = false;
9323 b.append("pkg=").append(mPackage);
9324 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009325 if (comp && mComponent != null) {
9326 if (!first) {
9327 b.append(' ');
9328 }
9329 first = false;
9330 b.append("cmp=").append(mComponent.flattenToShortString());
9331 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009332 if (mSourceBounds != null) {
9333 if (!first) {
9334 b.append(' ');
9335 }
9336 first = false;
9337 b.append("bnds=").append(mSourceBounds.toShortString());
9338 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009339 if (mClipData != null) {
9340 if (!first) {
9341 b.append(' ');
9342 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009343 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009344 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009345 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009346 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009347 if (mClipData.getDescription() != null) {
9348 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9349 } else {
9350 first = true;
9351 }
9352 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009353 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009354 first = false;
9355 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009356 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009357 if (extras && mExtras != null) {
9358 if (!first) {
9359 b.append(' ');
9360 }
9361 first = false;
9362 b.append("(has extras)");
9363 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009364 if (mContentUserHint != UserHandle.USER_CURRENT) {
9365 if (!first) {
9366 b.append(' ');
9367 }
9368 first = false;
9369 b.append("u=").append(mContentUserHint);
9370 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009371 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009372 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009373 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009374 b.append("}");
9375 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009376 }
9377
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009378 /**
9379 * Call {@link #toUri} with 0 flags.
9380 * @deprecated Use {@link #toUri} instead.
9381 */
9382 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009383 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009384 return toUri(0);
9385 }
9386
9387 /**
9388 * Convert this Intent into a String holding a URI representation of it.
9389 * The returned URI string has been properly URI encoded, so it can be
9390 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9391 * Intent's data as the base URI, with an additional fragment describing
9392 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009393 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009394 * <p>You can convert the returned string back to an Intent with
9395 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009396 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009397 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009398 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009399 * @return Returns a URI encoding URI string describing the entire contents
9400 * of the Intent.
9401 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009402 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009403 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009404 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9405 if (mPackage == null) {
9406 throw new IllegalArgumentException(
9407 "Intent must include an explicit package name to build an android-app: "
9408 + this);
9409 }
9410 uri.append("android-app://");
9411 uri.append(mPackage);
9412 String scheme = null;
9413 if (mData != null) {
9414 scheme = mData.getScheme();
9415 if (scheme != null) {
9416 uri.append('/');
9417 uri.append(scheme);
9418 String authority = mData.getEncodedAuthority();
9419 if (authority != null) {
9420 uri.append('/');
9421 uri.append(authority);
9422 String path = mData.getEncodedPath();
9423 if (path != null) {
9424 uri.append(path);
9425 }
9426 String queryParams = mData.getEncodedQuery();
9427 if (queryParams != null) {
9428 uri.append('?');
9429 uri.append(queryParams);
9430 }
9431 String fragment = mData.getEncodedFragment();
9432 if (fragment != null) {
9433 uri.append('#');
9434 uri.append(fragment);
9435 }
9436 }
9437 }
9438 }
9439 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9440 mPackage, flags);
9441 return uri.toString();
9442 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009443 String scheme = null;
9444 if (mData != null) {
9445 String data = mData.toString();
9446 if ((flags&URI_INTENT_SCHEME) != 0) {
9447 final int N = data.length();
9448 for (int i=0; i<N; i++) {
9449 char c = data.charAt(i);
9450 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9451 || c == '.' || c == '-') {
9452 continue;
9453 }
9454 if (c == ':' && i > 0) {
9455 // Valid scheme.
9456 scheme = data.substring(0, i);
9457 uri.append("intent:");
9458 data = data.substring(i+1);
9459 break;
9460 }
Tom Taylord4a47292009-12-21 13:59:18 -08009461
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009462 // No scheme.
9463 break;
9464 }
9465 }
9466 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009467
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009468 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9469 uri.append("intent:");
9470 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009471
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009472 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009473
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009474 return uri.toString();
9475 }
9476
9477 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9478 String defPackage, int flags) {
9479 StringBuilder frag = new StringBuilder(128);
9480
9481 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009482 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009483 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009484 // Note that for now we are not going to try to handle the
9485 // data part; not clear how to represent this as a URI, and
9486 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009487 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9488 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009489 }
9490
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009491 if (frag.length() > 0) {
9492 uri.append("#Intent;");
9493 uri.append(frag);
9494 uri.append("end");
9495 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009496 }
9497
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009498 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9499 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009500 if (scheme != null) {
9501 uri.append("scheme=").append(scheme).append(';');
9502 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009503 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009504 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009505 }
9506 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009507 for (int i=0; i<mCategories.size(); i++) {
9508 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009509 }
9510 }
9511 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009512 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009513 }
9514 if (mFlags != 0) {
9515 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9516 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009517 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009518 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9519 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009520 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009521 uri.append("component=").append(Uri.encode(
9522 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009523 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009524 if (mSourceBounds != null) {
9525 uri.append("sourceBounds=")
9526 .append(Uri.encode(mSourceBounds.flattenToString()))
9527 .append(';');
9528 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009529 if (mExtras != null) {
9530 for (String key : mExtras.keySet()) {
9531 final Object value = mExtras.get(key);
9532 char entryType =
9533 value instanceof String ? 'S' :
9534 value instanceof Boolean ? 'B' :
9535 value instanceof Byte ? 'b' :
9536 value instanceof Character ? 'c' :
9537 value instanceof Double ? 'd' :
9538 value instanceof Float ? 'f' :
9539 value instanceof Integer ? 'i' :
9540 value instanceof Long ? 'l' :
9541 value instanceof Short ? 's' :
9542 '\0';
9543
9544 if (entryType != '\0') {
9545 uri.append(entryType);
9546 uri.append('.');
9547 uri.append(Uri.encode(key));
9548 uri.append('=');
9549 uri.append(Uri.encode(value.toString()));
9550 uri.append(';');
9551 }
9552 }
9553 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009554 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009555
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009556 public int describeContents() {
9557 return (mExtras != null) ? mExtras.describeContents() : 0;
9558 }
9559
9560 public void writeToParcel(Parcel out, int flags) {
9561 out.writeString(mAction);
9562 Uri.writeToParcel(out, mData);
9563 out.writeString(mType);
9564 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009565 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009566 ComponentName.writeToParcel(mComponent, out);
9567
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009568 if (mSourceBounds != null) {
9569 out.writeInt(1);
9570 mSourceBounds.writeToParcel(out, flags);
9571 } else {
9572 out.writeInt(0);
9573 }
9574
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009575 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009576 final int N = mCategories.size();
9577 out.writeInt(N);
9578 for (int i=0; i<N; i++) {
9579 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009580 }
9581 } else {
9582 out.writeInt(0);
9583 }
9584
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009585 if (mSelector != null) {
9586 out.writeInt(1);
9587 mSelector.writeToParcel(out, flags);
9588 } else {
9589 out.writeInt(0);
9590 }
9591
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009592 if (mClipData != null) {
9593 out.writeInt(1);
9594 mClipData.writeToParcel(out, flags);
9595 } else {
9596 out.writeInt(0);
9597 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009598 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009599 out.writeBundle(mExtras);
9600 }
9601
9602 public static final Parcelable.Creator<Intent> CREATOR
9603 = new Parcelable.Creator<Intent>() {
9604 public Intent createFromParcel(Parcel in) {
9605 return new Intent(in);
9606 }
9607 public Intent[] newArray(int size) {
9608 return new Intent[size];
9609 }
9610 };
9611
Dianne Hackborneb034652009-09-07 00:49:58 -07009612 /** @hide */
9613 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009614 readFromParcel(in);
9615 }
9616
9617 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009618 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009619 mData = Uri.CREATOR.createFromParcel(in);
9620 mType = in.readString();
9621 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009622 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009623 mComponent = ComponentName.readFromParcel(in);
9624
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009625 if (in.readInt() != 0) {
9626 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9627 }
9628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009629 int N = in.readInt();
9630 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009631 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009632 int i;
9633 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009634 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009635 }
9636 } else {
9637 mCategories = null;
9638 }
9639
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009640 if (in.readInt() != 0) {
9641 mSelector = new Intent(in);
9642 }
9643
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009644 if (in.readInt() != 0) {
9645 mClipData = new ClipData(in);
9646 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009647 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009648 mExtras = in.readBundle();
9649 }
9650
9651 /**
9652 * Parses the "intent" element (and its children) from XML and instantiates
9653 * an Intent object. The given XML parser should be located at the tag
9654 * where parsing should start (often named "intent"), from which the
9655 * basic action, data, type, and package and class name will be
9656 * retrieved. The function will then parse in to any child elements,
9657 * looking for <category android:name="xxx"> tags to add categories and
9658 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9659 * to the intent.
9660 *
9661 * @param resources The Resources to use when inflating resources.
9662 * @param parser The XML parser pointing at an "intent" tag.
9663 * @param attrs The AttributeSet interface for retrieving extended
9664 * attribute data at the current <var>parser</var> location.
9665 * @return An Intent object matching the XML data.
9666 * @throws XmlPullParserException If there was an XML parsing error.
9667 * @throws IOException If there was an I/O error.
9668 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009669 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9670 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009671 throws XmlPullParserException, IOException {
9672 Intent intent = new Intent();
9673
9674 TypedArray sa = resources.obtainAttributes(attrs,
9675 com.android.internal.R.styleable.Intent);
9676
9677 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9678
9679 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9680 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9681 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9682
9683 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9684 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9685 if (packageName != null && className != null) {
9686 intent.setComponent(new ComponentName(packageName, className));
9687 }
9688
9689 sa.recycle();
9690
9691 int outerDepth = parser.getDepth();
9692 int type;
9693 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9694 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9695 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9696 continue;
9697 }
9698
9699 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009700 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009701 sa = resources.obtainAttributes(attrs,
9702 com.android.internal.R.styleable.IntentCategory);
9703 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9704 sa.recycle();
9705
9706 if (cat != null) {
9707 intent.addCategory(cat);
9708 }
9709 XmlUtils.skipCurrentTag(parser);
9710
Craig Mautner21d24a22014-04-23 11:45:37 -07009711 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009712 if (intent.mExtras == null) {
9713 intent.mExtras = new Bundle();
9714 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009715 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009716 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009717
9718 } else {
9719 XmlUtils.skipCurrentTag(parser);
9720 }
9721 }
9722
9723 return intent;
9724 }
Nick Pellyccae4122012-01-09 14:12:58 -08009725
Craig Mautner21d24a22014-04-23 11:45:37 -07009726 /** @hide */
9727 public void saveToXml(XmlSerializer out) throws IOException {
9728 if (mAction != null) {
9729 out.attribute(null, ATTR_ACTION, mAction);
9730 }
9731 if (mData != null) {
9732 out.attribute(null, ATTR_DATA, mData.toString());
9733 }
9734 if (mType != null) {
9735 out.attribute(null, ATTR_TYPE, mType);
9736 }
9737 if (mComponent != null) {
9738 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9739 }
9740 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9741
9742 if (mCategories != null) {
9743 out.startTag(null, TAG_CATEGORIES);
9744 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9745 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9746 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009747 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009748 }
9749 }
9750
9751 /** @hide */
9752 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9753 XmlPullParserException {
9754 Intent intent = new Intent();
9755 final int outerDepth = in.getDepth();
9756
9757 int attrCount = in.getAttributeCount();
9758 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9759 final String attrName = in.getAttributeName(attrNdx);
9760 final String attrValue = in.getAttributeValue(attrNdx);
9761 if (ATTR_ACTION.equals(attrName)) {
9762 intent.setAction(attrValue);
9763 } else if (ATTR_DATA.equals(attrName)) {
9764 intent.setData(Uri.parse(attrValue));
9765 } else if (ATTR_TYPE.equals(attrName)) {
9766 intent.setType(attrValue);
9767 } else if (ATTR_COMPONENT.equals(attrName)) {
9768 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9769 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009770 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009771 } else {
9772 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9773 }
9774 }
9775
9776 int event;
9777 String name;
9778 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9779 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9780 if (event == XmlPullParser.START_TAG) {
9781 name = in.getName();
9782 if (TAG_CATEGORIES.equals(name)) {
9783 attrCount = in.getAttributeCount();
9784 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9785 intent.addCategory(in.getAttributeValue(attrNdx));
9786 }
9787 } else {
9788 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9789 XmlUtils.skipCurrentTag(in);
9790 }
9791 }
9792 }
9793
9794 return intent;
9795 }
9796
Nick Pellyccae4122012-01-09 14:12:58 -08009797 /**
9798 * Normalize a MIME data type.
9799 *
9800 * <p>A normalized MIME type has white-space trimmed,
9801 * content-type parameters removed, and is lower-case.
9802 * This aligns the type with Android best practices for
9803 * intent filtering.
9804 *
9805 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9806 * "text/x-vCard" becomes "text/x-vcard".
9807 *
9808 * <p>All MIME types received from outside Android (such as user input,
9809 * or external sources like Bluetooth, NFC, or the Internet) should
9810 * be normalized before they are used to create an Intent.
9811 *
9812 * @param type MIME data type to normalize
9813 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009814 * @see #setType
9815 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009816 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009817 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009818 if (type == null) {
9819 return null;
9820 }
9821
Elliott Hughescb64d432013-08-02 10:00:44 -07009822 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009823
9824 final int semicolonIndex = type.indexOf(';');
9825 if (semicolonIndex != -1) {
9826 type = type.substring(0, semicolonIndex);
9827 }
9828 return type;
9829 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009830
9831 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009832 * Prepare this {@link Intent} to leave an app process.
9833 *
9834 * @hide
9835 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009836 public void prepareToLeaveProcess(Context context) {
9837 final boolean leavingPackage = (mComponent == null)
9838 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9839 prepareToLeaveProcess(leavingPackage);
9840 }
9841
9842 /**
9843 * Prepare this {@link Intent} to leave an app process.
9844 *
9845 * @hide
9846 */
9847 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009848 setAllowFds(false);
9849
9850 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009851 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009852 }
9853 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009854 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009855 }
9856
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009857 if (mExtras != null && !mExtras.isParcelled()) {
9858 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9859 if (intent instanceof Intent) {
9860 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9861 }
9862 }
9863
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009864 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9865 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009866 switch (mAction) {
9867 case ACTION_MEDIA_REMOVED:
9868 case ACTION_MEDIA_UNMOUNTED:
9869 case ACTION_MEDIA_CHECKING:
9870 case ACTION_MEDIA_NOFS:
9871 case ACTION_MEDIA_MOUNTED:
9872 case ACTION_MEDIA_SHARED:
9873 case ACTION_MEDIA_UNSHARED:
9874 case ACTION_MEDIA_BAD_REMOVAL:
9875 case ACTION_MEDIA_UNMOUNTABLE:
9876 case ACTION_MEDIA_EJECT:
9877 case ACTION_MEDIA_SCANNER_STARTED:
9878 case ACTION_MEDIA_SCANNER_FINISHED:
9879 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009880 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9881 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009882 // Ignore legacy actions
9883 break;
9884 default:
9885 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009886 }
9887 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009888
9889 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9890 && leavingPackage) {
9891 switch (mAction) {
9892 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -07009893 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009894 // Ignore actions that don't need to grant
9895 break;
9896 default:
9897 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9898 }
9899 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009900 }
9901
9902 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009903 * @hide
9904 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009905 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009906 // We just entered destination process, so we should be able to read all
9907 // parcelables inside.
9908 setDefusable(true);
9909
9910 if (mSelector != null) {
9911 mSelector.prepareToEnterProcess();
9912 }
9913 if (mClipData != null) {
9914 mClipData.prepareToEnterProcess();
9915 }
9916
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009917 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009918 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9919 fixUris(mContentUserHint);
9920 mContentUserHint = UserHandle.USER_CURRENT;
9921 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009922 }
9923 }
9924
9925 /**
9926 * @hide
9927 */
9928 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009929 Uri data = getData();
9930 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009931 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009932 }
9933 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009934 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009935 }
9936 String action = getAction();
9937 if (ACTION_SEND.equals(action)) {
9938 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9939 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009940 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009941 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009942 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009943 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9944 if (streams != null) {
9945 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9946 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009947 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009948 }
9949 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9950 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009951 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9952 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9953 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9954 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9955 if (output != null) {
9956 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9957 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009958 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009959 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009960
9961 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009962 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009963 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9964 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009965 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009966 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009967 * @hide
9968 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009969 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009970 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009971 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009972
9973 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009974 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009975
9976 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009977 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009978 // Inspect contained intents to see if we need to migrate extras. We
9979 // don't promote ClipData to the parent, since ChooserActivity will
9980 // already start the picked item as the caller, and we can't combine
9981 // the flags in a safe way.
9982
9983 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009984 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009985 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9986 if (intent != null) {
9987 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009988 }
9989 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009990 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009991 try {
9992 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9993 if (intents != null) {
9994 for (int i = 0; i < intents.length; i++) {
9995 final Intent intent = (Intent) intents[i];
9996 if (intent != null) {
9997 migrated |= intent.migrateExtraStreamToClipData();
9998 }
9999 }
10000 }
10001 } catch (ClassCastException e) {
10002 }
10003 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010004
10005 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010006 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010007 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10008 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10009 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10010 if (stream != null || text != null || htmlText != null) {
10011 final ClipData clipData = new ClipData(
10012 null, new String[] { getType() },
10013 new ClipData.Item(text, htmlText, null, stream));
10014 setClipData(clipData);
10015 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010016 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010017 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010018 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010019 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010020
10021 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010022 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010023 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10024 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10025 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10026 int num = -1;
10027 if (streams != null) {
10028 num = streams.size();
10029 }
10030 if (texts != null) {
10031 if (num >= 0 && num != texts.size()) {
10032 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010033 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010034 }
10035 num = texts.size();
10036 }
10037 if (htmlTexts != null) {
10038 if (num >= 0 && num != htmlTexts.size()) {
10039 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010040 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010041 }
10042 num = htmlTexts.size();
10043 }
10044 if (num > 0) {
10045 final ClipData clipData = new ClipData(
10046 null, new String[] { getType() },
10047 makeClipItem(streams, texts, htmlTexts, 0));
10048
10049 for (int i = 1; i < num; i++) {
10050 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10051 }
10052
10053 setClipData(clipData);
10054 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010055 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010056 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010057 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010058 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010059 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10060 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10061 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10062 final Uri output;
10063 try {
10064 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10065 } catch (ClassCastException e) {
10066 return false;
10067 }
10068 if (output != null) {
10069 setClipData(ClipData.newRawUri("", output));
10070 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10071 return true;
10072 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010073 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010074
10075 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010076 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010077
10078 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10079 ArrayList<String> htmlTexts, int which) {
10080 Uri uri = streams != null ? streams.get(which) : null;
10081 CharSequence text = texts != null ? texts.get(which) : null;
10082 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10083 return new ClipData.Item(text, htmlText, null, uri);
10084 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010085
10086 /** @hide */
10087 public boolean isDocument() {
10088 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10089 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010090}