blob: 9623da33b38465463394836f8cfd9d129e06e714 [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
267 * allows user to browse through a list of notes data and view details about
268 * individual items. Text in italics indicate places were you would replace a
269 * 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
1462 */
1463 @Deprecated
1464 @SystemApi
1465 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1466 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1467
1468 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001469 * Activity Action: Setup wizard to launch after a platform update. This
1470 * activity should have a string meta-data field associated with it,
1471 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1472 * the platform for setup. The activity will be launched only if
1473 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1474 * same value.
1475 * <p>Input: Nothing.
1476 * <p>Output: Nothing.
1477 * @hide
1478 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001479 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001480 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1481 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001482
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001483 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001484 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1485 * <p>Input: Nothing.
1486 * <p>Output: Nothing.
1487 * @hide
1488 */
1489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1490 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001491 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001492
1493 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001494 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1495 * <p>Input: Nothing.
1496 * <p>Output: Nothing.
1497 * @hide
1498 */
1499 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1500 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001501 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001502
1503 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001504 * Activity Action: Show settings for managing network data usage of a
1505 * specific application. Applications should define an activity that offers
1506 * options to control data usage.
1507 */
1508 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1509 public static final String ACTION_MANAGE_NETWORK_USAGE =
1510 "android.intent.action.MANAGE_NETWORK_USAGE";
1511
1512 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001513 * Activity Action: Launch application installer.
1514 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001515 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001516 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1517 * you can also use "package:<package-name>" to install an application for the
1518 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001519 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1520 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1521 * <p>
1522 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1523 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001524 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001525 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001526 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1527 * in order to launch the application installer.
1528 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001529 *
1530 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1531 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1532 * @see #EXTRA_RETURN_RESULT
1533 */
1534 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1535 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1536
1537 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001538 * Activity Action: Activity to handle split installation failures.
1539 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1540 * but the split that contains the application isn't installed. When a split is
1541 * installed in this manner, the containing package usually doesn't know this is
1542 * happening. However, if an error occurs during installation, the containing
1543 * package can define a single activity handling this action to deal with such
1544 * failures.
1545 * <p>The activity handling this action must be in the base package.
1546 * <p>
1547 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1548 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1549 */
1550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1551 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1552
1553 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001554 * @hide
1555 * @deprecated Do not use. This will go away.
1556 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1557 */
1558 @SystemApi
1559 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1560 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1561 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1562 /**
1563 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001564 * <p class="note">
1565 * This is a protected intent that can only be sent by the system.
1566 * </p>
1567 *
1568 * @hide
1569 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001570 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001571 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1573 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001574
1575 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001576 * @hide
1577 * @deprecated Do not use. This will go away.
1578 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1579 */
1580 @SystemApi
1581 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1582 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1583 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1584 /**
1585 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001586 * <p>
1587 * The system will have a persistent connection to this service.
1588 * This is a protected intent that can only be sent by the system.
1589 * </p>
1590 *
1591 * @hide
1592 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001593 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001594 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001595 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1596 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001597
1598 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 * @hide
1600 * @deprecated Do not use. This will go away.
1601 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1602 */
1603 @SystemApi
1604 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1605 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1606 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1607 /**
1608 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001609 *
1610 * <p class="note">
1611 * This is a protected intent that can only be sent by the system.
1612 * </p>
1613 *
1614 * @hide
1615 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001616 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001617 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001618 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1619 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001620
1621 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001622 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1623 * package. Specifies the installer package name; this package will receive the
1624 * {@link #ACTION_APP_ERROR} intent.
1625 */
1626 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1627 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1628
1629 /**
1630 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1631 * package. Specifies that the application being installed should not be
1632 * treated as coming from an unknown source, but as coming from the app
1633 * invoking the Intent. For this to work you must start the installer with
1634 * startActivityForResult().
1635 */
1636 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1637 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1638
1639 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001640 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1641 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001642 * data field originated from.
1643 */
rich cannings706e8ba2012-08-20 13:20:14 -07001644 public static final String EXTRA_ORIGINATING_URI
1645 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001646
1647 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001648 * This extra can be used with any Intent used to launch an activity, supplying information
1649 * about who is launching that activity. This field contains a {@link android.net.Uri}
1650 * object, typically an http: or https: URI of the web site that the referral came from;
1651 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1652 * a native application that it came from.
1653 *
1654 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1655 * instead of directly retrieving the extra. It is also valid for applications to
1656 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1657 * a string, not a Uri; the field here, if supplied, will always take precedence,
1658 * however.</p>
1659 *
1660 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001661 */
1662 public static final String EXTRA_REFERRER
1663 = "android.intent.extra.REFERRER";
1664
1665 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001666 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1667 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1668 * not be created, in particular when Intent extras are supplied through the
1669 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1670 * schemes.
1671 *
1672 * @see #EXTRA_REFERRER
1673 */
1674 public static final String EXTRA_REFERRER_NAME
1675 = "android.intent.extra.REFERRER_NAME";
1676
1677 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001678 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001679 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001680 * Currently only a system app that hosts the provider authority "downloads" or holds the
1681 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001682 * @hide
1683 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001684 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001685 public static final String EXTRA_ORIGINATING_UID
1686 = "android.intent.extra.ORIGINATING_UID";
1687
1688 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001689 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1690 * package. Tells the installer UI to skip the confirmation with the user
1691 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001692 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1693 * will no longer show an interstitial message about updating existing
1694 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001695 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001696 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001697 public static final String EXTRA_ALLOW_REPLACE
1698 = "android.intent.extra.ALLOW_REPLACE";
1699
1700 /**
1701 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1702 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1703 * return to the application the result code of the install/uninstall. The returned result
1704 * code will be {@link android.app.Activity#RESULT_OK} on success or
1705 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1706 */
1707 public static final String EXTRA_RETURN_RESULT
1708 = "android.intent.extra.RETURN_RESULT";
1709
1710 /**
1711 * Package manager install result code. @hide because result codes are not
1712 * yet ready to be exposed.
1713 */
1714 public static final String EXTRA_INSTALL_RESULT
1715 = "android.intent.extra.INSTALL_RESULT";
1716
1717 /**
1718 * Activity Action: Launch application uninstaller.
1719 * <p>
1720 * Input: The data must be a package: URI whose scheme specific part is
1721 * the package name of the current installed package to be uninstalled.
1722 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1723 * <p>
1724 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1725 * succeeded.
1726 */
1727 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1728 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1729
1730 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001731 * Specify whether the package should be uninstalled for all users.
1732 * @hide because these should not be part of normal application flow.
1733 */
1734 public static final String EXTRA_UNINSTALL_ALL_USERS
1735 = "android.intent.extra.UNINSTALL_ALL_USERS";
1736
1737 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001738 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1739 * describing the last run version of the platform that was setup.
1740 * @hide
1741 */
1742 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1743
Svet Ganov3695b8a2015-03-24 16:30:25 -07001744 /**
1745 * Activity action: Launch UI to manage the permissions of an app.
1746 * <p>
1747 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1748 * will be managed by the launched UI.
1749 * </p>
1750 * <p>
1751 * Output: Nothing.
1752 * </p>
1753 *
1754 * @see #EXTRA_PACKAGE_NAME
1755 *
1756 * @hide
1757 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001758 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001759 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1760 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1761 "android.intent.action.MANAGE_APP_PERMISSIONS";
1762
1763 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001764 * Activity action: Launch UI to manage permissions.
1765 * <p>
1766 * Input: Nothing.
1767 * </p>
1768 * <p>
1769 * Output: Nothing.
1770 * </p>
1771 *
1772 * @hide
1773 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001774 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001775 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1776 public static final String ACTION_MANAGE_PERMISSIONS =
1777 "android.intent.action.MANAGE_PERMISSIONS";
1778
1779 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001780 * Activity action: Launch UI to review permissions for an app.
1781 * The system uses this intent if permission review for apps not
1782 * supporting the new runtime permissions model is enabled. In
1783 * this mode a permission review is required before any of the
1784 * app components can run.
1785 * <p>
1786 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1787 * permissions will be reviewed (mandatory).
1788 * </p>
1789 * <p>
1790 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1791 * be fired after the permission review (optional).
1792 * </p>
1793 * <p>
1794 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1795 * be invoked after the permission review (optional).
1796 * </p>
1797 * <p>
1798 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1799 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1800 * </p>
1801 * <p>
1802 * Output: Nothing.
1803 * </p>
1804 *
1805 * @see #EXTRA_PACKAGE_NAME
1806 * @see #EXTRA_INTENT
1807 * @see #EXTRA_REMOTE_CALLBACK
1808 * @see #EXTRA_RESULT_NEEDED
1809 *
1810 * @hide
1811 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001812 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001813 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1814 public static final String ACTION_REVIEW_PERMISSIONS =
1815 "android.intent.action.REVIEW_PERMISSIONS";
1816
1817 /**
1818 * Intent extra: A callback for reporting remote result as a bundle.
1819 * <p>
1820 * Type: IRemoteCallback
1821 * </p>
1822 *
1823 * @hide
1824 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001825 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001826 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1827
1828 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001829 * Intent extra: An app package name.
1830 * <p>
1831 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001832 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001833 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001834 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001835 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1836
1837 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001838 * Intent extra: An app split name.
1839 * <p>
1840 * Type: String
1841 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001842 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001843 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1844
1845 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001846 * Intent extra: A {@link ComponentName} value.
1847 * <p>
1848 * Type: String
1849 * </p>
1850 */
1851 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1852
1853 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001854 * Intent extra: An extra for specifying whether a result is needed.
1855 * <p>
1856 * Type: boolean
1857 * </p>
1858 *
1859 * @hide
1860 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001861 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001862 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1863
1864 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001865 * Activity action: Launch UI to manage which apps have a given permission.
1866 * <p>
1867 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1868 * to which will be managed by the launched UI.
1869 * </p>
1870 * <p>
1871 * Output: Nothing.
1872 * </p>
1873 *
1874 * @see #EXTRA_PERMISSION_NAME
1875 *
1876 * @hide
1877 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001878 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001879 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1880 public static final String ACTION_MANAGE_PERMISSION_APPS =
1881 "android.intent.action.MANAGE_PERMISSION_APPS";
1882
1883 /**
1884 * Intent extra: The name of a permission.
1885 * <p>
1886 * Type: String
1887 * </p>
1888 *
1889 * @hide
1890 */
1891 @SystemApi
1892 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1893
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001894 // ---------------------------------------------------------------------
1895 // ---------------------------------------------------------------------
1896 // Standard intent broadcast actions (see action variable).
1897
1898 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001899 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1900 * <p>
1901 * For historical reasons, the name of this broadcast action refers to the power
1902 * state of the screen but it is actually sent in response to changes in the
1903 * overall interactive state of the device.
1904 * </p><p>
1905 * This broadcast is sent when the device becomes non-interactive which may have
1906 * nothing to do with the screen turning off. To determine the
1907 * actual state of the screen, use {@link android.view.Display#getState}.
1908 * </p><p>
1909 * See {@link android.os.PowerManager#isInteractive} for details.
1910 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001911 * You <em>cannot</em> receive this through components declared in
1912 * manifests, only by explicitly registering for it with
1913 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1914 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001915 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001916 * <p class="note">This is a protected intent that can only be sent
1917 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001921
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001922 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001923 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1924 * <p>
1925 * For historical reasons, the name of this broadcast action refers to the power
1926 * state of the screen but it is actually sent in response to changes in the
1927 * overall interactive state of the device.
1928 * </p><p>
1929 * This broadcast is sent when the device becomes interactive which may have
1930 * nothing to do with the screen turning on. To determine the
1931 * actual state of the screen, use {@link android.view.Display#getState}.
1932 * </p><p>
1933 * See {@link android.os.PowerManager#isInteractive} for details.
1934 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001935 * You <em>cannot</em> receive this through components declared in
1936 * manifests, only by explicitly registering for it with
1937 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1938 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001939 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001940 * <p class="note">This is a protected intent that can only be sent
1941 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001942 */
1943 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1944 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001945
1946 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001947 * Broadcast Action: Sent after the system stops dreaming.
1948 *
1949 * <p class="note">This is a protected intent that can only be sent by the system.
1950 * It is only sent to registered receivers.</p>
1951 */
1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1954
1955 /**
1956 * Broadcast Action: Sent after the system starts dreaming.
1957 *
1958 * <p class="note">This is a protected intent that can only be sent by the system.
1959 * It is only sent to registered receivers.</p>
1960 */
1961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1962 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1963
1964 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001965 * 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 -07001966 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001967 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001968 * <p class="note">This is a protected intent that can only be sent
1969 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001972 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001973
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001974 /**
1975 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001976 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001977 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1979 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001980 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001981 * <p class="note">This is a protected intent that can only be sent
1982 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1985 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1986 /**
1987 * Broadcast Action: The time was set.
1988 */
1989 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1990 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1991 /**
1992 * Broadcast Action: The date has changed.
1993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1996 /**
1997 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1998 * <ul>
1999 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2000 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002001 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002002 * <p class="note">This is a protected intent that can only be sent
2003 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002004 */
2005 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2006 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2007 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002008 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2009 * DNS entries should be tossed.
2010 * @hide
2011 */
2012 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2013 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2014 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002015 * Alarm Changed Action: This is broadcast when the AlarmClock
2016 * application's alarm is set or unset. It is used by the
2017 * AlarmClock application and the StatusBar service.
2018 * @hide
2019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002022
2023 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002024 * Broadcast Action: This is broadcast once, after the user has finished
2025 * booting, but while still in the "locked" state. It can be used to perform
2026 * application-specific initialization, such as installing alarms. You must
2027 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2028 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002029 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002030 * This broadcast is sent immediately at boot by all devices (regardless of
2031 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2032 * higher. Upon receipt of this broadcast, the user is still locked and only
2033 * device-protected storage can be accessed safely. If you want to access
2034 * credential-protected storage, you need to wait for the user to be
2035 * unlocked (typically by entering their lock pattern or PIN for the first
2036 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2037 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2038 * <p>
2039 * To receive this broadcast, your receiver component must be marked as
2040 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002041 * <p class="note">
2042 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002043 *
2044 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2048
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002049 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002050 * Broadcast Action: This is broadcast once, after the user has finished
2051 * booting. It can be used to perform application-specific initialization,
2052 * such as installing alarms. You must hold the
2053 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2054 * order to receive this broadcast.
2055 * <p>
2056 * This broadcast is sent at boot by all devices (both with and without
2057 * direct boot support). Upon receipt of this broadcast, the user is
2058 * unlocked and both device-protected and credential-protected storage can
2059 * accessed safely.
2060 * <p>
2061 * If you need to run while the user is still locked (before they've entered
2062 * their lock pattern or PIN for the first time), you can listen for the
2063 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2064 * <p class="note">
2065 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 */
2067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002068 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002069 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002070
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002071 /**
2072 * Broadcast Action: This is broadcast when a user action should request a
2073 * temporary system dialog to dismiss. Some examples of temporary system
2074 * dialogs are the notification window-shade and the recent tasks dialog.
2075 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2078 /**
2079 * Broadcast Action: Trigger the download and eventual installation
2080 * of a package.
2081 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002082 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002083 * <p class="note">This is a protected intent that can only be sent
2084 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002085 *
2086 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002087 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002088 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2090 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2091 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002092 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002093 * device. The data contains the name of the package. Note that the
2094 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002095 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002096 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002097 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2098 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002099 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2100 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002101 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002102 * <p class="note">This is a protected intent that can only be sent
2103 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2106 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2107 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002108 * Broadcast Action: A new version of an application package has been
2109 * installed, replacing an existing version that was previously installed.
2110 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002111 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002112 * <ul>
2113 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2114 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002115 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002116 * <p class="note">This is a protected intent that can only be sent
2117 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002118 */
2119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2120 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2121 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002122 * Broadcast Action: A new version of your application has been installed
2123 * over an existing one. This is only sent to the application that was
2124 * replaced. It does not contain any additional data; to receive it, just
2125 * use an intent filter for this action.
2126 *
2127 * <p class="note">This is a protected intent that can only be sent
2128 * by the system.
2129 */
2130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2131 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2132 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002133 * Broadcast Action: An existing application package has been removed from
2134 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002135 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002136 * <ul>
2137 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2138 * to the package.
2139 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2140 * application -- data and code -- is being removed.
2141 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2142 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2143 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002144 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002145 * <p class="note">This is a protected intent that can only be sent
2146 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2150 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002151 * Broadcast Action: An existing application package has been completely
2152 * removed from the device. The data contains the name of the package.
2153 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2154 * {@link #EXTRA_DATA_REMOVED} is true and
2155 * {@link #EXTRA_REPLACING} is false of that broadcast.
2156 *
2157 * <ul>
2158 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2159 * to the package.
2160 * </ul>
2161 *
2162 * <p class="note">This is a protected intent that can only be sent
2163 * by the system.
2164 */
2165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2166 public static final String ACTION_PACKAGE_FULLY_REMOVED
2167 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2168 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002169 * Broadcast Action: An existing application package has been changed (for
2170 * example, a component has been enabled or disabled). The data contains
2171 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002172 * <ul>
2173 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002174 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002175 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002176 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2177 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002178 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002179 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002180 * <p class="note">This is a protected intent that can only be sent
2181 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002182 */
2183 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2184 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2185 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002186 * @hide
2187 * Broadcast Action: Ask system services if there is any reason to
2188 * restart the given package. The data contains the name of the
2189 * package.
2190 * <ul>
2191 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2192 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2193 * </ul>
2194 *
2195 * <p class="note">This is a protected intent that can only be sent
2196 * by the system.
2197 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002198 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2200 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2201 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002202 * Broadcast Action: The user has restarted a package, and all of its
2203 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002204 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002205 * be removed. Note that the restarted package does <em>not</em>
2206 * receive this broadcast.
2207 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002208 * <ul>
2209 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2210 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002211 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002212 * <p class="note">This is a protected intent that can only be sent
2213 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2216 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2217 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002218 * Broadcast Action: The user has cleared the data of a package. This should
2219 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002220 * its persistent data is erased and this broadcast sent.
2221 * Note that the cleared package does <em>not</em>
2222 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002223 * <ul>
2224 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2225 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002226 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002227 * <p class="note">This is a protected intent that can only be sent
2228 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002229 */
2230 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2231 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2232 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002233 * Broadcast Action: Packages have been suspended.
2234 * <p>Includes the following extras:
2235 * <ul>
2236 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2237 * </ul>
2238 *
2239 * <p class="note">This is a protected intent that can only be sent
2240 * by the system. It is only sent to registered receivers.
2241 */
2242 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2243 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2244 /**
2245 * Broadcast Action: Packages have been unsuspended.
2246 * <p>Includes the following extras:
2247 * <ul>
2248 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2249 * </ul>
2250 *
2251 * <p class="note">This is a protected intent that can only be sent
2252 * by the system. It is only sent to registered receivers.
2253 */
2254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2255 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002257 * Broadcast Action: A user ID has been removed from the system. The user
2258 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002259 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002260 * <p class="note">This is a protected intent that can only be sent
2261 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002262 */
2263 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2264 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002265
2266 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002267 * Broadcast Action: Sent to the installer package of an application when
2268 * that application is first launched (that is the first time it is moved
2269 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002270 *
2271 * <p class="note">This is a protected intent that can only be sent
2272 * by the system.
2273 */
2274 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2275 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2276
2277 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002278 * Broadcast Action: Sent to the system package verifier when a package
2279 * needs to be verified. The data contains the package URI.
2280 * <p class="note">
2281 * This is a protected intent that can only be sent by the system.
2282 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002283 */
2284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2285 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2286
2287 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002288 * Broadcast Action: Sent to the system package verifier when a package is
2289 * verified. The data contains the package URI.
2290 * <p class="note">
2291 * This is a protected intent that can only be sent by the system.
2292 */
2293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2294 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2295
2296 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002297 * Broadcast Action: Sent to the system intent filter verifier when an
2298 * intent filter needs to be verified. The data contains the filter data
2299 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002300 * <p class="note">
2301 * This is a protected intent that can only be sent by the system.
2302 * </p>
2303 *
2304 * @hide
2305 */
2306 @SystemApi
2307 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2308 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2309
2310 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002311 * Broadcast Action: Resources for a set of packages (which were
2312 * previously unavailable) are currently
2313 * available since the media on which they exist is available.
2314 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2315 * list of packages whose availability changed.
2316 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2317 * list of uids of packages whose availability changed.
2318 * Note that the
2319 * packages in this list do <em>not</em> receive this broadcast.
2320 * The specified set of packages are now available on the system.
2321 * <p>Includes the following extras:
2322 * <ul>
2323 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2324 * whose resources(were previously unavailable) are currently available.
2325 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2326 * packages whose resources(were previously unavailable)
2327 * are currently available.
2328 * </ul>
2329 *
2330 * <p class="note">This is a protected intent that can only be sent
2331 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002332 */
2333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002334 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2335 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002336
2337 /**
2338 * Broadcast Action: Resources for a set of packages are currently
2339 * unavailable since the media on which they exist is unavailable.
2340 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2341 * list of packages whose availability changed.
2342 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2343 * list of uids of packages whose availability changed.
2344 * The specified set of packages can no longer be
2345 * launched and are practically unavailable on the system.
2346 * <p>Inclues the following extras:
2347 * <ul>
2348 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2349 * whose resources are no longer available.
2350 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2351 * whose resources are no longer available.
2352 * </ul>
2353 *
2354 * <p class="note">This is a protected intent that can only be sent
2355 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002356 */
2357 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002358 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002359 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002360
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002361 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002362 * Broadcast Action: preferred activities have changed *explicitly*.
2363 *
2364 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2365 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2366 * be sent.
2367 *
2368 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2369 *
2370 * @hide
2371 */
2372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2374 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2375
2376
2377 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002378 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002379 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002380 * This should <em>only</em> be used to determine when the wallpaper
2381 * has changed to show the new wallpaper to the user. You should certainly
2382 * never, in response to this, change the wallpaper or other attributes of
2383 * it such as the suggested size. That would be crazy, right? You'd cause
2384 * all kinds of loops, especially if other apps are doing similar things,
2385 * right? Of course. So please don't do this.
2386 *
2387 * @deprecated Modern applications should use
2388 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2389 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2390 * shown behind their UI, rather than watching for this broadcast and
2391 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002392 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002393 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002394 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2395 /**
2396 * Broadcast Action: The current device {@link android.content.res.Configuration}
2397 * (orientation, locale, etc) has changed. When such a change happens, the
2398 * UIs (view hierarchy) will need to be rebuilt based on this new
2399 * information; for the most part, applications don't need to worry about
2400 * this, because the system will take care of stopping and restarting the
2401 * application to make sure it sees the new changes. Some system code that
2402 * can not be restarted will need to watch for this action and handle it
2403 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002404 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002405 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002406 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002407 * in manifests, only by explicitly registering for it with
2408 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2409 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002410 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002411 * <p class="note">This is a protected intent that can only be sent
2412 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002413 *
2414 * @see android.content.res.Configuration
2415 */
2416 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2417 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2418 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002419 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002420 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002421 * <p class="note">This is a protected intent that can only be sent
2422 * by the system.
2423 */
2424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2425 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2426 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002427 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2428 * charging state, level, and other information about the battery.
2429 * See {@link android.os.BatteryManager} for documentation on the
2430 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002431 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002432 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002433 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002434 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002435 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002436 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2437 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2438 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2439 * broadcasts that are sent and can be received through manifest
2440 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002441 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002442 * <p class="note">This is a protected intent that can only be sent
2443 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002444 */
2445 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2446 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2447 /**
2448 * Broadcast Action: Indicates low battery condition on the device.
2449 * This broadcast corresponds to the "Low battery warning" system dialog.
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_LOW = "android.intent.action.BATTERY_LOW";
2456 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002457 * Broadcast Action: Indicates the battery is now okay after being low.
2458 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2459 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002460 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002461 * <p class="note">This is a protected intent that can only be sent
2462 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002463 */
2464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2465 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2466 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002467 * Broadcast Action: External power has been connected to the device.
2468 * This is intended for applications that wish to register specifically to this notification.
2469 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2470 * stay active to receive this notification. This action can be used to implement actions
2471 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002472 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002473 * <p class="note">This is a protected intent that can only be sent
2474 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002475 */
2476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002477 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002478 /**
2479 * Broadcast Action: External power has been removed from the device.
2480 * This is intended for applications that wish to register specifically to this notification.
2481 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2482 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002483 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002484 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002485 * <p class="note">This is a protected intent that can only be sent
2486 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002487 */
2488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002489 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002490 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002491 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002492 * Broadcast Action: Device is shutting down.
2493 * This is broadcast when the device is being shut down (completely turned
2494 * off, not sleeping). Once the broadcast is complete, the final shutdown
2495 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002496 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002497 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002498 * <p class="note">This is a protected intent that can only be sent
2499 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002500 * <p>May include the following extras:
2501 * <ul>
2502 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2503 * shutdown is only for userspace processes. If not set, assumed to be false.
2504 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002505 */
2506 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002507 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002508 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002509 * Activity Action: Start this activity to request system shutdown.
2510 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002511 * to request confirmation from the user before shutting down. The optional boolean
2512 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2513 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002514 *
2515 * <p class="note">This is a protected intent that can only be sent
2516 * by the system.
2517 *
2518 * {@hide}
2519 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002520 public static final String ACTION_REQUEST_SHUTDOWN
2521 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002522 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002523 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002524 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002525 * <p class="note">
2526 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002527 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002528 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2529 * or above, this broadcast will no longer be delivered to any
2530 * {@link BroadcastReceiver} defined in your manifest. Instead,
2531 * apps are strongly encouraged to use the improved
2532 * {@link Context#getCacheDir()} behavior so the system can
2533 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002534 */
2535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002536 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002537 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2538 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002539 * Broadcast Action: Indicates low storage space condition on the device no
2540 * longer exists
2541 * <p class="note">
2542 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002543 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002544 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2545 * or above, this broadcast will no longer be delivered to any
2546 * {@link BroadcastReceiver} defined in your manifest. Instead,
2547 * apps are strongly encouraged to use the improved
2548 * {@link Context#getCacheDir()} behavior so the system can
2549 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002550 */
2551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002553 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2554 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002555 * Broadcast Action: A sticky broadcast that indicates a storage space full
2556 * condition on the device. This is intended for activities that want to be
2557 * able to fill the data partition completely, leaving only enough free
2558 * space to prevent system-wide SQLite failures.
2559 * <p class="note">
2560 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002561 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002562 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2563 * or above, this broadcast will no longer be delivered to any
2564 * {@link BroadcastReceiver} defined in your manifest. Instead,
2565 * apps are strongly encouraged to use the improved
2566 * {@link Context#getCacheDir()} behavior so the system can
2567 * automatically free up storage when needed.
2568 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002569 */
2570 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002571 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002572 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2573 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002574 * Broadcast Action: Indicates storage space full condition on the device no
2575 * longer exists.
2576 * <p class="note">
2577 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002578 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002579 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2580 * or above, this broadcast will no longer be delivered to any
2581 * {@link BroadcastReceiver} defined in your manifest. Instead,
2582 * apps are strongly encouraged to use the improved
2583 * {@link Context#getCacheDir()} behavior so the system can
2584 * automatically free up storage when needed.
2585 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002586 */
2587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002588 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002589 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2590 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002591 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2592 * and package management should be started.
2593 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2594 * notification.
2595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2597 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2598 /**
2599 * Broadcast Action: The device has entered USB Mass Storage mode.
2600 * This is used mainly for the USB Settings panel.
2601 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2602 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002603 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002604 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002605 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002607 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2608
2609 /**
2610 * Broadcast Action: The device has exited USB Mass Storage mode.
2611 * This is used mainly for the USB Settings panel.
2612 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2613 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002614 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002616 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002617 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002618 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2619
2620 /**
2621 * Broadcast Action: External media has been removed.
2622 * The path to the mount point for the removed media is contained in the Intent.mData field.
2623 */
2624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2625 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2626
2627 /**
2628 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002629 * 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 -07002630 */
2631 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2632 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2633
2634 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002635 * Broadcast Action: External media is present, and being disk-checked
2636 * 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 -08002637 */
2638 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2639 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2640
2641 /**
2642 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2643 * 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 -08002644 */
2645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2646 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2647
2648 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002649 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002650 * 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 -07002651 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2652 * media was mounted read only.
2653 */
2654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2655 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2656
2657 /**
2658 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002659 * 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 -07002660 */
2661 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2662 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2663
2664 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002665 * Broadcast Action: External media is no longer being shared via USB mass storage.
2666 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2667 *
2668 * @hide
2669 */
2670 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2671
2672 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2674 * The path to the mount point for the removed media is contained in the Intent.mData field.
2675 */
2676 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2678
2679 /**
2680 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002681 * 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 -07002682 */
2683 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2684 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2685
2686 /**
2687 * Broadcast Action: User has expressed the desire to remove the external storage media.
2688 * Applications should close all files they have open within the mount point when they receive this intent.
2689 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2690 */
2691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2692 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2693
2694 /**
2695 * Broadcast Action: The media scanner has started scanning a directory.
2696 * The path to the directory being scanned is contained in the Intent.mData field.
2697 */
2698 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2699 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2700
2701 /**
2702 * Broadcast Action: The media scanner has finished scanning a directory.
2703 * The path to the scanned directory is contained in the Intent.mData field.
2704 */
2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2706 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2707
2708 /**
2709 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2710 * The path to the file is contained in the Intent.mData field.
2711 */
2712 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2713 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2714
2715 /**
2716 * Broadcast Action: The "Media Button" was pressed. Includes a single
2717 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2718 * caused the broadcast.
2719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2721 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2722
2723 /**
2724 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2725 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2726 * caused the broadcast.
2727 */
2728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2729 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2730
2731 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2732 // location; they are not general-purpose actions.
2733
2734 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002735 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2738 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2739 "android.intent.action.GTALK_CONNECTED";
2740
2741 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002742 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002743 */
2744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2746 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002747
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002748 /**
2749 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002750 */
2751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2752 public static final String ACTION_INPUT_METHOD_CHANGED =
2753 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002754
2755 /**
2756 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2757 * more radios have been turned off or on. The intent will have the following extra value:</p>
2758 * <ul>
2759 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2760 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2761 * turned off</li>
2762 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002763 *
Peng Xua35b5532016-01-20 00:05:45 -08002764 * <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 -07002765 */
2766 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2767 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2768
2769 /**
2770 * Broadcast Action: Some content providers have parts of their namespace
2771 * where they publish new events or items that the user may be especially
2772 * interested in. For these things, they may broadcast this action when the
2773 * set of interesting items change.
2774 *
2775 * For example, GmailProvider sends this notification when the set of unread
2776 * mail in the inbox changes.
2777 *
2778 * <p>The data of the intent identifies which part of which provider
2779 * changed. When queried through the content resolver, the data URI will
2780 * return the data set in question.
2781 *
2782 * <p>The intent will have the following extra values:
2783 * <ul>
2784 * <li><em>count</em> - The number of items in the data set. This is the
2785 * same as the number of items in the cursor returned by querying the
2786 * data URI. </li>
2787 * </ul>
2788 *
2789 * This intent will be sent at boot (if the count is non-zero) and when the
2790 * data set changes. It is possible for the data set to change without the
2791 * count changing (for example, if a new unread message arrives in the same
2792 * sync operation in which a message is archived). The phone should still
2793 * ring/vibrate/etc as normal in this case.
2794 */
2795 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2796 public static final String ACTION_PROVIDER_CHANGED =
2797 "android.intent.action.PROVIDER_CHANGED";
2798
2799 /**
2800 * Broadcast Action: Wired Headset plugged in or unplugged.
2801 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002802 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2803 * and documentation.
2804 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002805 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002806 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002807 */
2808 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002809 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002810
2811 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002812 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2813 * <ul>
2814 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2815 * </ul>
2816 *
2817 * <p class="note">This is a protected intent that can only be sent
2818 * by the system.
2819 *
2820 * @hide
2821 */
2822 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2823 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2824 = "android.intent.action.ADVANCED_SETTINGS";
2825
2826 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002827 * Broadcast Action: Sent after application restrictions are changed.
2828 *
2829 * <p class="note">This is a protected intent that can only be sent
2830 * by the system.</p>
2831 */
2832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2833 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2834 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2835
2836 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002837 * Broadcast Action: An outgoing call is about to be placed.
2838 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002839 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002840 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002841 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002842 * the phone number originally intended to be dialed.</li>
2843 * </ul>
2844 * <p>Once the broadcast is finished, the resultData is used as the actual
2845 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002846 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002847 * outgoing call in turn: for example, a parental control application
2848 * might verify that the user is authorized to place the call at that
2849 * time, then a number-rewriting application might add an area code if
2850 * one was not specified.</p>
2851 * <p>For consistency, any receiver whose purpose is to prohibit phone
2852 * calls should have a priority of 0, to ensure it will see the final
2853 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002854 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002855 * should have a positive priority.
2856 * Negative priorities are reserved for the system for this broadcast;
2857 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002858 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2859 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002860 * <p>Emergency calls cannot be intercepted using this mechanism, and
2861 * other calls cannot be modified to call emergency numbers using this
2862 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002863 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2864 * call to use their own service instead. Those apps should first prevent
2865 * the call from being placed by setting resultData to <code>null</code>
2866 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002867 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002868 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2869 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002870 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002871 * <p class="note">This is a protected intent that can only be sent
2872 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 */
2874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2875 public static final String ACTION_NEW_OUTGOING_CALL =
2876 "android.intent.action.NEW_OUTGOING_CALL";
2877
2878 /**
2879 * Broadcast Action: Have the device reboot. This is only for use by
2880 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002881 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002882 * <p class="note">This is a protected intent that can only be sent
2883 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002884 */
2885 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2886 public static final String ACTION_REBOOT =
2887 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002888
Wei Huang97ecc9c2009-05-11 17:44:20 -07002889 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002890 * Broadcast Action: A sticky broadcast for changes in the physical
2891 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002892 *
2893 * <p>The intent will have the following extra values:
2894 * <ul>
2895 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002896 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002897 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002898 * <p>This is intended for monitoring the current physical dock state.
2899 * See {@link android.app.UiModeManager} for the normal API dealing with
2900 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002901 */
2902 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2903 public static final String ACTION_DOCK_EVENT =
2904 "android.intent.action.DOCK_EVENT";
2905
2906 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002907 * Broadcast Action: A broadcast when idle maintenance can be started.
2908 * This means that the user is not interacting with the device and is
2909 * not expected to do so soon. Typical use of the idle maintenance is
2910 * to perform somehow expensive tasks that can be postponed at a moment
2911 * when they will not degrade user experience.
2912 * <p>
2913 * <p class="note">In order to keep the device responsive in case of an
2914 * unexpected user interaction, implementations of a maintenance task
2915 * should be interruptible. In such a scenario a broadcast with action
2916 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2917 * should not do the maintenance work in
2918 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2919 * maintenance service by {@link Context#startService(Intent)}. Also
2920 * you should hold a wake lock while your maintenance service is running
2921 * to prevent the device going to sleep.
2922 * </p>
2923 * <p>
2924 * <p class="note">This is a protected intent that can only be sent by
2925 * the system.
2926 * </p>
2927 *
2928 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002929 *
2930 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002931 */
2932 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2933 public static final String ACTION_IDLE_MAINTENANCE_START =
2934 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2935
2936 /**
2937 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2938 * This means that the user was not interacting with the device as a result
2939 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2940 * was sent and now the user started interacting with the device. Typical
2941 * use of the idle maintenance is to perform somehow expensive tasks that
2942 * can be postponed at a moment when they will not degrade user experience.
2943 * <p>
2944 * <p class="note">In order to keep the device responsive in case of an
2945 * unexpected user interaction, implementations of a maintenance task
2946 * should be interruptible. Hence, on receiving a broadcast with this
2947 * action, the maintenance task should be interrupted as soon as possible.
2948 * In other words, you should not do the maintenance work in
2949 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2950 * maintenance service that was started on receiving of
2951 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2952 * lock you acquired when your maintenance service started.
2953 * </p>
2954 * <p class="note">This is a protected intent that can only be sent
2955 * by the system.
2956 *
2957 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002958 *
2959 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002960 */
2961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2962 public static final String ACTION_IDLE_MAINTENANCE_END =
2963 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2964
2965 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002966 * Broadcast Action: a remote intent is to be broadcasted.
2967 *
2968 * A remote intent is used for remote RPC between devices. The remote intent
2969 * is serialized and sent from one device to another device. The receiving
2970 * device parses the remote intent and broadcasts it. Note that anyone can
2971 * broadcast a remote intent. However, if the intent receiver of the remote intent
2972 * does not trust intent broadcasts from arbitrary intent senders, it should require
2973 * the sender to hold certain permissions so only trusted sender's broadcast will be
2974 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002975 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002976 */
2977 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002978 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002979
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002980 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002981 * Broadcast Action: This is broadcast once when the user is booting after a
2982 * system update. It can be used to perform cleanup or upgrades after a
2983 * system update.
2984 * <p>
2985 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2986 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2987 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2988 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002989 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002990 * @hide
2991 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002992 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002993 public static final String ACTION_PRE_BOOT_COMPLETED =
2994 "android.intent.action.PRE_BOOT_COMPLETED";
2995
Amith Yamasani13593602012-03-22 16:16:17 -07002996 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002997 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002998 * on restricted users. The broadcast intent contains an extra
2999 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3000 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3001 * String[] depending on the restriction type.<p/>
3002 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003003 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3004 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3005 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003006 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3007 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003008 * @see RestrictionEntry
3009 */
3010 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3011 "android.intent.action.GET_RESTRICTION_ENTRIES";
3012
3013 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003014 * Sent the first time a user is starting, to allow system apps to
3015 * perform one time initialization. (This will not be seen by third
3016 * party applications because a newly initialized user does not have any
3017 * third party applications installed for it.) This is sent early in
3018 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003019 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3020 * broadcast, since it is part of a visible user interaction; be as quick
3021 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003022 */
3023 public static final String ACTION_USER_INITIALIZE =
3024 "android.intent.action.USER_INITIALIZE";
3025
3026 /**
3027 * Sent when a user switch is happening, causing the process's user to be
3028 * brought to the foreground. This is only sent to receivers registered
3029 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3030 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003031 * foreground. This is sent as a foreground
3032 * broadcast, since it is part of a visible user interaction; be as quick
3033 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003034 */
3035 public static final String ACTION_USER_FOREGROUND =
3036 "android.intent.action.USER_FOREGROUND";
3037
3038 /**
3039 * Sent when a user switch is happening, causing the process's user to be
3040 * sent to the background. This is only sent to receivers registered
3041 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3042 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003043 * background. This is sent as a foreground
3044 * broadcast, since it is part of a visible user interaction; be as quick
3045 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003046 */
3047 public static final String ACTION_USER_BACKGROUND =
3048 "android.intent.action.USER_BACKGROUND";
3049
3050 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003051 * Broadcast sent to the system when a user is added. Carries an extra
3052 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3053 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003054 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003055 * @hide
3056 */
3057 public static final String ACTION_USER_ADDED =
3058 "android.intent.action.USER_ADDED";
3059
3060 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003061 * Broadcast sent by the system when a user is started. Carries an extra
3062 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003063 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003064 * that has been started. This is sent as a foreground
3065 * broadcast, since it is part of a visible user interaction; be as quick
3066 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003067 * @hide
3068 */
3069 public static final String ACTION_USER_STARTED =
3070 "android.intent.action.USER_STARTED";
3071
3072 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003073 * Broadcast sent when a user is in the process of starting. Carries an extra
3074 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3075 * sent to registered receivers, not manifest receivers. It is sent to all
3076 * users (including the one that is being started). You must hold
3077 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3078 * this broadcast. This is sent as a background broadcast, since
3079 * its result is not part of the primary UX flow; to safely keep track of
3080 * started/stopped state of a user you can use this in conjunction with
3081 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3082 * other user state broadcasts since those are foreground broadcasts so can
3083 * execute in a different order.
3084 * @hide
3085 */
3086 public static final String ACTION_USER_STARTING =
3087 "android.intent.action.USER_STARTING";
3088
3089 /**
3090 * Broadcast sent when a user is going to be stopped. Carries an extra
3091 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3092 * sent to registered receivers, not manifest receivers. It is sent to all
3093 * users (including the one that is being stopped). You must hold
3094 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3095 * this broadcast. The user will not stop until all receivers have
3096 * handled the broadcast. This is sent as a background broadcast, since
3097 * its result is not part of the primary UX flow; to safely keep track of
3098 * started/stopped state of a user you can use this in conjunction with
3099 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3100 * other user state broadcasts since those are foreground broadcasts so can
3101 * execute in a different order.
3102 * @hide
3103 */
3104 public static final String ACTION_USER_STOPPING =
3105 "android.intent.action.USER_STOPPING";
3106
3107 /**
3108 * Broadcast sent to the system when a user is stopped. Carries an extra
3109 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3110 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3111 * specific package. This is only sent to registered receivers, not manifest
3112 * receivers. It is sent to all running users <em>except</em> the one that
3113 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003114 * @hide
3115 */
3116 public static final String ACTION_USER_STOPPED =
3117 "android.intent.action.USER_STOPPED";
3118
3119 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003120 * 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 -07003121 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003122 * one that has been removed. The user will not be completely removed until all receivers have
3123 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003124 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003125 * @hide
3126 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003127 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003128 public static final String ACTION_USER_REMOVED =
3129 "android.intent.action.USER_REMOVED";
3130
3131 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003132 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003133 * the userHandle of the user to become the current one. This is only sent to
3134 * registered receivers, not manifest receivers. It is sent to all running users.
3135 * You must hold
3136 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003137 * @hide
3138 */
3139 public static final String ACTION_USER_SWITCHED =
3140 "android.intent.action.USER_SWITCHED";
3141
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003142 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003143 * Broadcast Action: Sent when the credential-encrypted private storage has
3144 * become unlocked for the target user. This is only sent to registered
3145 * receivers, not manifest receivers.
3146 */
3147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3148 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3149
3150 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003151 * Broadcast sent to the system when a user's information changes. Carries an extra
3152 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003153 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003154 * @hide
3155 */
3156 public static final String ACTION_USER_INFO_CHANGED =
3157 "android.intent.action.USER_INFO_CHANGED";
3158
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003159 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003160 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3161 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003162 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3163 * that need to display merged content across both primary and managed profiles need to
3164 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003165 * not manifest receivers.
3166 */
3167 public static final String ACTION_MANAGED_PROFILE_ADDED =
3168 "android.intent.action.MANAGED_PROFILE_ADDED";
3169
3170 /**
3171 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003172 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3173 * Only applications (for example Launchers) that need to display merged content across both
3174 * primary and managed profiles need to worry about this broadcast. This is only sent to
3175 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003176 */
3177 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3178 "android.intent.action.MANAGED_PROFILE_REMOVED";
3179
3180 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003181 * Broadcast sent to the primary user when the credential-encrypted private storage for
3182 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3183 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3184 * Launchers) that need to display merged content across both primary and managed profiles
3185 * need to worry about this broadcast. This is only sent to registered receivers,
3186 * not manifest receivers.
3187 */
3188 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3189 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3190
3191 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003192 * Broadcast sent to the primary user when an associated managed profile has become available.
3193 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003194 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3195 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3196 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003197 */
Rubin Xue95057a2016-04-01 16:49:25 +01003198 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3199 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3200
3201 /**
3202 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3203 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3204 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3205 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3206 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3207 */
3208 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3209 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003210
3211 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003212 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3213 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3214 * the device was locked or unlocked.
3215 *
3216 * This is only sent to registered receivers.
3217 *
3218 * @hide
3219 */
3220 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3221 "android.intent.action.DEVICE_LOCKED_CHANGED";
3222
3223 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003224 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3225 */
3226 public static final String ACTION_QUICK_CLOCK =
3227 "android.intent.action.QUICK_CLOCK";
3228
Michael Wright0087a142013-02-05 16:29:39 -08003229 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003230 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003231 * @hide
3232 */
3233 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003234 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003235
Justin Kohd378ad72013-04-01 12:18:26 -07003236 /**
3237 * Broadcast Action: A global button was pressed. Includes a single
3238 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3239 * caused the broadcast.
3240 * @hide
3241 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003242 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003243 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3244
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003245 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003246 * Broadcast Action: Sent when media resource is granted.
3247 * <p>
3248 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3249 * granted.
3250 * </p>
3251 * <p class="note">
3252 * This is a protected intent that can only be sent by the system.
3253 * </p>
3254 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003255 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003256 * </p>
3257 *
3258 * @hide
3259 */
3260 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3261 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3262
3263 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003264 * Broadcast Action: An overlay package has changed. The data contains the
3265 * name of the overlay package which has changed. This is broadcast on all
3266 * changes to the OverlayInfo returned by {@link
3267 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3268 * most common change is a state change that will change whether the
3269 * overlay is enabled or not.
3270 * @hide
3271 */
3272 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3273
3274 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003275 * Activity Action: Allow the user to select and return one or more existing
3276 * documents. When invoked, the system will display the various
3277 * {@link DocumentsProvider} instances installed on the device, letting the
3278 * user interactively navigate through them. These documents include local
3279 * media, such as photos and video, and documents provided by installed
3280 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003281 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003282 * Each document is represented as a {@code content://} URI backed by a
3283 * {@link DocumentsProvider}, which can be opened as a stream with
3284 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3285 * {@link android.provider.DocumentsContract.Document} metadata.
3286 * <p>
3287 * All selected documents are returned to the calling application with
3288 * persistable read and write permission grants. If you want to maintain
3289 * access to the documents across device reboots, you need to explicitly
3290 * take the persistable permissions using
3291 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3292 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003293 * Callers must indicate the acceptable document MIME types through
3294 * {@link #setType(String)}. For example, to select photos, use
3295 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3296 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3297 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003298 * <p>
3299 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003300 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3301 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003302 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003303 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3304 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003305 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003306 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003307 * Callers can set a document URI through
3308 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3309 * location of documents navigator. System will do its best to launch the
3310 * navigator in the specified document if it's a folder, or the folder that
3311 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003312 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003313 * Output: The URI of the item that was picked, returned in
3314 * {@link #getData()}. This must be a {@code content://} URI so that any
3315 * receiver can access it. If multiple documents were selected, they are
3316 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003317 *
3318 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003319 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003320 * @see #ACTION_CREATE_DOCUMENT
3321 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003322 */
3323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3324 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3325
3326 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003327 * Activity Action: Allow the user to create a new document. When invoked,
3328 * the system will display the various {@link DocumentsProvider} instances
3329 * installed on the device, letting the user navigate through them. The
3330 * returned document may be a newly created document with no content, or it
3331 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003332 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003333 * Each document is represented as a {@code content://} URI backed by a
3334 * {@link DocumentsProvider}, which can be opened as a stream with
3335 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3336 * {@link android.provider.DocumentsContract.Document} metadata.
3337 * <p>
3338 * Callers must indicate the concrete MIME type of the document being
3339 * created by setting {@link #setType(String)}. This MIME type cannot be
3340 * changed after the document is created.
3341 * <p>
3342 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3343 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003344 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003345 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3346 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003347 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003348 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003349 * Callers can set a document URI through
3350 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3351 * location of documents navigator. System will do its best to launch the
3352 * navigator in the specified document if it's a folder, or the folder that
3353 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003354 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003355 * Output: The URI of the item that was created. This must be a
3356 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003357 *
3358 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003359 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003360 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003361 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003362 */
3363 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3364 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3365
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003366 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003367 * Activity Action: Allow the user to pick a directory subtree. When
3368 * invoked, the system will display the various {@link DocumentsProvider}
3369 * instances installed on the device, letting the user navigate through
3370 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003371 * <p>
3372 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003373 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3374 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3375 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003376 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003377 * Callers can set a document URI through
3378 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3379 * location of documents navigator. System will do its best to launch the
3380 * navigator in the specified document if it's a folder, or the folder that
3381 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003382 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003383 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003384 *
3385 * @see DocumentsContract
3386 */
3387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003388 public static final String
3389 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003390
Felipe Lemec7b1f892016-01-15 15:02:31 -08003391 /**
Peng Xua35b5532016-01-20 00:05:45 -08003392 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3393 * exisiting sensor being disconnected.
3394 *
3395 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3396 *
3397 * {@hide}
3398 */
3399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3400 public static final String
3401 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3402
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003403 /**
Sam Line707f832017-04-13 17:00:55 -07003404 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003405 * @hide
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003406 */
3407 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003408 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003409 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3410
Christopher Tate6597e342015-02-17 12:15:25 -08003411 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003412 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3413 * is about to be performed.
3414 * @hide
3415 */
3416 @SystemApi
3417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3418 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3419 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3420
3421 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003422 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3423 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3424 *
3425 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3426 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003427 * @hide
3428 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003429 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003430 public static final String EXTRA_FORCE_MASTER_CLEAR =
3431 "android.intent.extra.FORCE_MASTER_CLEAR";
3432
3433 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003434 * A broadcast action to trigger a factory reset.
3435 *
3436 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3437 *
3438 * <p>Not for use by third-party applications.
3439 *
3440 * @see #EXTRA_FORCE_MASTER_CLEAR
3441 *
3442 * {@hide}
3443 */
3444 @SystemApi
3445 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3446 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3447
3448 /**
3449 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3450 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3451 *
3452 * <p>Not for use by third-party applications.
3453 *
3454 * @hide
3455 */
3456 @SystemApi
3457 public static final String EXTRA_FORCE_FACTORY_RESET =
3458 "android.intent.extra.FORCE_FACTORY_RESET";
3459
3460 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003461 * Broadcast action: report that a settings element is being restored from backup. The intent
3462 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3463 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3464 * is the value of that settings entry prior to the restore operation. All of these values are
3465 * represented as strings.
3466 *
3467 * <p>This broadcast is sent only for settings provider entries known to require special handling
3468 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3469 * the provider's backup agent implementation.
3470 *
3471 * @see #EXTRA_SETTING_NAME
3472 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3473 * @see #EXTRA_SETTING_NEW_VALUE
3474 * {@hide}
3475 */
3476 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3477
3478 /** {@hide} */
3479 public static final String EXTRA_SETTING_NAME = "setting_name";
3480 /** {@hide} */
3481 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3482 /** {@hide} */
3483 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3484
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003485 /**
3486 * Activity Action: Process a piece of text.
3487 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3488 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3489 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3490 */
3491 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3492 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003493
3494 /**
3495 * Broadcast Action: The sim card state has changed.
3496 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3497 * because TelephonyIntents is an internal class.
3498 * @hide
3499 */
3500 @SystemApi
3501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3502 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3503
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003504 /**
fionaxu90fee272017-03-31 12:45:12 -07003505 * Broadcast Action: indicate that the phone service state has changed.
3506 * The intent will have the following extra values:</p>
3507 * <p>
3508 * @see #EXTRA_VOICE_REG_STATE
3509 * @see #EXTRA_DATA_REG_STATE
3510 * @see #EXTRA_VOICE_ROAMING_TYPE
3511 * @see #EXTRA_DATA_ROAMING_TYPE
3512 * @see #EXTRA_OPERATOR_ALPHA_LONG
3513 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3514 * @see #EXTRA_OPERATOR_NUMERIC
3515 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3516 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3517 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3518 * @see #EXTRA_MANUAL
3519 * @see #EXTRA_VOICE_RADIO_TECH
3520 * @see #EXTRA_DATA_RADIO_TECH
3521 * @see #EXTRA_CSS_INDICATOR
3522 * @see #EXTRA_NETWORK_ID
3523 * @see #EXTRA_SYSTEM_ID
3524 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3525 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3526 * @see #EXTRA_EMERGENCY_ONLY
3527 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3528 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3529 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3530 *
3531 * <p class="note">
3532 * Requires the READ_PHONE_STATE permission.
3533 *
3534 * <p class="note">This is a protected intent that can only be sent by the system.
3535 * @hide
3536 */
3537 @Deprecated
3538 @SystemApi
3539 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3540 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3541
3542 /**
3543 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3544 * state.
3545 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3546 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3547 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3548 * @see android.telephony.ServiceState#STATE_POWER_OFF
3549 * @hide
3550 */
3551 @Deprecated
3552 @SystemApi
3553 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3554
3555 /**
3556 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3557 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3558 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3559 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3560 * @see android.telephony.ServiceState#STATE_POWER_OFF
3561 * @hide
3562 */
3563 @Deprecated
3564 @SystemApi
3565 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3566
3567 /**
3568 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3569 * type.
3570 * @hide
3571 */
3572 @Deprecated
3573 @SystemApi
3574 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3575
3576 /**
3577 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3578 * type.
3579 * @hide
3580 */
3581 @Deprecated
3582 @SystemApi
3583 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3584
3585 /**
3586 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3587 * registered voice operator name in long alphanumeric format.
3588 * {@code null} if the operator name is not known or unregistered.
3589 * @hide
3590 */
3591 @Deprecated
3592 @SystemApi
3593 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3594
3595 /**
3596 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3597 * registered voice operator name in short alphanumeric format.
3598 * {@code null} if the operator name is not known or unregistered.
3599 * @hide
3600 */
3601 @Deprecated
3602 @SystemApi
3603 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3604
3605 /**
3606 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3607 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3608 * network.
3609 * @hide
3610 */
3611 @Deprecated
3612 @SystemApi
3613 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3614
3615 /**
3616 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3617 * registered data operator name in long alphanumeric format.
3618 * {@code null} if the operator name is not known or unregistered.
3619 * @hide
3620 */
3621 @Deprecated
3622 @SystemApi
3623 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3624
3625 /**
3626 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3627 * registered data operator name in short alphanumeric format.
3628 * {@code null} if the operator name is not known or unregistered.
3629 * @hide
3630 */
3631 @Deprecated
3632 @SystemApi
3633 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3634
3635 /**
3636 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3637 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3638 * data operator.
3639 * @hide
3640 */
3641 @Deprecated
3642 @SystemApi
3643 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3644
3645 /**
3646 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3647 * network selection mode is manual.
3648 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3649 * @hide
3650 */
3651 @Deprecated
3652 @SystemApi
3653 public static final String EXTRA_MANUAL = "manual";
3654
3655 /**
3656 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3657 * radio technology.
3658 * @hide
3659 */
3660 @Deprecated
3661 @SystemApi
3662 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3663
3664 /**
3665 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3666 * radio technology.
3667 * @hide
3668 */
3669 @Deprecated
3670 @SystemApi
3671 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3672
3673 /**
3674 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3675 * support on CDMA network.
3676 * Will be {@code true} if support, {@code false} otherwise.
3677 * @hide
3678 */
3679 @Deprecated
3680 @SystemApi
3681 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3682
3683 /**
3684 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3685 * id. {@code Integer.MAX_VALUE} if unknown.
3686 * @hide
3687 */
3688 @Deprecated
3689 @SystemApi
3690 public static final String EXTRA_NETWORK_ID = "networkId";
3691
3692 /**
3693 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3694 * {@code Integer.MAX_VALUE} if unknown.
3695 * @hide
3696 */
3697 @Deprecated
3698 @SystemApi
3699 public static final String EXTRA_SYSTEM_ID = "systemId";
3700
3701 /**
3702 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3703 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3704 * @hide
3705 */
3706 @Deprecated
3707 @SystemApi
3708 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3709
3710 /**
3711 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3712 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3713 * @hide
3714 */
3715 @Deprecated
3716 @SystemApi
3717 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3718
3719 /**
3720 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3721 * only mode.
3722 * {@code true} if in emergency only mode, {@code false} otherwise.
3723 * @hide
3724 */
3725 @Deprecated
3726 @SystemApi
3727 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3728
3729 /**
3730 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3731 * registration state is roaming.
3732 * {@code true} if registration indicates roaming, {@code false} otherwise
3733 * @hide
3734 */
3735 @Deprecated
3736 @SystemApi
3737 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3738 "isDataRoamingFromRegistration";
3739
3740 /**
3741 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3742 * aggregation is in use.
3743 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3744 * @hide
3745 */
3746 @Deprecated
3747 @SystemApi
3748 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3749
3750 /**
3751 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3752 * is reduced from the rsrp threshold while calculating signal strength level.
3753 * @hide
3754 */
3755 @Deprecated
3756 @SystemApi
3757 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3758
3759 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003760 * The name of the extra used to define the text to be processed, as a
3761 * CharSequence. Note that this may be a styled CharSequence, so you must use
3762 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003763 */
3764 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3765 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003766 * 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 +00003767 */
3768 public static final String EXTRA_PROCESS_TEXT_READONLY =
3769 "android.intent.extra.PROCESS_TEXT_READONLY";
3770
Bryce Leebc58f592015-09-25 16:43:01 -07003771 /**
3772 * Broadcast action: reports when a new thermal event has been reached. When the device
3773 * is reaching its maximum temperatue, the thermal level reported
3774 * {@hide}
3775 */
3776 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3777 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3778
3779 /** {@hide} */
3780 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3781
3782 /**
3783 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003784 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003785 * {@hide}
3786 */
3787 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3788
3789 /**
3790 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003791 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003792 * {@hide}
3793 */
3794 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3795
3796 /**
3797 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003798 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003799 * {@hide}
3800 */
3801 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3802
3803
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003804 // ---------------------------------------------------------------------
3805 // ---------------------------------------------------------------------
3806 // Standard intent categories (see addCategory()).
3807
3808 /**
3809 * Set if the activity should be an option for the default action
3810 * (center press) to perform on a piece of data. Setting this will
3811 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003812 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003813 * Intent when initiating an action -- it is for use in intent filters
3814 * specified in packages.
3815 */
3816 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3817 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3818 /**
3819 * Activities that can be safely invoked from a browser must support this
3820 * category. For example, if the user is viewing a web page or an e-mail
3821 * and clicks on a link in the text, the Intent generated execute that
3822 * link will require the BROWSABLE category, so that only activities
3823 * supporting this category will be considered as possible actions. By
3824 * supporting this category, you are promising that there is nothing
3825 * damaging (without user intervention) that can happen by invoking any
3826 * matching Intent.
3827 */
3828 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3829 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3830 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003831 * Categories for activities that can participate in voice interaction.
3832 * An activity that supports this category must be prepared to run with
3833 * no UI shown at all (though in some case it may have a UI shown), and
3834 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3835 */
3836 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3837 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3838 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003839 * Set if the activity should be considered as an alternative action to
3840 * the data the user is currently viewing. See also
3841 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3842 * applies to the selection in a list of items.
3843 *
3844 * <p>Supporting this category means that you would like your activity to be
3845 * displayed in the set of alternative things the user can do, usually as
3846 * part of the current activity's options menu. You will usually want to
3847 * include a specific label in the &lt;intent-filter&gt; of this action
3848 * describing to the user what it does.
3849 *
3850 * <p>The action of IntentFilter with this category is important in that it
3851 * describes the specific action the target will perform. This generally
3852 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3853 * a specific name such as "com.android.camera.action.CROP. Only one
3854 * alternative of any particular action will be shown to the user, so using
3855 * a specific action like this makes sure that your alternative will be
3856 * displayed while also allowing other applications to provide their own
3857 * overrides of that particular action.
3858 */
3859 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3860 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3861 /**
3862 * Set if the activity should be considered as an alternative selection
3863 * action to the data the user has currently selected. This is like
3864 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3865 * of items from which the user can select, giving them alternatives to the
3866 * default action that will be performed on it.
3867 */
3868 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3869 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3870 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003871 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003872 */
3873 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3874 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3875 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003876 * Should be displayed in the top-level launcher.
3877 */
3878 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3879 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3880 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003881 * Indicates an activity optimized for Leanback mode, and that should
3882 * be displayed in the Leanback launcher.
3883 */
3884 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3885 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3886 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003887 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3888 * @hide
3889 */
3890 @SystemApi
3891 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3892 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003893 * Provides information about the package it is in; typically used if
3894 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3895 * a front-door to the user without having to be shown in the all apps list.
3896 */
3897 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3898 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3899 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003900 * This is the home activity, that is the first activity that is displayed
3901 * when the device boots.
3902 */
3903 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3904 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3905 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003906 * This is the home activity that is displayed when the device is finished setting up and ready
3907 * for use.
3908 * @hide
3909 */
3910 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3911 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3912 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003913 * This is the setup wizard activity, that is the first activity that is displayed
3914 * when the user sets up the device for the first time.
3915 * @hide
3916 */
3917 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3918 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3919 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003920 * This activity is a preference panel.
3921 */
3922 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3923 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3924 /**
3925 * This activity is a development preference panel.
3926 */
3927 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3928 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3929 /**
3930 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003931 */
3932 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3933 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3934 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003935 * This activity allows the user to browse and download new applications.
3936 */
3937 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3938 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3939 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003940 * This activity may be exercised by the monkey or other automated test tools.
3941 */
3942 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3943 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3944 /**
3945 * To be used as a test (not part of the normal user experience).
3946 */
3947 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3948 /**
3949 * To be used as a unit test (run through the Test Harness).
3950 */
3951 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3952 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003953 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003954 * experience).
3955 */
3956 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003958 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003959 * Used to indicate that an intent only wants URIs that can be opened with
3960 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3961 * must support at least the columns defined in {@link OpenableColumns} when
3962 * queried.
3963 *
3964 * @see #ACTION_GET_CONTENT
3965 * @see #ACTION_OPEN_DOCUMENT
3966 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003967 */
3968 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3969 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3970
3971 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003972 * Used to indicate that an intent filter can accept files which are not necessarily
3973 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3974 * at least streamable via
3975 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3976 * using one of the stream types exposed via
3977 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3978 *
3979 * @see #ACTION_SEND
3980 * @see #ACTION_SEND_MULTIPLE
3981 */
3982 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3983 public static final String CATEGORY_TYPED_OPENABLE =
3984 "android.intent.category.TYPED_OPENABLE";
3985
3986 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003987 * To be used as code under test for framework instrumentation tests.
3988 */
3989 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3990 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003991 /**
3992 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003993 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3994 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003995 */
3996 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3997 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3998 /**
3999 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004000 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4001 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004002 */
4003 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4004 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004005 /**
4006 * An activity to run when device is inserted into a analog (low end) dock.
4007 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4008 * information, see {@link android.app.UiModeManager}.
4009 */
4010 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4011 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4012
4013 /**
4014 * An activity to run when device is inserted into a digital (high end) dock.
4015 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4016 * information, see {@link android.app.UiModeManager}.
4017 */
4018 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4019 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004020
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004021 /**
4022 * Used to indicate that the activity can be used in a car environment.
4023 */
4024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4025 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4026
Zak Cohendb6ca492017-01-26 14:09:00 -08004027 /**
4028 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4029 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4030 * information, see {@link android.app.UiModeManager}.
4031 */
4032 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4033 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004034 // ---------------------------------------------------------------------
4035 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004036 // Application launch intent categories (see addCategory()).
4037
4038 /**
4039 * Used with {@link #ACTION_MAIN} to launch the browser application.
4040 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004041 * <p>NOTE: This should not be used as the primary key of an Intent,
4042 * since it will not result in the app launching with the correct
4043 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004044 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004045 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004046 */
4047 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4048 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4049
4050 /**
4051 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4052 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004053 * <p>NOTE: This should not be used as the primary key of an Intent,
4054 * since it will not result in the app launching with the correct
4055 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004056 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004057 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004058 */
4059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4060 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4061
4062 /**
4063 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4064 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004065 * <p>NOTE: This should not be used as the primary key of an Intent,
4066 * since it will not result in the app launching with the correct
4067 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004068 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004069 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004070 */
4071 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4072 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4073
4074 /**
4075 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4076 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004077 * <p>NOTE: This should not be used as the primary key of an Intent,
4078 * since it will not result in the app launching with the correct
4079 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004080 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004081 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004082 */
4083 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4084 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4085
4086 /**
4087 * Used with {@link #ACTION_MAIN} to launch the email application.
4088 * The activity should be able to send and receive email.
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_EMAIL = "android.intent.category.APP_EMAIL";
4097
4098 /**
4099 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4100 * The activity should be able to view and manipulate image and video files
4101 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004102 * <p>NOTE: This should not be used as the primary key of an Intent,
4103 * since it will not result in the app launching with the correct
4104 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004105 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004106 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004107 */
4108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4109 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4110
4111 /**
4112 * Used with {@link #ACTION_MAIN} to launch the maps application.
4113 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004114 * <p>NOTE: This should not be used as the primary key of an Intent,
4115 * since it will not result in the app launching with the correct
4116 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004117 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004118 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004119 */
4120 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4121 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4122
4123 /**
4124 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4125 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004126 * <p>NOTE: This should not be used as the primary key of an Intent,
4127 * since it will not result in the app launching with the correct
4128 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004129 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004130 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004131 */
4132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4133 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4134
4135 /**
4136 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004137 * The activity should be able to play, browse, or manipulate music files
4138 * stored on the device.
4139 * <p>NOTE: This should not be used as the primary key of an Intent,
4140 * since it will not result in the app launching with the correct
4141 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004142 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004143 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004144 */
4145 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4146 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4147
4148 // ---------------------------------------------------------------------
4149 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004150 // Standard extra data keys.
4151
4152 /**
4153 * The initial data to place in a newly created record. Use with
4154 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4155 * fields as would be given to the underlying ContentProvider.insert()
4156 * call.
4157 */
4158 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4159
4160 /**
4161 * A constant CharSequence that is associated with the Intent, used with
4162 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4163 * this may be a styled CharSequence, so you must use
4164 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4165 * retrieve it.
4166 */
4167 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4168
4169 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004170 * A constant String that is associated with the Intent, used with
4171 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4172 * as HTML formatted text. Note that you <em>must</em> also supply
4173 * {@link #EXTRA_TEXT}.
4174 */
4175 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4176
4177 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004178 * A content: URI holding a stream of data associated with the Intent,
4179 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004180 */
4181 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4182
4183 /**
4184 * A String[] holding e-mail addresses that should be delivered to.
4185 */
4186 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4187
4188 /**
4189 * A String[] holding e-mail addresses that should be carbon copied.
4190 */
4191 public static final String EXTRA_CC = "android.intent.extra.CC";
4192
4193 /**
4194 * A String[] holding e-mail addresses that should be blind carbon copied.
4195 */
4196 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4197
4198 /**
4199 * A constant string holding the desired subject line of a message.
4200 */
4201 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4202
4203 /**
4204 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004205 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004206 */
4207 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4208
4209 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004210 * An int representing the user id to be used.
4211 *
4212 * @hide
4213 */
4214 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4215
4216 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004217 * An int representing the task id to be retrieved. This is used when a launch from recents is
4218 * intercepted by another action such as credentials confirmation to remember which task should
4219 * be resumed when complete.
4220 *
4221 * @hide
4222 */
4223 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4224
4225 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004226 * An Intent[] describing additional, alternate choices you would like shown with
4227 * {@link #ACTION_CHOOSER}.
4228 *
4229 * <p>An app may be capable of providing several different payload types to complete a
4230 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4231 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4232 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4233 * photo data or a hosted link where the photos can be viewed.</p>
4234 *
4235 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4236 * first/primary/preferred intent in the set. Additional intents specified in
4237 * this extra are ordered; by default intents that appear earlier in the array will be
4238 * preferred over intents that appear later in the array as matches for the same
4239 * target component. To alter this preference, a calling app may also supply
4240 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4241 */
4242 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4243
4244 /**
Adam Powell52c39212016-04-07 15:14:18 -07004245 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4246 * and omitted from a list of components presented to the user.
4247 *
4248 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4249 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4250 * from your own package or other apps from your organization if the idea of sending to those
4251 * targets would be redundant with other app functionality. Filtered components will not
4252 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4253 */
4254 public static final String EXTRA_EXCLUDE_COMPONENTS
4255 = "android.intent.extra.EXCLUDE_COMPONENTS";
4256
4257 /**
4258 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4259 * describing additional high-priority deep-link targets for the chooser to present to the user.
4260 *
4261 * <p>Targets provided in this way will be presented inline with all other targets provided
4262 * by services from other apps. They will be prioritized before other service targets, but
4263 * after those targets provided by sources that the user has manually pinned to the front.</p>
4264 *
4265 * @see #ACTION_CHOOSER
4266 */
4267 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4268
4269 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004270 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4271 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4272 *
4273 * <p>An app preparing an action for another app to complete may wish to allow the user to
4274 * disambiguate between several options for completing the action based on the chosen target
4275 * or otherwise refine the action before it is invoked.
4276 * </p>
4277 *
4278 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4279 * <ul>
4280 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4281 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4282 * chosen target beyond the first</li>
4283 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4284 * should fill in and send once the disambiguation is complete</li>
4285 * </ul>
4286 */
4287 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4288 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4289
4290 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004291 * An {@code ArrayList} of {@code String} annotations describing content for
4292 * {@link #ACTION_CHOOSER}.
4293 *
4294 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4295 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4296 *
4297 * <p>Annotations should describe the major components or topics of the content. It is up to
4298 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4299 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004300 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4301 * character. Performance on customized annotations can suffer, if they are rarely used for
4302 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4303 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004304 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004305 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004306 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004307 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004308 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004309 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004310 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004311 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004312 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004313 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4314 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4315 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4316 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4317 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004318 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004319 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4320 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004321 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004322 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004323 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004324 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004325 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004326 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004327 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004328 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004329 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004330 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004331 * Christmas and Thanksgiving.</li>
4332 * </ul>
4333 */
4334 public static final String EXTRA_CONTENT_ANNOTATIONS
4335 = "android.intent.extra.CONTENT_ANNOTATIONS";
4336
4337 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004338 * A {@link ResultReceiver} used to return data back to the sender.
4339 *
4340 * <p>Used to complete an app-specific
4341 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4342 *
4343 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4344 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4345 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4346 * when the user selects a target component from the chooser. It is up to the recipient
4347 * to send a result to this ResultReceiver to signal that disambiguation is complete
4348 * and that the chooser should invoke the user's choice.</p>
4349 *
4350 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4351 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4352 * to match and fill in the final Intent or ChooserTarget before starting it.
4353 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4354 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4355 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4356 *
4357 * <p>The result code passed to the ResultReceiver should be
4358 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4359 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4360 * the chooser should finish without starting a target.</p>
4361 */
4362 public static final String EXTRA_RESULT_RECEIVER
4363 = "android.intent.extra.RESULT_RECEIVER";
4364
4365 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004366 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004367 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004368 */
4369 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4370
4371 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004372 * A Parcelable[] of {@link Intent} or
4373 * {@link android.content.pm.LabeledIntent} objects as set with
4374 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4375 * a the front of the list of choices, when shown to the user with a
4376 * {@link #ACTION_CHOOSER}.
4377 */
4378 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4379
4380 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004381 * A {@link IntentSender} to start after ephemeral installation success.
4382 * @hide
4383 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004384 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4385
4386 /**
4387 * A {@link IntentSender} to start after ephemeral installation failure.
4388 * @hide
4389 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004390 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4391
4392 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004393 * The host name that triggered an ephemeral resolution.
4394 * @hide
4395 */
4396 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4397
4398 /**
4399 * An opaque token to track ephemeral resolution.
4400 * @hide
4401 */
4402 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4403
4404 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004405 * The version code of the app to install components from.
4406 * @hide
4407 */
4408 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4409
4410 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004411 * The app that triggered the ephemeral installation.
4412 * @hide
4413 */
4414 public static final String EXTRA_CALLING_PACKAGE
4415 = "android.intent.extra.CALLING_PACKAGE";
4416
4417 /**
4418 * Optional calling app provided bundle containing additional launch information the
4419 * installer may use.
4420 * @hide
4421 */
4422 public static final String EXTRA_VERIFICATION_BUNDLE
4423 = "android.intent.extra.VERIFICATION_BUNDLE";
4424
4425 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004426 * A Bundle forming a mapping of potential target package names to different extras Bundles
4427 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4428 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4429 * be currently installed on the device.
4430 *
4431 * <p>An application may choose to provide alternate extras for the case where a user
4432 * selects an activity from a predetermined set of target packages. If the activity
4433 * the user selects from the chooser belongs to a package with its package name as
4434 * a key in this bundle, the corresponding extras for that package will be merged with
4435 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4436 * extra has the same key as an extra already present in the intent it will overwrite
4437 * the extra from the intent.</p>
4438 *
4439 * <p><em>Examples:</em>
4440 * <ul>
4441 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4442 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4443 * parameters for that target.</li>
4444 * <li>An application may offer additional metadata for known targets of a given intent
4445 * to pass along information only relevant to that target such as account or content
4446 * identifiers already known to that application.</li>
4447 * </ul></p>
4448 */
4449 public static final String EXTRA_REPLACEMENT_EXTRAS =
4450 "android.intent.extra.REPLACEMENT_EXTRAS";
4451
4452 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004453 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4454 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4455 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4456 * {@link ComponentName} of the chosen component.
4457 *
4458 * <p>In some situations this callback may never come, for example if the user abandons
4459 * the chooser, switches to another task or any number of other reasons. Apps should not
4460 * be written assuming that this callback will always occur.</p>
4461 */
4462 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4463 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4464
4465 /**
4466 * The {@link ComponentName} chosen by the user to complete an action.
4467 *
4468 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4469 */
4470 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4471
4472 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004473 * A {@link android.view.KeyEvent} object containing the event that
4474 * triggered the creation of the Intent it is in.
4475 */
4476 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4477
4478 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004479 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4480 * before shutting down.
4481 *
4482 * {@hide}
4483 */
4484 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4485
4486 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004487 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4488 * requested by the user.
4489 *
4490 * {@hide}
4491 */
4492 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4493 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4494
4495 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004496 * 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 -07004497 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4498 * of restarting the application.
4499 */
4500 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4501
4502 /**
4503 * A String holding the phone number originally entered in
4504 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4505 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4506 */
4507 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004508
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004509 /**
4510 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4511 * intents to supply the uid the package had been assigned. Also an optional
4512 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4513 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4514 * purpose.
4515 */
4516 public static final String EXTRA_UID = "android.intent.extra.UID";
4517
4518 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004519 * @hide String array of package names.
4520 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004521 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004522 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4523
4524 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004525 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4526 * intents to indicate whether this represents a full uninstall (removing
4527 * both the code and its data) or a partial uninstall (leaving its data,
4528 * implying that this is an update).
4529 */
4530 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004531
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004532 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004533 * @hide
4534 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4535 * intents to indicate that at this point the package has been removed for
4536 * all users on the device.
4537 */
4538 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4539 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4540
4541 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004542 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4543 * intents to indicate that this is a replacement of the package, so this
4544 * broadcast will immediately be followed by an add broadcast for a
4545 * different version of the same package.
4546 */
4547 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004548
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004549 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004550 * Used as an int extra field in {@link android.app.AlarmManager} intents
4551 * to tell the application being invoked how many pending alarms are being
4552 * delievered with the intent. For one-shot alarms this will always be 1.
4553 * For recurring alarms, this might be greater than 1 if the device was
4554 * asleep or powered off at the time an earlier alarm would have been
4555 * delivered.
4556 */
4557 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004558
Jacek Surazski86b6c532009-05-13 14:38:28 +02004559 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004560 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4561 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004562 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4563 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004564 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4565 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4566 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004567 */
4568 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4569
4570 /**
4571 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4572 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004573 */
4574 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4575
4576 /**
4577 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4578 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004579 */
4580 public static final int EXTRA_DOCK_STATE_DESK = 1;
4581
4582 /**
4583 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4584 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004585 */
4586 public static final int EXTRA_DOCK_STATE_CAR = 2;
4587
4588 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004589 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4590 * to represent that the phone is in a analog (low end) dock.
4591 */
4592 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4593
4594 /**
4595 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4596 * to represent that the phone is in a digital (high end) dock.
4597 */
4598 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4599
4600 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004601 * Boolean that can be supplied as meta-data with a dock activity, to
4602 * indicate that the dock should take over the home key when it is active.
4603 */
4604 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004605
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004606 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004607 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4608 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004609 */
4610 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4611
4612 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004613 * Used in the extra field in the remote intent. It's astring token passed with the
4614 * remote intent.
4615 */
4616 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4617 "android.intent.extra.remote_intent_token";
4618
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004619 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004620 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004621 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004622 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004623 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004624 "android.intent.extra.changed_component_name";
4625
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004626 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004627 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004628 * and contains a string array of all of the components that have changed. If
4629 * the state of the overall package has changed, then it will contain an entry
4630 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004631 */
4632 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4633 "android.intent.extra.changed_component_name_list";
4634
4635 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004636 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004637 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004638 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4639 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4640 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004641 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004642 */
4643 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4644 "android.intent.extra.changed_package_list";
4645
4646 /**
4647 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004648 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4649 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004650 * and contains an integer array of uids of all of the components
4651 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004652 */
4653 public static final String EXTRA_CHANGED_UID_LIST =
4654 "android.intent.extra.changed_uid_list";
4655
4656 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004657 * @hide
4658 * Magic extra system code can use when binding, to give a label for
4659 * who it is that has bound to a service. This is an integer giving
4660 * a framework string resource that can be displayed to the user.
4661 */
4662 public static final String EXTRA_CLIENT_LABEL =
4663 "android.intent.extra.client_label";
4664
4665 /**
4666 * @hide
4667 * Magic extra system code can use when binding, to give a PendingIntent object
4668 * that can be launched for the user to disable the system's use of this
4669 * service.
4670 */
4671 public static final String EXTRA_CLIENT_INTENT =
4672 "android.intent.extra.client_intent";
4673
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004674 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004675 * Extra used to indicate that an intent should only return data that is on
4676 * the local device. This is a boolean extra; the default is false. If true,
4677 * an implementation should only allow the user to select data that is
4678 * already on the device, not requiring it be downloaded from a remote
4679 * service when opened.
4680 *
4681 * @see #ACTION_GET_CONTENT
4682 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004683 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004684 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004685 */
4686 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004687 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004688
Amith Yamasani13593602012-03-22 16:16:17 -07004689 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004690 * Extra used to indicate that an intent can allow the user to select and
4691 * return multiple items. This is a boolean extra; the default is false. If
4692 * true, an implementation is allowed to present the user with a UI where
4693 * they can pick multiple items that are all returned to the caller. When
4694 * this happens, they should be returned as the {@link #getClipData()} part
4695 * of the result Intent.
4696 *
4697 * @see #ACTION_GET_CONTENT
4698 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004699 */
4700 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004701 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004702
4703 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004704 * The integer userHandle carried with broadcast intents related to addition, removal and
4705 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4706 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4707 *
Amith Yamasani13593602012-03-22 16:16:17 -07004708 * @hide
4709 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004710 public static final String EXTRA_USER_HANDLE =
4711 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004712
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004713 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004714 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4715 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4716 */
4717 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004718 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004719
4720 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004721 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004722 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4723 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004724 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004725 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4726
4727 /**
4728 * Extra sent in the intent to the BroadcastReceiver that handles
4729 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4730 * the restrictions as key/value pairs.
4731 */
4732 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4733 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004734
Amith Yamasani86118ba2013-03-28 14:33:16 -07004735 /**
4736 * Extra used in the response from a BroadcastReceiver that handles
4737 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4738 */
4739 public static final String EXTRA_RESTRICTIONS_INTENT =
4740 "android.intent.extra.restrictions_intent";
4741
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004742 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004743 * Extra used to communicate a set of acceptable MIME types. The type of the
4744 * extra is {@code String[]}. Values may be a combination of concrete MIME
4745 * types (such as "image/png") and/or partial MIME types (such as
4746 * "audio/*").
4747 *
4748 * @see #ACTION_GET_CONTENT
4749 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004750 */
4751 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4752
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004753 /**
4754 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4755 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004756 * When this is true, hardware devices can use this information to determine that
4757 * they shouldn't do a complete shutdown of their device since this is not a
4758 * complete shutdown down to the kernel, but only user space restarting.
4759 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004760 */
4761 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4762 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4763
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004764 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004765 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4766 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4767 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4768 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004769 *
4770 * @hide for internal use only.
4771 */
4772 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4773 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004774 /** @hide */
4775 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4776 /** @hide */
4777 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4778 /** @hide */
4779 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004780
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004781 /** {@hide} */
4782 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4783
qingxi240c2bb2017-04-12 17:31:18 -07004784 /**
4785 * {@hide}
4786 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4787 */
Rubin Xue8490f12015-06-25 12:17:48 +01004788 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4789
Santos Cordon15a13782015-03-31 18:32:31 -07004790 /**
qingxi240c2bb2017-04-12 17:31:18 -07004791 * {@hide}
4792 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4793 * reset for the device with eSIM. This extra will be sent together with
4794 * {@link #ACTION_FACTORY_RESET}
4795 */
4796 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4797
4798 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004799 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4800 * activation request.
4801 * TODO: Add information about the structure and response data used with the pending intent.
4802 * @hide
4803 */
4804 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4805 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4806
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004807 /**
4808 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004809 *
4810 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004811 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004812 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004813 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4814
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004815 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004816 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4817 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4818 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004819 *
4820 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004821 * @see #ACTION_QUICK_VIEW
4822 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004823 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004824 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004825 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4826 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004827
4828 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004829 * An optional extra of {@code String[]} indicating which quick view features should be made
4830 * available to the user in the quick view UI while handing a
4831 * {@link Intent#ACTION_QUICK_VIEW} intent.
4832 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4833 * Quick viewer can implement features not listed below.
4834 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4835 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4836 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4837 * <p>
4838 * Requirements:
4839 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4840 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4841 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4842 * internal policies.
4843 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4844 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4845 * disable or hide features.
4846 *
4847 * @see #ACTION_QUICK_VIEW
4848 */
4849 public static final String EXTRA_QUICK_VIEW_FEATURES =
4850 "android.intent.extra.QUICK_VIEW_FEATURES";
4851
4852 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004853 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004854 * When a profile goes into quiet mode, all apps in the profile are killed and the
4855 * profile user is stopped. Widgets originating from the profile are masked, and app
4856 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004857 */
4858 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004859
4860 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004861 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004862 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004863 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4864 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004865 *
4866 * @hide
4867 */
4868 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4869 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4870
4871 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004872 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4873 * whether to show the chooser or not when there is only one application available
4874 * to choose from.
4875 *
4876 * @hide
4877 */
4878 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4879 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4880
4881 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004882 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004883 * to represent that a video codec is allowed to use.
4884 *
4885 * @hide
4886 */
4887 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4888
4889 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004890 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004891 * to represent that a audio codec is allowed to use.
4892 *
4893 * @hide
4894 */
4895 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4896
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004897 // ---------------------------------------------------------------------
4898 // ---------------------------------------------------------------------
4899 // Intent flags (see mFlags variable).
4900
Tor Norbyed9273d62013-05-30 15:59:53 -07004901 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004902 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004903 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4904 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004905 @Retention(RetentionPolicy.SOURCE)
4906 public @interface GrantUriMode {}
4907
Jeff Sharkey846318a2014-04-04 12:12:41 -07004908 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004909 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004910 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4911 @Retention(RetentionPolicy.SOURCE)
4912 public @interface AccessUriMode {}
4913
4914 /**
4915 * Test if given mode flags specify an access mode, which must be at least
4916 * read and/or write.
4917 *
4918 * @hide
4919 */
4920 public static boolean isAccessUriMode(int modeFlags) {
4921 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4922 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4923 }
4924
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004925 /** @hide */
4926 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4927 FLAG_GRANT_READ_URI_PERMISSION,
4928 FLAG_GRANT_WRITE_URI_PERMISSION,
4929 FLAG_FROM_BACKGROUND,
4930 FLAG_DEBUG_LOG_RESOLUTION,
4931 FLAG_EXCLUDE_STOPPED_PACKAGES,
4932 FLAG_INCLUDE_STOPPED_PACKAGES,
4933 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
4934 FLAG_GRANT_PREFIX_URI_PERMISSION,
4935 FLAG_DEBUG_TRIAGED_MISSING,
4936 FLAG_IGNORE_EPHEMERAL,
4937 FLAG_ACTIVITY_NO_HISTORY,
4938 FLAG_ACTIVITY_SINGLE_TOP,
4939 FLAG_ACTIVITY_NEW_TASK,
4940 FLAG_ACTIVITY_MULTIPLE_TASK,
4941 FLAG_ACTIVITY_CLEAR_TOP,
4942 FLAG_ACTIVITY_FORWARD_RESULT,
4943 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4944 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4945 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4946 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4947 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4948 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4949 FLAG_ACTIVITY_NEW_DOCUMENT,
4950 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4951 FLAG_ACTIVITY_NO_USER_ACTION,
4952 FLAG_ACTIVITY_REORDER_TO_FRONT,
4953 FLAG_ACTIVITY_NO_ANIMATION,
4954 FLAG_ACTIVITY_CLEAR_TASK,
4955 FLAG_ACTIVITY_TASK_ON_HOME,
4956 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
4957 FLAG_ACTIVITY_LAUNCH_ADJACENT,
4958 FLAG_RECEIVER_REGISTERED_ONLY,
4959 FLAG_RECEIVER_REPLACE_PENDING,
4960 FLAG_RECEIVER_FOREGROUND,
4961 FLAG_RECEIVER_NO_ABORT,
4962 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
4963 FLAG_RECEIVER_BOOT_UPGRADE,
4964 FLAG_RECEIVER_INCLUDE_BACKGROUND,
4965 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
4966 FLAG_RECEIVER_FROM_SHELL,
4967 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
4968 })
4969 @Retention(RetentionPolicy.SOURCE)
4970 public @interface Flags {}
4971
4972 /** @hide */
4973 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4974 FLAG_FROM_BACKGROUND,
4975 FLAG_DEBUG_LOG_RESOLUTION,
4976 FLAG_EXCLUDE_STOPPED_PACKAGES,
4977 FLAG_INCLUDE_STOPPED_PACKAGES,
4978 FLAG_DEBUG_TRIAGED_MISSING,
4979 FLAG_IGNORE_EPHEMERAL,
4980 FLAG_ACTIVITY_NO_HISTORY,
4981 FLAG_ACTIVITY_SINGLE_TOP,
4982 FLAG_ACTIVITY_NEW_TASK,
4983 FLAG_ACTIVITY_MULTIPLE_TASK,
4984 FLAG_ACTIVITY_CLEAR_TOP,
4985 FLAG_ACTIVITY_FORWARD_RESULT,
4986 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4987 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4988 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4989 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4990 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4991 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4992 FLAG_ACTIVITY_NEW_DOCUMENT,
4993 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4994 FLAG_ACTIVITY_NO_USER_ACTION,
4995 FLAG_ACTIVITY_REORDER_TO_FRONT,
4996 FLAG_ACTIVITY_NO_ANIMATION,
4997 FLAG_ACTIVITY_CLEAR_TASK,
4998 FLAG_ACTIVITY_TASK_ON_HOME,
4999 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5000 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5001 FLAG_RECEIVER_REGISTERED_ONLY,
5002 FLAG_RECEIVER_REPLACE_PENDING,
5003 FLAG_RECEIVER_FOREGROUND,
5004 FLAG_RECEIVER_NO_ABORT,
5005 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5006 FLAG_RECEIVER_BOOT_UPGRADE,
5007 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5008 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5009 FLAG_RECEIVER_FROM_SHELL,
5010 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5011 })
5012 @Retention(RetentionPolicy.SOURCE)
5013 public @interface MutableFlags {}
5014
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005015 /**
5016 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005017 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005018 * specified in its ClipData. When applying to an Intent's ClipData,
5019 * all URIs as well as recursive traversals through data or other ClipData
5020 * in Intent items will be granted; only the grant flags of the top-level
5021 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005022 */
5023 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5024 /**
5025 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005026 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005027 * specified in its ClipData. When applying to an Intent's ClipData,
5028 * all URIs as well as recursive traversals through data or other ClipData
5029 * in Intent items will be granted; only the grant flags of the top-level
5030 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005031 */
5032 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5033 /**
5034 * Can be set by the caller to indicate that this Intent is coming from
5035 * a background operation, not from direct user interaction.
5036 */
5037 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5038 /**
5039 * A flag you can enable for debugging: when set, log messages will be
5040 * printed during the resolution of this intent to show you what has
5041 * been found to create the final resolved list.
5042 */
5043 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005044 /**
5045 * If set, this intent will not match any components in packages that
5046 * are currently stopped. If this is not set, then the default behavior
5047 * is to include such applications in the result.
5048 */
5049 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5050 /**
5051 * If set, this intent will always match any components in packages that
5052 * are currently stopped. This is the default behavior when
5053 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5054 * flags are set, this one wins (it allows overriding of exclude for
5055 * places where the framework may automatically set the exclude flag).
5056 */
5057 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005058
5059 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005060 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005061 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005062 * persisted across device reboots until explicitly revoked with
5063 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5064 * grant for possible persisting; the receiving application must call
5065 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5066 * actually persist.
5067 *
5068 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5069 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5070 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005071 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005072 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005073 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005074
5075 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005076 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5077 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5078 * applies to any URI that is a prefix match against the original granted
5079 * URI. (Without this flag, the URI must match exactly for access to be
5080 * granted.) Another URI is considered a prefix match only when scheme,
5081 * authority, and all path segments defined by the prefix are an exact
5082 * match.
5083 */
5084 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5085
5086 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005087 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005088 * homework and verified that they correctly handle packages and components
5089 * that come and go over time. In particular:
5090 * <ul>
5091 * <li>Apps installed on external storage, which will appear to be
5092 * uninstalled while the the device is ejected.
5093 * <li>Apps with encryption unaware components, which will appear to not
5094 * exist while the device is locked.
5095 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005096 *
5097 * @hide
5098 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005099 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005100
5101 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005102 * Internal flag used to indicate ephemeral applications should not be
5103 * considered when resolving the intent.
5104 *
5105 * @hide
5106 */
5107 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5108
5109 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005110 * If set, the new activity is not kept in the history stack. As soon as
5111 * the user navigates away from it, the activity is finished. This may also
5112 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5113 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005114 *
5115 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5116 * is never invoked when the current activity starts a new activity which
5117 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005118 */
5119 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5120 /**
5121 * If set, the activity will not be launched if it is already running
5122 * at the top of the history stack.
5123 */
5124 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5125 /**
5126 * If set, this activity will become the start of a new task on this
5127 * history stack. A task (from the activity that started it to the
5128 * next task activity) defines an atomic group of activities that the
5129 * user can move to. Tasks can be moved to the foreground and background;
5130 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005131 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005132 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5133 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005134 *
5135 * <p>This flag is generally used by activities that want
5136 * to present a "launcher" style behavior: they give the user a list of
5137 * separate things that can be done, which otherwise run completely
5138 * independently of the activity launching them.
5139 *
5140 * <p>When using this flag, if a task is already running for the activity
5141 * you are now starting, then a new activity will not be started; instead,
5142 * the current task will simply be brought to the front of the screen with
5143 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5144 * to disable this behavior.
5145 *
5146 * <p>This flag can not be used when the caller is requesting a result from
5147 * the activity being launched.
5148 */
5149 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5150 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005151 * This flag is used to create a new task and launch an activity into it.
5152 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5153 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5154 * search through existing tasks for ones matching this Intent. Only if no such
5155 * task is found would a new task be created. When paired with
5156 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5157 * the search for a matching task and unconditionally start a new task.
5158 *
5159 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5160 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005161 * top-level application launcher.</strong> Used in conjunction with
5162 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5163 * behavior of bringing an existing task to the foreground. When set,
5164 * a new task is <em>always</em> started to host the Activity for the
5165 * Intent, regardless of whether there is already an existing task running
5166 * the same thing.
5167 *
5168 * <p><strong>Because the default system does not include graphical task management,
5169 * you should not use this flag unless you provide some way for a user to
5170 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005171 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005172 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5173 * creating new document tasks.
5174 *
5175 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005176 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 *
Scott Main7aee61f2011-02-08 11:25:01 -08005178 * <p>See
5179 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5180 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005181 *
5182 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5183 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005184 */
5185 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5186 /**
5187 * If set, and the activity being launched is already running in the
5188 * current task, then instead of launching a new instance of that activity,
5189 * all of the other activities on top of it will be closed and this Intent
5190 * will be delivered to the (now on top) old activity as a new Intent.
5191 *
5192 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5193 * If D calls startActivity() with an Intent that resolves to the component
5194 * of activity B, then C and D will be finished and B receive the given
5195 * Intent, resulting in the stack now being: A, B.
5196 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005197 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005198 * either receive the new intent you are starting here in its
5199 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005200 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005201 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5202 * the same intent, then it will be finished and re-created; for all other
5203 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5204 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005205 *
5206 * <p>This launch mode can also be used to good effect in conjunction with
5207 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5208 * of a task, it will bring any currently running instance of that task
5209 * to the foreground, and then clear it to its root state. This is
5210 * especially useful, for example, when launching an activity from the
5211 * notification manager.
5212 *
Scott Main7aee61f2011-02-08 11:25:01 -08005213 * <p>See
5214 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5215 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005216 */
5217 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5218 /**
5219 * If set and this intent is being used to launch a new activity from an
5220 * existing one, then the reply target of the existing activity will be
5221 * transfered to the new activity. This way the new activity can call
5222 * {@link android.app.Activity#setResult} and have that result sent back to
5223 * the reply target of the original activity.
5224 */
5225 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5226 /**
5227 * If set and this intent is being used to launch a new activity from an
5228 * existing one, the current activity will not be counted as the top
5229 * activity for deciding whether the new intent should be delivered to
5230 * the top instead of starting a new one. The previous activity will
5231 * be used as the top, with the assumption being that the current activity
5232 * will finish itself immediately.
5233 */
5234 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5235 /**
5236 * If set, the new activity is not kept in the list of recently launched
5237 * activities.
5238 */
5239 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5240 /**
5241 * This flag is not normally set by application code, but set for you by
5242 * the system as described in the
5243 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5244 * launchMode} documentation for the singleTask mode.
5245 */
5246 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5247 /**
5248 * If set, and this activity is either being started in a new task or
5249 * bringing to the top an existing task, then it will be launched as
5250 * the front door of the task. This will result in the application of
5251 * any affinities needed to have that task in the proper state (either
5252 * moving activities to or from it), or simply resetting that task to
5253 * its initial state if needed.
5254 */
5255 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5256 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005257 * This flag is not normally set by application code, but set for you by
5258 * the system if this activity is being launched from history
5259 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005260 */
5261 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005262 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005263 * @deprecated As of API 21 this performs identically to
5264 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005265 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005266 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005267 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005268 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005269 * This flag is used to open a document into a new task rooted at the activity launched
5270 * by this Intent. Through the use of this flag, or its equivalent attribute,
5271 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005272 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005273 *
Craig Mautner026596b2014-05-21 15:35:44 -07005274 * <p>The use of the activity attribute form of this,
5275 * {@link android.R.attr#documentLaunchMode}, is
5276 * preferred over the Intent flag described here. The attribute form allows the
5277 * Activity to specify multiple document behavior for all launchers of the Activity
5278 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005279 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005280 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5281 * it is kept after the activity is finished is different than the use of
5282 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5283 * this flag is being used to create a new recents entry, then by default that entry
5284 * will be removed once the activity is finished. You can modify this behavior with
5285 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5286 *
Craig Mautner026596b2014-05-21 15:35:44 -07005287 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5288 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5289 * equivalent of the Activity manifest specifying {@link
5290 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5291 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5292 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005293 *
Craig Mautner026596b2014-05-21 15:35:44 -07005294 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005295 *
Craig Mautner026596b2014-05-21 15:35:44 -07005296 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005297 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5298 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005299 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005300 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005301 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005302 * callback from occurring on the current frontmost activity before it is
5303 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005304 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005305 * <p>Typically, an activity can rely on that callback to indicate that an
5306 * explicit user action has caused their activity to be moved out of the
5307 * foreground. The callback marks an appropriate point in the activity's
5308 * lifecycle for it to dismiss any notifications that it intends to display
5309 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005310 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005311 * <p>If an activity is ever started via any non-user-driven events such as
5312 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5313 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005314 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005315 */
5316 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005317 /**
5318 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5319 * this flag will cause the launched activity to be brought to the front of its
5320 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005321 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005322 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5323 * If D calls startActivity() with an Intent that resolves to the component
5324 * of activity B, then B will be brought to the front of the history stack,
5325 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005326 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005327 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005328 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005329 */
5330 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005331 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005332 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5333 * this flag will prevent the system from applying an activity transition
5334 * animation to go to the next activity state. This doesn't mean an
5335 * animation will never run -- if another activity change happens that doesn't
5336 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005337 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005338 * when you are going to do a series of activity operations but the
5339 * animation seen by the user shouldn't be driven by the first activity
5340 * change but rather a later one.
5341 */
5342 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5343 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005344 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5345 * this flag will cause any existing task that would be associated with the
5346 * activity to be cleared before the activity is started. That is, the activity
5347 * becomes the new root of an otherwise empty task, and any old activities
5348 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5349 */
5350 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5351 /**
5352 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5353 * this flag will cause a newly launching task to be placed on top of the current
5354 * home activity task (if there is one). That is, pressing back from the task
5355 * will always return the user to home even if that was not the last activity they
5356 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5357 */
5358 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5359 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005360 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5361 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005362 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005363 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005364 * this flag. When set and the task's activity is finished, the recents
5365 * entry will remain in the interface for the user to re-launch it, like a
5366 * recents entry for a top-level application.
5367 * <p>
5368 * The receiving activity can override this request with
5369 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5370 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005371 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005372 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005373 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005374
5375 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005376 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5377 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005378 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5379 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005380 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005381 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005382
5383 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005384 * If set, when sending a broadcast only registered receivers will be
5385 * called -- no BroadcastReceiver components will be launched.
5386 */
5387 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005388 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005389 * If set, when sending a broadcast the new broadcast will replace
5390 * any existing pending broadcast that matches it. Matching is defined
5391 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5392 * true for the intents of the two broadcasts. When a match is found,
5393 * the new broadcast (and receivers associated with it) will replace the
5394 * existing one in the pending broadcast list, remaining at the same
5395 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005396 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005397 * <p>This flag is most typically used with sticky broadcasts, which
5398 * only care about delivering the most recent values of the broadcast
5399 * to their receivers.
5400 */
5401 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5402 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005403 * If set, when sending a broadcast the recipient is allowed to run at
5404 * foreground priority, with a shorter timeout interval. During normal
5405 * broadcasts the receivers are not automatically hoisted out of the
5406 * background priority class.
5407 */
5408 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5409 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005410 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5411 * They can still propagate results through to later receivers, but they can not prevent
5412 * later receivers from seeing the broadcast.
5413 */
5414 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5415 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005416 * If set, when sending a broadcast <i>before boot has completed</i> only
5417 * registered receivers will be called -- no BroadcastReceiver components
5418 * will be launched. Sticky intent state will be recorded properly even
5419 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5420 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005421 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005422 * <p>This flag is only for use by system sevices as a convenience to
5423 * avoid having to implement a more complex mechanism around detection
5424 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005425 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005426 * @hide
5427 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005428 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005429 /**
5430 * Set when this broadcast is for a boot upgrade, a special mode that
5431 * allows the broadcast to be sent before the system is ready and launches
5432 * the app process with no providers running in it.
5433 * @hide
5434 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005435 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005436 /**
5437 * If set, the broadcast will always go to manifest receivers in background (cached
5438 * or not running) apps, regardless of whether that would be done by default. By
5439 * default they will only receive broadcasts if the broadcast has specified an
5440 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005441 *
5442 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5443 * the broadcast code there must also be changed to match.
5444 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005445 * @hide
5446 */
5447 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5448 /**
5449 * If set, the broadcast will never go to manifest receivers in background (cached
5450 * or not running) apps, regardless of whether that would be done by default. By
5451 * default they will receive broadcasts if the broadcast has specified an
5452 * explicit component or package name.
5453 * @hide
5454 */
5455 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005456 /**
5457 * If set, this broadcast is being sent from the shell.
5458 * @hide
5459 */
5460 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005461
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005462 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005463 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5464 * will not receive broadcasts.
5465 *
5466 * <em>This flag has no effect when used by an Instant App.</em>
5467 */
5468 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5469
5470 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005471 * @hide Flags that can't be changed with PendingIntent.
5472 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005473 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5474 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5475 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005476
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005477 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005478 // ---------------------------------------------------------------------
5479 // toUri() and parseUri() options.
5480
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005481 /** @hide */
5482 @IntDef(flag = true, prefix = { "URI_" }, value = {
5483 URI_ALLOW_UNSAFE,
5484 URI_ANDROID_APP_SCHEME,
5485 URI_INTENT_SCHEME,
5486 })
5487 @Retention(RetentionPolicy.SOURCE)
5488 public @interface UriFlags {}
5489
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005490 /**
5491 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5492 * always has the "intent:" scheme. This syntax can be used when you want
5493 * to later disambiguate between URIs that are intended to describe an
5494 * Intent vs. all others that should be treated as raw URIs. When used
5495 * with {@link #parseUri}, any other scheme will result in a generic
5496 * VIEW action for that raw URI.
5497 */
5498 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005499
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005500 /**
5501 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5502 * always has the "android-app:" scheme. This is a variation of
5503 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5504 * http/https URI being delivered to a specific package name. The format
5505 * is:
5506 *
5507 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005508 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005509 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005510 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5511 * you must also include a scheme; including a path also requires both a host and a scheme.
5512 * The final #Intent; fragment can be used without a scheme, host, or path.
5513 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005514 * used with intents that have a {@link #setSelector}, since the base intent
5515 * will always have an explicit package name.</p>
5516 *
5517 * <p>Some examples of how this scheme maps to Intent objects:</p>
5518 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5519 * <colgroup align="left" />
5520 * <colgroup align="left" />
5521 * <thead>
5522 * <tr><th>URI</th> <th>Intent</th></tr>
5523 * </thead>
5524 *
5525 * <tbody>
5526 * <tr><td><code>android-app://com.example.app</code></td>
5527 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5528 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5529 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5530 * </table></td>
5531 * </tr>
5532 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5533 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5534 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5535 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5536 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5537 * </table></td>
5538 * </tr>
5539 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5540 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5541 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5542 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5543 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5544 * </table></td>
5545 * </tr>
5546 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5547 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5548 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5549 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5550 * </table></td>
5551 * </tr>
5552 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5553 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5554 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5555 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5556 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5557 * </table></td>
5558 * </tr>
5559 * <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>
5560 * <td><table border="" style="margin:0" >
5561 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5562 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5563 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5564 * </table></td>
5565 * </tr>
5566 * </tbody>
5567 * </table>
5568 */
5569 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5570
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005571 /**
5572 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5573 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5574 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5575 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5576 * generated Intent can not cause unexpected data access to happen.
5577 *
5578 * <p>If you do not trust the source of the URI being parsed, you should still do further
5579 * processing to protect yourself from it. In particular, when using it to start an
5580 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5581 * that can handle it.</p>
5582 */
5583 public static final int URI_ALLOW_UNSAFE = 1<<2;
5584
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005585 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005586
5587 private String mAction;
5588 private Uri mData;
5589 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005590 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005591 private ComponentName mComponent;
5592 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005593 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005594 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005595 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005596 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005597 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005598 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005599 /** Token to track instant app launches. Local only; do not copy cross-process. */
5600 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005601
5602 // ---------------------------------------------------------------------
5603
Makoto Onuki97f82f22017-05-31 16:20:21 -07005604 private static final int COPY_MODE_ALL = 0;
5605 private static final int COPY_MODE_FILTER = 1;
5606 private static final int COPY_MODE_HISTORY = 2;
5607
5608 /** @hide */
5609 @IntDef(value = {COPY_MODE_ALL, COPY_MODE_FILTER, COPY_MODE_HISTORY})
5610 @Retention(RetentionPolicy.SOURCE)
5611 public @interface CopyMode {}
5612
5613
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005614 /**
5615 * Create an empty intent.
5616 */
5617 public Intent() {
5618 }
5619
5620 /**
5621 * Copy constructor.
5622 */
5623 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005624 this(o, COPY_MODE_ALL);
5625 }
5626
5627 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 this.mAction = o.mAction;
5629 this.mData = o.mData;
5630 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005631 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005632 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005633
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005634 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005635 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005636 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005637
5638 if (copyMode != COPY_MODE_FILTER) {
5639 this.mFlags = o.mFlags;
5640 this.mContentUserHint = o.mContentUserHint;
5641 this.mLaunchToken = o.mLaunchToken;
5642 if (o.mSourceBounds != null) {
5643 this.mSourceBounds = new Rect(o.mSourceBounds);
5644 }
5645 if (o.mSelector != null) {
5646 this.mSelector = new Intent(o.mSelector);
5647 }
5648
5649 if (copyMode != COPY_MODE_HISTORY) {
5650 if (o.mExtras != null) {
5651 this.mExtras = new Bundle(o.mExtras);
5652 }
5653 if (o.mClipData != null) {
5654 this.mClipData = new ClipData(o.mClipData);
5655 }
5656 } else {
5657 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5658 this.mExtras = Bundle.STRIPPED;
5659 }
5660
5661 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5662 // history.
5663 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005664 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005665 }
5666
5667 @Override
5668 public Object clone() {
5669 return new Intent(this);
5670 }
5671
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005672 /**
5673 * Make a clone of only the parts of the Intent that are relevant for
5674 * filter matching: the action, data, type, component, and categories.
5675 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005676 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005677 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005678 }
5679
5680 /**
5681 * Create an intent with a given action. All other fields (data, type,
5682 * class) are null. Note that the action <em>must</em> be in a
5683 * namespace because Intents are used globally in the system -- for
5684 * example the system VIEW action is android.intent.action.VIEW; an
5685 * application's custom action would be something like
5686 * com.google.app.myapp.CUSTOM_ACTION.
5687 *
5688 * @param action The Intent action, such as ACTION_VIEW.
5689 */
5690 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005691 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005692 }
5693
5694 /**
5695 * Create an intent with a given action and for a given data url. Note
5696 * that the action <em>must</em> be in a namespace because Intents are
5697 * used globally in the system -- for example the system VIEW action is
5698 * android.intent.action.VIEW; an application's custom action would be
5699 * something like com.google.app.myapp.CUSTOM_ACTION.
5700 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005701 * <p><em>Note: scheme and host name matching in the Android framework is
5702 * case-sensitive, unlike the formal RFC. As a result,
5703 * you should always ensure that you write your Uri with these elements
5704 * using lower case letters, and normalize any Uris you receive from
5705 * outside of Android to ensure the scheme and host is lower case.</em></p>
5706 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005707 * @param action The Intent action, such as ACTION_VIEW.
5708 * @param uri The Intent data URI.
5709 */
5710 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005711 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005712 mData = uri;
5713 }
5714
5715 /**
5716 * Create an intent for a specific component. All other fields (action, data,
5717 * type, class) are null, though they can be modified later with explicit
5718 * calls. This provides a convenient way to create an intent that is
5719 * intended to execute a hard-coded class name, rather than relying on the
5720 * system to find an appropriate class for you; see {@link #setComponent}
5721 * for more information on the repercussions of this.
5722 *
5723 * @param packageContext A Context of the application package implementing
5724 * this class.
5725 * @param cls The component class that is to be used for the intent.
5726 *
5727 * @see #setClass
5728 * @see #setComponent
5729 * @see #Intent(String, android.net.Uri , Context, Class)
5730 */
5731 public Intent(Context packageContext, Class<?> cls) {
5732 mComponent = new ComponentName(packageContext, cls);
5733 }
5734
5735 /**
5736 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005737 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005738 * construct the Intent and then calling {@link #setClass} to set its
5739 * class.
5740 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005741 * <p><em>Note: scheme and host name matching in the Android framework is
5742 * case-sensitive, unlike the formal RFC. As a result,
5743 * you should always ensure that you write your Uri with these elements
5744 * using lower case letters, and normalize any Uris you receive from
5745 * outside of Android to ensure the scheme and host is lower case.</em></p>
5746 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005747 * @param action The Intent action, such as ACTION_VIEW.
5748 * @param uri The Intent data URI.
5749 * @param packageContext A Context of the application package implementing
5750 * this class.
5751 * @param cls The component class that is to be used for the intent.
5752 *
5753 * @see #Intent(String, android.net.Uri)
5754 * @see #Intent(Context, Class)
5755 * @see #setClass
5756 * @see #setComponent
5757 */
5758 public Intent(String action, Uri uri,
5759 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005760 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005761 mData = uri;
5762 mComponent = new ComponentName(packageContext, cls);
5763 }
5764
5765 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005766 * Create an intent to launch the main (root) activity of a task. This
5767 * is the Intent that is started when the application's is launched from
5768 * Home. For anything else that wants to launch an application in the
5769 * same way, it is important that they use an Intent structured the same
5770 * way, and can use this function to ensure this is the case.
5771 *
5772 * <p>The returned Intent has the given Activity component as its explicit
5773 * component, {@link #ACTION_MAIN} as its action, and includes the
5774 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5775 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5776 * to do that through {@link #addFlags(int)} on the returned Intent.
5777 *
5778 * @param mainActivity The main activity component that this Intent will
5779 * launch.
5780 * @return Returns a newly created Intent that can be used to launch the
5781 * activity as a main application entry.
5782 *
5783 * @see #setClass
5784 * @see #setComponent
5785 */
5786 public static Intent makeMainActivity(ComponentName mainActivity) {
5787 Intent intent = new Intent(ACTION_MAIN);
5788 intent.setComponent(mainActivity);
5789 intent.addCategory(CATEGORY_LAUNCHER);
5790 return intent;
5791 }
5792
5793 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005794 * Make an Intent for the main activity of an application, without
5795 * specifying a specific activity to run but giving a selector to find
5796 * the activity. This results in a final Intent that is structured
5797 * the same as when the application is launched from
5798 * Home. For anything else that wants to launch an application in the
5799 * same way, it is important that they use an Intent structured the same
5800 * way, and can use this function to ensure this is the case.
5801 *
5802 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5803 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5804 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5805 * to do that through {@link #addFlags(int)} on the returned Intent.
5806 *
5807 * @param selectorAction The action name of the Intent's selector.
5808 * @param selectorCategory The name of a category to add to the Intent's
5809 * selector.
5810 * @return Returns a newly created Intent that can be used to launch the
5811 * activity as a main application entry.
5812 *
5813 * @see #setSelector(Intent)
5814 */
5815 public static Intent makeMainSelectorActivity(String selectorAction,
5816 String selectorCategory) {
5817 Intent intent = new Intent(ACTION_MAIN);
5818 intent.addCategory(CATEGORY_LAUNCHER);
5819 Intent selector = new Intent();
5820 selector.setAction(selectorAction);
5821 selector.addCategory(selectorCategory);
5822 intent.setSelector(selector);
5823 return intent;
5824 }
5825
5826 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005827 * Make an Intent that can be used to re-launch an application's task
5828 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5829 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5830 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5831 *
5832 * @param mainActivity The activity component that is the root of the
5833 * task; this is the activity that has been published in the application's
5834 * manifest as the main launcher icon.
5835 *
5836 * @return Returns a newly created Intent that can be used to relaunch the
5837 * activity's task in its root state.
5838 */
5839 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5840 Intent intent = makeMainActivity(mainActivity);
5841 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5842 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5843 return intent;
5844 }
5845
5846 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005847 * Call {@link #parseUri} with 0 flags.
5848 * @deprecated Use {@link #parseUri} instead.
5849 */
5850 @Deprecated
5851 public static Intent getIntent(String uri) throws URISyntaxException {
5852 return parseUri(uri, 0);
5853 }
Tom Taylord4a47292009-12-21 13:59:18 -08005854
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005855 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005856 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005857 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005858 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005859 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005860 *
5861 * <p>The URI given here must not be relative -- that is, it must include
5862 * the scheme and full path.
5863 *
5864 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005865 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005866 *
5867 * @return Intent The newly created Intent object.
5868 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005869 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5870 * it bad (as parsed by the Uri class) or the Intent data within the
5871 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005872 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005873 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005874 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005875 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005876 int i = 0;
5877 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005878 final boolean androidApp = uri.startsWith("android-app:");
5879
5880 // Validate intent scheme if requested.
5881 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5882 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005883 Intent intent = new Intent(ACTION_VIEW);
5884 try {
5885 intent.setData(Uri.parse(uri));
5886 } catch (IllegalArgumentException e) {
5887 throw new URISyntaxException(uri, e.getMessage());
5888 }
5889 return intent;
5890 }
5891 }
Tom Taylord4a47292009-12-21 13:59:18 -08005892
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005893 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005894 // simple case
5895 if (i == -1) {
5896 if (!androidApp) {
5897 return new Intent(ACTION_VIEW, Uri.parse(uri));
5898 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899
5900 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005901 } else if (!uri.startsWith("#Intent;", i)) {
5902 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005903 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005904 } else {
5905 i = -1;
5906 }
5907 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005908
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005909 // new format
5910 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005911 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005912 boolean explicitAction = false;
5913 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005914
5915 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005916 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005917 String data;
5918 if (i >= 0) {
5919 data = uri.substring(0, i);
5920 i += 8; // length of "#Intent;"
5921 } else {
5922 data = uri;
5923 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005924
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005925 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005926 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005927 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005928 if (eq < 0) eq = i-1;
5929 int semi = uri.indexOf(';', i);
5930 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005931
5932 // action
5933 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005934 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005935 if (!inSelector) {
5936 explicitAction = true;
5937 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005938 }
5939
5940 // categories
5941 else if (uri.startsWith("category=", i)) {
5942 intent.addCategory(value);
5943 }
5944
5945 // type
5946 else if (uri.startsWith("type=", i)) {
5947 intent.mType = value;
5948 }
5949
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005950 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005951 else if (uri.startsWith("launchFlags=", i)) {
5952 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005953 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5954 intent.mFlags &= ~IMMUTABLE_FLAGS;
5955 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005956 }
5957
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005958 // package
5959 else if (uri.startsWith("package=", i)) {
5960 intent.mPackage = value;
5961 }
5962
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963 // component
5964 else if (uri.startsWith("component=", i)) {
5965 intent.mComponent = ComponentName.unflattenFromString(value);
5966 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005967
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005968 // scheme
5969 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005970 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005971 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005972 } else {
5973 scheme = value;
5974 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005975 }
5976
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005977 // source bounds
5978 else if (uri.startsWith("sourceBounds=", i)) {
5979 intent.mSourceBounds = Rect.unflattenFromString(value);
5980 }
5981
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005982 // selector
5983 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5984 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005985 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005986 }
5987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005988 // extra
5989 else {
5990 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 // create Bundle if it doesn't already exist
5992 if (intent.mExtras == null) intent.mExtras = new Bundle();
5993 Bundle b = intent.mExtras;
5994 // add EXTRA
5995 if (uri.startsWith("S.", i)) b.putString(key, value);
5996 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5997 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5998 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5999 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6000 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6001 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6002 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6003 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6004 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6005 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006006
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006007 // move to the next item
6008 i = semi + 1;
6009 }
6010
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006011 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006012 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006013 if (baseIntent.mPackage == null) {
6014 baseIntent.setSelector(intent);
6015 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006016 intent = baseIntent;
6017 }
6018
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006019 if (data != null) {
6020 if (data.startsWith("intent:")) {
6021 data = data.substring(7);
6022 if (scheme != null) {
6023 data = scheme + ':' + data;
6024 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006025 } else if (data.startsWith("android-app:")) {
6026 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6027 // Correctly formed android-app, first part is package name.
6028 int end = data.indexOf('/', 14);
6029 if (end < 0) {
6030 // All we have is a package name.
6031 intent.mPackage = data.substring(14);
6032 if (!explicitAction) {
6033 intent.setAction(ACTION_MAIN);
6034 }
6035 data = "";
6036 } else {
6037 // Target the Intent at the given package name always.
6038 String authority = null;
6039 intent.mPackage = data.substring(14, end);
6040 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006041 if ((end+1) < data.length()) {
6042 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6043 // Found a scheme, remember it.
6044 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006045 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006046 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6047 // Found a authority, remember it.
6048 authority = data.substring(end+1, newEnd);
6049 end = newEnd;
6050 }
6051 } else {
6052 // All we have is a scheme.
6053 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006054 }
6055 }
6056 if (scheme == null) {
6057 // If there was no scheme, then this just targets the package.
6058 if (!explicitAction) {
6059 intent.setAction(ACTION_MAIN);
6060 }
6061 data = "";
6062 } else if (authority == null) {
6063 data = scheme + ":";
6064 } else {
6065 data = scheme + "://" + authority + data.substring(end);
6066 }
6067 }
6068 } else {
6069 data = "";
6070 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006071 }
Tom Taylord4a47292009-12-21 13:59:18 -08006072
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006073 if (data.length() > 0) {
6074 try {
6075 intent.mData = Uri.parse(data);
6076 } catch (IllegalArgumentException e) {
6077 throw new URISyntaxException(uri, e.getMessage());
6078 }
6079 }
6080 }
Tom Taylord4a47292009-12-21 13:59:18 -08006081
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006082 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006083
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006084 } catch (IndexOutOfBoundsException e) {
6085 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6086 }
6087 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006088
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006089 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006090 return getIntentOld(uri, 0);
6091 }
6092
6093 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006094 Intent intent;
6095
6096 int i = uri.lastIndexOf('#');
6097 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006098 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006099 final int intentFragmentStart = i;
6100 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006101
6102 i++;
6103
6104 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006105 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006106 i += 7;
6107 int j = uri.indexOf(')', i);
6108 action = uri.substring(i, j);
6109 i = j + 1;
6110 }
6111
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006112 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006113
6114 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006115 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006116 i += 11;
6117 int j = uri.indexOf(')', i);
6118 while (i < j) {
6119 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006120 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006121 if (i < sep) {
6122 intent.addCategory(uri.substring(i, sep));
6123 }
6124 i = sep + 1;
6125 }
6126 i = j + 1;
6127 }
6128
6129 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006130 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006131 i += 5;
6132 int j = uri.indexOf(')', i);
6133 intent.mType = uri.substring(i, j);
6134 i = j + 1;
6135 }
6136
6137 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006138 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006139 i += 12;
6140 int j = uri.indexOf(')', i);
6141 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006142 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6143 intent.mFlags &= ~IMMUTABLE_FLAGS;
6144 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006145 i = j + 1;
6146 }
6147
6148 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006149 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006150 i += 10;
6151 int j = uri.indexOf(')', i);
6152 int sep = uri.indexOf('!', i);
6153 if (sep >= 0 && sep < j) {
6154 String pkg = uri.substring(i, sep);
6155 String cls = uri.substring(sep + 1, j);
6156 intent.mComponent = new ComponentName(pkg, cls);
6157 }
6158 i = j + 1;
6159 }
6160
6161 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006162 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006163 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006164
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006165 final int closeParen = uri.indexOf(')', i);
6166 if (closeParen == -1) throw new URISyntaxException(uri,
6167 "EXTRA missing trailing ')'", i);
6168
6169 while (i < closeParen) {
6170 // fetch the key value
6171 int j = uri.indexOf('=', i);
6172 if (j <= i + 1 || i >= closeParen) {
6173 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6174 }
6175 char type = uri.charAt(i);
6176 i++;
6177 String key = uri.substring(i, j);
6178 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006179
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006180 // get type-value
6181 j = uri.indexOf('!', i);
6182 if (j == -1 || j >= closeParen) j = closeParen;
6183 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6184 String value = uri.substring(i, j);
6185 i = j;
6186
6187 // create Bundle if it doesn't already exist
6188 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006189
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006190 // add item to bundle
6191 try {
6192 switch (type) {
6193 case 'S':
6194 intent.mExtras.putString(key, Uri.decode(value));
6195 break;
6196 case 'B':
6197 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6198 break;
6199 case 'b':
6200 intent.mExtras.putByte(key, Byte.parseByte(value));
6201 break;
6202 case 'c':
6203 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6204 break;
6205 case 'd':
6206 intent.mExtras.putDouble(key, Double.parseDouble(value));
6207 break;
6208 case 'f':
6209 intent.mExtras.putFloat(key, Float.parseFloat(value));
6210 break;
6211 case 'i':
6212 intent.mExtras.putInt(key, Integer.parseInt(value));
6213 break;
6214 case 'l':
6215 intent.mExtras.putLong(key, Long.parseLong(value));
6216 break;
6217 case 's':
6218 intent.mExtras.putShort(key, Short.parseShort(value));
6219 break;
6220 default:
6221 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6222 }
6223 } catch (NumberFormatException e) {
6224 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6225 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006226
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006227 char ch = uri.charAt(i);
6228 if (ch == ')') break;
6229 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6230 i++;
6231 }
6232 }
6233
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006234 if (isIntentFragment) {
6235 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6236 } else {
6237 intent.mData = Uri.parse(uri);
6238 }
Tom Taylord4a47292009-12-21 13:59:18 -08006239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006240 if (intent.mAction == null) {
6241 // By default, if no action is specified, then use VIEW.
6242 intent.mAction = ACTION_VIEW;
6243 }
6244
6245 } else {
6246 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6247 }
6248
6249 return intent;
6250 }
6251
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006252 /** @hide */
6253 public interface CommandOptionHandler {
6254 boolean handleOption(String opt, ShellCommand cmd);
6255 }
6256
6257 /** @hide */
6258 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6259 throws URISyntaxException {
6260 Intent intent = new Intent();
6261 Intent baseIntent = intent;
6262 boolean hasIntentInfo = false;
6263
6264 Uri data = null;
6265 String type = null;
6266
6267 String opt;
6268 while ((opt=cmd.getNextOption()) != null) {
6269 switch (opt) {
6270 case "-a":
6271 intent.setAction(cmd.getNextArgRequired());
6272 if (intent == baseIntent) {
6273 hasIntentInfo = true;
6274 }
6275 break;
6276 case "-d":
6277 data = Uri.parse(cmd.getNextArgRequired());
6278 if (intent == baseIntent) {
6279 hasIntentInfo = true;
6280 }
6281 break;
6282 case "-t":
6283 type = cmd.getNextArgRequired();
6284 if (intent == baseIntent) {
6285 hasIntentInfo = true;
6286 }
6287 break;
6288 case "-c":
6289 intent.addCategory(cmd.getNextArgRequired());
6290 if (intent == baseIntent) {
6291 hasIntentInfo = true;
6292 }
6293 break;
6294 case "-e":
6295 case "--es": {
6296 String key = cmd.getNextArgRequired();
6297 String value = cmd.getNextArgRequired();
6298 intent.putExtra(key, value);
6299 }
6300 break;
6301 case "--esn": {
6302 String key = cmd.getNextArgRequired();
6303 intent.putExtra(key, (String) null);
6304 }
6305 break;
6306 case "--ei": {
6307 String key = cmd.getNextArgRequired();
6308 String value = cmd.getNextArgRequired();
6309 intent.putExtra(key, Integer.decode(value));
6310 }
6311 break;
6312 case "--eu": {
6313 String key = cmd.getNextArgRequired();
6314 String value = cmd.getNextArgRequired();
6315 intent.putExtra(key, Uri.parse(value));
6316 }
6317 break;
6318 case "--ecn": {
6319 String key = cmd.getNextArgRequired();
6320 String value = cmd.getNextArgRequired();
6321 ComponentName cn = ComponentName.unflattenFromString(value);
6322 if (cn == null)
6323 throw new IllegalArgumentException("Bad component name: " + value);
6324 intent.putExtra(key, cn);
6325 }
6326 break;
6327 case "--eia": {
6328 String key = cmd.getNextArgRequired();
6329 String value = cmd.getNextArgRequired();
6330 String[] strings = value.split(",");
6331 int[] list = new int[strings.length];
6332 for (int i = 0; i < strings.length; i++) {
6333 list[i] = Integer.decode(strings[i]);
6334 }
6335 intent.putExtra(key, list);
6336 }
6337 break;
6338 case "--eial": {
6339 String key = cmd.getNextArgRequired();
6340 String value = cmd.getNextArgRequired();
6341 String[] strings = value.split(",");
6342 ArrayList<Integer> list = new ArrayList<>(strings.length);
6343 for (int i = 0; i < strings.length; i++) {
6344 list.add(Integer.decode(strings[i]));
6345 }
6346 intent.putExtra(key, list);
6347 }
6348 break;
6349 case "--el": {
6350 String key = cmd.getNextArgRequired();
6351 String value = cmd.getNextArgRequired();
6352 intent.putExtra(key, Long.valueOf(value));
6353 }
6354 break;
6355 case "--ela": {
6356 String key = cmd.getNextArgRequired();
6357 String value = cmd.getNextArgRequired();
6358 String[] strings = value.split(",");
6359 long[] list = new long[strings.length];
6360 for (int i = 0; i < strings.length; i++) {
6361 list[i] = Long.valueOf(strings[i]);
6362 }
6363 intent.putExtra(key, list);
6364 hasIntentInfo = true;
6365 }
6366 break;
6367 case "--elal": {
6368 String key = cmd.getNextArgRequired();
6369 String value = cmd.getNextArgRequired();
6370 String[] strings = value.split(",");
6371 ArrayList<Long> list = new ArrayList<>(strings.length);
6372 for (int i = 0; i < strings.length; i++) {
6373 list.add(Long.valueOf(strings[i]));
6374 }
6375 intent.putExtra(key, list);
6376 hasIntentInfo = true;
6377 }
6378 break;
6379 case "--ef": {
6380 String key = cmd.getNextArgRequired();
6381 String value = cmd.getNextArgRequired();
6382 intent.putExtra(key, Float.valueOf(value));
6383 hasIntentInfo = true;
6384 }
6385 break;
6386 case "--efa": {
6387 String key = cmd.getNextArgRequired();
6388 String value = cmd.getNextArgRequired();
6389 String[] strings = value.split(",");
6390 float[] list = new float[strings.length];
6391 for (int i = 0; i < strings.length; i++) {
6392 list[i] = Float.valueOf(strings[i]);
6393 }
6394 intent.putExtra(key, list);
6395 hasIntentInfo = true;
6396 }
6397 break;
6398 case "--efal": {
6399 String key = cmd.getNextArgRequired();
6400 String value = cmd.getNextArgRequired();
6401 String[] strings = value.split(",");
6402 ArrayList<Float> list = new ArrayList<>(strings.length);
6403 for (int i = 0; i < strings.length; i++) {
6404 list.add(Float.valueOf(strings[i]));
6405 }
6406 intent.putExtra(key, list);
6407 hasIntentInfo = true;
6408 }
6409 break;
6410 case "--esa": {
6411 String key = cmd.getNextArgRequired();
6412 String value = cmd.getNextArgRequired();
6413 // Split on commas unless they are preceeded by an escape.
6414 // The escape character must be escaped for the string and
6415 // again for the regex, thus four escape characters become one.
6416 String[] strings = value.split("(?<!\\\\),");
6417 intent.putExtra(key, strings);
6418 hasIntentInfo = true;
6419 }
6420 break;
6421 case "--esal": {
6422 String key = cmd.getNextArgRequired();
6423 String value = cmd.getNextArgRequired();
6424 // Split on commas unless they are preceeded by an escape.
6425 // The escape character must be escaped for the string and
6426 // again for the regex, thus four escape characters become one.
6427 String[] strings = value.split("(?<!\\\\),");
6428 ArrayList<String> list = new ArrayList<>(strings.length);
6429 for (int i = 0; i < strings.length; i++) {
6430 list.add(strings[i]);
6431 }
6432 intent.putExtra(key, list);
6433 hasIntentInfo = true;
6434 }
6435 break;
6436 case "--ez": {
6437 String key = cmd.getNextArgRequired();
6438 String value = cmd.getNextArgRequired().toLowerCase();
6439 // Boolean.valueOf() results in false for anything that is not "true", which is
6440 // error-prone in shell commands
6441 boolean arg;
6442 if ("true".equals(value) || "t".equals(value)) {
6443 arg = true;
6444 } else if ("false".equals(value) || "f".equals(value)) {
6445 arg = false;
6446 } else {
6447 try {
6448 arg = Integer.decode(value) != 0;
6449 } catch (NumberFormatException ex) {
6450 throw new IllegalArgumentException("Invalid boolean value: " + value);
6451 }
6452 }
6453
6454 intent.putExtra(key, arg);
6455 }
6456 break;
6457 case "-n": {
6458 String str = cmd.getNextArgRequired();
6459 ComponentName cn = ComponentName.unflattenFromString(str);
6460 if (cn == null)
6461 throw new IllegalArgumentException("Bad component name: " + str);
6462 intent.setComponent(cn);
6463 if (intent == baseIntent) {
6464 hasIntentInfo = true;
6465 }
6466 }
6467 break;
6468 case "-p": {
6469 String str = cmd.getNextArgRequired();
6470 intent.setPackage(str);
6471 if (intent == baseIntent) {
6472 hasIntentInfo = true;
6473 }
6474 }
6475 break;
6476 case "-f":
6477 String str = cmd.getNextArgRequired();
6478 intent.setFlags(Integer.decode(str).intValue());
6479 break;
6480 case "--grant-read-uri-permission":
6481 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6482 break;
6483 case "--grant-write-uri-permission":
6484 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6485 break;
6486 case "--grant-persistable-uri-permission":
6487 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6488 break;
6489 case "--grant-prefix-uri-permission":
6490 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6491 break;
6492 case "--exclude-stopped-packages":
6493 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6494 break;
6495 case "--include-stopped-packages":
6496 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6497 break;
6498 case "--debug-log-resolution":
6499 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6500 break;
6501 case "--activity-brought-to-front":
6502 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6503 break;
6504 case "--activity-clear-top":
6505 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6506 break;
6507 case "--activity-clear-when-task-reset":
6508 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6509 break;
6510 case "--activity-exclude-from-recents":
6511 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6512 break;
6513 case "--activity-launched-from-history":
6514 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6515 break;
6516 case "--activity-multiple-task":
6517 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6518 break;
6519 case "--activity-no-animation":
6520 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6521 break;
6522 case "--activity-no-history":
6523 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6524 break;
6525 case "--activity-no-user-action":
6526 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6527 break;
6528 case "--activity-previous-is-top":
6529 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6530 break;
6531 case "--activity-reorder-to-front":
6532 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6533 break;
6534 case "--activity-reset-task-if-needed":
6535 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6536 break;
6537 case "--activity-single-top":
6538 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6539 break;
6540 case "--activity-clear-task":
6541 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6542 break;
6543 case "--activity-task-on-home":
6544 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6545 break;
6546 case "--receiver-registered-only":
6547 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6548 break;
6549 case "--receiver-replace-pending":
6550 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6551 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006552 case "--receiver-foreground":
6553 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6554 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006555 case "--receiver-no-abort":
6556 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6557 break;
6558 case "--receiver-include-background":
6559 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6560 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006561 case "--selector":
6562 intent.setDataAndType(data, type);
6563 intent = new Intent();
6564 break;
6565 default:
6566 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6567 // Okay, caller handled this option.
6568 } else {
6569 throw new IllegalArgumentException("Unknown option: " + opt);
6570 }
6571 break;
6572 }
6573 }
6574 intent.setDataAndType(data, type);
6575
6576 final boolean hasSelector = intent != baseIntent;
6577 if (hasSelector) {
6578 // A selector was specified; fix up.
6579 baseIntent.setSelector(intent);
6580 intent = baseIntent;
6581 }
6582
6583 String arg = cmd.getNextArg();
6584 baseIntent = null;
6585 if (arg == null) {
6586 if (hasSelector) {
6587 // If a selector has been specified, and no arguments
6588 // have been supplied for the main Intent, then we can
6589 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6590 // need to have a component name specified yet, the
6591 // selector will take care of that.
6592 baseIntent = new Intent(Intent.ACTION_MAIN);
6593 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6594 }
6595 } else if (arg.indexOf(':') >= 0) {
6596 // The argument is a URI. Fully parse it, and use that result
6597 // to fill in any data not specified so far.
6598 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6599 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6600 } else if (arg.indexOf('/') >= 0) {
6601 // The argument is a component name. Build an Intent to launch
6602 // it.
6603 baseIntent = new Intent(Intent.ACTION_MAIN);
6604 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6605 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6606 } else {
6607 // Assume the argument is a package name.
6608 baseIntent = new Intent(Intent.ACTION_MAIN);
6609 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6610 baseIntent.setPackage(arg);
6611 }
6612 if (baseIntent != null) {
6613 Bundle extras = intent.getExtras();
6614 intent.replaceExtras((Bundle)null);
6615 Bundle uriExtras = baseIntent.getExtras();
6616 baseIntent.replaceExtras((Bundle)null);
6617 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6618 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6619 for (String c : cats) {
6620 baseIntent.removeCategory(c);
6621 }
6622 }
6623 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6624 if (extras == null) {
6625 extras = uriExtras;
6626 } else if (uriExtras != null) {
6627 uriExtras.putAll(extras);
6628 extras = uriExtras;
6629 }
6630 intent.replaceExtras(extras);
6631 hasIntentInfo = true;
6632 }
6633
6634 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6635 return intent;
6636 }
6637
6638 /** @hide */
6639 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6640 final String[] lines = new String[] {
6641 "<INTENT> specifications include these flags and arguments:",
6642 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6643 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6644 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6645 " [--esn <EXTRA_KEY> ...]",
6646 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6647 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6648 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6649 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6650 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6651 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6652 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6653 " (mutiple extras passed as Integer[])",
6654 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6655 " (mutiple extras passed as List<Integer>)",
6656 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6657 " (mutiple extras passed as Long[])",
6658 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6659 " (mutiple extras passed as List<Long>)",
6660 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6661 " (mutiple extras passed as Float[])",
6662 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6663 " (mutiple extras passed as List<Float>)",
6664 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6665 " (mutiple extras passed as String[]; to embed a comma into a string,",
6666 " escape it using \"\\,\")",
6667 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6668 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6669 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006670 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006671 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6672 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6673 " [--debug-log-resolution] [--exclude-stopped-packages]",
6674 " [--include-stopped-packages]",
6675 " [--activity-brought-to-front] [--activity-clear-top]",
6676 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6677 " [--activity-launched-from-history] [--activity-multiple-task]",
6678 " [--activity-no-animation] [--activity-no-history]",
6679 " [--activity-no-user-action] [--activity-previous-is-top]",
6680 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6681 " [--activity-single-top] [--activity-clear-task]",
6682 " [--activity-task-on-home]",
6683 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006684 " [--receiver-foreground] [--receiver-no-abort]",
6685 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006686 " [--selector]",
6687 " [<URI> | <PACKAGE> | <COMPONENT>]"
6688 };
6689 for (String line : lines) {
6690 pw.print(prefix);
6691 pw.println(line);
6692 }
6693 }
6694
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006695 /**
6696 * Retrieve the general action to be performed, such as
6697 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6698 * the information in the intent should be interpreted -- most importantly,
6699 * what to do with the data returned by {@link #getData}.
6700 *
6701 * @return The action of this intent or null if none is specified.
6702 *
6703 * @see #setAction
6704 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006705 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006706 return mAction;
6707 }
6708
6709 /**
6710 * Retrieve data this intent is operating on. This URI specifies the name
6711 * of the data; often it uses the content: scheme, specifying data in a
6712 * content provider. Other schemes may be handled by specific activities,
6713 * such as http: by the web browser.
6714 *
6715 * @return The URI of the data this intent is targeting or null.
6716 *
6717 * @see #getScheme
6718 * @see #setData
6719 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006720 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006721 return mData;
6722 }
6723
6724 /**
6725 * The same as {@link #getData()}, but returns the URI as an encoded
6726 * String.
6727 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006728 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006729 return mData != null ? mData.toString() : null;
6730 }
6731
6732 /**
6733 * Return the scheme portion of the intent's data. If the data is null or
6734 * does not include a scheme, null is returned. Otherwise, the scheme
6735 * prefix without the final ':' is returned, i.e. "http".
6736 *
6737 * <p>This is the same as calling getData().getScheme() (and checking for
6738 * null data).
6739 *
6740 * @return The scheme of this intent.
6741 *
6742 * @see #getData
6743 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006744 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006745 return mData != null ? mData.getScheme() : null;
6746 }
6747
6748 /**
6749 * Retrieve any explicit MIME type included in the intent. This is usually
6750 * null, as the type is determined by the intent data.
6751 *
6752 * @return If a type was manually set, it is returned; else null is
6753 * returned.
6754 *
6755 * @see #resolveType(ContentResolver)
6756 * @see #setType
6757 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006758 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006759 return mType;
6760 }
6761
6762 /**
6763 * Return the MIME data type of this intent. If the type field is
6764 * explicitly set, that is simply returned. Otherwise, if the data is set,
6765 * the type of that data is returned. If neither fields are set, a null is
6766 * returned.
6767 *
6768 * @return The MIME type of this intent.
6769 *
6770 * @see #getType
6771 * @see #resolveType(ContentResolver)
6772 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006773 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006774 return resolveType(context.getContentResolver());
6775 }
6776
6777 /**
6778 * Return the MIME data type of this intent. If the type field is
6779 * explicitly set, that is simply returned. Otherwise, if the data is set,
6780 * the type of that data is returned. If neither fields are set, a null is
6781 * returned.
6782 *
6783 * @param resolver A ContentResolver that can be used to determine the MIME
6784 * type of the intent's data.
6785 *
6786 * @return The MIME type of this intent.
6787 *
6788 * @see #getType
6789 * @see #resolveType(Context)
6790 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006791 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006792 if (mType != null) {
6793 return mType;
6794 }
6795 if (mData != null) {
6796 if ("content".equals(mData.getScheme())) {
6797 return resolver.getType(mData);
6798 }
6799 }
6800 return null;
6801 }
6802
6803 /**
6804 * Return the MIME data type of this intent, only if it will be needed for
6805 * intent resolution. This is not generally useful for application code;
6806 * it is used by the frameworks for communicating with back-end system
6807 * services.
6808 *
6809 * @param resolver A ContentResolver that can be used to determine the MIME
6810 * type of the intent's data.
6811 *
6812 * @return The MIME type of this intent, or null if it is unknown or not
6813 * needed.
6814 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006815 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006816 if (mComponent != null) {
6817 return mType;
6818 }
6819 return resolveType(resolver);
6820 }
6821
6822 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006823 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006824 *
6825 * @param category The category to check.
6826 *
6827 * @return boolean True if the intent contains the category, else false.
6828 *
6829 * @see #getCategories
6830 * @see #addCategory
6831 */
6832 public boolean hasCategory(String category) {
6833 return mCategories != null && mCategories.contains(category);
6834 }
6835
6836 /**
6837 * Return the set of all categories in the intent. If there are no categories,
6838 * returns NULL.
6839 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006840 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006841 *
6842 * @see #hasCategory
6843 * @see #addCategory
6844 */
6845 public Set<String> getCategories() {
6846 return mCategories;
6847 }
6848
6849 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006850 * Return the specific selector associated with this Intent. If there is
6851 * none, returns null. See {@link #setSelector} for more information.
6852 *
6853 * @see #setSelector
6854 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006855 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006856 return mSelector;
6857 }
6858
6859 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006860 * Return the {@link ClipData} associated with this Intent. If there is
6861 * none, returns null. See {@link #setClipData} for more information.
6862 *
John Spurlock125d1332013-11-25 11:58:37 -05006863 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006865 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006866 return mClipData;
6867 }
6868
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006869 /** @hide */
6870 public int getContentUserHint() {
6871 return mContentUserHint;
6872 }
6873
Todd Kennedyb3b431302017-03-20 16:05:48 -07006874 /** @hide */
6875 public String getLaunchToken() {
6876 return mLaunchToken;
6877 }
6878
6879 /** @hide */
6880 public void setLaunchToken(String launchToken) {
6881 mLaunchToken = launchToken;
6882 }
6883
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006884 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006885 * Sets the ClassLoader that will be used when unmarshalling
6886 * any Parcelable values from the extras of this Intent.
6887 *
6888 * @param loader a ClassLoader, or null to use the default loader
6889 * at the time of unmarshalling.
6890 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006891 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006892 if (mExtras != null) {
6893 mExtras.setClassLoader(loader);
6894 }
6895 }
6896
6897 /**
6898 * Returns true if an extra value is associated with the given name.
6899 * @param name the extra's name
6900 * @return true if the given extra is present.
6901 */
6902 public boolean hasExtra(String name) {
6903 return mExtras != null && mExtras.containsKey(name);
6904 }
6905
6906 /**
6907 * Returns true if the Intent's extras contain a parcelled file descriptor.
6908 * @return true if the Intent contains a parcelled file descriptor.
6909 */
6910 public boolean hasFileDescriptors() {
6911 return mExtras != null && mExtras.hasFileDescriptors();
6912 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006913
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006914 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006915 public void setAllowFds(boolean allowFds) {
6916 if (mExtras != null) {
6917 mExtras.setAllowFds(allowFds);
6918 }
6919 }
6920
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006921 /** {@hide} */
6922 public void setDefusable(boolean defusable) {
6923 if (mExtras != null) {
6924 mExtras.setDefusable(defusable);
6925 }
6926 }
6927
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006928 /**
6929 * Retrieve extended data from the intent.
6930 *
6931 * @param name The name of the desired item.
6932 *
6933 * @return the value of an item that previously added with putExtra()
6934 * or null if none was found.
6935 *
6936 * @deprecated
6937 * @hide
6938 */
6939 @Deprecated
6940 public Object getExtra(String name) {
6941 return getExtra(name, null);
6942 }
6943
6944 /**
6945 * Retrieve extended data from the intent.
6946 *
6947 * @param name The name of the desired item.
6948 * @param defaultValue the value to be returned if no value of the desired
6949 * type is stored with the given name.
6950 *
6951 * @return the value of an item that previously added with putExtra()
6952 * or the default value if none was found.
6953 *
6954 * @see #putExtra(String, boolean)
6955 */
6956 public boolean getBooleanExtra(String name, boolean defaultValue) {
6957 return mExtras == null ? defaultValue :
6958 mExtras.getBoolean(name, defaultValue);
6959 }
6960
6961 /**
6962 * Retrieve extended data from the intent.
6963 *
6964 * @param name The name of the desired item.
6965 * @param defaultValue the value to be returned if no value of the desired
6966 * type is stored with the given name.
6967 *
6968 * @return the value of an item that previously added with putExtra()
6969 * or the default value if none was found.
6970 *
6971 * @see #putExtra(String, byte)
6972 */
6973 public byte getByteExtra(String name, byte defaultValue) {
6974 return mExtras == null ? defaultValue :
6975 mExtras.getByte(name, defaultValue);
6976 }
6977
6978 /**
6979 * Retrieve extended data from the intent.
6980 *
6981 * @param name The name of the desired item.
6982 * @param defaultValue the value to be returned if no value of the desired
6983 * type is stored with the given name.
6984 *
6985 * @return the value of an item that previously added with putExtra()
6986 * or the default value if none was found.
6987 *
6988 * @see #putExtra(String, short)
6989 */
6990 public short getShortExtra(String name, short defaultValue) {
6991 return mExtras == null ? defaultValue :
6992 mExtras.getShort(name, defaultValue);
6993 }
6994
6995 /**
6996 * Retrieve extended data from the intent.
6997 *
6998 * @param name The name of the desired item.
6999 * @param defaultValue the value to be returned if no value of the desired
7000 * type is stored with the given name.
7001 *
7002 * @return the value of an item that previously added with putExtra()
7003 * or the default value if none was found.
7004 *
7005 * @see #putExtra(String, char)
7006 */
7007 public char getCharExtra(String name, char defaultValue) {
7008 return mExtras == null ? defaultValue :
7009 mExtras.getChar(name, defaultValue);
7010 }
7011
7012 /**
7013 * Retrieve extended data from the intent.
7014 *
7015 * @param name The name of the desired item.
7016 * @param defaultValue the value to be returned if no value of the desired
7017 * type is stored with the given name.
7018 *
7019 * @return the value of an item that previously added with putExtra()
7020 * or the default value if none was found.
7021 *
7022 * @see #putExtra(String, int)
7023 */
7024 public int getIntExtra(String name, int defaultValue) {
7025 return mExtras == null ? defaultValue :
7026 mExtras.getInt(name, defaultValue);
7027 }
7028
7029 /**
7030 * Retrieve extended data from the intent.
7031 *
7032 * @param name The name of the desired item.
7033 * @param defaultValue the value to be returned if no value of the desired
7034 * type is stored with the given name.
7035 *
7036 * @return the value of an item that previously added with putExtra()
7037 * or the default value if none was found.
7038 *
7039 * @see #putExtra(String, long)
7040 */
7041 public long getLongExtra(String name, long defaultValue) {
7042 return mExtras == null ? defaultValue :
7043 mExtras.getLong(name, defaultValue);
7044 }
7045
7046 /**
7047 * Retrieve extended data from the intent.
7048 *
7049 * @param name The name of the desired item.
7050 * @param defaultValue the value to be returned if no value of the desired
7051 * type is stored with the given name.
7052 *
7053 * @return the value of an item that previously added with putExtra(),
7054 * or the default value if no such item is present
7055 *
7056 * @see #putExtra(String, float)
7057 */
7058 public float getFloatExtra(String name, float defaultValue) {
7059 return mExtras == null ? defaultValue :
7060 mExtras.getFloat(name, defaultValue);
7061 }
7062
7063 /**
7064 * Retrieve extended data from the intent.
7065 *
7066 * @param name The name of the desired item.
7067 * @param defaultValue the value to be returned if no value of the desired
7068 * type is stored with the given name.
7069 *
7070 * @return the value of an item that previously added with putExtra()
7071 * or the default value if none was found.
7072 *
7073 * @see #putExtra(String, double)
7074 */
7075 public double getDoubleExtra(String name, double defaultValue) {
7076 return mExtras == null ? defaultValue :
7077 mExtras.getDouble(name, defaultValue);
7078 }
7079
7080 /**
7081 * Retrieve extended data from the intent.
7082 *
7083 * @param name The name of the desired item.
7084 *
7085 * @return the value of an item that previously added with putExtra()
7086 * or null if no String value was found.
7087 *
7088 * @see #putExtra(String, String)
7089 */
7090 public String getStringExtra(String name) {
7091 return mExtras == null ? null : mExtras.getString(name);
7092 }
7093
7094 /**
7095 * Retrieve extended data from the intent.
7096 *
7097 * @param name The name of the desired item.
7098 *
7099 * @return the value of an item that previously added with putExtra()
7100 * or null if no CharSequence value was found.
7101 *
7102 * @see #putExtra(String, CharSequence)
7103 */
7104 public CharSequence getCharSequenceExtra(String name) {
7105 return mExtras == null ? null : mExtras.getCharSequence(name);
7106 }
7107
7108 /**
7109 * Retrieve extended data from the intent.
7110 *
7111 * @param name The name of the desired item.
7112 *
7113 * @return the value of an item that previously added with putExtra()
7114 * or null if no Parcelable value was found.
7115 *
7116 * @see #putExtra(String, Parcelable)
7117 */
7118 public <T extends Parcelable> T getParcelableExtra(String name) {
7119 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7120 }
7121
7122 /**
7123 * Retrieve extended data from the intent.
7124 *
7125 * @param name The name of the desired item.
7126 *
7127 * @return the value of an item that previously added with putExtra()
7128 * or null if no Parcelable[] value was found.
7129 *
7130 * @see #putExtra(String, Parcelable[])
7131 */
7132 public Parcelable[] getParcelableArrayExtra(String name) {
7133 return mExtras == null ? null : mExtras.getParcelableArray(name);
7134 }
7135
7136 /**
7137 * Retrieve extended data from the intent.
7138 *
7139 * @param name The name of the desired item.
7140 *
7141 * @return the value of an item that previously added with putExtra()
7142 * or null if no ArrayList<Parcelable> value was found.
7143 *
7144 * @see #putParcelableArrayListExtra(String, ArrayList)
7145 */
7146 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7147 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7148 }
7149
7150 /**
7151 * Retrieve extended data from the intent.
7152 *
7153 * @param name The name of the desired item.
7154 *
7155 * @return the value of an item that previously added with putExtra()
7156 * or null if no Serializable value was found.
7157 *
7158 * @see #putExtra(String, Serializable)
7159 */
7160 public Serializable getSerializableExtra(String name) {
7161 return mExtras == null ? null : mExtras.getSerializable(name);
7162 }
7163
7164 /**
7165 * Retrieve extended data from the intent.
7166 *
7167 * @param name The name of the desired item.
7168 *
7169 * @return the value of an item that previously added with putExtra()
7170 * or null if no ArrayList<Integer> value was found.
7171 *
7172 * @see #putIntegerArrayListExtra(String, ArrayList)
7173 */
7174 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7175 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7176 }
7177
7178 /**
7179 * Retrieve extended data from the intent.
7180 *
7181 * @param name The name of the desired item.
7182 *
7183 * @return the value of an item that previously added with putExtra()
7184 * or null if no ArrayList<String> value was found.
7185 *
7186 * @see #putStringArrayListExtra(String, ArrayList)
7187 */
7188 public ArrayList<String> getStringArrayListExtra(String name) {
7189 return mExtras == null ? null : mExtras.getStringArrayList(name);
7190 }
7191
7192 /**
7193 * Retrieve extended data from the intent.
7194 *
7195 * @param name The name of the desired item.
7196 *
7197 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007198 * or null if no ArrayList<CharSequence> value was found.
7199 *
7200 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7201 */
7202 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7203 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7204 }
7205
7206 /**
7207 * Retrieve extended data from the intent.
7208 *
7209 * @param name The name of the desired item.
7210 *
7211 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007212 * or null if no boolean array value was found.
7213 *
7214 * @see #putExtra(String, boolean[])
7215 */
7216 public boolean[] getBooleanArrayExtra(String name) {
7217 return mExtras == null ? null : mExtras.getBooleanArray(name);
7218 }
7219
7220 /**
7221 * Retrieve extended data from the intent.
7222 *
7223 * @param name The name of the desired item.
7224 *
7225 * @return the value of an item that previously added with putExtra()
7226 * or null if no byte array value was found.
7227 *
7228 * @see #putExtra(String, byte[])
7229 */
7230 public byte[] getByteArrayExtra(String name) {
7231 return mExtras == null ? null : mExtras.getByteArray(name);
7232 }
7233
7234 /**
7235 * Retrieve extended data from the intent.
7236 *
7237 * @param name The name of the desired item.
7238 *
7239 * @return the value of an item that previously added with putExtra()
7240 * or null if no short array value was found.
7241 *
7242 * @see #putExtra(String, short[])
7243 */
7244 public short[] getShortArrayExtra(String name) {
7245 return mExtras == null ? null : mExtras.getShortArray(name);
7246 }
7247
7248 /**
7249 * Retrieve extended data from the intent.
7250 *
7251 * @param name The name of the desired item.
7252 *
7253 * @return the value of an item that previously added with putExtra()
7254 * or null if no char array value was found.
7255 *
7256 * @see #putExtra(String, char[])
7257 */
7258 public char[] getCharArrayExtra(String name) {
7259 return mExtras == null ? null : mExtras.getCharArray(name);
7260 }
7261
7262 /**
7263 * Retrieve extended data from the intent.
7264 *
7265 * @param name The name of the desired item.
7266 *
7267 * @return the value of an item that previously added with putExtra()
7268 * or null if no int array value was found.
7269 *
7270 * @see #putExtra(String, int[])
7271 */
7272 public int[] getIntArrayExtra(String name) {
7273 return mExtras == null ? null : mExtras.getIntArray(name);
7274 }
7275
7276 /**
7277 * Retrieve extended data from the intent.
7278 *
7279 * @param name The name of the desired item.
7280 *
7281 * @return the value of an item that previously added with putExtra()
7282 * or null if no long array value was found.
7283 *
7284 * @see #putExtra(String, long[])
7285 */
7286 public long[] getLongArrayExtra(String name) {
7287 return mExtras == null ? null : mExtras.getLongArray(name);
7288 }
7289
7290 /**
7291 * Retrieve extended data from the intent.
7292 *
7293 * @param name The name of the desired item.
7294 *
7295 * @return the value of an item that previously added with putExtra()
7296 * or null if no float array value was found.
7297 *
7298 * @see #putExtra(String, float[])
7299 */
7300 public float[] getFloatArrayExtra(String name) {
7301 return mExtras == null ? null : mExtras.getFloatArray(name);
7302 }
7303
7304 /**
7305 * Retrieve extended data from the intent.
7306 *
7307 * @param name The name of the desired item.
7308 *
7309 * @return the value of an item that previously added with putExtra()
7310 * or null if no double array value was found.
7311 *
7312 * @see #putExtra(String, double[])
7313 */
7314 public double[] getDoubleArrayExtra(String name) {
7315 return mExtras == null ? null : mExtras.getDoubleArray(name);
7316 }
7317
7318 /**
7319 * Retrieve extended data from the intent.
7320 *
7321 * @param name The name of the desired item.
7322 *
7323 * @return the value of an item that previously added with putExtra()
7324 * or null if no String array value was found.
7325 *
7326 * @see #putExtra(String, String[])
7327 */
7328 public String[] getStringArrayExtra(String name) {
7329 return mExtras == null ? null : mExtras.getStringArray(name);
7330 }
7331
7332 /**
7333 * Retrieve extended data from the intent.
7334 *
7335 * @param name The name of the desired item.
7336 *
7337 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007338 * or null if no CharSequence array value was found.
7339 *
7340 * @see #putExtra(String, CharSequence[])
7341 */
7342 public CharSequence[] getCharSequenceArrayExtra(String name) {
7343 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7344 }
7345
7346 /**
7347 * Retrieve extended data from the intent.
7348 *
7349 * @param name The name of the desired item.
7350 *
7351 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007352 * or null if no Bundle value was found.
7353 *
7354 * @see #putExtra(String, Bundle)
7355 */
7356 public Bundle getBundleExtra(String name) {
7357 return mExtras == null ? null : mExtras.getBundle(name);
7358 }
7359
7360 /**
7361 * Retrieve extended data from the intent.
7362 *
7363 * @param name The name of the desired item.
7364 *
7365 * @return the value of an item that previously added with putExtra()
7366 * or null if no IBinder value was found.
7367 *
7368 * @see #putExtra(String, IBinder)
7369 *
7370 * @deprecated
7371 * @hide
7372 */
7373 @Deprecated
7374 public IBinder getIBinderExtra(String name) {
7375 return mExtras == null ? null : mExtras.getIBinder(name);
7376 }
7377
7378 /**
7379 * Retrieve extended data from the intent.
7380 *
7381 * @param name The name of the desired item.
7382 * @param defaultValue The default value to return in case no item is
7383 * associated with the key 'name'
7384 *
7385 * @return the value of an item that previously added with putExtra()
7386 * or defaultValue if none was found.
7387 *
7388 * @see #putExtra
7389 *
7390 * @deprecated
7391 * @hide
7392 */
7393 @Deprecated
7394 public Object getExtra(String name, Object defaultValue) {
7395 Object result = defaultValue;
7396 if (mExtras != null) {
7397 Object result2 = mExtras.get(name);
7398 if (result2 != null) {
7399 result = result2;
7400 }
7401 }
7402
7403 return result;
7404 }
7405
7406 /**
7407 * Retrieves a map of extended data from the intent.
7408 *
7409 * @return the map of all extras previously added with putExtra(),
7410 * or null if none have been added.
7411 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007412 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007413 return (mExtras != null)
7414 ? new Bundle(mExtras)
7415 : null;
7416 }
7417
7418 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007419 * Filter extras to only basic types.
7420 * @hide
7421 */
7422 public void removeUnsafeExtras() {
7423 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007424 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007425 }
7426 }
7427
7428 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007429 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7430 * return itself as-is.
7431 * @hide
7432 */
7433 public boolean canStripForHistory() {
7434 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7435 }
7436
7437 /**
7438 * Call it when the system needs to keep an intent for logging purposes to remove fields
7439 * that are not needed for logging.
7440 * @hide
7441 */
7442 public Intent maybeStripForHistory() {
7443 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7444
7445 if (!canStripForHistory()) {
7446 return this;
7447 }
7448 return new Intent(this, COPY_MODE_HISTORY);
7449 }
7450
7451 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007452 * Retrieve any special flags associated with this intent. You will
7453 * normally just set them with {@link #setFlags} and let the system
7454 * take the appropriate action with them.
7455 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007456 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007457 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007458 * @see #addFlags
7459 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007460 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007461 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007462 return mFlags;
7463 }
7464
Dianne Hackborne7f97212011-02-24 14:40:20 -08007465 /** @hide */
7466 public boolean isExcludingStopped() {
7467 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7468 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7469 }
7470
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007471 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007472 * Retrieve the application package name this Intent is limited to. When
7473 * resolving an Intent, if non-null this limits the resolution to only
7474 * components in the given application package.
7475 *
7476 * @return The name of the application package for the Intent.
7477 *
7478 * @see #resolveActivity
7479 * @see #setPackage
7480 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007481 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007482 return mPackage;
7483 }
7484
7485 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007486 * Retrieve the concrete component associated with the intent. When receiving
7487 * an intent, this is the component that was found to best handle it (that is,
7488 * yourself) and will always be non-null; in all other cases it will be
7489 * null unless explicitly set.
7490 *
7491 * @return The name of the application component to handle the intent.
7492 *
7493 * @see #resolveActivity
7494 * @see #setComponent
7495 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007496 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007497 return mComponent;
7498 }
7499
7500 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007501 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7502 * used as a hint to the receiver for animations and the like. Null means that there
7503 * is no source bounds.
7504 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007505 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007506 return mSourceBounds;
7507 }
7508
7509 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007510 * Return the Activity component that should be used to handle this intent.
7511 * The appropriate component is determined based on the information in the
7512 * intent, evaluated as follows:
7513 *
7514 * <p>If {@link #getComponent} returns an explicit class, that is returned
7515 * without any further consideration.
7516 *
7517 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7518 * category to be considered.
7519 *
7520 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7521 * action.
7522 *
7523 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7524 * this type.
7525 *
7526 * <p>If {@link #addCategory} has added any categories, the activity must
7527 * handle ALL of the categories specified.
7528 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007529 * <p>If {@link #getPackage} is non-NULL, only activity components in
7530 * that application package will be considered.
7531 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007532 * <p>If there are no activities that satisfy all of these conditions, a
7533 * null string is returned.
7534 *
7535 * <p>If multiple activities are found to satisfy the intent, the one with
7536 * the highest priority will be used. If there are multiple activities
7537 * with the same priority, the system will either pick the best activity
7538 * based on user preference, or resolve to a system class that will allow
7539 * the user to pick an activity and forward from there.
7540 *
7541 * <p>This method is implemented simply by calling
7542 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7543 * true.</p>
7544 * <p> This API is called for you as part of starting an activity from an
7545 * intent. You do not normally need to call it yourself.</p>
7546 *
7547 * @param pm The package manager with which to resolve the Intent.
7548 *
7549 * @return Name of the component implementing an activity that can
7550 * display the intent.
7551 *
7552 * @see #setComponent
7553 * @see #getComponent
7554 * @see #resolveActivityInfo
7555 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007556 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007557 if (mComponent != null) {
7558 return mComponent;
7559 }
7560
7561 ResolveInfo info = pm.resolveActivity(
7562 this, PackageManager.MATCH_DEFAULT_ONLY);
7563 if (info != null) {
7564 return new ComponentName(
7565 info.activityInfo.applicationInfo.packageName,
7566 info.activityInfo.name);
7567 }
7568
7569 return null;
7570 }
7571
7572 /**
7573 * Resolve the Intent into an {@link ActivityInfo}
7574 * describing the activity that should execute the intent. Resolution
7575 * follows the same rules as described for {@link #resolveActivity}, but
7576 * you get back the completely information about the resolved activity
7577 * instead of just its class name.
7578 *
7579 * @param pm The package manager with which to resolve the Intent.
7580 * @param flags Addition information to retrieve as per
7581 * {@link PackageManager#getActivityInfo(ComponentName, int)
7582 * PackageManager.getActivityInfo()}.
7583 *
7584 * @return PackageManager.ActivityInfo
7585 *
7586 * @see #resolveActivity
7587 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007588 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7589 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007590 ActivityInfo ai = null;
7591 if (mComponent != null) {
7592 try {
7593 ai = pm.getActivityInfo(mComponent, flags);
7594 } catch (PackageManager.NameNotFoundException e) {
7595 // ignore
7596 }
7597 } else {
7598 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007599 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007600 if (info != null) {
7601 ai = info.activityInfo;
7602 }
7603 }
7604
7605 return ai;
7606 }
7607
7608 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007609 * Special function for use by the system to resolve service
7610 * intents to system apps. Throws an exception if there are
7611 * multiple potential matches to the Intent. Returns null if
7612 * there are no matches.
7613 * @hide
7614 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007615 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7616 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007617 if (mComponent != null) {
7618 return mComponent;
7619 }
7620
7621 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7622 if (results == null) {
7623 return null;
7624 }
7625 ComponentName comp = null;
7626 for (int i=0; i<results.size(); i++) {
7627 ResolveInfo ri = results.get(i);
7628 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7629 continue;
7630 }
7631 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7632 ri.serviceInfo.name);
7633 if (comp != null) {
7634 throw new IllegalStateException("Multiple system services handle " + this
7635 + ": " + comp + ", " + foundComp);
7636 }
7637 comp = foundComp;
7638 }
7639 return comp;
7640 }
7641
7642 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007643 * Set the general action to be performed.
7644 *
7645 * @param action An action name, such as ACTION_VIEW. Application-specific
7646 * actions should be prefixed with the vendor's package name.
7647 *
7648 * @return Returns the same Intent object, for chaining multiple calls
7649 * into a single statement.
7650 *
7651 * @see #getAction
7652 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007653 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007654 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007655 return this;
7656 }
7657
7658 /**
7659 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007660 * clears any type that was previously set by {@link #setType} or
7661 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007662 *
Nick Pellyccae4122012-01-09 14:12:58 -08007663 * <p><em>Note: scheme matching in the Android framework is
7664 * case-sensitive, unlike the formal RFC. As a result,
7665 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007666 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007667 * {@link #setDataAndNormalize}
7668 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007669 *
Nick Pellyccae4122012-01-09 14:12:58 -08007670 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007671 *
7672 * @return Returns the same Intent object, for chaining multiple calls
7673 * into a single statement.
7674 *
7675 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007676 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007677 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007678 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007679 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007680 mData = data;
7681 mType = null;
7682 return this;
7683 }
7684
7685 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007686 * Normalize and set the data this intent is operating on.
7687 *
7688 * <p>This method automatically clears any type that was
7689 * previously set (for example, by {@link #setType}).
7690 *
7691 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007692 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007693 * so really this is just a convenience method for
7694 * <pre>
7695 * setData(data.normalize())
7696 * </pre>
7697 *
7698 * @param data The Uri of the data this intent is now targeting.
7699 *
7700 * @return Returns the same Intent object, for chaining multiple calls
7701 * into a single statement.
7702 *
7703 * @see #getData
7704 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007705 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007706 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007707 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007708 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007709 }
7710
7711 /**
7712 * Set an explicit MIME data type.
7713 *
7714 * <p>This is used to create intents that only specify a type and not data,
7715 * for example to indicate the type of data to return.
7716 *
7717 * <p>This method automatically clears any data that was
7718 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007719 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007720 * <p><em>Note: MIME type matching in the Android framework is
7721 * case-sensitive, unlike formal RFC MIME types. As a result,
7722 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007723 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7724 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007725 *
7726 * @param type The MIME type of the data being handled by this intent.
7727 *
7728 * @return Returns the same Intent object, for chaining multiple calls
7729 * into a single statement.
7730 *
7731 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007732 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007733 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007734 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007735 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007736 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007737 mData = null;
7738 mType = type;
7739 return this;
7740 }
7741
7742 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007743 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007744 *
Nick Pellyccae4122012-01-09 14:12:58 -08007745 * <p>This is used to create intents that only specify a type and not data,
7746 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007747 *
Nick Pellyccae4122012-01-09 14:12:58 -08007748 * <p>This method automatically clears any data that was
7749 * previously set (for example by {@link #setData}).
7750 *
7751 * <p>The MIME type is normalized using
7752 * {@link #normalizeMimeType} before it is set,
7753 * so really this is just a convenience method for
7754 * <pre>
7755 * setType(Intent.normalizeMimeType(type))
7756 * </pre>
7757 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007758 * @param type The MIME type of the data being handled by this intent.
7759 *
7760 * @return Returns the same Intent object, for chaining multiple calls
7761 * into a single statement.
7762 *
Nick Pellyccae4122012-01-09 14:12:58 -08007763 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007764 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007765 * @see #normalizeMimeType
7766 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007767 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007768 return setType(normalizeMimeType(type));
7769 }
7770
7771 /**
7772 * (Usually optional) Set the data for the intent along with an explicit
7773 * MIME data type. This method should very rarely be used -- it allows you
7774 * to override the MIME type that would ordinarily be inferred from the
7775 * data with your own type given here.
7776 *
7777 * <p><em>Note: MIME type and Uri scheme matching in the
7778 * Android framework is case-sensitive, unlike the formal RFC definitions.
7779 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007780 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007781 * {@link #setDataAndTypeAndNormalize}
7782 * to ensure that they are converted to lower case.</em>
7783 *
7784 * @param data The Uri of the data this intent is now targeting.
7785 * @param type The MIME type of the data being handled by this intent.
7786 *
7787 * @return Returns the same Intent object, for chaining multiple calls
7788 * into a single statement.
7789 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007790 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007791 * @see #setData
7792 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007793 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007794 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007796 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007797 mData = data;
7798 mType = type;
7799 return this;
7800 }
7801
7802 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007803 * (Usually optional) Normalize and set both the data Uri and an explicit
7804 * MIME data type. This method should very rarely be used -- it allows you
7805 * to override the MIME type that would ordinarily be inferred from the
7806 * data with your own type given here.
7807 *
7808 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007809 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007810 * before they are set, so really this is just a convenience method for
7811 * <pre>
7812 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7813 * </pre>
7814 *
7815 * @param data The Uri of the data this intent is now targeting.
7816 * @param type The MIME type of the data being handled by this intent.
7817 *
7818 * @return Returns the same Intent object, for chaining multiple calls
7819 * into a single statement.
7820 *
7821 * @see #setType
7822 * @see #setData
7823 * @see #setDataAndType
7824 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007825 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007826 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007827 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007828 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007829 }
7830
7831 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007832 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007833 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007834 * activities that provide <em>all</em> of the requested categories will be
7835 * used.
7836 *
7837 * @param category The desired category. This can be either one of the
7838 * predefined Intent categories, or a custom category in your own
7839 * namespace.
7840 *
7841 * @return Returns the same Intent object, for chaining multiple calls
7842 * into a single statement.
7843 *
7844 * @see #hasCategory
7845 * @see #removeCategory
7846 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007847 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007849 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007850 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007851 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 return this;
7853 }
7854
7855 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007856 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007857 *
7858 * @param category The category to remove.
7859 *
7860 * @see #addCategory
7861 */
7862 public void removeCategory(String category) {
7863 if (mCategories != null) {
7864 mCategories.remove(category);
7865 if (mCategories.size() == 0) {
7866 mCategories = null;
7867 }
7868 }
7869 }
7870
7871 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007872 * Set a selector for this Intent. This is a modification to the kinds of
7873 * things the Intent will match. If the selector is set, it will be used
7874 * when trying to find entities that can handle the Intent, instead of the
7875 * main contents of the Intent. This allows you build an Intent containing
7876 * a generic protocol while targeting it more specifically.
7877 *
7878 * <p>An example of where this may be used is with things like
7879 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7880 * Intent that will launch the Browser application. However, the correct
7881 * main entry point of an application is actually {@link #ACTION_MAIN}
7882 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7883 * used to specify the actual Activity to launch. If you launch the browser
7884 * with something different, undesired behavior may happen if the user has
7885 * previously or later launches it the normal way, since they do not match.
7886 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7887 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7888 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7889 *
7890 * <p>Setting a selector does not impact the behavior of
7891 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7892 * desired behavior of a selector -- it does not impact the base meaning
7893 * of the Intent, just what kinds of things will be matched against it
7894 * when determining who can handle it.</p>
7895 *
7896 * <p>You can not use both a selector and {@link #setPackage(String)} on
7897 * the same base Intent.</p>
7898 *
7899 * @param selector The desired selector Intent; set to null to not use
7900 * a special selector.
7901 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007902 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007903 if (selector == this) {
7904 throw new IllegalArgumentException(
7905 "Intent being set as a selector of itself");
7906 }
7907 if (selector != null && mPackage != null) {
7908 throw new IllegalArgumentException(
7909 "Can't set selector when package name is already set");
7910 }
7911 mSelector = selector;
7912 }
7913
7914 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007915 * Set a {@link ClipData} associated with this Intent. This replaces any
7916 * previously set ClipData.
7917 *
7918 * <p>The ClipData in an intent is not used for Intent matching or other
7919 * such operations. Semantically it is like extras, used to transmit
7920 * additional data with the Intent. The main feature of using this over
7921 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7922 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7923 * items included in the clip data. This is useful, in particular, if
7924 * you want to transmit an Intent containing multiple <code>content:</code>
7925 * URIs for which the recipient may not have global permission to access the
7926 * content provider.
7927 *
7928 * <p>If the ClipData contains items that are themselves Intents, any
7929 * grant flags in those Intents will be ignored. Only the top-level flags
7930 * of the main Intent are respected, and will be applied to all Uri or
7931 * Intent items in the clip (or sub-items of the clip).
7932 *
7933 * <p>The MIME type, label, and icon in the ClipData object are not
7934 * directly used by Intent. Applications should generally rely on the
7935 * MIME type of the Intent itself, not what it may find in the ClipData.
7936 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007937 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007938 *
7939 * @param clip The new clip to set. May be null to clear the current clip.
7940 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007941 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007942 mClipData = clip;
7943 }
7944
7945 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007946 * This is NOT a secure mechanism to identify the user who sent the intent.
7947 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7948 * who sent the intent.
7949 * @hide
7950 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007951 public void prepareToLeaveUser(int userId) {
7952 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7953 // We want mContentUserHint to refer to the original user, so don't do anything.
7954 if (mContentUserHint == UserHandle.USER_CURRENT) {
7955 mContentUserHint = userId;
7956 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007957 }
7958
7959 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007960 * Add extended data to the intent. The name must include a package
7961 * prefix, for example the app com.android.contacts would use names
7962 * like "com.android.contacts.ShowAll".
7963 *
7964 * @param name The name of the extra data, with package prefix.
7965 * @param value The boolean data value.
7966 *
7967 * @return Returns the same Intent object, for chaining multiple calls
7968 * into a single statement.
7969 *
7970 * @see #putExtras
7971 * @see #removeExtra
7972 * @see #getBooleanExtra(String, boolean)
7973 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007974 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007975 if (mExtras == null) {
7976 mExtras = new Bundle();
7977 }
7978 mExtras.putBoolean(name, value);
7979 return this;
7980 }
7981
7982 /**
7983 * Add extended data to the intent. The name must include a package
7984 * prefix, for example the app com.android.contacts would use names
7985 * like "com.android.contacts.ShowAll".
7986 *
7987 * @param name The name of the extra data, with package prefix.
7988 * @param value The byte data value.
7989 *
7990 * @return Returns the same Intent object, for chaining multiple calls
7991 * into a single statement.
7992 *
7993 * @see #putExtras
7994 * @see #removeExtra
7995 * @see #getByteExtra(String, byte)
7996 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007997 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007998 if (mExtras == null) {
7999 mExtras = new Bundle();
8000 }
8001 mExtras.putByte(name, value);
8002 return this;
8003 }
8004
8005 /**
8006 * Add extended data to the intent. The name must include a package
8007 * prefix, for example the app com.android.contacts would use names
8008 * like "com.android.contacts.ShowAll".
8009 *
8010 * @param name The name of the extra data, with package prefix.
8011 * @param value The char data value.
8012 *
8013 * @return Returns the same Intent object, for chaining multiple calls
8014 * into a single statement.
8015 *
8016 * @see #putExtras
8017 * @see #removeExtra
8018 * @see #getCharExtra(String, char)
8019 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008020 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008021 if (mExtras == null) {
8022 mExtras = new Bundle();
8023 }
8024 mExtras.putChar(name, value);
8025 return this;
8026 }
8027
8028 /**
8029 * Add extended data to the intent. The name must include a package
8030 * prefix, for example the app com.android.contacts would use names
8031 * like "com.android.contacts.ShowAll".
8032 *
8033 * @param name The name of the extra data, with package prefix.
8034 * @param value The short data value.
8035 *
8036 * @return Returns the same Intent object, for chaining multiple calls
8037 * into a single statement.
8038 *
8039 * @see #putExtras
8040 * @see #removeExtra
8041 * @see #getShortExtra(String, short)
8042 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008043 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008044 if (mExtras == null) {
8045 mExtras = new Bundle();
8046 }
8047 mExtras.putShort(name, value);
8048 return this;
8049 }
8050
8051 /**
8052 * Add extended data to the intent. The name must include a package
8053 * prefix, for example the app com.android.contacts would use names
8054 * like "com.android.contacts.ShowAll".
8055 *
8056 * @param name The name of the extra data, with package prefix.
8057 * @param value The integer data value.
8058 *
8059 * @return Returns the same Intent object, for chaining multiple calls
8060 * into a single statement.
8061 *
8062 * @see #putExtras
8063 * @see #removeExtra
8064 * @see #getIntExtra(String, int)
8065 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008066 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008067 if (mExtras == null) {
8068 mExtras = new Bundle();
8069 }
8070 mExtras.putInt(name, value);
8071 return this;
8072 }
8073
8074 /**
8075 * Add extended data to the intent. The name must include a package
8076 * prefix, for example the app com.android.contacts would use names
8077 * like "com.android.contacts.ShowAll".
8078 *
8079 * @param name The name of the extra data, with package prefix.
8080 * @param value The long data value.
8081 *
8082 * @return Returns the same Intent object, for chaining multiple calls
8083 * into a single statement.
8084 *
8085 * @see #putExtras
8086 * @see #removeExtra
8087 * @see #getLongExtra(String, long)
8088 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008089 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008090 if (mExtras == null) {
8091 mExtras = new Bundle();
8092 }
8093 mExtras.putLong(name, value);
8094 return this;
8095 }
8096
8097 /**
8098 * Add extended data to the intent. The name must include a package
8099 * prefix, for example the app com.android.contacts would use names
8100 * like "com.android.contacts.ShowAll".
8101 *
8102 * @param name The name of the extra data, with package prefix.
8103 * @param value The float data value.
8104 *
8105 * @return Returns the same Intent object, for chaining multiple calls
8106 * into a single statement.
8107 *
8108 * @see #putExtras
8109 * @see #removeExtra
8110 * @see #getFloatExtra(String, float)
8111 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008112 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008113 if (mExtras == null) {
8114 mExtras = new Bundle();
8115 }
8116 mExtras.putFloat(name, value);
8117 return this;
8118 }
8119
8120 /**
8121 * Add extended data to the intent. The name must include a package
8122 * prefix, for example the app com.android.contacts would use names
8123 * like "com.android.contacts.ShowAll".
8124 *
8125 * @param name The name of the extra data, with package prefix.
8126 * @param value The double data value.
8127 *
8128 * @return Returns the same Intent object, for chaining multiple calls
8129 * into a single statement.
8130 *
8131 * @see #putExtras
8132 * @see #removeExtra
8133 * @see #getDoubleExtra(String, double)
8134 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008135 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008136 if (mExtras == null) {
8137 mExtras = new Bundle();
8138 }
8139 mExtras.putDouble(name, value);
8140 return this;
8141 }
8142
8143 /**
8144 * Add extended data to the intent. The name must include a package
8145 * prefix, for example the app com.android.contacts would use names
8146 * like "com.android.contacts.ShowAll".
8147 *
8148 * @param name The name of the extra data, with package prefix.
8149 * @param value The String data value.
8150 *
8151 * @return Returns the same Intent object, for chaining multiple calls
8152 * into a single statement.
8153 *
8154 * @see #putExtras
8155 * @see #removeExtra
8156 * @see #getStringExtra(String)
8157 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008158 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159 if (mExtras == null) {
8160 mExtras = new Bundle();
8161 }
8162 mExtras.putString(name, value);
8163 return this;
8164 }
8165
8166 /**
8167 * Add extended data to the intent. The name must include a package
8168 * prefix, for example the app com.android.contacts would use names
8169 * like "com.android.contacts.ShowAll".
8170 *
8171 * @param name The name of the extra data, with package prefix.
8172 * @param value The CharSequence data value.
8173 *
8174 * @return Returns the same Intent object, for chaining multiple calls
8175 * into a single statement.
8176 *
8177 * @see #putExtras
8178 * @see #removeExtra
8179 * @see #getCharSequenceExtra(String)
8180 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008181 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008182 if (mExtras == null) {
8183 mExtras = new Bundle();
8184 }
8185 mExtras.putCharSequence(name, value);
8186 return this;
8187 }
8188
8189 /**
8190 * Add extended data to the intent. The name must include a package
8191 * prefix, for example the app com.android.contacts would use names
8192 * like "com.android.contacts.ShowAll".
8193 *
8194 * @param name The name of the extra data, with package prefix.
8195 * @param value The Parcelable data value.
8196 *
8197 * @return Returns the same Intent object, for chaining multiple calls
8198 * into a single statement.
8199 *
8200 * @see #putExtras
8201 * @see #removeExtra
8202 * @see #getParcelableExtra(String)
8203 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008204 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008205 if (mExtras == null) {
8206 mExtras = new Bundle();
8207 }
8208 mExtras.putParcelable(name, value);
8209 return this;
8210 }
8211
8212 /**
8213 * Add extended data to the intent. The name must include a package
8214 * prefix, for example the app com.android.contacts would use names
8215 * like "com.android.contacts.ShowAll".
8216 *
8217 * @param name The name of the extra data, with package prefix.
8218 * @param value The Parcelable[] data value.
8219 *
8220 * @return Returns the same Intent object, for chaining multiple calls
8221 * into a single statement.
8222 *
8223 * @see #putExtras
8224 * @see #removeExtra
8225 * @see #getParcelableArrayExtra(String)
8226 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008227 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008228 if (mExtras == null) {
8229 mExtras = new Bundle();
8230 }
8231 mExtras.putParcelableArray(name, value);
8232 return this;
8233 }
8234
8235 /**
8236 * Add extended data to the intent. The name must include a package
8237 * prefix, for example the app com.android.contacts would use names
8238 * like "com.android.contacts.ShowAll".
8239 *
8240 * @param name The name of the extra data, with package prefix.
8241 * @param value The ArrayList<Parcelable> data value.
8242 *
8243 * @return Returns the same Intent object, for chaining multiple calls
8244 * into a single statement.
8245 *
8246 * @see #putExtras
8247 * @see #removeExtra
8248 * @see #getParcelableArrayListExtra(String)
8249 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008250 public @NonNull Intent putParcelableArrayListExtra(String name,
8251 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008252 if (mExtras == null) {
8253 mExtras = new Bundle();
8254 }
8255 mExtras.putParcelableArrayList(name, value);
8256 return this;
8257 }
8258
8259 /**
8260 * Add extended data to the intent. The name must include a package
8261 * prefix, for example the app com.android.contacts would use names
8262 * like "com.android.contacts.ShowAll".
8263 *
8264 * @param name The name of the extra data, with package prefix.
8265 * @param value The ArrayList<Integer> data value.
8266 *
8267 * @return Returns the same Intent object, for chaining multiple calls
8268 * into a single statement.
8269 *
8270 * @see #putExtras
8271 * @see #removeExtra
8272 * @see #getIntegerArrayListExtra(String)
8273 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008274 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008275 if (mExtras == null) {
8276 mExtras = new Bundle();
8277 }
8278 mExtras.putIntegerArrayList(name, value);
8279 return this;
8280 }
8281
8282 /**
8283 * Add extended data to the intent. The name must include a package
8284 * prefix, for example the app com.android.contacts would use names
8285 * like "com.android.contacts.ShowAll".
8286 *
8287 * @param name The name of the extra data, with package prefix.
8288 * @param value The ArrayList<String> data value.
8289 *
8290 * @return Returns the same Intent object, for chaining multiple calls
8291 * into a single statement.
8292 *
8293 * @see #putExtras
8294 * @see #removeExtra
8295 * @see #getStringArrayListExtra(String)
8296 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008297 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008298 if (mExtras == null) {
8299 mExtras = new Bundle();
8300 }
8301 mExtras.putStringArrayList(name, value);
8302 return this;
8303 }
8304
8305 /**
8306 * Add extended data to the intent. The name must include a package
8307 * prefix, for example the app com.android.contacts would use names
8308 * like "com.android.contacts.ShowAll".
8309 *
8310 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008311 * @param value The ArrayList<CharSequence> data value.
8312 *
8313 * @return Returns the same Intent object, for chaining multiple calls
8314 * into a single statement.
8315 *
8316 * @see #putExtras
8317 * @see #removeExtra
8318 * @see #getCharSequenceArrayListExtra(String)
8319 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008320 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8321 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008322 if (mExtras == null) {
8323 mExtras = new Bundle();
8324 }
8325 mExtras.putCharSequenceArrayList(name, value);
8326 return this;
8327 }
8328
8329 /**
8330 * Add extended data to the intent. The name must include a package
8331 * prefix, for example the app com.android.contacts would use names
8332 * like "com.android.contacts.ShowAll".
8333 *
8334 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008335 * @param value The Serializable data value.
8336 *
8337 * @return Returns the same Intent object, for chaining multiple calls
8338 * into a single statement.
8339 *
8340 * @see #putExtras
8341 * @see #removeExtra
8342 * @see #getSerializableExtra(String)
8343 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008344 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008345 if (mExtras == null) {
8346 mExtras = new Bundle();
8347 }
8348 mExtras.putSerializable(name, value);
8349 return this;
8350 }
8351
8352 /**
8353 * Add extended data to the intent. The name must include a package
8354 * prefix, for example the app com.android.contacts would use names
8355 * like "com.android.contacts.ShowAll".
8356 *
8357 * @param name The name of the extra data, with package prefix.
8358 * @param value The boolean array data value.
8359 *
8360 * @return Returns the same Intent object, for chaining multiple calls
8361 * into a single statement.
8362 *
8363 * @see #putExtras
8364 * @see #removeExtra
8365 * @see #getBooleanArrayExtra(String)
8366 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008367 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008368 if (mExtras == null) {
8369 mExtras = new Bundle();
8370 }
8371 mExtras.putBooleanArray(name, value);
8372 return this;
8373 }
8374
8375 /**
8376 * Add extended data to the intent. The name must include a package
8377 * prefix, for example the app com.android.contacts would use names
8378 * like "com.android.contacts.ShowAll".
8379 *
8380 * @param name The name of the extra data, with package prefix.
8381 * @param value The byte array data value.
8382 *
8383 * @return Returns the same Intent object, for chaining multiple calls
8384 * into a single statement.
8385 *
8386 * @see #putExtras
8387 * @see #removeExtra
8388 * @see #getByteArrayExtra(String)
8389 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008390 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008391 if (mExtras == null) {
8392 mExtras = new Bundle();
8393 }
8394 mExtras.putByteArray(name, value);
8395 return this;
8396 }
8397
8398 /**
8399 * Add extended data to the intent. The name must include a package
8400 * prefix, for example the app com.android.contacts would use names
8401 * like "com.android.contacts.ShowAll".
8402 *
8403 * @param name The name of the extra data, with package prefix.
8404 * @param value The short array data value.
8405 *
8406 * @return Returns the same Intent object, for chaining multiple calls
8407 * into a single statement.
8408 *
8409 * @see #putExtras
8410 * @see #removeExtra
8411 * @see #getShortArrayExtra(String)
8412 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008413 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008414 if (mExtras == null) {
8415 mExtras = new Bundle();
8416 }
8417 mExtras.putShortArray(name, value);
8418 return this;
8419 }
8420
8421 /**
8422 * Add extended data to the intent. The name must include a package
8423 * prefix, for example the app com.android.contacts would use names
8424 * like "com.android.contacts.ShowAll".
8425 *
8426 * @param name The name of the extra data, with package prefix.
8427 * @param value The char array data value.
8428 *
8429 * @return Returns the same Intent object, for chaining multiple calls
8430 * into a single statement.
8431 *
8432 * @see #putExtras
8433 * @see #removeExtra
8434 * @see #getCharArrayExtra(String)
8435 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008436 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008437 if (mExtras == null) {
8438 mExtras = new Bundle();
8439 }
8440 mExtras.putCharArray(name, value);
8441 return this;
8442 }
8443
8444 /**
8445 * Add extended data to the intent. The name must include a package
8446 * prefix, for example the app com.android.contacts would use names
8447 * like "com.android.contacts.ShowAll".
8448 *
8449 * @param name The name of the extra data, with package prefix.
8450 * @param value The int array data value.
8451 *
8452 * @return Returns the same Intent object, for chaining multiple calls
8453 * into a single statement.
8454 *
8455 * @see #putExtras
8456 * @see #removeExtra
8457 * @see #getIntArrayExtra(String)
8458 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008459 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008460 if (mExtras == null) {
8461 mExtras = new Bundle();
8462 }
8463 mExtras.putIntArray(name, value);
8464 return this;
8465 }
8466
8467 /**
8468 * Add extended data to the intent. The name must include a package
8469 * prefix, for example the app com.android.contacts would use names
8470 * like "com.android.contacts.ShowAll".
8471 *
8472 * @param name The name of the extra data, with package prefix.
8473 * @param value The byte array data value.
8474 *
8475 * @return Returns the same Intent object, for chaining multiple calls
8476 * into a single statement.
8477 *
8478 * @see #putExtras
8479 * @see #removeExtra
8480 * @see #getLongArrayExtra(String)
8481 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008482 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008483 if (mExtras == null) {
8484 mExtras = new Bundle();
8485 }
8486 mExtras.putLongArray(name, value);
8487 return this;
8488 }
8489
8490 /**
8491 * Add extended data to the intent. The name must include a package
8492 * prefix, for example the app com.android.contacts would use names
8493 * like "com.android.contacts.ShowAll".
8494 *
8495 * @param name The name of the extra data, with package prefix.
8496 * @param value The float array data value.
8497 *
8498 * @return Returns the same Intent object, for chaining multiple calls
8499 * into a single statement.
8500 *
8501 * @see #putExtras
8502 * @see #removeExtra
8503 * @see #getFloatArrayExtra(String)
8504 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008505 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008506 if (mExtras == null) {
8507 mExtras = new Bundle();
8508 }
8509 mExtras.putFloatArray(name, value);
8510 return this;
8511 }
8512
8513 /**
8514 * Add extended data to the intent. The name must include a package
8515 * prefix, for example the app com.android.contacts would use names
8516 * like "com.android.contacts.ShowAll".
8517 *
8518 * @param name The name of the extra data, with package prefix.
8519 * @param value The double array data value.
8520 *
8521 * @return Returns the same Intent object, for chaining multiple calls
8522 * into a single statement.
8523 *
8524 * @see #putExtras
8525 * @see #removeExtra
8526 * @see #getDoubleArrayExtra(String)
8527 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008528 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008529 if (mExtras == null) {
8530 mExtras = new Bundle();
8531 }
8532 mExtras.putDoubleArray(name, value);
8533 return this;
8534 }
8535
8536 /**
8537 * Add extended data to the intent. The name must include a package
8538 * prefix, for example the app com.android.contacts would use names
8539 * like "com.android.contacts.ShowAll".
8540 *
8541 * @param name The name of the extra data, with package prefix.
8542 * @param value The String array data value.
8543 *
8544 * @return Returns the same Intent object, for chaining multiple calls
8545 * into a single statement.
8546 *
8547 * @see #putExtras
8548 * @see #removeExtra
8549 * @see #getStringArrayExtra(String)
8550 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008551 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008552 if (mExtras == null) {
8553 mExtras = new Bundle();
8554 }
8555 mExtras.putStringArray(name, value);
8556 return this;
8557 }
8558
8559 /**
8560 * Add extended data to the intent. The name must include a package
8561 * prefix, for example the app com.android.contacts would use names
8562 * like "com.android.contacts.ShowAll".
8563 *
8564 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008565 * @param value The CharSequence array data value.
8566 *
8567 * @return Returns the same Intent object, for chaining multiple calls
8568 * into a single statement.
8569 *
8570 * @see #putExtras
8571 * @see #removeExtra
8572 * @see #getCharSequenceArrayExtra(String)
8573 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008574 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008575 if (mExtras == null) {
8576 mExtras = new Bundle();
8577 }
8578 mExtras.putCharSequenceArray(name, value);
8579 return this;
8580 }
8581
8582 /**
8583 * Add extended data to the intent. The name must include a package
8584 * prefix, for example the app com.android.contacts would use names
8585 * like "com.android.contacts.ShowAll".
8586 *
8587 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008588 * @param value The Bundle data value.
8589 *
8590 * @return Returns the same Intent object, for chaining multiple calls
8591 * into a single statement.
8592 *
8593 * @see #putExtras
8594 * @see #removeExtra
8595 * @see #getBundleExtra(String)
8596 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008597 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 if (mExtras == null) {
8599 mExtras = new Bundle();
8600 }
8601 mExtras.putBundle(name, value);
8602 return this;
8603 }
8604
8605 /**
8606 * Add extended data to the intent. The name must include a package
8607 * prefix, for example the app com.android.contacts would use names
8608 * like "com.android.contacts.ShowAll".
8609 *
8610 * @param name The name of the extra data, with package prefix.
8611 * @param value The IBinder data value.
8612 *
8613 * @return Returns the same Intent object, for chaining multiple calls
8614 * into a single statement.
8615 *
8616 * @see #putExtras
8617 * @see #removeExtra
8618 * @see #getIBinderExtra(String)
8619 *
8620 * @deprecated
8621 * @hide
8622 */
8623 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008624 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008625 if (mExtras == null) {
8626 mExtras = new Bundle();
8627 }
8628 mExtras.putIBinder(name, value);
8629 return this;
8630 }
8631
8632 /**
8633 * Copy all extras in 'src' in to this intent.
8634 *
8635 * @param src Contains the extras to copy.
8636 *
8637 * @see #putExtra
8638 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008639 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008640 if (src.mExtras != null) {
8641 if (mExtras == null) {
8642 mExtras = new Bundle(src.mExtras);
8643 } else {
8644 mExtras.putAll(src.mExtras);
8645 }
8646 }
8647 return this;
8648 }
8649
8650 /**
8651 * Add a set of extended data to the intent. The keys must include a package
8652 * prefix, for example the app com.android.contacts would use names
8653 * like "com.android.contacts.ShowAll".
8654 *
8655 * @param extras The Bundle of extras to add to this intent.
8656 *
8657 * @see #putExtra
8658 * @see #removeExtra
8659 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008660 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008661 if (mExtras == null) {
8662 mExtras = new Bundle();
8663 }
8664 mExtras.putAll(extras);
8665 return this;
8666 }
8667
8668 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008669 * Completely replace the extras in the Intent with the extras in the
8670 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008671 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008672 * @param src The exact extras contained in this Intent are copied
8673 * into the target intent, replacing any that were previously there.
8674 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008675 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008676 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8677 return this;
8678 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008679
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008680 /**
8681 * Completely replace the extras in the Intent with the given Bundle of
8682 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008683 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008684 * @param extras The new set of extras in the Intent, or null to erase
8685 * all extras.
8686 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008687 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008688 mExtras = extras != null ? new Bundle(extras) : null;
8689 return this;
8690 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008691
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008692 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008693 * Remove extended data from the intent.
8694 *
8695 * @see #putExtra
8696 */
8697 public void removeExtra(String name) {
8698 if (mExtras != null) {
8699 mExtras.remove(name);
8700 if (mExtras.size() == 0) {
8701 mExtras = null;
8702 }
8703 }
8704 }
8705
8706 /**
8707 * Set special flags controlling how this intent is handled. Most values
8708 * here depend on the type of component being executed by the Intent,
8709 * specifically the FLAG_ACTIVITY_* flags are all for use with
8710 * {@link Context#startActivity Context.startActivity()} and the
8711 * FLAG_RECEIVER_* flags are all for use with
8712 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8713 *
Scott Main7aee61f2011-02-08 11:25:01 -08008714 * <p>See the
8715 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8716 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008717 * the behavior of your application.
8718 *
8719 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008720 * @return Returns the same Intent object, for chaining multiple calls
8721 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008722 * @see #getFlags
8723 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008724 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008725 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008726 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008727 mFlags = flags;
8728 return this;
8729 }
8730
8731 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008732 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008733 *
8734 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008735 * @return Returns the same Intent object, for chaining multiple calls into
8736 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008737 * @see #setFlags
8738 * @see #getFlags
8739 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008740 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008741 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008742 mFlags |= flags;
8743 return this;
8744 }
8745
8746 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008747 * Remove these flags from the intent.
8748 *
8749 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008750 * @see #setFlags
8751 * @see #getFlags
8752 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008753 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008754 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008755 mFlags &= ~flags;
8756 }
8757
8758 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008759 * (Usually optional) Set an explicit application package name that limits
8760 * the components this Intent will resolve to. If left to the default
8761 * value of null, all components in all applications will considered.
8762 * If non-null, the Intent can only match the components in the given
8763 * application package.
8764 *
8765 * @param packageName The name of the application package to handle the
8766 * intent, or null to allow any application package.
8767 *
8768 * @return Returns the same Intent object, for chaining multiple calls
8769 * into a single statement.
8770 *
8771 * @see #getPackage
8772 * @see #resolveActivity
8773 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008774 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008775 if (packageName != null && mSelector != null) {
8776 throw new IllegalArgumentException(
8777 "Can't set package name when selector is already set");
8778 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008779 mPackage = packageName;
8780 return this;
8781 }
8782
8783 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008784 * (Usually optional) Explicitly set the component to handle the intent.
8785 * If left with the default value of null, the system will determine the
8786 * appropriate class to use based on the other fields (action, data,
8787 * type, categories) in the Intent. If this class is defined, the
8788 * specified class will always be used regardless of the other fields. You
8789 * should only set this value when you know you absolutely want a specific
8790 * class to be used; otherwise it is better to let the system find the
8791 * appropriate class so that you will respect the installed applications
8792 * and user preferences.
8793 *
8794 * @param component The name of the application component to handle the
8795 * intent, or null to let the system find one for you.
8796 *
8797 * @return Returns the same Intent object, for chaining multiple calls
8798 * into a single statement.
8799 *
8800 * @see #setClass
8801 * @see #setClassName(Context, String)
8802 * @see #setClassName(String, String)
8803 * @see #getComponent
8804 * @see #resolveActivity
8805 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008806 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008807 mComponent = component;
8808 return this;
8809 }
8810
8811 /**
8812 * Convenience for calling {@link #setComponent} with an
8813 * explicit class name.
8814 *
8815 * @param packageContext A Context of the application package implementing
8816 * this class.
8817 * @param className The name of a class inside of the application package
8818 * that will be used as the component for this Intent.
8819 *
8820 * @return Returns the same Intent object, for chaining multiple calls
8821 * into a single statement.
8822 *
8823 * @see #setComponent
8824 * @see #setClass
8825 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008826 public @NonNull Intent setClassName(@NonNull Context packageContext,
8827 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008828 mComponent = new ComponentName(packageContext, className);
8829 return this;
8830 }
8831
8832 /**
8833 * Convenience for calling {@link #setComponent} with an
8834 * explicit application package name and class name.
8835 *
8836 * @param packageName The name of the package implementing the desired
8837 * component.
8838 * @param className The name of a class inside of the application package
8839 * that will be used as the component for this Intent.
8840 *
8841 * @return Returns the same Intent object, for chaining multiple calls
8842 * into a single statement.
8843 *
8844 * @see #setComponent
8845 * @see #setClass
8846 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008847 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008848 mComponent = new ComponentName(packageName, className);
8849 return this;
8850 }
8851
8852 /**
8853 * Convenience for calling {@link #setComponent(ComponentName)} with the
8854 * name returned by a {@link Class} object.
8855 *
8856 * @param packageContext A Context of the application package implementing
8857 * this class.
8858 * @param cls The class name to set, equivalent to
8859 * <code>setClassName(context, cls.getName())</code>.
8860 *
8861 * @return Returns the same Intent object, for chaining multiple calls
8862 * into a single statement.
8863 *
8864 * @see #setComponent
8865 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008866 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008867 mComponent = new ComponentName(packageContext, cls);
8868 return this;
8869 }
8870
8871 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008872 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8873 * used as a hint to the receiver for animations and the like. Null means that there
8874 * is no source bounds.
8875 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008876 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008877 if (r != null) {
8878 mSourceBounds = new Rect(r);
8879 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008880 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008881 }
8882 }
8883
Tor Norbyed9273d62013-05-30 15:59:53 -07008884 /** @hide */
8885 @IntDef(flag = true,
8886 value = {
8887 FILL_IN_ACTION,
8888 FILL_IN_DATA,
8889 FILL_IN_CATEGORIES,
8890 FILL_IN_COMPONENT,
8891 FILL_IN_PACKAGE,
8892 FILL_IN_SOURCE_BOUNDS,
8893 FILL_IN_SELECTOR,
8894 FILL_IN_CLIP_DATA
8895 })
8896 @Retention(RetentionPolicy.SOURCE)
8897 public @interface FillInFlags {}
8898
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008899 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008900 * Use with {@link #fillIn} to allow the current action value to be
8901 * overwritten, even if it is already set.
8902 */
8903 public static final int FILL_IN_ACTION = 1<<0;
8904
8905 /**
8906 * Use with {@link #fillIn} to allow the current data or type value
8907 * overwritten, even if it is already set.
8908 */
8909 public static final int FILL_IN_DATA = 1<<1;
8910
8911 /**
8912 * Use with {@link #fillIn} to allow the current categories to be
8913 * overwritten, even if they are already set.
8914 */
8915 public static final int FILL_IN_CATEGORIES = 1<<2;
8916
8917 /**
8918 * Use with {@link #fillIn} to allow the current component value to be
8919 * overwritten, even if it is already set.
8920 */
8921 public static final int FILL_IN_COMPONENT = 1<<3;
8922
8923 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008924 * Use with {@link #fillIn} to allow the current package value to be
8925 * overwritten, even if it is already set.
8926 */
8927 public static final int FILL_IN_PACKAGE = 1<<4;
8928
8929 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008930 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008931 * overwritten, even if it is already set.
8932 */
8933 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8934
8935 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008936 * Use with {@link #fillIn} to allow the current selector to be
8937 * overwritten, even if it is already set.
8938 */
8939 public static final int FILL_IN_SELECTOR = 1<<6;
8940
8941 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008942 * Use with {@link #fillIn} to allow the current ClipData to be
8943 * overwritten, even if it is already set.
8944 */
8945 public static final int FILL_IN_CLIP_DATA = 1<<7;
8946
8947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008948 * Copy the contents of <var>other</var> in to this object, but only
8949 * where fields are not defined by this object. For purposes of a field
8950 * being defined, the following pieces of data in the Intent are
8951 * considered to be separate fields:
8952 *
8953 * <ul>
8954 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008955 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008956 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8957 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008958 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008959 * <li> component, as set by {@link #setComponent(ComponentName)} or
8960 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008961 * <li> source bounds, as set by {@link #setSourceBounds}.
8962 * <li> selector, as set by {@link #setSelector(Intent)}.
8963 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008964 * <li> each top-level name in the associated extras.
8965 * </ul>
8966 *
8967 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008968 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008969 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8970 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8971 * the restriction where the corresponding field will not be replaced if
8972 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008973 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008974 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8975 * is explicitly specified. The selector will only be copied if
8976 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008977 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008978 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8979 * and Intent B with {action="gotit", data-type="some/thing",
8980 * categories="one","two"}.
8981 *
8982 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8983 * containing: {action="gotit", data-type="some/thing",
8984 * categories="bar"}.
8985 *
8986 * @param other Another Intent whose values are to be used to fill in
8987 * the current one.
8988 * @param flags Options to control which fields can be filled in.
8989 *
8990 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008991 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008992 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008993 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008994 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008995 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008996 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008997 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008998 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008999 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009000 if (other.mAction != null
9001 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009002 mAction = other.mAction;
9003 changes |= FILL_IN_ACTION;
9004 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009005 if ((other.mData != null || other.mType != null)
9006 && ((mData == null && mType == null)
9007 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009008 mData = other.mData;
9009 mType = other.mType;
9010 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009011 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009012 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009013 if (other.mCategories != null
9014 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009015 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009016 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009017 }
9018 changes |= FILL_IN_CATEGORIES;
9019 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009020 if (other.mPackage != null
9021 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009022 // Only do this if mSelector is not set.
9023 if (mSelector == null) {
9024 mPackage = other.mPackage;
9025 changes |= FILL_IN_PACKAGE;
9026 }
9027 }
9028 // Selector is special: it can only be set if explicitly allowed,
9029 // for the same reason as the component name.
9030 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9031 if (mPackage == null) {
9032 mSelector = new Intent(other.mSelector);
9033 mPackage = null;
9034 changes |= FILL_IN_SELECTOR;
9035 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009036 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009037 if (other.mClipData != null
9038 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9039 mClipData = other.mClipData;
9040 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009041 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009042 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009043 // Component is special: it can -only- be set if explicitly allowed,
9044 // since otherwise the sender could force the intent somewhere the
9045 // originator didn't intend.
9046 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009047 mComponent = other.mComponent;
9048 changes |= FILL_IN_COMPONENT;
9049 }
9050 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009051 if (other.mSourceBounds != null
9052 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9053 mSourceBounds = new Rect(other.mSourceBounds);
9054 changes |= FILL_IN_SOURCE_BOUNDS;
9055 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009056 if (mExtras == null) {
9057 if (other.mExtras != null) {
9058 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009059 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009060 }
9061 } else if (other.mExtras != null) {
9062 try {
9063 Bundle newb = new Bundle(other.mExtras);
9064 newb.putAll(mExtras);
9065 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009066 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 } catch (RuntimeException e) {
9068 // Modifying the extras can cause us to unparcel the contents
9069 // of the bundle, and if we do this in the system process that
9070 // may fail. We really should handle this (i.e., the Bundle
9071 // impl shouldn't be on top of a plain map), but for now just
9072 // ignore it and keep the original contents. :(
9073 Log.w("Intent", "Failure filling in extras", e);
9074 }
9075 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009076 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9077 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9078 mContentUserHint = other.mContentUserHint;
9079 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009080 return changes;
9081 }
9082
9083 /**
9084 * Wrapper class holding an Intent and implementing comparisons on it for
9085 * the purpose of filtering. The class implements its
9086 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9087 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9088 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9089 * on the wrapped Intent.
9090 */
9091 public static final class FilterComparison {
9092 private final Intent mIntent;
9093 private final int mHashCode;
9094
9095 public FilterComparison(Intent intent) {
9096 mIntent = intent;
9097 mHashCode = intent.filterHashCode();
9098 }
9099
9100 /**
9101 * Return the Intent that this FilterComparison represents.
9102 * @return Returns the Intent held by the FilterComparison. Do
9103 * not modify!
9104 */
9105 public Intent getIntent() {
9106 return mIntent;
9107 }
9108
9109 @Override
9110 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009111 if (obj instanceof FilterComparison) {
9112 Intent other = ((FilterComparison)obj).mIntent;
9113 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009115 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 }
9117
9118 @Override
9119 public int hashCode() {
9120 return mHashCode;
9121 }
9122 }
9123
9124 /**
9125 * Determine if two intents are the same for the purposes of intent
9126 * resolution (filtering). That is, if their action, data, type,
9127 * class, and categories are the same. This does <em>not</em> compare
9128 * any extra data included in the intents.
9129 *
9130 * @param other The other Intent to compare against.
9131 *
9132 * @return Returns true if action, data, type, class, and categories
9133 * are the same.
9134 */
9135 public boolean filterEquals(Intent other) {
9136 if (other == null) {
9137 return false;
9138 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009139 if (!Objects.equals(this.mAction, other.mAction)) return false;
9140 if (!Objects.equals(this.mData, other.mData)) return false;
9141 if (!Objects.equals(this.mType, other.mType)) return false;
9142 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9143 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9144 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009145
9146 return true;
9147 }
9148
9149 /**
9150 * Generate hash code that matches semantics of filterEquals().
9151 *
9152 * @return Returns the hash value of the action, data, type, class, and
9153 * categories.
9154 *
9155 * @see #filterEquals
9156 */
9157 public int filterHashCode() {
9158 int code = 0;
9159 if (mAction != null) {
9160 code += mAction.hashCode();
9161 }
9162 if (mData != null) {
9163 code += mData.hashCode();
9164 }
9165 if (mType != null) {
9166 code += mType.hashCode();
9167 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009168 if (mPackage != null) {
9169 code += mPackage.hashCode();
9170 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009171 if (mComponent != null) {
9172 code += mComponent.hashCode();
9173 }
9174 if (mCategories != null) {
9175 code += mCategories.hashCode();
9176 }
9177 return code;
9178 }
9179
9180 @Override
9181 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009182 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009183
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009184 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009185 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009186 b.append(" }");
9187
9188 return b.toString();
9189 }
9190
9191 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009192 public String toInsecureString() {
9193 StringBuilder b = new StringBuilder(128);
9194
9195 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009196 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009197 b.append(" }");
9198
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009199 return b.toString();
9200 }
Romain Guy4969af72009-06-17 10:53:19 -07009201
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009202 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009203 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009204 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009205
9206 b.append("Intent { ");
9207 toShortString(b, false, true, true, true);
9208 b.append(" }");
9209
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009210 return b.toString();
9211 }
9212
9213 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009214 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9215 StringBuilder b = new StringBuilder(128);
9216 toShortString(b, secure, comp, extras, clip);
9217 return b.toString();
9218 }
9219
9220 /** @hide */
9221 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9222 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009223 boolean first = true;
9224 if (mAction != null) {
9225 b.append("act=").append(mAction);
9226 first = false;
9227 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009228 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009229 if (!first) {
9230 b.append(' ');
9231 }
9232 first = false;
9233 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009234 for (int i=0; i<mCategories.size(); i++) {
9235 if (i > 0) b.append(',');
9236 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009237 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009238 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009239 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009240 if (mData != null) {
9241 if (!first) {
9242 b.append(' ');
9243 }
9244 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009245 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009246 if (secure) {
9247 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009248 } else {
9249 b.append(mData);
9250 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009251 }
9252 if (mType != null) {
9253 if (!first) {
9254 b.append(' ');
9255 }
9256 first = false;
9257 b.append("typ=").append(mType);
9258 }
9259 if (mFlags != 0) {
9260 if (!first) {
9261 b.append(' ');
9262 }
9263 first = false;
9264 b.append("flg=0x").append(Integer.toHexString(mFlags));
9265 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009266 if (mPackage != null) {
9267 if (!first) {
9268 b.append(' ');
9269 }
9270 first = false;
9271 b.append("pkg=").append(mPackage);
9272 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009273 if (comp && mComponent != null) {
9274 if (!first) {
9275 b.append(' ');
9276 }
9277 first = false;
9278 b.append("cmp=").append(mComponent.flattenToShortString());
9279 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009280 if (mSourceBounds != null) {
9281 if (!first) {
9282 b.append(' ');
9283 }
9284 first = false;
9285 b.append("bnds=").append(mSourceBounds.toShortString());
9286 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009287 if (mClipData != null) {
9288 if (!first) {
9289 b.append(' ');
9290 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009291 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009292 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009293 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009294 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009295 if (mClipData.getDescription() != null) {
9296 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9297 } else {
9298 first = true;
9299 }
9300 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009301 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009302 first = false;
9303 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009304 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009305 if (extras && mExtras != null) {
9306 if (!first) {
9307 b.append(' ');
9308 }
9309 first = false;
9310 b.append("(has extras)");
9311 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009312 if (mContentUserHint != UserHandle.USER_CURRENT) {
9313 if (!first) {
9314 b.append(' ');
9315 }
9316 first = false;
9317 b.append("u=").append(mContentUserHint);
9318 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009319 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009320 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009321 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009322 b.append("}");
9323 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009324 }
9325
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009326 /**
9327 * Call {@link #toUri} with 0 flags.
9328 * @deprecated Use {@link #toUri} instead.
9329 */
9330 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009331 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009332 return toUri(0);
9333 }
9334
9335 /**
9336 * Convert this Intent into a String holding a URI representation of it.
9337 * The returned URI string has been properly URI encoded, so it can be
9338 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9339 * Intent's data as the base URI, with an additional fragment describing
9340 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009341 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009342 * <p>You can convert the returned string back to an Intent with
9343 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009344 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009345 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009346 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009347 * @return Returns a URI encoding URI string describing the entire contents
9348 * of the Intent.
9349 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009350 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009351 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009352 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9353 if (mPackage == null) {
9354 throw new IllegalArgumentException(
9355 "Intent must include an explicit package name to build an android-app: "
9356 + this);
9357 }
9358 uri.append("android-app://");
9359 uri.append(mPackage);
9360 String scheme = null;
9361 if (mData != null) {
9362 scheme = mData.getScheme();
9363 if (scheme != null) {
9364 uri.append('/');
9365 uri.append(scheme);
9366 String authority = mData.getEncodedAuthority();
9367 if (authority != null) {
9368 uri.append('/');
9369 uri.append(authority);
9370 String path = mData.getEncodedPath();
9371 if (path != null) {
9372 uri.append(path);
9373 }
9374 String queryParams = mData.getEncodedQuery();
9375 if (queryParams != null) {
9376 uri.append('?');
9377 uri.append(queryParams);
9378 }
9379 String fragment = mData.getEncodedFragment();
9380 if (fragment != null) {
9381 uri.append('#');
9382 uri.append(fragment);
9383 }
9384 }
9385 }
9386 }
9387 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9388 mPackage, flags);
9389 return uri.toString();
9390 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009391 String scheme = null;
9392 if (mData != null) {
9393 String data = mData.toString();
9394 if ((flags&URI_INTENT_SCHEME) != 0) {
9395 final int N = data.length();
9396 for (int i=0; i<N; i++) {
9397 char c = data.charAt(i);
9398 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9399 || c == '.' || c == '-') {
9400 continue;
9401 }
9402 if (c == ':' && i > 0) {
9403 // Valid scheme.
9404 scheme = data.substring(0, i);
9405 uri.append("intent:");
9406 data = data.substring(i+1);
9407 break;
9408 }
Tom Taylord4a47292009-12-21 13:59:18 -08009409
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009410 // No scheme.
9411 break;
9412 }
9413 }
9414 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009415
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009416 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9417 uri.append("intent:");
9418 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009419
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009420 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009421
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009422 return uri.toString();
9423 }
9424
9425 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9426 String defPackage, int flags) {
9427 StringBuilder frag = new StringBuilder(128);
9428
9429 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009430 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009431 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009432 // Note that for now we are not going to try to handle the
9433 // data part; not clear how to represent this as a URI, and
9434 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009435 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9436 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009437 }
9438
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009439 if (frag.length() > 0) {
9440 uri.append("#Intent;");
9441 uri.append(frag);
9442 uri.append("end");
9443 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009444 }
9445
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009446 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9447 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009448 if (scheme != null) {
9449 uri.append("scheme=").append(scheme).append(';');
9450 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009451 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009452 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009453 }
9454 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009455 for (int i=0; i<mCategories.size(); i++) {
9456 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009457 }
9458 }
9459 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009460 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009461 }
9462 if (mFlags != 0) {
9463 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9464 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009465 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009466 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9467 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009468 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009469 uri.append("component=").append(Uri.encode(
9470 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009471 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009472 if (mSourceBounds != null) {
9473 uri.append("sourceBounds=")
9474 .append(Uri.encode(mSourceBounds.flattenToString()))
9475 .append(';');
9476 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009477 if (mExtras != null) {
9478 for (String key : mExtras.keySet()) {
9479 final Object value = mExtras.get(key);
9480 char entryType =
9481 value instanceof String ? 'S' :
9482 value instanceof Boolean ? 'B' :
9483 value instanceof Byte ? 'b' :
9484 value instanceof Character ? 'c' :
9485 value instanceof Double ? 'd' :
9486 value instanceof Float ? 'f' :
9487 value instanceof Integer ? 'i' :
9488 value instanceof Long ? 'l' :
9489 value instanceof Short ? 's' :
9490 '\0';
9491
9492 if (entryType != '\0') {
9493 uri.append(entryType);
9494 uri.append('.');
9495 uri.append(Uri.encode(key));
9496 uri.append('=');
9497 uri.append(Uri.encode(value.toString()));
9498 uri.append(';');
9499 }
9500 }
9501 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009502 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009503
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009504 public int describeContents() {
9505 return (mExtras != null) ? mExtras.describeContents() : 0;
9506 }
9507
9508 public void writeToParcel(Parcel out, int flags) {
9509 out.writeString(mAction);
9510 Uri.writeToParcel(out, mData);
9511 out.writeString(mType);
9512 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009513 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009514 ComponentName.writeToParcel(mComponent, out);
9515
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009516 if (mSourceBounds != null) {
9517 out.writeInt(1);
9518 mSourceBounds.writeToParcel(out, flags);
9519 } else {
9520 out.writeInt(0);
9521 }
9522
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009523 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009524 final int N = mCategories.size();
9525 out.writeInt(N);
9526 for (int i=0; i<N; i++) {
9527 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009528 }
9529 } else {
9530 out.writeInt(0);
9531 }
9532
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009533 if (mSelector != null) {
9534 out.writeInt(1);
9535 mSelector.writeToParcel(out, flags);
9536 } else {
9537 out.writeInt(0);
9538 }
9539
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009540 if (mClipData != null) {
9541 out.writeInt(1);
9542 mClipData.writeToParcel(out, flags);
9543 } else {
9544 out.writeInt(0);
9545 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009546 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009547 out.writeBundle(mExtras);
9548 }
9549
9550 public static final Parcelable.Creator<Intent> CREATOR
9551 = new Parcelable.Creator<Intent>() {
9552 public Intent createFromParcel(Parcel in) {
9553 return new Intent(in);
9554 }
9555 public Intent[] newArray(int size) {
9556 return new Intent[size];
9557 }
9558 };
9559
Dianne Hackborneb034652009-09-07 00:49:58 -07009560 /** @hide */
9561 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009562 readFromParcel(in);
9563 }
9564
9565 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009566 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009567 mData = Uri.CREATOR.createFromParcel(in);
9568 mType = in.readString();
9569 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009570 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009571 mComponent = ComponentName.readFromParcel(in);
9572
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009573 if (in.readInt() != 0) {
9574 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9575 }
9576
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009577 int N = in.readInt();
9578 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009579 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009580 int i;
9581 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009582 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009583 }
9584 } else {
9585 mCategories = null;
9586 }
9587
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009588 if (in.readInt() != 0) {
9589 mSelector = new Intent(in);
9590 }
9591
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009592 if (in.readInt() != 0) {
9593 mClipData = new ClipData(in);
9594 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009595 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009596 mExtras = in.readBundle();
9597 }
9598
9599 /**
9600 * Parses the "intent" element (and its children) from XML and instantiates
9601 * an Intent object. The given XML parser should be located at the tag
9602 * where parsing should start (often named "intent"), from which the
9603 * basic action, data, type, and package and class name will be
9604 * retrieved. The function will then parse in to any child elements,
9605 * looking for <category android:name="xxx"> tags to add categories and
9606 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9607 * to the intent.
9608 *
9609 * @param resources The Resources to use when inflating resources.
9610 * @param parser The XML parser pointing at an "intent" tag.
9611 * @param attrs The AttributeSet interface for retrieving extended
9612 * attribute data at the current <var>parser</var> location.
9613 * @return An Intent object matching the XML data.
9614 * @throws XmlPullParserException If there was an XML parsing error.
9615 * @throws IOException If there was an I/O error.
9616 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009617 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9618 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009619 throws XmlPullParserException, IOException {
9620 Intent intent = new Intent();
9621
9622 TypedArray sa = resources.obtainAttributes(attrs,
9623 com.android.internal.R.styleable.Intent);
9624
9625 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9626
9627 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9628 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9629 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9630
9631 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9632 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9633 if (packageName != null && className != null) {
9634 intent.setComponent(new ComponentName(packageName, className));
9635 }
9636
9637 sa.recycle();
9638
9639 int outerDepth = parser.getDepth();
9640 int type;
9641 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9642 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9643 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9644 continue;
9645 }
9646
9647 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009648 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009649 sa = resources.obtainAttributes(attrs,
9650 com.android.internal.R.styleable.IntentCategory);
9651 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9652 sa.recycle();
9653
9654 if (cat != null) {
9655 intent.addCategory(cat);
9656 }
9657 XmlUtils.skipCurrentTag(parser);
9658
Craig Mautner21d24a22014-04-23 11:45:37 -07009659 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009660 if (intent.mExtras == null) {
9661 intent.mExtras = new Bundle();
9662 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009663 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009664 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009665
9666 } else {
9667 XmlUtils.skipCurrentTag(parser);
9668 }
9669 }
9670
9671 return intent;
9672 }
Nick Pellyccae4122012-01-09 14:12:58 -08009673
Craig Mautner21d24a22014-04-23 11:45:37 -07009674 /** @hide */
9675 public void saveToXml(XmlSerializer out) throws IOException {
9676 if (mAction != null) {
9677 out.attribute(null, ATTR_ACTION, mAction);
9678 }
9679 if (mData != null) {
9680 out.attribute(null, ATTR_DATA, mData.toString());
9681 }
9682 if (mType != null) {
9683 out.attribute(null, ATTR_TYPE, mType);
9684 }
9685 if (mComponent != null) {
9686 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9687 }
9688 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9689
9690 if (mCategories != null) {
9691 out.startTag(null, TAG_CATEGORIES);
9692 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9693 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9694 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009695 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009696 }
9697 }
9698
9699 /** @hide */
9700 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9701 XmlPullParserException {
9702 Intent intent = new Intent();
9703 final int outerDepth = in.getDepth();
9704
9705 int attrCount = in.getAttributeCount();
9706 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9707 final String attrName = in.getAttributeName(attrNdx);
9708 final String attrValue = in.getAttributeValue(attrNdx);
9709 if (ATTR_ACTION.equals(attrName)) {
9710 intent.setAction(attrValue);
9711 } else if (ATTR_DATA.equals(attrName)) {
9712 intent.setData(Uri.parse(attrValue));
9713 } else if (ATTR_TYPE.equals(attrName)) {
9714 intent.setType(attrValue);
9715 } else if (ATTR_COMPONENT.equals(attrName)) {
9716 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9717 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009718 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009719 } else {
9720 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9721 }
9722 }
9723
9724 int event;
9725 String name;
9726 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9727 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9728 if (event == XmlPullParser.START_TAG) {
9729 name = in.getName();
9730 if (TAG_CATEGORIES.equals(name)) {
9731 attrCount = in.getAttributeCount();
9732 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9733 intent.addCategory(in.getAttributeValue(attrNdx));
9734 }
9735 } else {
9736 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9737 XmlUtils.skipCurrentTag(in);
9738 }
9739 }
9740 }
9741
9742 return intent;
9743 }
9744
Nick Pellyccae4122012-01-09 14:12:58 -08009745 /**
9746 * Normalize a MIME data type.
9747 *
9748 * <p>A normalized MIME type has white-space trimmed,
9749 * content-type parameters removed, and is lower-case.
9750 * This aligns the type with Android best practices for
9751 * intent filtering.
9752 *
9753 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9754 * "text/x-vCard" becomes "text/x-vcard".
9755 *
9756 * <p>All MIME types received from outside Android (such as user input,
9757 * or external sources like Bluetooth, NFC, or the Internet) should
9758 * be normalized before they are used to create an Intent.
9759 *
9760 * @param type MIME data type to normalize
9761 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009762 * @see #setType
9763 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009764 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009765 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009766 if (type == null) {
9767 return null;
9768 }
9769
Elliott Hughescb64d432013-08-02 10:00:44 -07009770 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009771
9772 final int semicolonIndex = type.indexOf(';');
9773 if (semicolonIndex != -1) {
9774 type = type.substring(0, semicolonIndex);
9775 }
9776 return type;
9777 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009778
9779 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009780 * Prepare this {@link Intent} to leave an app process.
9781 *
9782 * @hide
9783 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009784 public void prepareToLeaveProcess(Context context) {
9785 final boolean leavingPackage = (mComponent == null)
9786 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9787 prepareToLeaveProcess(leavingPackage);
9788 }
9789
9790 /**
9791 * Prepare this {@link Intent} to leave an app process.
9792 *
9793 * @hide
9794 */
9795 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009796 setAllowFds(false);
9797
9798 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009799 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009800 }
9801 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009802 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009803 }
9804
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009805 if (mExtras != null && !mExtras.isParcelled()) {
9806 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9807 if (intent instanceof Intent) {
9808 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9809 }
9810 }
9811
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009812 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9813 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009814 switch (mAction) {
9815 case ACTION_MEDIA_REMOVED:
9816 case ACTION_MEDIA_UNMOUNTED:
9817 case ACTION_MEDIA_CHECKING:
9818 case ACTION_MEDIA_NOFS:
9819 case ACTION_MEDIA_MOUNTED:
9820 case ACTION_MEDIA_SHARED:
9821 case ACTION_MEDIA_UNSHARED:
9822 case ACTION_MEDIA_BAD_REMOVAL:
9823 case ACTION_MEDIA_UNMOUNTABLE:
9824 case ACTION_MEDIA_EJECT:
9825 case ACTION_MEDIA_SCANNER_STARTED:
9826 case ACTION_MEDIA_SCANNER_FINISHED:
9827 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009828 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9829 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009830 // Ignore legacy actions
9831 break;
9832 default:
9833 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009834 }
9835 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009836
9837 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9838 && leavingPackage) {
9839 switch (mAction) {
9840 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -07009841 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009842 // Ignore actions that don't need to grant
9843 break;
9844 default:
9845 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9846 }
9847 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009848 }
9849
9850 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009851 * @hide
9852 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009853 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009854 // We just entered destination process, so we should be able to read all
9855 // parcelables inside.
9856 setDefusable(true);
9857
9858 if (mSelector != null) {
9859 mSelector.prepareToEnterProcess();
9860 }
9861 if (mClipData != null) {
9862 mClipData.prepareToEnterProcess();
9863 }
9864
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009865 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009866 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9867 fixUris(mContentUserHint);
9868 mContentUserHint = UserHandle.USER_CURRENT;
9869 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009870 }
9871 }
9872
9873 /**
9874 * @hide
9875 */
9876 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009877 Uri data = getData();
9878 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009879 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009880 }
9881 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009882 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009883 }
9884 String action = getAction();
9885 if (ACTION_SEND.equals(action)) {
9886 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9887 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009888 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009889 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009890 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009891 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9892 if (streams != null) {
9893 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9894 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009895 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009896 }
9897 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9898 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009899 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9900 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9901 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9902 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9903 if (output != null) {
9904 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9905 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009906 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009907 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009908
9909 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009910 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009911 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9912 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009913 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009914 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009915 * @hide
9916 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009917 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009918 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009919 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009920
9921 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009922 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009923
9924 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009925 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009926 // Inspect contained intents to see if we need to migrate extras. We
9927 // don't promote ClipData to the parent, since ChooserActivity will
9928 // already start the picked item as the caller, and we can't combine
9929 // the flags in a safe way.
9930
9931 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009932 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009933 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9934 if (intent != null) {
9935 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009936 }
9937 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009938 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009939 try {
9940 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9941 if (intents != null) {
9942 for (int i = 0; i < intents.length; i++) {
9943 final Intent intent = (Intent) intents[i];
9944 if (intent != null) {
9945 migrated |= intent.migrateExtraStreamToClipData();
9946 }
9947 }
9948 }
9949 } catch (ClassCastException e) {
9950 }
9951 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009952
9953 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009954 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009955 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9956 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9957 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9958 if (stream != null || text != null || htmlText != null) {
9959 final ClipData clipData = new ClipData(
9960 null, new String[] { getType() },
9961 new ClipData.Item(text, htmlText, null, stream));
9962 setClipData(clipData);
9963 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009964 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009965 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009966 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009967 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009968
9969 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009970 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009971 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9972 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9973 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9974 int num = -1;
9975 if (streams != null) {
9976 num = streams.size();
9977 }
9978 if (texts != null) {
9979 if (num >= 0 && num != texts.size()) {
9980 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009981 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009982 }
9983 num = texts.size();
9984 }
9985 if (htmlTexts != null) {
9986 if (num >= 0 && num != htmlTexts.size()) {
9987 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009988 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009989 }
9990 num = htmlTexts.size();
9991 }
9992 if (num > 0) {
9993 final ClipData clipData = new ClipData(
9994 null, new String[] { getType() },
9995 makeClipItem(streams, texts, htmlTexts, 0));
9996
9997 for (int i = 1; i < num; i++) {
9998 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9999 }
10000
10001 setClipData(clipData);
10002 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010003 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010004 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010005 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010006 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010007 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10008 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10009 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10010 final Uri output;
10011 try {
10012 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10013 } catch (ClassCastException e) {
10014 return false;
10015 }
10016 if (output != null) {
10017 setClipData(ClipData.newRawUri("", output));
10018 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10019 return true;
10020 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010021 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010022
10023 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010024 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010025
10026 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10027 ArrayList<String> htmlTexts, int which) {
10028 Uri uri = streams != null ? streams.get(which) : null;
10029 CharSequence text = texts != null ? texts.get(which) : null;
10030 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10031 return new ClipData.Item(text, htmlText, null, uri);
10032 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010033
10034 /** @hide */
10035 public boolean isDocument() {
10036 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10037 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010038}