blob: a6e6ceb029fa15b8d4c4cd7a94acea0c6c6c020f [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
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070022import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050024import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060027import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30import android.content.res.Resources;
31import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080032import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060034import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.os.Bundle;
36import android.os.IBinder;
37import android.os.Parcel;
38import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000039import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050040import android.os.ResultReceiver;
41import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070042import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010043import android.os.UserHandle;
Jeff Sharkey81aebe72017-04-03 20:14:10 +000044import android.os.storage.StorageManager;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070045import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070048import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070050import android.util.AttributeSet;
51import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080052import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import org.xmlpull.v1.XmlPullParser;
54import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070055import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070056
57import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080058import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070060import java.lang.annotation.Retention;
61import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.net.URISyntaxException;
63import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080064import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070065import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080066import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070067import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.util.Set;
69
Jeff Sharkey81aebe72017-04-03 20:14:10 +000070import static android.content.ContentProvider.maybeAddUserId;
71
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072/**
73 * An intent is an abstract description of an operation to be performed. It
74 * can be used with {@link Context#startActivity(Intent) startActivity} to
75 * launch an {@link android.app.Activity},
76 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
77 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
78 * and {@link android.content.Context#startService} or
79 * {@link android.content.Context#bindService} to communicate with a
80 * background {@link android.app.Service}.
81 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 * <p>An Intent provides a facility for performing late runtime binding between the code in
83 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070084 * can be thought of as the glue between activities. It is basically a passive data structure
85 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 *
87 * <div class="special reference">
88 * <h3>Developer Guides</h3>
89 * <p>For information about how to create and resolve intents, read the
90 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
91 * developer guide.</p>
92 * </div>
93 *
94 * <a name="IntentStructure"></a>
95 * <h3>Intent Structure</h3>
96 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 *
98 * <ul>
99 * <li> <p><b>action</b> -- The general action to be performed, such as
100 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
101 * etc.</p>
102 * </li>
103 * <li> <p><b>data</b> -- The data to operate on, such as a person record
104 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
105 * </li>
106 * </ul>
107 *
108 *
109 * <p>Some examples of action/data pairs are:</p>
110 *
111 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700112 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700113 * information about the person whose identifier is "1".</p>
114 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700115 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700116 * the phone dialer with the person filled in.</p>
117 * </li>
118 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
119 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700120 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * a particular URI.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in.</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * information about the person whose identifier is "1".</p>
128 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a list of people, which the user can browse through. This example is a
131 * typical top-level entry into the Contacts application, showing you the
132 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700133 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * being used to start an activity to display that person.</p>
135 * </li>
136 * </ul>
137 *
138 * <p>In addition to these primary attributes, there are a number of secondary
139 * attributes that you can also include with an intent:</p>
140 *
141 * <ul>
142 * <li> <p><b>category</b> -- Gives additional information about the action
143 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
144 * appear in the Launcher as a top-level application, while
145 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
146 * of alternative actions the user can perform on a piece of data.</p>
147 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
148 * intent data. Normally the type is inferred from the data itself.
149 * By setting this attribute, you disable that evaluation and force
150 * an explicit type.</p>
151 * <li> <p><b>component</b> -- Specifies an explicit name of a component
152 * class to use for the intent. Normally this is determined by looking
153 * at the other information in the intent (the action, data/type, and
154 * categories) and matching that with a component that can handle it.
155 * If this attribute is set then none of the evaluation is performed,
156 * and this component is used exactly as is. By specifying this attribute,
157 * all of the other Intent attributes become optional.</p>
158 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
159 * This can be used to provide extended information to the component.
160 * For example, if we have a action to send an e-mail message, we could
161 * also include extra pieces of data here to supply a subject, body,
162 * etc.</p>
163 * </ul>
164 *
165 * <p>Here are some examples of other operations you can specify as intents
166 * using these additional parameters:</p>
167 *
168 * <ul>
169 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
170 * Launch the home screen.</p>
171 * </li>
172 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
173 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
174 * vnd.android.cursor.item/phone}</i></b>
175 * -- Display the list of people's phone numbers, allowing the user to
176 * browse through them and pick one and return it to the parent activity.</p>
177 * </li>
178 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
180 * -- Display all pickers for data that can be opened with
181 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
182 * allowing the user to pick one of them and then some data inside of it
183 * and returning the resulting URI to the caller. This can be used,
184 * for example, in an e-mail application to allow the user to pick some
185 * data to include as an attachment.</p>
186 * </li>
187 * </ul>
188 *
189 * <p>There are a variety of standard Intent action and category constants
190 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700191 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700193 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700194 *
195 * <p>Put together, the set of actions, data types, categories, and extra data
196 * defines a language for the system allowing for the expression of phrases
197 * such as "call john smith's cell". As applications are added to the system,
198 * they can extend this language by adding new actions, types, and categories, or
199 * they can modify the behavior of existing phrases by supplying their own
200 * activities that handle them.</p>
201 *
202 * <a name="IntentResolution"></a>
203 * <h3>Intent Resolution</h3>
204 *
205 * <p>There are two primary forms of intents you will use.
206 *
207 * <ul>
208 * <li> <p><b>Explicit Intents</b> have specified a component (via
209 * {@link #setComponent} or {@link #setClass}), which provides the exact
210 * class to be run. Often these will not include any other information,
211 * simply being a way for an application to launch various internal
212 * activities it has as the user interacts with the application.
213 *
214 * <li> <p><b>Implicit Intents</b> have not specified a component;
215 * instead, they must include enough information for the system to
216 * determine which of the available components is best to run for that
217 * intent.
218 * </ul>
219 *
220 * <p>When using implicit intents, given such an arbitrary intent we need to
221 * know what to do with it. This is handled by the process of <em>Intent
222 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
223 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
224 * more activities/receivers) that can handle it.</p>
225 *
226 * <p>The intent resolution mechanism basically revolves around matching an
227 * Intent against all of the &lt;intent-filter&gt; descriptions in the
228 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
229 * objects explicitly registered with {@link Context#registerReceiver}.) More
230 * details on this can be found in the documentation on the {@link
231 * IntentFilter} class.</p>
232 *
233 * <p>There are three pieces of information in the Intent that are used for
234 * resolution: the action, type, and category. Using this information, a query
235 * is done on the {@link PackageManager} for a component that can handle the
236 * intent. The appropriate component is determined based on the intent
237 * information supplied in the <code>AndroidManifest.xml</code> file as
238 * follows:</p>
239 *
240 * <ul>
241 * <li> <p>The <b>action</b>, if given, must be listed by the component as
242 * one it handles.</p>
243 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
244 * already supplied in the Intent. Like the action, if a type is
245 * included in the intent (either explicitly or implicitly in its
246 * data), then this must be listed by the component as one it handles.</p>
247 * <li> For data that is not a <code>content:</code> URI and where no explicit
248 * type is included in the Intent, instead the <b>scheme</b> of the
249 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
250 * considered. Again like the action, if we are matching a scheme it
251 * must be listed by the component as one it can handle.
252 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
253 * by the activity as categories it handles. That is, if you include
254 * the categories {@link #CATEGORY_LAUNCHER} and
255 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
256 * with an intent that lists <em>both</em> of those categories.
257 * Activities will very often need to support the
258 * {@link #CATEGORY_DEFAULT} so that they can be found by
259 * {@link Context#startActivity Context.startActivity()}.</p>
260 * </ul>
261 *
262 * <p>For example, consider the Note Pad sample application that
263 * allows user to browse through a list of notes data and view details about
264 * individual items. Text in italics indicate places were you would replace a
265 * name with one specific to your own package.</p>
266 *
267 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
268 * package="<i>com.android.notepad</i>"&gt;
269 * &lt;application android:icon="@drawable/app_notes"
270 * android:label="@string/app_name"&gt;
271 *
272 * &lt;provider class=".NotePadProvider"
273 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
274 *
275 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.MAIN" /&gt;
278 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700279 * &lt;/intent-filter&gt;
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.VIEW" /&gt;
282 * &lt;action android:name="android.intent.action.EDIT" /&gt;
283 * &lt;action android:name="android.intent.action.PICK" /&gt;
284 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;/activity&gt;
293 *
294 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
295 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.VIEW" /&gt;
297 * &lt;action android:name="android.intent.action.EDIT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 *
302 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700303 * &lt;action android:name="android.intent.action.INSERT" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700306 * &lt;/intent-filter&gt;
307 *
308 * &lt;/activity&gt;
309 *
310 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
311 * android:theme="@android:style/Theme.Dialog"&gt;
312 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
314 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
316 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
317 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700318 * &lt;/intent-filter&gt;
319 * &lt;/activity&gt;
320 *
321 * &lt;/application&gt;
322 * &lt;/manifest&gt;</pre>
323 *
324 * <p>The first activity,
325 * <code>com.android.notepad.NotesList</code>, serves as our main
326 * entry into the app. It can do three things as described by its three intent
327 * templates:
328 * <ol>
329 * <li><pre>
330 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700331 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
332 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700333 * &lt;/intent-filter&gt;</pre>
334 * <p>This provides a top-level entry into the NotePad application: the standard
335 * MAIN action is a main entry point (not requiring any other information in
336 * the Intent), and the LAUNCHER category says that this entry point should be
337 * listed in the application launcher.</p>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
341 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
342 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
343 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700344 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700345 * &lt;/intent-filter&gt;</pre>
346 * <p>This declares the things that the activity can do on a directory of
347 * notes. The type being supported is given with the &lt;type&gt; tag, where
348 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
349 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
350 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
351 * The activity allows the user to view or edit the directory of data (via
352 * the VIEW and EDIT actions), or to pick a particular note and return it
353 * to the caller (via the PICK action). Note also the DEFAULT category
354 * supplied here: this is <em>required</em> for the
355 * {@link Context#startActivity Context.startActivity} method to resolve your
356 * activity when its component name is not explicitly specified.</p>
357 * <li><pre>
358 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700359 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
360 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700363 * <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 -0700364 * the user without needing to know where it came from. The data type
365 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
366 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
367 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
368 * The GET_CONTENT action is similar to the PICK action, where the activity
369 * will return to its caller a piece of data selected by the user. Here,
370 * however, the caller specifies the type of data they desire instead of
371 * the type of data the user will be picking from.</p>
372 * </ol>
373 *
374 * <p>Given these capabilities, the following intents will resolve to the
375 * NotesList activity:</p>
376 *
377 * <ul>
378 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
379 * activities that can be used as top-level entry points into an
380 * application.</p>
381 * <li> <p><b>{ action=android.app.action.MAIN,
382 * category=android.app.category.LAUNCHER }</b> is the actual intent
383 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700384 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700385 * data=content://com.google.provider.NotePad/notes }</b>
386 * displays a list of all the notes under
387 * "content://com.google.provider.NotePad/notes", which
388 * the user can browse through and see the details on.</p>
389 * <li> <p><b>{ action=android.app.action.PICK
390 * data=content://com.google.provider.NotePad/notes }</b>
391 * provides a list of the notes under
392 * "content://com.google.provider.NotePad/notes", from which
393 * the user can pick a note whose data URL is returned back to the caller.</p>
394 * <li> <p><b>{ action=android.app.action.GET_CONTENT
395 * type=vnd.android.cursor.item/vnd.google.note }</b>
396 * is similar to the pick action, but allows the caller to specify the
397 * kind of data they want back so that the system can find the appropriate
398 * activity to pick something of that data type.</p>
399 * </ul>
400 *
401 * <p>The second activity,
402 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
403 * note entry and allows them to edit it. It can do two things as described
404 * by its two intent templates:
405 * <ol>
406 * <li><pre>
407 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700408 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
409 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
410 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
411 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700412 * &lt;/intent-filter&gt;</pre>
413 * <p>The first, primary, purpose of this activity is to let the user interact
414 * with a single note, as decribed by the MIME type
415 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
416 * either VIEW a note or allow the user to EDIT it. Again we support the
417 * DEFAULT category to allow the activity to be launched without explicitly
418 * specifying its component.</p>
419 * <li><pre>
420 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700421 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
422 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
423 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700424 * &lt;/intent-filter&gt;</pre>
425 * <p>The secondary use of this activity is to insert a new note entry into
426 * an existing directory of notes. This is used when the user creates a new
427 * note: the INSERT action is executed on the directory of notes, causing
428 * this activity to run and have the user create the new note data which
429 * it then adds to the content provider.</p>
430 * </ol>
431 *
432 * <p>Given these capabilities, the following intents will resolve to the
433 * NoteEditor activity:</p>
434 *
435 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700436 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700437 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 * shows the user the content of note <var>{ID}</var>.</p>
439 * <li> <p><b>{ action=android.app.action.EDIT
440 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
441 * allows the user to edit the content of note <var>{ID}</var>.</p>
442 * <li> <p><b>{ action=android.app.action.INSERT
443 * data=content://com.google.provider.NotePad/notes }</b>
444 * creates a new, empty note in the notes list at
445 * "content://com.google.provider.NotePad/notes"
446 * and allows the user to edit it. If they keep their changes, the URI
447 * of the newly created note is returned to the caller.</p>
448 * </ul>
449 *
450 * <p>The last activity,
451 * <code>com.android.notepad.TitleEditor</code>, allows the user to
452 * edit the title of a note. This could be implemented as a class that the
453 * application directly invokes (by explicitly setting its component in
454 * the Intent), but here we show a way you can publish alternative
455 * operations on existing data:</p>
456 *
457 * <pre>
458 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700459 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
463 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700464 * &lt;/intent-filter&gt;</pre>
465 *
466 * <p>In the single intent template here, we
467 * have created our own private action called
468 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
469 * edit the title of a note. It must be invoked on a specific note
470 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
471 * view and edit actions, but here displays and edits the title contained
472 * in the note data.
473 *
474 * <p>In addition to supporting the default category as usual, our title editor
475 * also supports two other standard categories: ALTERNATIVE and
476 * SELECTED_ALTERNATIVE. Implementing
477 * these categories allows others to find the special action it provides
478 * without directly knowing about it, through the
479 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
480 * more often to build dynamic menu items with
481 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
482 * template here was also supply an explicit name for the template
483 * (via <code>android:label="@string/resolve_title"</code>) to better control
484 * what the user sees when presented with this activity as an alternative
485 * action to the data they are viewing.
486 *
487 * <p>Given these capabilities, the following intent will resolve to the
488 * TitleEditor activity:</p>
489 *
490 * <ul>
491 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
492 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
493 * displays and allows the user to edit the title associated
494 * with note <var>{ID}</var>.</p>
495 * </ul>
496 *
497 * <h3>Standard Activity Actions</h3>
498 *
499 * <p>These are the current standard actions that Intent defines for launching
500 * activities (usually through {@link Context#startActivity}. The most
501 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
502 * {@link #ACTION_EDIT}.
503 *
504 * <ul>
505 * <li> {@link #ACTION_MAIN}
506 * <li> {@link #ACTION_VIEW}
507 * <li> {@link #ACTION_ATTACH_DATA}
508 * <li> {@link #ACTION_EDIT}
509 * <li> {@link #ACTION_PICK}
510 * <li> {@link #ACTION_CHOOSER}
511 * <li> {@link #ACTION_GET_CONTENT}
512 * <li> {@link #ACTION_DIAL}
513 * <li> {@link #ACTION_CALL}
514 * <li> {@link #ACTION_SEND}
515 * <li> {@link #ACTION_SENDTO}
516 * <li> {@link #ACTION_ANSWER}
517 * <li> {@link #ACTION_INSERT}
518 * <li> {@link #ACTION_DELETE}
519 * <li> {@link #ACTION_RUN}
520 * <li> {@link #ACTION_SYNC}
521 * <li> {@link #ACTION_PICK_ACTIVITY}
522 * <li> {@link #ACTION_SEARCH}
523 * <li> {@link #ACTION_WEB_SEARCH}
524 * <li> {@link #ACTION_FACTORY_TEST}
525 * </ul>
526 *
527 * <h3>Standard Broadcast Actions</h3>
528 *
529 * <p>These are the current standard actions that Intent defines for receiving
530 * broadcasts (usually through {@link Context#registerReceiver} or a
531 * &lt;receiver&gt; tag in a manifest).
532 *
533 * <ul>
534 * <li> {@link #ACTION_TIME_TICK}
535 * <li> {@link #ACTION_TIME_CHANGED}
536 * <li> {@link #ACTION_TIMEZONE_CHANGED}
537 * <li> {@link #ACTION_BOOT_COMPLETED}
538 * <li> {@link #ACTION_PACKAGE_ADDED}
539 * <li> {@link #ACTION_PACKAGE_CHANGED}
540 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 * <li> {@link #ACTION_PACKAGE_RESTARTED}
542 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000543 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
544 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * <li> {@link #ACTION_UID_REMOVED}
546 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700547 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700548 * <li> {@link #ACTION_POWER_DISCONNECTED}
549 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * </ul>
551 *
552 * <h3>Standard Categories</h3>
553 *
554 * <p>These are the current standard categories that can be used to further
555 * clarify an Intent via {@link #addCategory}.
556 *
557 * <ul>
558 * <li> {@link #CATEGORY_DEFAULT}
559 * <li> {@link #CATEGORY_BROWSABLE}
560 * <li> {@link #CATEGORY_TAB}
561 * <li> {@link #CATEGORY_ALTERNATIVE}
562 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
563 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_HOME}
566 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400568 * <li> {@link #CATEGORY_CAR_DOCK}
569 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500570 * <li> {@link #CATEGORY_LE_DESK_DOCK}
571 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200572 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700573 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800574 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661 * performed on a piece of data.
662 */
663 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900666 * Activity Action: Quick view the data. Launches a quick viewer for
667 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900668 * <p>Activities handling this intent action should handle the vast majority of
669 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700670 * <p>Quick viewers must render the quick view image locally, and must not send
671 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900672 * <p>Input: {@link #getData} is a mandatory content URI of the item to
673 * preview. {@link #getClipData} contains an optional list of content URIs
674 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
675 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700676 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
677 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700678 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900679 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700680 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
684
685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700686 * Used to indicate that some piece of data should be attached to some other
687 * place. For example, image data could be attached to a contact. It is up
688 * to the recipient to decide where the data should be attached; the intent
689 * does not specify the ultimate destination.
690 * <p>Input: {@link #getData} is URI of data to be attached.
691 * <p>Output: nothing.
692 */
693 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
694 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800695
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 /**
697 * Activity Action: Provide explicit editable access to the given data.
698 * <p>Input: {@link #getData} is URI of data to be edited.
699 * <p>Output: nothing.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
706 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
707 * The extras can contain type specific data to pass through to the editing/creating
708 * activity.
709 * <p>Output: The URI of the item that was picked. This must be a content:
710 * URI so that any receiver can access it.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Pick an item from the data, returning what was selected.
717 * <p>Input: {@link #getData} is URI containing a directory of data
718 * (vnd.android.cursor.dir/*) from which to pick an item.
719 * <p>Output: The URI of the item that was picked.
720 */
721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
722 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724 /**
725 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800727 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
728 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
730 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800731 * (value: ShortcutIconResource).</p>
732 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800733 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 * @see #EXTRA_SHORTCUT_INTENT
735 * @see #EXTRA_SHORTCUT_NAME
736 * @see #EXTRA_SHORTCUT_ICON
737 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
742
743 /**
744 * The name of the extra used to define the Intent of a shortcut.
745 *
746 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
751 /**
752 * The name of the extra used to define the name of a shortcut.
753 *
754 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800755 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700756 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
759 /**
760 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
761 *
762 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
767 /**
768 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
769 *
770 * @see #ACTION_CREATE_SHORTCUT
771 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
776 "android.intent.extra.shortcut.ICON_RESOURCE";
777
778 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500779 * An activity that provides a user interface for adjusting application preferences.
780 * Optional but recommended settings for all applications which have settings.
781 */
782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
783 public static final String ACTION_APPLICATION_PREFERENCES
784 = "android.intent.action.APPLICATION_PREFERENCES";
785
786 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700787 * Activity Action: Launch an activity showing the app information.
788 * For applications which install other applications (such as app stores), it is recommended
789 * to handle this action for providing the app information to the user.
790 *
791 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
792 * to be displayed.
793 * <p>Output: Nothing.
794 */
795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
796 public static final String ACTION_SHOW_APP_INFO
797 = "android.intent.action.SHOW_APP_INFO";
798
799 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800800 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700801 *
802 * @see Intent#ACTION_CREATE_SHORTCUT
803 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800804 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
805 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806 */
807 public static class ShortcutIconResource implements Parcelable {
808 /**
809 * The package name of the application containing the icon.
810 */
811 public String packageName;
812
813 /**
814 * The resource name of the icon, including package, name and type.
815 */
816 public String resourceName;
817
818 /**
819 * Creates a new ShortcutIconResource for the specified context and resource
820 * identifier.
821 *
822 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700823 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700825 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700827 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 ShortcutIconResource icon = new ShortcutIconResource();
829 icon.packageName = context.getPackageName();
830 icon.resourceName = context.getResources().getResourceName(resourceId);
831 return icon;
832 }
833
834 /**
835 * Used to read a ShortcutIconResource from a Parcel.
836 */
837 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
838 new Parcelable.Creator<ShortcutIconResource>() {
839
840 public ShortcutIconResource createFromParcel(Parcel source) {
841 ShortcutIconResource icon = new ShortcutIconResource();
842 icon.packageName = source.readString();
843 icon.resourceName = source.readString();
844 return icon;
845 }
846
847 public ShortcutIconResource[] newArray(int size) {
848 return new ShortcutIconResource[size];
849 }
850 };
851
852 /**
853 * No special parcel contents.
854 */
855 public int describeContents() {
856 return 0;
857 }
858
859 public void writeToParcel(Parcel dest, int flags) {
860 dest.writeString(packageName);
861 dest.writeString(resourceName);
862 }
863
864 @Override
865 public String toString() {
866 return resourceName;
867 }
868 }
869
870 /**
871 * Activity Action: Display an activity chooser, allowing the user to pick
872 * what they want to before proceeding. This can be used as an alternative
873 * to the standard activity picker that is displayed by the system when
874 * you try to start an activity with multiple possible matches, with these
875 * differences in behavior:
876 * <ul>
877 * <li>You can specify the title that will appear in the activity chooser.
878 * <li>The user does not have the option to make one of the matching
879 * activities a preferred activity, and all possible activities will
880 * always be shown even if one of them is currently marked as the
881 * preferred activity.
882 * </ul>
883 * <p>
884 * This action should be used when the user will naturally expect to
885 * select an activity in order to proceed. An example if when not to use
886 * it is when the user clicks on a "mailto:" link. They would naturally
887 * expect to go directly to their mail app, so startActivity() should be
888 * called directly: it will
889 * either launch the current preferred app, or put up a dialog allowing the
890 * user to pick an app to use and optionally marking that as preferred.
891 * <p>
892 * In contrast, if the user is selecting a menu item to send a picture
893 * they are viewing to someone else, there are many different things they
894 * may want to do at this point: send it through e-mail, upload it to a
895 * web service, etc. In this case the CHOOSER action should be used, to
896 * always present to the user a list of the things they can do, with a
897 * nice title given by the caller such as "Send this photo with:".
898 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700899 * If you need to grant URI permissions through a chooser, you must specify
900 * the permissions to be granted on the ACTION_CHOOSER Intent
901 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
902 * {@link #setClipData} to specify the URIs to be granted as well as
903 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
904 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
905 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700906 * As a convenience, an Intent of this form can be created with the
907 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700908 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
911 * and can optionally have a {@link #EXTRA_TITLE} field containing the
912 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700913 * <p>
914 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915 */
916 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
917 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
918
919 /**
920 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
921 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700922 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
923 * target intent, also optionally supplying a title. If the target
924 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
925 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
926 * set in the returned chooser intent, with its ClipData set appropriately:
927 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500928 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700929 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 * @param target The Intent that the user will be selecting an activity
931 * to perform.
932 * @param title Optional title that will be displayed in the chooser.
933 * @return Return a new Intent object that you can hand to
934 * {@link Context#startActivity(Intent) Context.startActivity()} and
935 * related methods.
936 */
937 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700938 return createChooser(target, title, null);
939 }
940
941 /**
942 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
943 *
944 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
945 * target intent, also optionally supplying a title. If the target
946 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
947 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
948 * set in the returned chooser intent, with its ClipData set appropriately:
949 * either a direct reflection of {@link #getClipData()} if that is non-null,
950 * or a new ClipData built from {@link #getData()}.</p>
951 *
952 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
953 * when the user makes a choice. This can be useful if the calling application wants
954 * to remember the last chosen target and surface it as a more prominent or one-touch
955 * affordance elsewhere in the UI for next time.</p>
956 *
957 * @param target The Intent that the user will be selecting an activity
958 * to perform.
959 * @param title Optional title that will be displayed in the chooser.
960 * @param sender Optional IntentSender to be called when a choice is made.
961 * @return Return a new Intent object that you can hand to
962 * {@link Context#startActivity(Intent) Context.startActivity()} and
963 * related methods.
964 */
965 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 Intent intent = new Intent(ACTION_CHOOSER);
967 intent.putExtra(EXTRA_INTENT, target);
968 if (title != null) {
969 intent.putExtra(EXTRA_TITLE, title);
970 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700971
Adam Powell0b3c1122014-10-09 12:50:14 -0700972 if (sender != null) {
973 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
974 }
975
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700976 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700977 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
978 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
979 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700980 if (permFlags != 0) {
981 ClipData targetClipData = target.getClipData();
982 if (targetClipData == null && target.getData() != null) {
983 ClipData.Item item = new ClipData.Item(target.getData());
984 String[] mimeTypes;
985 if (target.getType() != null) {
986 mimeTypes = new String[] { target.getType() };
987 } else {
988 mimeTypes = new String[] { };
989 }
990 targetClipData = new ClipData(null, mimeTypes, item);
991 }
992 if (targetClipData != null) {
993 intent.setClipData(targetClipData);
994 intent.addFlags(permFlags);
995 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700996 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700998 return intent;
999 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 /**
1002 * Activity Action: Allow the user to select a particular kind of data and
1003 * return it. This is different than {@link #ACTION_PICK} in that here we
1004 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001005 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001006 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001007 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * etc.
1009 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001010 * 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 -07001011 * of data, such as a person contact, you set the MIME type to the kind of
1012 * data you want and launch it with {@link Context#startActivity(Intent)}.
1013 * The system will then launch the best application to select that kind
1014 * of data for you.
1015 * <p>
1016 * You may also be interested in any of a set of types of content the user
1017 * can pick. For example, an e-mail application that wants to allow the
1018 * user to add an attachment to an e-mail message can use this action to
1019 * bring up a list of all of the types of content the user can attach.
1020 * <p>
1021 * In this case, you should wrap the GET_CONTENT intent with a chooser
1022 * (through {@link #createChooser}), which will give the proper interface
1023 * for the user to pick how to send your data and allow you to specify
1024 * a prompt indicating what they are doing. You will usually specify a
1025 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1026 * broad range of content types the user can select from.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * only pick from data that can be represented as a stream. This is
1030 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1031 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001032 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001033 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001034 * is locally available on the device. For example, if this extra is set
1035 * to true then an image picker should not show any pictures that are available
1036 * from a remote server but not already on the local device (thus requiring
1037 * they be downloaded when opened).
1038 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001039 * If the caller can handle multiple returned items (the user performing
1040 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1041 * to indicate this.
1042 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1044 * that no URI is supplied in the intent, as there are no constraints on
1045 * where the returned data originally comes from. You may also include the
1046 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001048 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1049 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001050 * <p>
1051 * Output: The URI of the item that was picked. This must be a content:
1052 * URI so that any receiver can access it.
1053 */
1054 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1055 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1056 /**
1057 * Activity Action: Dial a number as specified by the data. This shows a
1058 * UI with the number being dialed, allowing the user to explicitly
1059 * initiate the call.
1060 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1061 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1062 * number.
1063 * <p>Output: nothing.
1064 */
1065 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1066 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1067 /**
1068 * Activity Action: Perform a call to someone specified by the data.
1069 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1070 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1071 * number.
1072 * <p>Output: nothing.
1073 *
1074 * <p>Note: there will be restrictions on which applications can initiate a
1075 * call; most applications should use the {@link #ACTION_DIAL}.
1076 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1077 * numbers. Applications can <strong>dial</strong> emergency numbers using
1078 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001079 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001080 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001081 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001082 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001083 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_CALL = "android.intent.action.CALL";
1087 /**
1088 * Activity Action: Perform a call to an emergency number specified by the
1089 * data.
1090 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1091 * tel: URI of an explicit phone number.
1092 * <p>Output: nothing.
1093 * @hide
1094 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001095 @SystemApi
1096 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001097 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1098 /**
1099 * Activity action: Perform a call to any number (emergency or not)
1100 * specified by the data.
1101 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1102 * tel: URI of an explicit phone number.
1103 * <p>Output: nothing.
1104 * @hide
1105 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001106 @SystemApi
1107 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001108 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001109
Santos Cordon15a13782015-03-31 18:32:31 -07001110 /**
fionaxuadfe7002017-02-17 17:20:46 -08001111 * Activity Action: Main entry point for carrier setup apps.
1112 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1113 * carrier service and typically require
1114 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1115 * fulfill their duties.
1116 */
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1119 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001120 * Activity Action: Send a message to someone specified by the data.
1121 * <p>Input: {@link #getData} is URI describing the target.
1122 * <p>Output: nothing.
1123 */
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1126 /**
1127 * Activity Action: Deliver some data to someone else. Who the data is
1128 * being delivered to is not specified; it is up to the receiver of this
1129 * action to ask the user where the data should be sent.
1130 * <p>
1131 * When launching a SEND intent, you should usually wrap it in a chooser
1132 * (through {@link #createChooser}), which will give the proper interface
1133 * for the user to pick how to send your data and allow you to specify
1134 * a prompt indicating what they are doing.
1135 * <p>
1136 * Input: {@link #getType} is the MIME type of the data being sent.
1137 * get*Extra can have either a {@link #EXTRA_TEXT}
1138 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1139 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1140 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1141 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001142 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1143 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1144 * your text with HTML formatting.
1145 * <p>
1146 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1147 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1148 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1149 * content: URIs and other advanced features of {@link ClipData}. If
1150 * using this approach, you still must supply the same data through the
1151 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1152 * for compatibility with old applications. If you don't set a ClipData,
1153 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001154 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001155 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1156 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1157 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1158 * be openable only as asset typed files using
1159 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1160 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001161 * Optional standard extras, which may be interpreted by some recipients as
1162 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1163 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1164 * <p>
1165 * Output: nothing.
1166 */
1167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1168 public static final String ACTION_SEND = "android.intent.action.SEND";
1169 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001170 * Activity Action: Deliver multiple data to someone else.
1171 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001172 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001173 * <p>
1174 * Input: {@link #getType} is the MIME type of the data being sent.
1175 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001176 * #EXTRA_STREAM} field, containing the data to be sent. If using
1177 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1178 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001179 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001180 * Multiple types are supported, and receivers should handle mixed types
1181 * whenever possible. The right way for the receiver to check them is to
1182 * use the content resolver on each URI. The intent sender should try to
1183 * put the most concrete mime type in the intent type, but it can fall
1184 * back to {@literal <type>/*} or {@literal *}/* as needed.
1185 * <p>
1186 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1187 * be image/jpg, but if you are sending image/jpg and image/png, then the
1188 * intent's type should be image/*.
1189 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001190 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1191 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1192 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1193 * content: URIs and other advanced features of {@link ClipData}. If
1194 * using this approach, you still must supply the same data through the
1195 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1196 * for compatibility with old applications. If you don't set a ClipData,
1197 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1198 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001199 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1200 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1201 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1202 * be openable only as asset typed files using
1203 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1204 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001205 * Optional standard extras, which may be interpreted by some recipients as
1206 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1207 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1208 * <p>
1209 * Output: nothing.
1210 */
1211 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1212 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1213 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001214 * Activity Action: Handle an incoming phone call.
1215 * <p>Input: nothing.
1216 * <p>Output: nothing.
1217 */
1218 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1220 /**
1221 * Activity Action: Insert an empty item into the given container.
1222 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1223 * in which to place the data.
1224 * <p>Output: URI of the new data that was created.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1228 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001229 * Activity Action: Create a new item in the given container, initializing it
1230 * from the current contents of the clipboard.
1231 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1232 * in which to place the data.
1233 * <p>Output: URI of the new data that was created.
1234 */
1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1237 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001238 * Activity Action: Delete the given data from its container.
1239 * <p>Input: {@link #getData} is URI of data to be deleted.
1240 * <p>Output: nothing.
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1244 /**
1245 * Activity Action: Run the data, whatever that means.
1246 * <p>Input: ? (Note: this is currently specific to the test harness.)
1247 * <p>Output: nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_RUN = "android.intent.action.RUN";
1251 /**
1252 * Activity Action: Perform a data synchronization.
1253 * <p>Input: ?
1254 * <p>Output: ?
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1258 /**
1259 * Activity Action: Pick an activity given an intent, returning the class
1260 * selected.
1261 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1262 * used with {@link PackageManager#queryIntentActivities} to determine the
1263 * set of activities from which to pick.
1264 * <p>Output: Class name of the activity that was selected.
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1268 /**
1269 * Activity Action: Perform a search.
1270 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1271 * is the text to search for. If empty, simply
1272 * enter your search results Activity with the search UI activated.
1273 * <p>Output: nothing.
1274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1277 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001278 * Activity Action: Start the platform-defined tutorial
1279 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1280 * is the text to search for. If empty, simply
1281 * enter your search results Activity with the search UI activated.
1282 * <p>Output: nothing.
1283 */
1284 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1285 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1286 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001287 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001288 * <p>
1289 * Input: {@link android.app.SearchManager#QUERY
1290 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1291 * a url starts with http or https, the site will be opened. If it is plain
1292 * text, Google search will be applied.
1293 * <p>
1294 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001295 */
1296 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1297 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001298
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299 /**
Jim Miller07994402012-05-02 14:22:27 -07001300 * Activity Action: Perform assist action.
1301 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001302 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1303 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001304 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1305 * information.
Jim Miller07994402012-05-02 14:22:27 -07001306 * Output: nothing.
1307 */
1308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001310
1311 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001312 * Activity Action: Perform voice assist action.
1313 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001314 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1315 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001316 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001317 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001318 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001319 */
Amith Yamasani16452032017-03-03 10:15:57 -08001320 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1323
1324 /**
Adam Skory7140a252013-09-11 12:04:58 +01001325 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1326 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001327 */
1328 public static final String EXTRA_ASSIST_PACKAGE
1329 = "android.intent.extra.ASSIST_PACKAGE";
1330
1331 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001332 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1333 * application package at the time the assist was invoked.
1334 */
1335 public static final String EXTRA_ASSIST_UID
1336 = "android.intent.extra.ASSIST_UID";
1337
1338 /**
Adam Skory7140a252013-09-11 12:04:58 +01001339 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1340 * information supplied by the current foreground app at the time of the assist request.
1341 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001342 */
1343 public static final String EXTRA_ASSIST_CONTEXT
1344 = "android.intent.extra.ASSIST_CONTEXT";
1345
Jim Miller07994402012-05-02 14:22:27 -07001346 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001347 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1348 * keyboard as the primary input device for assistance.
1349 */
1350 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1351 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1352
1353 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001354 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1355 * that was used to invoke the assist.
1356 */
1357 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1358 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1359
1360 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001361 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001362 * <p>Input: Nothing.
1363 * <p>Output: nothing.
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1367 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001368 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001369 * <p>Input: Nothing.
1370 * <p>Output: Nothing.
1371 */
1372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1373 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1374
1375 /**
1376 * Activity Action: Show activity for reporting a bug.
1377 * <p>Input: Nothing.
1378 * <p>Output: Nothing.
1379 */
1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1382
1383 /**
1384 * Activity Action: Main entry point for factory tests. Only used when
1385 * the device is booting in factory test node. The implementing package
1386 * must be installed in the system image.
1387 * <p>Input: nothing
1388 * <p>Output: nothing
1389 */
1390 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1391
1392 /**
1393 * Activity Action: The user pressed the "call" button to go to the dialer
1394 * or other appropriate UI for placing a call.
1395 * <p>Input: Nothing.
1396 * <p>Output: Nothing.
1397 */
1398 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1399 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1400
1401 /**
1402 * Activity Action: Start Voice Command.
1403 * <p>Input: Nothing.
1404 * <p>Output: Nothing.
1405 */
1406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1407 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001408
1409 /**
1410 * Activity Action: Start action associated with long pressing on the
1411 * search key.
1412 * <p>Input: Nothing.
1413 * <p>Output: Nothing.
1414 */
1415 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1416 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001417
Jacek Surazski86b6c532009-05-13 14:38:28 +02001418 /**
1419 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1420 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001421 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001422 * <p>Input: No data is specified. The bug report is passed in using
1423 * an {@link #EXTRA_BUG_REPORT} field.
1424 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001425 *
1426 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001430
1431 /**
1432 * Activity Action: Show power usage information to the user.
1433 * <p>Input: Nothing.
1434 * <p>Output: Nothing.
1435 */
1436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1437 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001438
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001439 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001440 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1441 * to run.
1442 * <p>Input: Nothing.
1443 * <p>Output: Nothing.
1444 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1445 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1446 * @hide
1447 */
1448 @Deprecated
1449 @SystemApi
1450 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1451 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1452
1453 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001454 * Activity Action: Setup wizard to launch after a platform update. This
1455 * activity should have a string meta-data field associated with it,
1456 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1457 * the platform for setup. The activity will be launched only if
1458 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1459 * same value.
1460 * <p>Input: Nothing.
1461 * <p>Output: Nothing.
1462 * @hide
1463 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001464 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001465 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1466 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001467
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001468 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001469 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1470 * <p>Input: Nothing.
1471 * <p>Output: Nothing.
1472 * @hide
1473 */
1474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1475 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001476 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001477
1478 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001479 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1480 * <p>Input: Nothing.
1481 * <p>Output: Nothing.
1482 * @hide
1483 */
1484 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1485 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001486 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001487
1488 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001489 * Activity Action: Show settings for managing network data usage of a
1490 * specific application. Applications should define an activity that offers
1491 * options to control data usage.
1492 */
1493 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1494 public static final String ACTION_MANAGE_NETWORK_USAGE =
1495 "android.intent.action.MANAGE_NETWORK_USAGE";
1496
1497 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001498 * Activity Action: Launch application installer.
1499 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001500 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001501 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1502 * you can also use "package:<package-name>" to install an application for the
1503 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001504 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1505 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1506 * <p>
1507 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1508 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001509 * <p>
1510 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1511 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1512 * in order to launch the application installer.
1513 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001514 *
1515 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1516 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1517 * @see #EXTRA_RETURN_RESULT
1518 */
1519 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1520 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1521
1522 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001523 * @hide
1524 * @deprecated Do not use. This will go away.
1525 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1526 */
1527 @SystemApi
1528 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1529 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1530 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1531 /**
1532 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001533 * <p class="note">
1534 * This is a protected intent that can only be sent by the system.
1535 * </p>
1536 *
1537 * @hide
1538 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001539 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001540 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001541 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1542 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001543
1544 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001545 * @hide
1546 * @deprecated Do not use. This will go away.
1547 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1548 */
1549 @SystemApi
1550 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1551 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1552 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1553 /**
1554 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001555 * <p>
1556 * The system will have a persistent connection to this service.
1557 * This is a protected intent that can only be sent by the system.
1558 * </p>
1559 *
1560 * @hide
1561 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001562 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001563 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001564 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1565 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001566
1567 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001568 * @hide
1569 * @deprecated Do not use. This will go away.
1570 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1571 */
1572 @SystemApi
1573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1574 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1575 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1576 /**
1577 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001578 *
1579 * <p class="note">
1580 * This is a protected intent that can only be sent by the system.
1581 * </p>
1582 *
1583 * @hide
1584 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001585 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001586 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001587 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1588 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001589
1590 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001591 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1592 * package. Specifies the installer package name; this package will receive the
1593 * {@link #ACTION_APP_ERROR} intent.
1594 */
1595 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1596 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1597
1598 /**
1599 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1600 * package. Specifies that the application being installed should not be
1601 * treated as coming from an unknown source, but as coming from the app
1602 * invoking the Intent. For this to work you must start the installer with
1603 * startActivityForResult().
1604 */
1605 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1606 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1607
1608 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001609 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1610 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001611 * data field originated from.
1612 */
rich cannings706e8ba2012-08-20 13:20:14 -07001613 public static final String EXTRA_ORIGINATING_URI
1614 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001615
1616 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001617 * This extra can be used with any Intent used to launch an activity, supplying information
1618 * about who is launching that activity. This field contains a {@link android.net.Uri}
1619 * object, typically an http: or https: URI of the web site that the referral came from;
1620 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1621 * a native application that it came from.
1622 *
1623 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1624 * instead of directly retrieving the extra. It is also valid for applications to
1625 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1626 * a string, not a Uri; the field here, if supplied, will always take precedence,
1627 * however.</p>
1628 *
1629 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001630 */
1631 public static final String EXTRA_REFERRER
1632 = "android.intent.extra.REFERRER";
1633
1634 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001635 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1636 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1637 * not be created, in particular when Intent extras are supplied through the
1638 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1639 * schemes.
1640 *
1641 * @see #EXTRA_REFERRER
1642 */
1643 public static final String EXTRA_REFERRER_NAME
1644 = "android.intent.extra.REFERRER_NAME";
1645
1646 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001647 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001648 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001649 * @hide
1650 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001651 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001652 public static final String EXTRA_ORIGINATING_UID
1653 = "android.intent.extra.ORIGINATING_UID";
1654
1655 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001656 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1657 * package. Tells the installer UI to skip the confirmation with the user
1658 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001659 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1660 * will no longer show an interstitial message about updating existing
1661 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001662 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001663 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001664 public static final String EXTRA_ALLOW_REPLACE
1665 = "android.intent.extra.ALLOW_REPLACE";
1666
1667 /**
1668 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1669 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1670 * return to the application the result code of the install/uninstall. The returned result
1671 * code will be {@link android.app.Activity#RESULT_OK} on success or
1672 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1673 */
1674 public static final String EXTRA_RETURN_RESULT
1675 = "android.intent.extra.RETURN_RESULT";
1676
1677 /**
1678 * Package manager install result code. @hide because result codes are not
1679 * yet ready to be exposed.
1680 */
1681 public static final String EXTRA_INSTALL_RESULT
1682 = "android.intent.extra.INSTALL_RESULT";
1683
1684 /**
1685 * Activity Action: Launch application uninstaller.
1686 * <p>
1687 * Input: The data must be a package: URI whose scheme specific part is
1688 * the package name of the current installed package to be uninstalled.
1689 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1690 * <p>
1691 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1692 * succeeded.
1693 */
1694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1695 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1696
1697 /**
msnider3c191b82017-01-23 14:23:16 -08001698 * Activity Action: Launch application uninstaller.
1699 * <p>
1700 * Input: The data must be a package: URI whose scheme specific part is
1701 * the package name of the current installed package to be uninstalled.
1702 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1703 * <p>
1704 * Output: Nothing.
1705 * </p>
1706 */
1707 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1708 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1709
1710 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001711 * Specify whether the package should be uninstalled for all users.
1712 * @hide because these should not be part of normal application flow.
1713 */
1714 public static final String EXTRA_UNINSTALL_ALL_USERS
1715 = "android.intent.extra.UNINSTALL_ALL_USERS";
1716
1717 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001718 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1719 * describing the last run version of the platform that was setup.
1720 * @hide
1721 */
1722 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1723
Svet Ganov3695b8a2015-03-24 16:30:25 -07001724 /**
1725 * Activity action: Launch UI to manage the permissions of an app.
1726 * <p>
1727 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1728 * will be managed by the launched UI.
1729 * </p>
1730 * <p>
1731 * Output: Nothing.
1732 * </p>
1733 *
1734 * @see #EXTRA_PACKAGE_NAME
1735 *
1736 * @hide
1737 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001738 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001739 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1740 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1741 "android.intent.action.MANAGE_APP_PERMISSIONS";
1742
1743 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001744 * Activity action: Launch UI to manage permissions.
1745 * <p>
1746 * Input: Nothing.
1747 * </p>
1748 * <p>
1749 * Output: Nothing.
1750 * </p>
1751 *
1752 * @hide
1753 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001754 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001755 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1756 public static final String ACTION_MANAGE_PERMISSIONS =
1757 "android.intent.action.MANAGE_PERMISSIONS";
1758
1759 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001760 * Activity action: Launch UI to review permissions for an app.
1761 * The system uses this intent if permission review for apps not
1762 * supporting the new runtime permissions model is enabled. In
1763 * this mode a permission review is required before any of the
1764 * app components can run.
1765 * <p>
1766 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1767 * permissions will be reviewed (mandatory).
1768 * </p>
1769 * <p>
1770 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1771 * be fired after the permission review (optional).
1772 * </p>
1773 * <p>
1774 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1775 * be invoked after the permission review (optional).
1776 * </p>
1777 * <p>
1778 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1779 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1780 * </p>
1781 * <p>
1782 * Output: Nothing.
1783 * </p>
1784 *
1785 * @see #EXTRA_PACKAGE_NAME
1786 * @see #EXTRA_INTENT
1787 * @see #EXTRA_REMOTE_CALLBACK
1788 * @see #EXTRA_RESULT_NEEDED
1789 *
1790 * @hide
1791 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001792 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001793 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1794 public static final String ACTION_REVIEW_PERMISSIONS =
1795 "android.intent.action.REVIEW_PERMISSIONS";
1796
1797 /**
1798 * Intent extra: A callback for reporting remote result as a bundle.
1799 * <p>
1800 * Type: IRemoteCallback
1801 * </p>
1802 *
1803 * @hide
1804 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001805 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001806 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1807
1808 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001809 * Intent extra: An app package name.
1810 * <p>
1811 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001812 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001813 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001814 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001815 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1816
1817 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001818 * Intent extra: An app split name.
1819 * <p>
1820 * Type: String
1821 * </p>
1822 * @hide
1823 */
1824 @SystemApi
1825 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1826
1827 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001828 * Intent extra: An extra for specifying whether a result is needed.
1829 * <p>
1830 * Type: boolean
1831 * </p>
1832 *
1833 * @hide
1834 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001835 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001836 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1837
1838 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001839 * Activity action: Launch UI to manage which apps have a given permission.
1840 * <p>
1841 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1842 * to which will be managed by the launched UI.
1843 * </p>
1844 * <p>
1845 * Output: Nothing.
1846 * </p>
1847 *
1848 * @see #EXTRA_PERMISSION_NAME
1849 *
1850 * @hide
1851 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001852 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001853 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1854 public static final String ACTION_MANAGE_PERMISSION_APPS =
1855 "android.intent.action.MANAGE_PERMISSION_APPS";
1856
1857 /**
1858 * Intent extra: The name of a permission.
1859 * <p>
1860 * Type: String
1861 * </p>
1862 *
1863 * @hide
1864 */
1865 @SystemApi
1866 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1867
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001868 // ---------------------------------------------------------------------
1869 // ---------------------------------------------------------------------
1870 // Standard intent broadcast actions (see action variable).
1871
1872 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001873 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1874 * <p>
1875 * For historical reasons, the name of this broadcast action refers to the power
1876 * state of the screen but it is actually sent in response to changes in the
1877 * overall interactive state of the device.
1878 * </p><p>
1879 * This broadcast is sent when the device becomes non-interactive which may have
1880 * nothing to do with the screen turning off. To determine the
1881 * actual state of the screen, use {@link android.view.Display#getState}.
1882 * </p><p>
1883 * See {@link android.os.PowerManager#isInteractive} for details.
1884 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001885 * You <em>cannot</em> receive this through components declared in
1886 * manifests, only by explicitly registering for it with
1887 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1888 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001889 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001890 * <p class="note">This is a protected intent that can only be sent
1891 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1894 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001895
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001896 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001897 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1898 * <p>
1899 * For historical reasons, the name of this broadcast action refers to the power
1900 * state of the screen but it is actually sent in response to changes in the
1901 * overall interactive state of the device.
1902 * </p><p>
1903 * This broadcast is sent when the device becomes interactive which may have
1904 * nothing to do with the screen turning on. To determine the
1905 * actual state of the screen, use {@link android.view.Display#getState}.
1906 * </p><p>
1907 * See {@link android.os.PowerManager#isInteractive} for details.
1908 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001909 * You <em>cannot</em> receive this through components declared in
1910 * manifests, only by explicitly registering for it with
1911 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1912 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001913 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001914 * <p class="note">This is a protected intent that can only be sent
1915 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001916 */
1917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1918 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001919
1920 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001921 * Broadcast Action: Sent after the system stops dreaming.
1922 *
1923 * <p class="note">This is a protected intent that can only be sent by the system.
1924 * It is only sent to registered receivers.</p>
1925 */
1926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1927 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1928
1929 /**
1930 * Broadcast Action: Sent after the system starts dreaming.
1931 *
1932 * <p class="note">This is a protected intent that can only be sent by the system.
1933 * It is only sent to registered receivers.</p>
1934 */
1935 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1936 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1937
1938 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001939 * 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 -07001940 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001941 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001942 * <p class="note">This is a protected intent that can only be sent
1943 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001946 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001947
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001948 /**
1949 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001950 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001951 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001952 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1953 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001954 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001955 * <p class="note">This is a protected intent that can only be sent
1956 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001957 */
1958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1959 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1960 /**
1961 * Broadcast Action: The time was set.
1962 */
1963 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1964 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1965 /**
1966 * Broadcast Action: The date has changed.
1967 */
1968 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1969 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1970 /**
1971 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1972 * <ul>
1973 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1974 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001975 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001976 * <p class="note">This is a protected intent that can only be sent
1977 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1981 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001982 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1983 * DNS entries should be tossed.
1984 * @hide
1985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1987 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1988 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001989 * Alarm Changed Action: This is broadcast when the AlarmClock
1990 * application's alarm is set or unset. It is used by the
1991 * AlarmClock application and the StatusBar service.
1992 * @hide
1993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001996
1997 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001998 * Broadcast Action: This is broadcast once, after the user has finished
1999 * booting, but while still in the "locked" state. It can be used to perform
2000 * application-specific initialization, such as installing alarms. You must
2001 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2002 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002003 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002004 * This broadcast is sent immediately at boot by all devices (regardless of
2005 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2006 * higher. Upon receipt of this broadcast, the user is still locked and only
2007 * device-protected storage can be accessed safely. If you want to access
2008 * credential-protected storage, you need to wait for the user to be
2009 * unlocked (typically by entering their lock pattern or PIN for the first
2010 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2011 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2012 * <p>
2013 * To receive this broadcast, your receiver component must be marked as
2014 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002015 * <p class="note">
2016 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002017 *
2018 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002024 * Broadcast Action: This is broadcast once, after the user has finished
2025 * booting. It can be used to perform application-specific initialization,
2026 * such as installing alarms. You must hold the
2027 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2028 * order to receive this broadcast.
2029 * <p>
2030 * This broadcast is sent at boot by all devices (both with and without
2031 * direct boot support). Upon receipt of this broadcast, the user is
2032 * unlocked and both device-protected and credential-protected storage can
2033 * accessed safely.
2034 * <p>
2035 * If you need to run while the user is still locked (before they've entered
2036 * their lock pattern or PIN for the first time), you can listen for the
2037 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2038 * <p class="note">
2039 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002040 */
2041 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002042 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002043 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002044
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 /**
2046 * Broadcast Action: This is broadcast when a user action should request a
2047 * temporary system dialog to dismiss. Some examples of temporary system
2048 * dialogs are the notification window-shade and the recent tasks dialog.
2049 */
2050 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2051 /**
2052 * Broadcast Action: Trigger the download and eventual installation
2053 * of a package.
2054 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002055 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002056 * <p class="note">This is a protected intent that can only be sent
2057 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002058 *
2059 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002060 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002061 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002062 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2063 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2064 /**
2065 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002066 * device. The data contains the name of the package. Note that the
2067 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002068 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002069 * <ul>
2070 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2071 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2072 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2073 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002074 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002075 * <p class="note">This is a protected intent that can only be sent
2076 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 */
2078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2079 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2080 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002081 * Broadcast Action: A new version of an application package has been
2082 * installed, replacing an existing version that was previously installed.
2083 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002084 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002085 * <ul>
2086 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2087 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002088 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002089 * <p class="note">This is a protected intent that can only be sent
2090 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002091 */
2092 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2093 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2094 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002095 * Broadcast Action: A new version of your application has been installed
2096 * over an existing one. This is only sent to the application that was
2097 * replaced. It does not contain any additional data; to receive it, just
2098 * use an intent filter for this action.
2099 *
2100 * <p class="note">This is a protected intent that can only be sent
2101 * by the system.
2102 */
2103 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2104 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2105 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 * Broadcast Action: An existing application package has been removed from
2107 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002108 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002109 * <ul>
2110 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2111 * to the package.
2112 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2113 * application -- data and code -- is being removed.
2114 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2115 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2116 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002117 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002118 * <p class="note">This is a protected intent that can only be sent
2119 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002120 */
2121 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2122 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2123 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002124 * Broadcast Action: An existing application package has been completely
2125 * removed from the device. The data contains the name of the package.
2126 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2127 * {@link #EXTRA_DATA_REMOVED} is true and
2128 * {@link #EXTRA_REPLACING} is false of that broadcast.
2129 *
2130 * <ul>
2131 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2132 * to the package.
2133 * </ul>
2134 *
2135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
2137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_PACKAGE_FULLY_REMOVED
2140 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2141 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002142 * Broadcast Action: An existing application package has been changed (for
2143 * example, a component has been enabled or disabled). The data contains
2144 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002145 * <ul>
2146 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002147 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002148 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002149 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2150 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002151 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002152 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2158 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002159 * @hide
2160 * Broadcast Action: Ask system services if there is any reason to
2161 * restart the given package. The data contains the name of the
2162 * package.
2163 * <ul>
2164 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2165 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2166 * </ul>
2167 *
2168 * <p class="note">This is a protected intent that can only be sent
2169 * by the system.
2170 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002171 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002172 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2173 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2174 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002175 * Broadcast Action: The user has restarted a package, and all of its
2176 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002177 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002178 * be removed. Note that the restarted package does <em>not</em>
2179 * receive this broadcast.
2180 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002181 * <ul>
2182 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2183 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2190 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002191 * Broadcast Action: The user has cleared the data of a package. This should
2192 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002193 * its persistent data is erased and this broadcast sent.
2194 * Note that the cleared package does <em>not</em>
2195 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002196 * <ul>
2197 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2198 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002199 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002200 * <p class="note">This is a protected intent that can only be sent
2201 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002202 */
2203 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2204 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2205 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002206 * Broadcast Action: Packages have been suspended.
2207 * <p>Includes the following extras:
2208 * <ul>
2209 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2210 * </ul>
2211 *
2212 * <p class="note">This is a protected intent that can only be sent
2213 * by the system. It is only sent to registered receivers.
2214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2216 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2217 /**
2218 * Broadcast Action: Packages have been unsuspended.
2219 * <p>Includes the following extras:
2220 * <ul>
2221 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2222 * </ul>
2223 *
2224 * <p class="note">This is a protected intent that can only be sent
2225 * by the system. It is only sent to registered receivers.
2226 */
2227 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2228 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2229 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002230 * Broadcast Action: A user ID has been removed from the system. The user
2231 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002232 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002233 * <p class="note">This is a protected intent that can only be sent
2234 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002235 */
2236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2237 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002238
2239 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002240 * Broadcast Action: Sent to the installer package of an application when
2241 * that application is first launched (that is the first time it is moved
2242 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002243 *
2244 * <p class="note">This is a protected intent that can only be sent
2245 * by the system.
2246 */
2247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2248 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2249
2250 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002251 * Broadcast Action: Sent to the system package verifier when a package
2252 * needs to be verified. The data contains the package URI.
2253 * <p class="note">
2254 * This is a protected intent that can only be sent by the system.
2255 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2259
2260 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002261 * Broadcast Action: Sent to the system package verifier when a package is
2262 * verified. The data contains the package URI.
2263 * <p class="note">
2264 * This is a protected intent that can only be sent by the system.
2265 */
2266 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2267 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2268
2269 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002270 * Broadcast Action: Sent to the system intent filter verifier when an
2271 * intent filter needs to be verified. The data contains the filter data
2272 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002273 * <p class="note">
2274 * This is a protected intent that can only be sent by the system.
2275 * </p>
2276 *
2277 * @hide
2278 */
2279 @SystemApi
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2281 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2282
2283 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002284 * Broadcast Action: Resources for a set of packages (which were
2285 * previously unavailable) are currently
2286 * available since the media on which they exist is available.
2287 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2288 * list of packages whose availability changed.
2289 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2290 * list of uids of packages whose availability changed.
2291 * Note that the
2292 * packages in this list do <em>not</em> receive this broadcast.
2293 * The specified set of packages are now available on the system.
2294 * <p>Includes the following extras:
2295 * <ul>
2296 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2297 * whose resources(were previously unavailable) are currently available.
2298 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2299 * packages whose resources(were previously unavailable)
2300 * are currently available.
2301 * </ul>
2302 *
2303 * <p class="note">This is a protected intent that can only be sent
2304 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002307 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2308 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002309
2310 /**
2311 * Broadcast Action: Resources for a set of packages are currently
2312 * unavailable since the media on which they exist is unavailable.
2313 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2314 * list of packages whose availability changed.
2315 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2316 * list of uids of packages whose availability changed.
2317 * The specified set of packages can no longer be
2318 * launched and are practically unavailable on the system.
2319 * <p>Inclues the following extras:
2320 * <ul>
2321 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2322 * whose resources are no longer available.
2323 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2324 * whose resources are no longer available.
2325 * </ul>
2326 *
2327 * <p class="note">This is a protected intent that can only be sent
2328 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002329 */
2330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002331 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002332 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002333
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002334 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002335 * Broadcast Action: preferred activities have changed *explicitly*.
2336 *
2337 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2338 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2339 * be sent.
2340 *
2341 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2342 *
2343 * @hide
2344 */
2345 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2346 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2347 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2348
2349
2350 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002351 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002352 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002353 * This should <em>only</em> be used to determine when the wallpaper
2354 * has changed to show the new wallpaper to the user. You should certainly
2355 * never, in response to this, change the wallpaper or other attributes of
2356 * it such as the suggested size. That would be crazy, right? You'd cause
2357 * all kinds of loops, especially if other apps are doing similar things,
2358 * right? Of course. So please don't do this.
2359 *
2360 * @deprecated Modern applications should use
2361 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2362 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2363 * shown behind their UI, rather than watching for this broadcast and
2364 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002365 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002366 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002367 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2368 /**
2369 * Broadcast Action: The current device {@link android.content.res.Configuration}
2370 * (orientation, locale, etc) has changed. When such a change happens, the
2371 * UIs (view hierarchy) will need to be rebuilt based on this new
2372 * information; for the most part, applications don't need to worry about
2373 * this, because the system will take care of stopping and restarting the
2374 * application to make sure it sees the new changes. Some system code that
2375 * can not be restarted will need to watch for this action and handle it
2376 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002377 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002378 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002379 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002380 * in manifests, only by explicitly registering for it with
2381 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2382 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002383 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002384 * <p class="note">This is a protected intent that can only be sent
2385 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002386 *
2387 * @see android.content.res.Configuration
2388 */
2389 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2390 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2391 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002392 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002393 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002394 * <p class="note">This is a protected intent that can only be sent
2395 * by the system.
2396 */
2397 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2398 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2399 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002400 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2401 * charging state, level, and other information about the battery.
2402 * See {@link android.os.BatteryManager} for documentation on the
2403 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002404 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002406 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002407 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002408 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002409 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2410 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2411 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2412 * broadcasts that are sent and can be received through manifest
2413 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002414 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002417 */
2418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2419 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2420 /**
2421 * Broadcast Action: Indicates low battery condition on the device.
2422 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002423 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002424 * <p class="note">This is a protected intent that can only be sent
2425 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002426 */
2427 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2428 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2429 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002430 * Broadcast Action: Indicates the battery is now okay after being low.
2431 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2432 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002433 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2438 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2439 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002440 * Broadcast Action: External power has been connected to the device.
2441 * This is intended for applications that wish to register specifically to this notification.
2442 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2443 * stay active to receive this notification. This action can be used to implement actions
2444 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002445 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002446 * <p class="note">This is a protected intent that can only be sent
2447 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002450 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002451 /**
2452 * Broadcast Action: External power has been removed from the device.
2453 * This is intended for applications that wish to register specifically to this notification.
2454 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2455 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002456 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002457 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002458 * <p class="note">This is a protected intent that can only be sent
2459 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002460 */
2461 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002462 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002463 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002464 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002465 * Broadcast Action: Device is shutting down.
2466 * This is broadcast when the device is being shut down (completely turned
2467 * off, not sleeping). Once the broadcast is complete, the final shutdown
2468 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002469 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002470 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002471 * <p class="note">This is a protected intent that can only be sent
2472 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002473 * <p>May include the following extras:
2474 * <ul>
2475 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2476 * shutdown is only for userspace processes. If not set, assumed to be false.
2477 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002478 */
2479 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002480 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002481 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002482 * Activity Action: Start this activity to request system shutdown.
2483 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002484 * to request confirmation from the user before shutting down. The optional boolean
2485 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2486 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002487 *
2488 * <p class="note">This is a protected intent that can only be sent
2489 * by the system.
2490 *
2491 * {@hide}
2492 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002493 public static final String ACTION_REQUEST_SHUTDOWN
2494 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002495 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002496 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002497 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002498 * <p class="note">
2499 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002500 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002501 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2502 * or above, this broadcast will no longer be delivered to any
2503 * {@link BroadcastReceiver} defined in your manifest. Instead,
2504 * apps are strongly encouraged to use the improved
2505 * {@link Context#getCacheDir()} behavior so the system can
2506 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002507 */
2508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002509 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002510 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2511 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002512 * Broadcast Action: Indicates low storage space condition on the device no
2513 * longer exists
2514 * <p class="note">
2515 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002516 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002517 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2518 * or above, this broadcast will no longer be delivered to any
2519 * {@link BroadcastReceiver} defined in your manifest. Instead,
2520 * apps are strongly encouraged to use the improved
2521 * {@link Context#getCacheDir()} behavior so the system can
2522 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002523 */
2524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002525 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002526 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2527 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002528 * Broadcast Action: A sticky broadcast that indicates a storage space full
2529 * condition on the device. This is intended for activities that want to be
2530 * able to fill the data partition completely, leaving only enough free
2531 * space to prevent system-wide SQLite failures.
2532 * <p class="note">
2533 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002534 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002535 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2536 * or above, this broadcast will no longer be delivered to any
2537 * {@link BroadcastReceiver} defined in your manifest. Instead,
2538 * apps are strongly encouraged to use the improved
2539 * {@link Context#getCacheDir()} behavior so the system can
2540 * automatically free up storage when needed.
2541 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002542 */
2543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002544 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002545 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2546 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002547 * Broadcast Action: Indicates storage space full condition on the device no
2548 * longer exists.
2549 * <p class="note">
2550 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002551 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2553 * or above, this broadcast will no longer be delivered to any
2554 * {@link BroadcastReceiver} defined in your manifest. Instead,
2555 * apps are strongly encouraged to use the improved
2556 * {@link Context#getCacheDir()} behavior so the system can
2557 * automatically free up storage when needed.
2558 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002561 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002562 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2563 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002564 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2565 * and package management should be started.
2566 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2567 * notification.
2568 */
2569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2570 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2571 /**
2572 * Broadcast Action: The device has entered USB Mass Storage mode.
2573 * This is used mainly for the USB Settings panel.
2574 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2575 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002576 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002577 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002578 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2580
2581 /**
2582 * Broadcast Action: The device has exited USB Mass Storage mode.
2583 * This is used mainly for the USB Settings panel.
2584 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2585 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002586 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002587 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002588 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2590
2591 /**
2592 * Broadcast Action: External media has been removed.
2593 * The path to the mount point for the removed media is contained in the Intent.mData field.
2594 */
2595 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2596 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2597
2598 /**
2599 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002600 * 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 -07002601 */
2602 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2603 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2604
2605 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002606 * Broadcast Action: External media is present, and being disk-checked
2607 * 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 -08002608 */
2609 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2610 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2611
2612 /**
2613 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2614 * 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 -08002615 */
2616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2617 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2618
2619 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002620 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002621 * 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 -07002622 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2623 * media was mounted read only.
2624 */
2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2627
2628 /**
2629 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002630 * 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 -07002631 */
2632 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2633 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2634
2635 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002636 * Broadcast Action: External media is no longer being shared via USB mass storage.
2637 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2638 *
2639 * @hide
2640 */
2641 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2642
2643 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002644 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2645 * The path to the mount point for the removed media is contained in the Intent.mData field.
2646 */
2647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2648 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2649
2650 /**
2651 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002652 * 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 -07002653 */
2654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2655 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2656
2657 /**
2658 * Broadcast Action: User has expressed the desire to remove the external storage media.
2659 * Applications should close all files they have open within the mount point when they receive this intent.
2660 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2664
2665 /**
2666 * Broadcast Action: The media scanner has started scanning a directory.
2667 * The path to the directory being scanned is contained in the Intent.mData field.
2668 */
2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2670 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2671
2672 /**
2673 * Broadcast Action: The media scanner has finished scanning a directory.
2674 * The path to the scanned directory is contained in the Intent.mData field.
2675 */
2676 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2678
2679 /**
2680 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2681 * The path to the file is contained in the Intent.mData field.
2682 */
2683 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2684 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2685
2686 /**
2687 * Broadcast Action: The "Media Button" was pressed. Includes a single
2688 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2689 * caused the broadcast.
2690 */
2691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2692 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2693
2694 /**
2695 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2696 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2697 * caused the broadcast.
2698 */
2699 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2700 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2701
2702 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2703 // location; they are not general-purpose actions.
2704
2705 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002706 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002707 */
2708 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2709 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2710 "android.intent.action.GTALK_CONNECTED";
2711
2712 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002713 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002714 */
2715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2716 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2717 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002718
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002719 /**
2720 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_INPUT_METHOD_CHANGED =
2724 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725
2726 /**
2727 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2728 * more radios have been turned off or on. The intent will have the following extra value:</p>
2729 * <ul>
2730 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2731 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2732 * turned off</li>
2733 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002734 *
Peng Xua35b5532016-01-20 00:05:45 -08002735 * <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 -07002736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2738 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2739
2740 /**
2741 * Broadcast Action: Some content providers have parts of their namespace
2742 * where they publish new events or items that the user may be especially
2743 * interested in. For these things, they may broadcast this action when the
2744 * set of interesting items change.
2745 *
2746 * For example, GmailProvider sends this notification when the set of unread
2747 * mail in the inbox changes.
2748 *
2749 * <p>The data of the intent identifies which part of which provider
2750 * changed. When queried through the content resolver, the data URI will
2751 * return the data set in question.
2752 *
2753 * <p>The intent will have the following extra values:
2754 * <ul>
2755 * <li><em>count</em> - The number of items in the data set. This is the
2756 * same as the number of items in the cursor returned by querying the
2757 * data URI. </li>
2758 * </ul>
2759 *
2760 * This intent will be sent at boot (if the count is non-zero) and when the
2761 * data set changes. It is possible for the data set to change without the
2762 * count changing (for example, if a new unread message arrives in the same
2763 * sync operation in which a message is archived). The phone should still
2764 * ring/vibrate/etc as normal in this case.
2765 */
2766 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2767 public static final String ACTION_PROVIDER_CHANGED =
2768 "android.intent.action.PROVIDER_CHANGED";
2769
2770 /**
2771 * Broadcast Action: Wired Headset plugged in or unplugged.
2772 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002773 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2774 * and documentation.
2775 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002776 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002777 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002780 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002781
2782 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002783 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2784 * <ul>
2785 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2786 * </ul>
2787 *
2788 * <p class="note">This is a protected intent that can only be sent
2789 * by the system.
2790 *
2791 * @hide
2792 */
2793 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2794 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2795 = "android.intent.action.ADVANCED_SETTINGS";
2796
2797 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002798 * Broadcast Action: Sent after application restrictions are changed.
2799 *
2800 * <p class="note">This is a protected intent that can only be sent
2801 * by the system.</p>
2802 */
2803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2804 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2805 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2806
2807 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002808 * Broadcast Action: An outgoing call is about to be placed.
2809 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002810 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002811 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002812 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 * the phone number originally intended to be dialed.</li>
2814 * </ul>
2815 * <p>Once the broadcast is finished, the resultData is used as the actual
2816 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002817 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 * outgoing call in turn: for example, a parental control application
2819 * might verify that the user is authorized to place the call at that
2820 * time, then a number-rewriting application might add an area code if
2821 * one was not specified.</p>
2822 * <p>For consistency, any receiver whose purpose is to prohibit phone
2823 * calls should have a priority of 0, to ensure it will see the final
2824 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002825 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002826 * should have a positive priority.
2827 * Negative priorities are reserved for the system for this broadcast;
2828 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002829 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2830 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002831 * <p>Emergency calls cannot be intercepted using this mechanism, and
2832 * other calls cannot be modified to call emergency numbers using this
2833 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002834 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2835 * call to use their own service instead. Those apps should first prevent
2836 * the call from being placed by setting resultData to <code>null</code>
2837 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002838 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002839 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2840 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002841 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002842 * <p class="note">This is a protected intent that can only be sent
2843 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_NEW_OUTGOING_CALL =
2847 "android.intent.action.NEW_OUTGOING_CALL";
2848
2849 /**
2850 * Broadcast Action: Have the device reboot. This is only for use by
2851 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002852 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002853 * <p class="note">This is a protected intent that can only be sent
2854 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002855 */
2856 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2857 public static final String ACTION_REBOOT =
2858 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002859
Wei Huang97ecc9c2009-05-11 17:44:20 -07002860 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002861 * Broadcast Action: A sticky broadcast for changes in the physical
2862 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002863 *
2864 * <p>The intent will have the following extra values:
2865 * <ul>
2866 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002867 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002868 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002869 * <p>This is intended for monitoring the current physical dock state.
2870 * See {@link android.app.UiModeManager} for the normal API dealing with
2871 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002872 */
2873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2874 public static final String ACTION_DOCK_EVENT =
2875 "android.intent.action.DOCK_EVENT";
2876
2877 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002878 * Broadcast Action: A broadcast when idle maintenance can be started.
2879 * This means that the user is not interacting with the device and is
2880 * not expected to do so soon. Typical use of the idle maintenance is
2881 * to perform somehow expensive tasks that can be postponed at a moment
2882 * when they will not degrade user experience.
2883 * <p>
2884 * <p class="note">In order to keep the device responsive in case of an
2885 * unexpected user interaction, implementations of a maintenance task
2886 * should be interruptible. In such a scenario a broadcast with action
2887 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2888 * should not do the maintenance work in
2889 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2890 * maintenance service by {@link Context#startService(Intent)}. Also
2891 * you should hold a wake lock while your maintenance service is running
2892 * to prevent the device going to sleep.
2893 * </p>
2894 * <p>
2895 * <p class="note">This is a protected intent that can only be sent by
2896 * the system.
2897 * </p>
2898 *
2899 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002900 *
2901 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002902 */
2903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2904 public static final String ACTION_IDLE_MAINTENANCE_START =
2905 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2906
2907 /**
2908 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2909 * This means that the user was not interacting with the device as a result
2910 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2911 * was sent and now the user started interacting with the device. Typical
2912 * use of the idle maintenance is to perform somehow expensive tasks that
2913 * can be postponed at a moment when they will not degrade user experience.
2914 * <p>
2915 * <p class="note">In order to keep the device responsive in case of an
2916 * unexpected user interaction, implementations of a maintenance task
2917 * should be interruptible. Hence, on receiving a broadcast with this
2918 * action, the maintenance task should be interrupted as soon as possible.
2919 * In other words, you should not do the maintenance work in
2920 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2921 * maintenance service that was started on receiving of
2922 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2923 * lock you acquired when your maintenance service started.
2924 * </p>
2925 * <p class="note">This is a protected intent that can only be sent
2926 * by the system.
2927 *
2928 * @see #ACTION_IDLE_MAINTENANCE_START
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_END =
2934 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2935
2936 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002937 * Broadcast Action: a remote intent is to be broadcasted.
2938 *
2939 * A remote intent is used for remote RPC between devices. The remote intent
2940 * is serialized and sent from one device to another device. The receiving
2941 * device parses the remote intent and broadcasts it. Note that anyone can
2942 * broadcast a remote intent. However, if the intent receiver of the remote intent
2943 * does not trust intent broadcasts from arbitrary intent senders, it should require
2944 * the sender to hold certain permissions so only trusted sender's broadcast will be
2945 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002946 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002947 */
2948 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002949 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002950
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002951 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002952 * Broadcast Action: This is broadcast once when the user is booting after a
2953 * system update. It can be used to perform cleanup or upgrades after a
2954 * system update.
2955 * <p>
2956 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2957 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2958 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2959 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002960 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002961 * @hide
2962 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002963 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002964 public static final String ACTION_PRE_BOOT_COMPLETED =
2965 "android.intent.action.PRE_BOOT_COMPLETED";
2966
Amith Yamasani13593602012-03-22 16:16:17 -07002967 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002968 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002969 * on restricted users. The broadcast intent contains an extra
2970 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2971 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2972 * String[] depending on the restriction type.<p/>
2973 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002974 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2975 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2976 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002977 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2978 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002979 * @see RestrictionEntry
2980 */
2981 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2982 "android.intent.action.GET_RESTRICTION_ENTRIES";
2983
2984 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002985 * Sent the first time a user is starting, to allow system apps to
2986 * perform one time initialization. (This will not be seen by third
2987 * party applications because a newly initialized user does not have any
2988 * third party applications installed for it.) This is sent early in
2989 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002990 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2991 * broadcast, since it is part of a visible user interaction; be as quick
2992 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002993 */
2994 public static final String ACTION_USER_INITIALIZE =
2995 "android.intent.action.USER_INITIALIZE";
2996
2997 /**
2998 * Sent when a user switch is happening, causing the process's user to be
2999 * brought to the foreground. This is only sent to receivers registered
3000 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3001 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003002 * foreground. This is sent as a foreground
3003 * broadcast, since it is part of a visible user interaction; be as quick
3004 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003005 */
3006 public static final String ACTION_USER_FOREGROUND =
3007 "android.intent.action.USER_FOREGROUND";
3008
3009 /**
3010 * Sent when a user switch is happening, causing the process's user to be
3011 * sent to the background. This is only sent to receivers registered
3012 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3013 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003014 * background. This is sent as a foreground
3015 * broadcast, since it is part of a visible user interaction; be as quick
3016 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003017 */
3018 public static final String ACTION_USER_BACKGROUND =
3019 "android.intent.action.USER_BACKGROUND";
3020
3021 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003022 * Broadcast sent to the system when a user is added. Carries an extra
3023 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3024 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003025 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003026 * @hide
3027 */
3028 public static final String ACTION_USER_ADDED =
3029 "android.intent.action.USER_ADDED";
3030
3031 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003032 * Broadcast sent by the system when a user is started. Carries an extra
3033 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003034 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003035 * that has been started. This is sent as a foreground
3036 * broadcast, since it is part of a visible user interaction; be as quick
3037 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003038 * @hide
3039 */
3040 public static final String ACTION_USER_STARTED =
3041 "android.intent.action.USER_STARTED";
3042
3043 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003044 * Broadcast sent when a user is in the process of starting. Carries an extra
3045 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3046 * sent to registered receivers, not manifest receivers. It is sent to all
3047 * users (including the one that is being started). You must hold
3048 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3049 * this broadcast. This is sent as a background broadcast, since
3050 * its result is not part of the primary UX flow; to safely keep track of
3051 * started/stopped state of a user you can use this in conjunction with
3052 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3053 * other user state broadcasts since those are foreground broadcasts so can
3054 * execute in a different order.
3055 * @hide
3056 */
3057 public static final String ACTION_USER_STARTING =
3058 "android.intent.action.USER_STARTING";
3059
3060 /**
3061 * Broadcast sent when a user is going to be stopped. Carries an extra
3062 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3063 * sent to registered receivers, not manifest receivers. It is sent to all
3064 * users (including the one that is being stopped). You must hold
3065 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3066 * this broadcast. The user will not stop until all receivers have
3067 * handled the broadcast. This is sent as a background broadcast, since
3068 * its result is not part of the primary UX flow; to safely keep track of
3069 * started/stopped state of a user you can use this in conjunction with
3070 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3071 * other user state broadcasts since those are foreground broadcasts so can
3072 * execute in a different order.
3073 * @hide
3074 */
3075 public static final String ACTION_USER_STOPPING =
3076 "android.intent.action.USER_STOPPING";
3077
3078 /**
3079 * Broadcast sent to the system when a user is stopped. Carries an extra
3080 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3081 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3082 * specific package. This is only sent to registered receivers, not manifest
3083 * receivers. It is sent to all running users <em>except</em> the one that
3084 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003085 * @hide
3086 */
3087 public static final String ACTION_USER_STOPPED =
3088 "android.intent.action.USER_STOPPED";
3089
3090 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003091 * 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 -07003092 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003093 * one that has been removed. The user will not be completely removed until all receivers have
3094 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003095 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003096 * @hide
3097 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003098 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003099 public static final String ACTION_USER_REMOVED =
3100 "android.intent.action.USER_REMOVED";
3101
3102 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003103 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003104 * the userHandle of the user to become the current one. This is only sent to
3105 * registered receivers, not manifest receivers. It is sent to all running users.
3106 * You must hold
3107 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003108 * @hide
3109 */
3110 public static final String ACTION_USER_SWITCHED =
3111 "android.intent.action.USER_SWITCHED";
3112
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003113 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003114 * Broadcast Action: Sent when the credential-encrypted private storage has
3115 * become unlocked for the target user. This is only sent to registered
3116 * receivers, not manifest receivers.
3117 */
3118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3119 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3120
3121 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003122 * Broadcast sent to the system when a user's information changes. Carries an extra
3123 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003124 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003125 * @hide
3126 */
3127 public static final String ACTION_USER_INFO_CHANGED =
3128 "android.intent.action.USER_INFO_CHANGED";
3129
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003130 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003131 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3132 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003133 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3134 * that need to display merged content across both primary and managed profiles need to
3135 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003136 * not manifest receivers.
3137 */
3138 public static final String ACTION_MANAGED_PROFILE_ADDED =
3139 "android.intent.action.MANAGED_PROFILE_ADDED";
3140
3141 /**
3142 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003143 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3144 * Only applications (for example Launchers) that need to display merged content across both
3145 * primary and managed profiles need to worry about this broadcast. This is only sent to
3146 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003147 */
3148 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3149 "android.intent.action.MANAGED_PROFILE_REMOVED";
3150
3151 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003152 * Broadcast sent to the primary user when the credential-encrypted private storage for
3153 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3154 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3155 * Launchers) that need to display merged content across both primary and managed profiles
3156 * need to worry about this broadcast. This is only sent to registered receivers,
3157 * not manifest receivers.
3158 */
3159 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3160 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3161
3162 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003163 * Broadcast sent to the primary user when an associated managed profile has become available.
3164 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003165 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3166 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3167 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003168 */
Rubin Xue95057a2016-04-01 16:49:25 +01003169 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3170 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3171
3172 /**
3173 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3174 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3175 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3176 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3177 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3178 */
3179 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3180 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003181
3182 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003183 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3184 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3185 * the device was locked or unlocked.
3186 *
3187 * This is only sent to registered receivers.
3188 *
3189 * @hide
3190 */
3191 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3192 "android.intent.action.DEVICE_LOCKED_CHANGED";
3193
3194 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003195 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3196 */
3197 public static final String ACTION_QUICK_CLOCK =
3198 "android.intent.action.QUICK_CLOCK";
3199
Michael Wright0087a142013-02-05 16:29:39 -08003200 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003201 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003202 * @hide
3203 */
3204 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003205 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003206
Justin Kohd378ad72013-04-01 12:18:26 -07003207 /**
3208 * Broadcast Action: A global button was pressed. Includes a single
3209 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3210 * caused the broadcast.
3211 * @hide
3212 */
3213 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3214
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003215 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003216 * Broadcast Action: Sent when media resource is granted.
3217 * <p>
3218 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3219 * granted.
3220 * </p>
3221 * <p class="note">
3222 * This is a protected intent that can only be sent by the system.
3223 * </p>
3224 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003225 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003226 * </p>
3227 *
3228 * @hide
3229 */
3230 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3231 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3232
3233 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003234 * Broadcast Action: An overlay package has changed. The data contains the
3235 * name of the overlay package which has changed. This is broadcast on all
3236 * changes to the OverlayInfo returned by {@link
3237 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3238 * most common change is a state change that will change whether the
3239 * overlay is enabled or not.
3240 * @hide
3241 */
3242 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3243
3244 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003245 * Activity Action: Allow the user to select and return one or more existing
3246 * documents. When invoked, the system will display the various
3247 * {@link DocumentsProvider} instances installed on the device, letting the
3248 * user interactively navigate through them. These documents include local
3249 * media, such as photos and video, and documents provided by installed
3250 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003251 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003252 * Each document is represented as a {@code content://} URI backed by a
3253 * {@link DocumentsProvider}, which can be opened as a stream with
3254 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3255 * {@link android.provider.DocumentsContract.Document} metadata.
3256 * <p>
3257 * All selected documents are returned to the calling application with
3258 * persistable read and write permission grants. If you want to maintain
3259 * access to the documents across device reboots, you need to explicitly
3260 * take the persistable permissions using
3261 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3262 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003263 * Callers must indicate the acceptable document MIME types through
3264 * {@link #setType(String)}. For example, to select photos, use
3265 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3266 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3267 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003268 * <p>
3269 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003270 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3271 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003272 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003273 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3274 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003275 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003276 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003277 * Callers can set a document URI through
3278 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3279 * location of documents navigator. System will do its best to launch the
3280 * navigator in the specified document if it's a folder, or the folder that
3281 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003282 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003283 * Output: The URI of the item that was picked, returned in
3284 * {@link #getData()}. This must be a {@code content://} URI so that any
3285 * receiver can access it. If multiple documents were selected, they are
3286 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003287 *
3288 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003289 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003290 * @see #ACTION_CREATE_DOCUMENT
3291 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003292 */
3293 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3294 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3295
3296 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003297 * Activity Action: Allow the user to create a new document. When invoked,
3298 * the system will display the various {@link DocumentsProvider} instances
3299 * installed on the device, letting the user navigate through them. The
3300 * returned document may be a newly created document with no content, or it
3301 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003302 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003303 * Each document is represented as a {@code content://} URI backed by a
3304 * {@link DocumentsProvider}, which can be opened as a stream with
3305 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3306 * {@link android.provider.DocumentsContract.Document} metadata.
3307 * <p>
3308 * Callers must indicate the concrete MIME type of the document being
3309 * created by setting {@link #setType(String)}. This MIME type cannot be
3310 * changed after the document is created.
3311 * <p>
3312 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3313 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003314 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003315 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3316 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003317 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003318 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003319 * Callers can set a document URI through
3320 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3321 * location of documents navigator. System will do its best to launch the
3322 * navigator in the specified document if it's a folder, or the folder that
3323 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003324 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003325 * Output: The URI of the item that was created. This must be a
3326 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003327 *
3328 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003329 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003330 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003331 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003332 */
3333 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3334 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3335
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003336 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003337 * Activity Action: Allow the user to pick a directory subtree. When
3338 * invoked, the system will display the various {@link DocumentsProvider}
3339 * instances installed on the device, letting the user navigate through
3340 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003341 * <p>
3342 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003343 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3344 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3345 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003346 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003347 * Callers can set a document URI through
3348 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3349 * location of documents navigator. System will do its best to launch the
3350 * navigator in the specified document if it's a folder, or the folder that
3351 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003352 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003353 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003354 *
3355 * @see DocumentsContract
3356 */
3357 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003358 public static final String
3359 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003360
Felipe Lemec7b1f892016-01-15 15:02:31 -08003361 /**
Peng Xua35b5532016-01-20 00:05:45 -08003362 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3363 * exisiting sensor being disconnected.
3364 *
3365 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3366 *
3367 * {@hide}
3368 */
3369 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3370 public static final String
3371 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3372
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003373 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003374 * Broadcast Action: The default subscription has changed. This has the following
3375 * extra values:</p>
3376 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3377 */
3378 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3379 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3380 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3381
3382 /**
3383 * Broadcast Action: The default sms subscription has changed. This has the following
3384 * extra values:</p>
3385 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3386 * subscription index
3387 */
3388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3389 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3390 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3391
3392 /**
3393 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3394 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3395 * which has changed.
3396 */
3397 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3398
3399 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003400 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3401 *
3402 * {@hide}
3403 */
3404 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003405 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3406
Christopher Tate6597e342015-02-17 12:15:25 -08003407 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003408 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3409 * is about to be performed.
3410 * @hide
3411 */
3412 @SystemApi
3413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3414 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3415 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3416
3417 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003418 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3419 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3420 *
3421 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3422 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003423 * @hide
3424 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003425 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003426 public static final String EXTRA_FORCE_MASTER_CLEAR =
3427 "android.intent.extra.FORCE_MASTER_CLEAR";
3428
3429 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003430 * A broadcast action to trigger a factory reset.
3431 *
3432 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3433 *
3434 * <p>Not for use by third-party applications.
3435 *
3436 * @see #EXTRA_FORCE_MASTER_CLEAR
3437 *
3438 * {@hide}
3439 */
3440 @SystemApi
3441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3442 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3443
3444 /**
3445 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3446 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3447 *
3448 * <p>Not for use by third-party applications.
3449 *
3450 * @hide
3451 */
3452 @SystemApi
3453 public static final String EXTRA_FORCE_FACTORY_RESET =
3454 "android.intent.extra.FORCE_FACTORY_RESET";
3455
3456 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003457 * Broadcast action: report that a settings element is being restored from backup. The intent
3458 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3459 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3460 * is the value of that settings entry prior to the restore operation. All of these values are
3461 * represented as strings.
3462 *
3463 * <p>This broadcast is sent only for settings provider entries known to require special handling
3464 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3465 * the provider's backup agent implementation.
3466 *
3467 * @see #EXTRA_SETTING_NAME
3468 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3469 * @see #EXTRA_SETTING_NEW_VALUE
3470 * {@hide}
3471 */
3472 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3473
3474 /** {@hide} */
3475 public static final String EXTRA_SETTING_NAME = "setting_name";
3476 /** {@hide} */
3477 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3478 /** {@hide} */
3479 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3480
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003481 /**
3482 * Activity Action: Process a piece of text.
3483 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3484 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3485 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3486 */
3487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3488 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003489
3490 /**
3491 * Broadcast Action: The sim card state has changed.
3492 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3493 * because TelephonyIntents is an internal class.
3494 * @hide
3495 */
3496 @SystemApi
3497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3498 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3499
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003500 /**
fionaxu90fee272017-03-31 12:45:12 -07003501 * Broadcast Action: indicate that the phone service state has changed.
3502 * The intent will have the following extra values:</p>
3503 * <p>
3504 * @see #EXTRA_VOICE_REG_STATE
3505 * @see #EXTRA_DATA_REG_STATE
3506 * @see #EXTRA_VOICE_ROAMING_TYPE
3507 * @see #EXTRA_DATA_ROAMING_TYPE
3508 * @see #EXTRA_OPERATOR_ALPHA_LONG
3509 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3510 * @see #EXTRA_OPERATOR_NUMERIC
3511 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3512 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3513 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3514 * @see #EXTRA_MANUAL
3515 * @see #EXTRA_VOICE_RADIO_TECH
3516 * @see #EXTRA_DATA_RADIO_TECH
3517 * @see #EXTRA_CSS_INDICATOR
3518 * @see #EXTRA_NETWORK_ID
3519 * @see #EXTRA_SYSTEM_ID
3520 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3521 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3522 * @see #EXTRA_EMERGENCY_ONLY
3523 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3524 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3525 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3526 *
3527 * <p class="note">
3528 * Requires the READ_PHONE_STATE permission.
3529 *
3530 * <p class="note">This is a protected intent that can only be sent by the system.
3531 * @hide
3532 */
3533 @Deprecated
3534 @SystemApi
3535 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3536 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3537
3538 /**
3539 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3540 * state.
3541 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3542 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3543 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3544 * @see android.telephony.ServiceState#STATE_POWER_OFF
3545 * @hide
3546 */
3547 @Deprecated
3548 @SystemApi
3549 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3550
3551 /**
3552 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3553 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3554 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3555 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3556 * @see android.telephony.ServiceState#STATE_POWER_OFF
3557 * @hide
3558 */
3559 @Deprecated
3560 @SystemApi
3561 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3562
3563 /**
3564 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3565 * type.
3566 * @hide
3567 */
3568 @Deprecated
3569 @SystemApi
3570 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3571
3572 /**
3573 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3574 * type.
3575 * @hide
3576 */
3577 @Deprecated
3578 @SystemApi
3579 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3580
3581 /**
3582 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3583 * registered voice operator name in long alphanumeric format.
3584 * {@code null} if the operator name is not known or unregistered.
3585 * @hide
3586 */
3587 @Deprecated
3588 @SystemApi
3589 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3590
3591 /**
3592 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3593 * registered voice operator name in short alphanumeric format.
3594 * {@code null} if the operator name is not known or unregistered.
3595 * @hide
3596 */
3597 @Deprecated
3598 @SystemApi
3599 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3600
3601 /**
3602 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3603 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3604 * network.
3605 * @hide
3606 */
3607 @Deprecated
3608 @SystemApi
3609 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3610
3611 /**
3612 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3613 * registered data operator name in long alphanumeric format.
3614 * {@code null} if the operator name is not known or unregistered.
3615 * @hide
3616 */
3617 @Deprecated
3618 @SystemApi
3619 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3620
3621 /**
3622 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3623 * registered data operator name in short alphanumeric format.
3624 * {@code null} if the operator name is not known or unregistered.
3625 * @hide
3626 */
3627 @Deprecated
3628 @SystemApi
3629 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3630
3631 /**
3632 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3633 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3634 * data operator.
3635 * @hide
3636 */
3637 @Deprecated
3638 @SystemApi
3639 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3640
3641 /**
3642 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3643 * network selection mode is manual.
3644 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3645 * @hide
3646 */
3647 @Deprecated
3648 @SystemApi
3649 public static final String EXTRA_MANUAL = "manual";
3650
3651 /**
3652 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3653 * radio technology.
3654 * @hide
3655 */
3656 @Deprecated
3657 @SystemApi
3658 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3659
3660 /**
3661 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3662 * radio technology.
3663 * @hide
3664 */
3665 @Deprecated
3666 @SystemApi
3667 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3668
3669 /**
3670 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3671 * support on CDMA network.
3672 * Will be {@code true} if support, {@code false} otherwise.
3673 * @hide
3674 */
3675 @Deprecated
3676 @SystemApi
3677 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3678
3679 /**
3680 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3681 * id. {@code Integer.MAX_VALUE} if unknown.
3682 * @hide
3683 */
3684 @Deprecated
3685 @SystemApi
3686 public static final String EXTRA_NETWORK_ID = "networkId";
3687
3688 /**
3689 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3690 * {@code Integer.MAX_VALUE} if unknown.
3691 * @hide
3692 */
3693 @Deprecated
3694 @SystemApi
3695 public static final String EXTRA_SYSTEM_ID = "systemId";
3696
3697 /**
3698 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3699 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3700 * @hide
3701 */
3702 @Deprecated
3703 @SystemApi
3704 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3705
3706 /**
3707 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3708 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3709 * @hide
3710 */
3711 @Deprecated
3712 @SystemApi
3713 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3714
3715 /**
3716 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3717 * only mode.
3718 * {@code true} if in emergency only mode, {@code false} otherwise.
3719 * @hide
3720 */
3721 @Deprecated
3722 @SystemApi
3723 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3724
3725 /**
3726 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3727 * registration state is roaming.
3728 * {@code true} if registration indicates roaming, {@code false} otherwise
3729 * @hide
3730 */
3731 @Deprecated
3732 @SystemApi
3733 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3734 "isDataRoamingFromRegistration";
3735
3736 /**
3737 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3738 * aggregation is in use.
3739 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3740 * @hide
3741 */
3742 @Deprecated
3743 @SystemApi
3744 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3745
3746 /**
3747 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3748 * is reduced from the rsrp threshold while calculating signal strength level.
3749 * @hide
3750 */
3751 @Deprecated
3752 @SystemApi
3753 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3754
3755 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003756 * The name of the extra used to define the text to be processed, as a
3757 * CharSequence. Note that this may be a styled CharSequence, so you must use
3758 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003759 */
3760 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3761 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003762 * 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 +00003763 */
3764 public static final String EXTRA_PROCESS_TEXT_READONLY =
3765 "android.intent.extra.PROCESS_TEXT_READONLY";
3766
Bryce Leebc58f592015-09-25 16:43:01 -07003767 /**
3768 * Broadcast action: reports when a new thermal event has been reached. When the device
3769 * is reaching its maximum temperatue, the thermal level reported
3770 * {@hide}
3771 */
3772 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3773 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3774
3775 /** {@hide} */
3776 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3777
3778 /**
3779 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003780 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003781 * {@hide}
3782 */
3783 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3784
3785 /**
3786 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003787 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003788 * {@hide}
3789 */
3790 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3791
3792 /**
3793 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003794 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003795 * {@hide}
3796 */
3797 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3798
3799
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003800 // ---------------------------------------------------------------------
3801 // ---------------------------------------------------------------------
3802 // Standard intent categories (see addCategory()).
3803
3804 /**
3805 * Set if the activity should be an option for the default action
3806 * (center press) to perform on a piece of data. Setting this will
3807 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003808 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003809 * Intent when initiating an action -- it is for use in intent filters
3810 * specified in packages.
3811 */
3812 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3813 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3814 /**
3815 * Activities that can be safely invoked from a browser must support this
3816 * category. For example, if the user is viewing a web page or an e-mail
3817 * and clicks on a link in the text, the Intent generated execute that
3818 * link will require the BROWSABLE category, so that only activities
3819 * supporting this category will be considered as possible actions. By
3820 * supporting this category, you are promising that there is nothing
3821 * damaging (without user intervention) that can happen by invoking any
3822 * matching Intent.
3823 */
3824 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3825 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3826 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003827 * Categories for activities that can participate in voice interaction.
3828 * An activity that supports this category must be prepared to run with
3829 * no UI shown at all (though in some case it may have a UI shown), and
3830 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3831 */
3832 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3833 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3834 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003835 * Set if the activity should be considered as an alternative action to
3836 * the data the user is currently viewing. See also
3837 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3838 * applies to the selection in a list of items.
3839 *
3840 * <p>Supporting this category means that you would like your activity to be
3841 * displayed in the set of alternative things the user can do, usually as
3842 * part of the current activity's options menu. You will usually want to
3843 * include a specific label in the &lt;intent-filter&gt; of this action
3844 * describing to the user what it does.
3845 *
3846 * <p>The action of IntentFilter with this category is important in that it
3847 * describes the specific action the target will perform. This generally
3848 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3849 * a specific name such as "com.android.camera.action.CROP. Only one
3850 * alternative of any particular action will be shown to the user, so using
3851 * a specific action like this makes sure that your alternative will be
3852 * displayed while also allowing other applications to provide their own
3853 * overrides of that particular action.
3854 */
3855 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3856 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3857 /**
3858 * Set if the activity should be considered as an alternative selection
3859 * action to the data the user has currently selected. This is like
3860 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3861 * of items from which the user can select, giving them alternatives to the
3862 * default action that will be performed on it.
3863 */
3864 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3865 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3866 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003867 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003868 */
3869 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3870 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3871 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003872 * Should be displayed in the top-level launcher.
3873 */
3874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3875 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3876 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003877 * Indicates an activity optimized for Leanback mode, and that should
3878 * be displayed in the Leanback launcher.
3879 */
3880 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3881 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3882 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003883 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3884 * @hide
3885 */
3886 @SystemApi
3887 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003889 * Provides information about the package it is in; typically used if
3890 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3891 * a front-door to the user without having to be shown in the all apps list.
3892 */
3893 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3894 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3895 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003896 * This is the home activity, that is the first activity that is displayed
3897 * when the device boots.
3898 */
3899 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3900 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3901 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003902 * This is the home activity that is displayed when the device is finished setting up and ready
3903 * for use.
3904 * @hide
3905 */
3906 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3907 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3908 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003909 * This is the setup wizard activity, that is the first activity that is displayed
3910 * when the user sets up the device for the first time.
3911 * @hide
3912 */
3913 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3914 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3915 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003916 * This activity is a preference panel.
3917 */
3918 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3919 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3920 /**
3921 * This activity is a development preference panel.
3922 */
3923 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3924 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3925 /**
3926 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003927 */
3928 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3929 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3930 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003931 * This activity allows the user to browse and download new applications.
3932 */
3933 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3934 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3935 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003936 * This activity may be exercised by the monkey or other automated test tools.
3937 */
3938 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3939 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3940 /**
3941 * To be used as a test (not part of the normal user experience).
3942 */
3943 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3944 /**
3945 * To be used as a unit test (run through the Test Harness).
3946 */
3947 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3948 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003949 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003950 * experience).
3951 */
3952 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003954 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003955 * Used to indicate that an intent only wants URIs that can be opened with
3956 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3957 * must support at least the columns defined in {@link OpenableColumns} when
3958 * queried.
3959 *
3960 * @see #ACTION_GET_CONTENT
3961 * @see #ACTION_OPEN_DOCUMENT
3962 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003963 */
3964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3965 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3966
3967 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003968 * Used to indicate that an intent filter can accept files which are not necessarily
3969 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3970 * at least streamable via
3971 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3972 * using one of the stream types exposed via
3973 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3974 *
3975 * @see #ACTION_SEND
3976 * @see #ACTION_SEND_MULTIPLE
3977 */
3978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3979 public static final String CATEGORY_TYPED_OPENABLE =
3980 "android.intent.category.TYPED_OPENABLE";
3981
3982 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003983 * To be used as code under test for framework instrumentation tests.
3984 */
3985 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3986 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003987 /**
3988 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003989 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3990 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003991 */
3992 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3993 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3994 /**
3995 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003996 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3997 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003998 */
3999 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4000 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004001 /**
4002 * An activity to run when device is inserted into a analog (low end) dock.
4003 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4004 * information, see {@link android.app.UiModeManager}.
4005 */
4006 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4007 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4008
4009 /**
4010 * An activity to run when device is inserted into a digital (high end) dock.
4011 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4012 * information, see {@link android.app.UiModeManager}.
4013 */
4014 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4015 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004016
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004017 /**
4018 * Used to indicate that the activity can be used in a car environment.
4019 */
4020 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4021 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4022
Zak Cohendb6ca492017-01-26 14:09:00 -08004023 /**
4024 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4025 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4026 * information, see {@link android.app.UiModeManager}.
4027 */
4028 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4029 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004030 // ---------------------------------------------------------------------
4031 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004032 // Application launch intent categories (see addCategory()).
4033
4034 /**
4035 * Used with {@link #ACTION_MAIN} to launch the browser application.
4036 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004037 * <p>NOTE: This should not be used as the primary key of an Intent,
4038 * since it will not result in the app launching with the correct
4039 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004040 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004041 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004042 */
4043 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4044 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4045
4046 /**
4047 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4048 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004049 * <p>NOTE: This should not be used as the primary key of an Intent,
4050 * since it will not result in the app launching with the correct
4051 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004052 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004053 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004054 */
4055 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4056 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4057
4058 /**
4059 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4060 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004061 * <p>NOTE: This should not be used as the primary key of an Intent,
4062 * since it will not result in the app launching with the correct
4063 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004064 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004065 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004066 */
4067 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4068 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4069
4070 /**
4071 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4072 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004073 * <p>NOTE: This should not be used as the primary key of an Intent,
4074 * since it will not result in the app launching with the correct
4075 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004076 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004077 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004078 */
4079 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4080 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4081
4082 /**
4083 * Used with {@link #ACTION_MAIN} to launch the email application.
4084 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004085 * <p>NOTE: This should not be used as the primary key of an Intent,
4086 * since it will not result in the app launching with the correct
4087 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004088 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004089 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004090 */
4091 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4092 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4093
4094 /**
4095 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4096 * The activity should be able to view and manipulate image and video files
4097 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004098 * <p>NOTE: This should not be used as the primary key of an Intent,
4099 * since it will not result in the app launching with the correct
4100 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004101 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004102 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004103 */
4104 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4105 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4106
4107 /**
4108 * Used with {@link #ACTION_MAIN} to launch the maps application.
4109 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004110 * <p>NOTE: This should not be used as the primary key of an Intent,
4111 * since it will not result in the app launching with the correct
4112 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004113 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004114 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004115 */
4116 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4117 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4118
4119 /**
4120 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4121 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004122 * <p>NOTE: This should not be used as the primary key of an Intent,
4123 * since it will not result in the app launching with the correct
4124 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004125 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004126 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004127 */
4128 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4129 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4130
4131 /**
4132 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004133 * The activity should be able to play, browse, or manipulate music files
4134 * stored on the device.
4135 * <p>NOTE: This should not be used as the primary key of an Intent,
4136 * since it will not result in the app launching with the correct
4137 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004138 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004139 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004140 */
4141 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4142 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4143
4144 // ---------------------------------------------------------------------
4145 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004146 // Standard extra data keys.
4147
4148 /**
4149 * The initial data to place in a newly created record. Use with
4150 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4151 * fields as would be given to the underlying ContentProvider.insert()
4152 * call.
4153 */
4154 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4155
4156 /**
4157 * A constant CharSequence that is associated with the Intent, used with
4158 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4159 * this may be a styled CharSequence, so you must use
4160 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4161 * retrieve it.
4162 */
4163 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4164
4165 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004166 * A constant String that is associated with the Intent, used with
4167 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4168 * as HTML formatted text. Note that you <em>must</em> also supply
4169 * {@link #EXTRA_TEXT}.
4170 */
4171 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4172
4173 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004174 * A content: URI holding a stream of data associated with the Intent,
4175 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004176 */
4177 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4178
4179 /**
4180 * A String[] holding e-mail addresses that should be delivered to.
4181 */
4182 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4183
4184 /**
4185 * A String[] holding e-mail addresses that should be carbon copied.
4186 */
4187 public static final String EXTRA_CC = "android.intent.extra.CC";
4188
4189 /**
4190 * A String[] holding e-mail addresses that should be blind carbon copied.
4191 */
4192 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4193
4194 /**
4195 * A constant string holding the desired subject line of a message.
4196 */
4197 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4198
4199 /**
4200 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004201 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004202 */
4203 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4204
4205 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004206 * An int representing the user id to be used.
4207 *
4208 * @hide
4209 */
4210 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4211
4212 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004213 * An int representing the task id to be retrieved. This is used when a launch from recents is
4214 * intercepted by another action such as credentials confirmation to remember which task should
4215 * be resumed when complete.
4216 *
4217 * @hide
4218 */
4219 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4220
4221 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004222 * An Intent[] describing additional, alternate choices you would like shown with
4223 * {@link #ACTION_CHOOSER}.
4224 *
4225 * <p>An app may be capable of providing several different payload types to complete a
4226 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4227 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4228 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4229 * photo data or a hosted link where the photos can be viewed.</p>
4230 *
4231 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4232 * first/primary/preferred intent in the set. Additional intents specified in
4233 * this extra are ordered; by default intents that appear earlier in the array will be
4234 * preferred over intents that appear later in the array as matches for the same
4235 * target component. To alter this preference, a calling app may also supply
4236 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4237 */
4238 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4239
4240 /**
Adam Powell52c39212016-04-07 15:14:18 -07004241 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4242 * and omitted from a list of components presented to the user.
4243 *
4244 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4245 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4246 * from your own package or other apps from your organization if the idea of sending to those
4247 * targets would be redundant with other app functionality. Filtered components will not
4248 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4249 */
4250 public static final String EXTRA_EXCLUDE_COMPONENTS
4251 = "android.intent.extra.EXCLUDE_COMPONENTS";
4252
4253 /**
4254 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4255 * describing additional high-priority deep-link targets for the chooser to present to the user.
4256 *
4257 * <p>Targets provided in this way will be presented inline with all other targets provided
4258 * by services from other apps. They will be prioritized before other service targets, but
4259 * after those targets provided by sources that the user has manually pinned to the front.</p>
4260 *
4261 * @see #ACTION_CHOOSER
4262 */
4263 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4264
4265 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004266 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4267 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4268 *
4269 * <p>An app preparing an action for another app to complete may wish to allow the user to
4270 * disambiguate between several options for completing the action based on the chosen target
4271 * or otherwise refine the action before it is invoked.
4272 * </p>
4273 *
4274 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4275 * <ul>
4276 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4277 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4278 * chosen target beyond the first</li>
4279 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4280 * should fill in and send once the disambiguation is complete</li>
4281 * </ul>
4282 */
4283 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4284 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4285
4286 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004287 * An {@code ArrayList} of {@code String} annotations describing content for
4288 * {@link #ACTION_CHOOSER}.
4289 *
4290 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4291 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4292 *
4293 * <p>Annotations should describe the major components or topics of the content. It is up to
4294 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4295 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4296 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4297 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4298 * use the following annotations when applicable:</p>
4299 * <ul>
4300 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4301 * health & beauty, and office supplies.</li>
4302 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4303 * happy, and sad.</li>
4304 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4305 * face, finger, standing, and walking.</li>
4306 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4307 * child, and baby.</li>
4308 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4309 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4310 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4311 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4312 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4313 * flowers.</li>
4314 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4315 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4316 * sunglasses, jewelry, handbags and clothing.</li>
4317 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4318 * paper, and silk.</li>
4319 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4320 * cars, and boats.</li>
4321 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4322 * posters.</li>
4323 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4324 * and designs of houses.</li>
4325 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4326 * Christmas and Thanksgiving.</li>
4327 * </ul>
4328 */
4329 public static final String EXTRA_CONTENT_ANNOTATIONS
4330 = "android.intent.extra.CONTENT_ANNOTATIONS";
4331
4332 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004333 * A {@link ResultReceiver} used to return data back to the sender.
4334 *
4335 * <p>Used to complete an app-specific
4336 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4337 *
4338 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4339 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4340 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4341 * when the user selects a target component from the chooser. It is up to the recipient
4342 * to send a result to this ResultReceiver to signal that disambiguation is complete
4343 * and that the chooser should invoke the user's choice.</p>
4344 *
4345 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4346 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4347 * to match and fill in the final Intent or ChooserTarget before starting it.
4348 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4349 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4350 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4351 *
4352 * <p>The result code passed to the ResultReceiver should be
4353 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4354 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4355 * the chooser should finish without starting a target.</p>
4356 */
4357 public static final String EXTRA_RESULT_RECEIVER
4358 = "android.intent.extra.RESULT_RECEIVER";
4359
4360 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004361 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004362 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 */
4364 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4365
4366 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004367 * A Parcelable[] of {@link Intent} or
4368 * {@link android.content.pm.LabeledIntent} objects as set with
4369 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4370 * a the front of the list of choices, when shown to the user with a
4371 * {@link #ACTION_CHOOSER}.
4372 */
4373 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4374
4375 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004376 * A {@link IntentSender} to start after ephemeral installation success.
4377 * @hide
4378 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004379 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4380
4381 /**
4382 * A {@link IntentSender} to start after ephemeral installation failure.
4383 * @hide
4384 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004385 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4386
4387 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004388 * The host name that triggered an ephemeral resolution.
4389 * @hide
4390 */
4391 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4392
4393 /**
4394 * An opaque token to track ephemeral resolution.
4395 * @hide
4396 */
4397 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4398
4399 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004400 * The version code of the app to install components from.
4401 * @hide
4402 */
4403 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4404
4405 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004406 * A Bundle forming a mapping of potential target package names to different extras Bundles
4407 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4408 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4409 * be currently installed on the device.
4410 *
4411 * <p>An application may choose to provide alternate extras for the case where a user
4412 * selects an activity from a predetermined set of target packages. If the activity
4413 * the user selects from the chooser belongs to a package with its package name as
4414 * a key in this bundle, the corresponding extras for that package will be merged with
4415 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4416 * extra has the same key as an extra already present in the intent it will overwrite
4417 * the extra from the intent.</p>
4418 *
4419 * <p><em>Examples:</em>
4420 * <ul>
4421 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4422 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4423 * parameters for that target.</li>
4424 * <li>An application may offer additional metadata for known targets of a given intent
4425 * to pass along information only relevant to that target such as account or content
4426 * identifiers already known to that application.</li>
4427 * </ul></p>
4428 */
4429 public static final String EXTRA_REPLACEMENT_EXTRAS =
4430 "android.intent.extra.REPLACEMENT_EXTRAS";
4431
4432 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004433 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4434 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4435 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4436 * {@link ComponentName} of the chosen component.
4437 *
4438 * <p>In some situations this callback may never come, for example if the user abandons
4439 * the chooser, switches to another task or any number of other reasons. Apps should not
4440 * be written assuming that this callback will always occur.</p>
4441 */
4442 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4443 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4444
4445 /**
4446 * The {@link ComponentName} chosen by the user to complete an action.
4447 *
4448 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4449 */
4450 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4451
4452 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004453 * A {@link android.view.KeyEvent} object containing the event that
4454 * triggered the creation of the Intent it is in.
4455 */
4456 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4457
4458 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004459 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4460 * before shutting down.
4461 *
4462 * {@hide}
4463 */
4464 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4465
4466 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004467 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4468 * requested by the user.
4469 *
4470 * {@hide}
4471 */
4472 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4473 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4474
4475 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004476 * 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 -07004477 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4478 * of restarting the application.
4479 */
4480 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4481
4482 /**
4483 * A String holding the phone number originally entered in
4484 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4485 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4486 */
4487 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004488
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004489 /**
4490 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4491 * intents to supply the uid the package had been assigned. Also an optional
4492 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4493 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4494 * purpose.
4495 */
4496 public static final String EXTRA_UID = "android.intent.extra.UID";
4497
4498 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004499 * @hide String array of package names.
4500 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004501 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004502 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4503
4504 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004505 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4506 * intents to indicate whether this represents a full uninstall (removing
4507 * both the code and its data) or a partial uninstall (leaving its data,
4508 * implying that this is an update).
4509 */
4510 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004511
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004512 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004513 * @hide
4514 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4515 * intents to indicate that at this point the package has been removed for
4516 * all users on the device.
4517 */
4518 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4519 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4520
4521 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004522 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4523 * intents to indicate that this is a replacement of the package, so this
4524 * broadcast will immediately be followed by an add broadcast for a
4525 * different version of the same package.
4526 */
4527 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004528
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004529 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004530 * Used as an int extra field in {@link android.app.AlarmManager} intents
4531 * to tell the application being invoked how many pending alarms are being
4532 * delievered with the intent. For one-shot alarms this will always be 1.
4533 * For recurring alarms, this might be greater than 1 if the device was
4534 * asleep or powered off at the time an earlier alarm would have been
4535 * delivered.
4536 */
4537 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004538
Jacek Surazski86b6c532009-05-13 14:38:28 +02004539 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004540 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4541 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004542 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4543 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004544 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4545 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4546 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004547 */
4548 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4549
4550 /**
4551 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4552 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004553 */
4554 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4555
4556 /**
4557 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4558 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004559 */
4560 public static final int EXTRA_DOCK_STATE_DESK = 1;
4561
4562 /**
4563 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4564 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004565 */
4566 public static final int EXTRA_DOCK_STATE_CAR = 2;
4567
4568 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004569 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4570 * to represent that the phone is in a analog (low end) dock.
4571 */
4572 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4573
4574 /**
4575 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4576 * to represent that the phone is in a digital (high end) dock.
4577 */
4578 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4579
4580 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004581 * Boolean that can be supplied as meta-data with a dock activity, to
4582 * indicate that the dock should take over the home key when it is active.
4583 */
4584 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004585
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004586 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004587 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4588 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004589 */
4590 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4591
4592 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004593 * Used in the extra field in the remote intent. It's astring token passed with the
4594 * remote intent.
4595 */
4596 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4597 "android.intent.extra.remote_intent_token";
4598
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004599 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004600 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004601 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004602 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004603 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004604 "android.intent.extra.changed_component_name";
4605
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004606 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004607 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004608 * and contains a string array of all of the components that have changed. If
4609 * the state of the overall package has changed, then it will contain an entry
4610 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004611 */
4612 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4613 "android.intent.extra.changed_component_name_list";
4614
4615 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004616 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004617 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004618 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4619 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4620 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004621 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004622 */
4623 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4624 "android.intent.extra.changed_package_list";
4625
4626 /**
4627 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004628 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4629 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004630 * and contains an integer array of uids of all of the components
4631 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004632 */
4633 public static final String EXTRA_CHANGED_UID_LIST =
4634 "android.intent.extra.changed_uid_list";
4635
4636 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004637 * @hide
4638 * Magic extra system code can use when binding, to give a label for
4639 * who it is that has bound to a service. This is an integer giving
4640 * a framework string resource that can be displayed to the user.
4641 */
4642 public static final String EXTRA_CLIENT_LABEL =
4643 "android.intent.extra.client_label";
4644
4645 /**
4646 * @hide
4647 * Magic extra system code can use when binding, to give a PendingIntent object
4648 * that can be launched for the user to disable the system's use of this
4649 * service.
4650 */
4651 public static final String EXTRA_CLIENT_INTENT =
4652 "android.intent.extra.client_intent";
4653
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004654 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004655 * Extra used to indicate that an intent should only return data that is on
4656 * the local device. This is a boolean extra; the default is false. If true,
4657 * an implementation should only allow the user to select data that is
4658 * already on the device, not requiring it be downloaded from a remote
4659 * service when opened.
4660 *
4661 * @see #ACTION_GET_CONTENT
4662 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004663 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004664 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004665 */
4666 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004667 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004668
Amith Yamasani13593602012-03-22 16:16:17 -07004669 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004670 * Extra used to indicate that an intent can allow the user to select and
4671 * return multiple items. This is a boolean extra; the default is false. If
4672 * true, an implementation is allowed to present the user with a UI where
4673 * they can pick multiple items that are all returned to the caller. When
4674 * this happens, they should be returned as the {@link #getClipData()} part
4675 * of the result Intent.
4676 *
4677 * @see #ACTION_GET_CONTENT
4678 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004679 */
4680 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004681 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004682
4683 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004684 * The integer userHandle carried with broadcast intents related to addition, removal and
4685 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4686 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4687 *
Amith Yamasani13593602012-03-22 16:16:17 -07004688 * @hide
4689 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004690 public static final String EXTRA_USER_HANDLE =
4691 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004692
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004693 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004694 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4695 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4696 */
4697 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004698 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004699
4700 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004701 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004702 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4703 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004704 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004705 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4706
4707 /**
4708 * Extra sent in the intent to the BroadcastReceiver that handles
4709 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4710 * the restrictions as key/value pairs.
4711 */
4712 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4713 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004714
Amith Yamasani86118ba2013-03-28 14:33:16 -07004715 /**
4716 * Extra used in the response from a BroadcastReceiver that handles
4717 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4718 */
4719 public static final String EXTRA_RESTRICTIONS_INTENT =
4720 "android.intent.extra.restrictions_intent";
4721
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004722 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004723 * Extra used to communicate a set of acceptable MIME types. The type of the
4724 * extra is {@code String[]}. Values may be a combination of concrete MIME
4725 * types (such as "image/png") and/or partial MIME types (such as
4726 * "audio/*").
4727 *
4728 * @see #ACTION_GET_CONTENT
4729 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004730 */
4731 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4732
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004733 /**
4734 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4735 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004736 * When this is true, hardware devices can use this information to determine that
4737 * they shouldn't do a complete shutdown of their device since this is not a
4738 * complete shutdown down to the kernel, but only user space restarting.
4739 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004740 */
4741 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4742 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4743
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004744 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004745 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4746 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4747 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4748 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004749 *
4750 * @hide for internal use only.
4751 */
4752 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4753 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004754 /** @hide */
4755 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4756 /** @hide */
4757 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4758 /** @hide */
4759 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004760
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004761 /** {@hide} */
4762 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4763
qingxi240c2bb2017-04-12 17:31:18 -07004764 /**
4765 * {@hide}
4766 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
4767 */
Rubin Xue8490f12015-06-25 12:17:48 +01004768 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4769
Santos Cordon15a13782015-03-31 18:32:31 -07004770 /**
qingxi240c2bb2017-04-12 17:31:18 -07004771 * {@hide}
4772 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
4773 * reset for the device with eSIM. This extra will be sent together with
4774 * {@link #ACTION_FACTORY_RESET}
4775 */
4776 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
4777
4778 /**
Santos Cordon15a13782015-03-31 18:32:31 -07004779 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4780 * activation request.
4781 * TODO: Add information about the structure and response data used with the pending intent.
4782 * @hide
4783 */
4784 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4785 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4786
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004787 /**
4788 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004789 *
4790 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004791 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004792 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004793 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4794
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004795 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004796 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4797 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4798 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004799 *
4800 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004801 * @see #ACTION_QUICK_VIEW
4802 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004803 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004804 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004805 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4806 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004807
4808 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004809 * An optional extra of {@code String[]} indicating which quick view features should be made
4810 * available to the user in the quick view UI while handing a
4811 * {@link Intent#ACTION_QUICK_VIEW} intent.
4812 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4813 * Quick viewer can implement features not listed below.
4814 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4815 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4816 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4817 * <p>
4818 * Requirements:
4819 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4820 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4821 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4822 * internal policies.
4823 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4824 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4825 * disable or hide features.
4826 *
4827 * @see #ACTION_QUICK_VIEW
4828 */
4829 public static final String EXTRA_QUICK_VIEW_FEATURES =
4830 "android.intent.extra.QUICK_VIEW_FEATURES";
4831
4832 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004833 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004834 * When a profile goes into quiet mode, all apps in the profile are killed and the
4835 * profile user is stopped. Widgets originating from the profile are masked, and app
4836 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004837 */
4838 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004839
4840 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004841 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004842 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004843 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4844 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004845 *
4846 * @hide
4847 */
4848 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4849 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4850
4851 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004852 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4853 * whether to show the chooser or not when there is only one application available
4854 * to choose from.
4855 *
4856 * @hide
4857 */
4858 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4859 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4860
4861 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004862 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004863 * to represent that a video codec is allowed to use.
4864 *
4865 * @hide
4866 */
4867 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4868
4869 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004870 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004871 * to represent that a audio codec is allowed to use.
4872 *
4873 * @hide
4874 */
4875 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4876
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004877 // ---------------------------------------------------------------------
4878 // ---------------------------------------------------------------------
4879 // Intent flags (see mFlags variable).
4880
Tor Norbyed9273d62013-05-30 15:59:53 -07004881 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004882 @IntDef(flag = true, value = {
4883 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4884 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004885 @Retention(RetentionPolicy.SOURCE)
4886 public @interface GrantUriMode {}
4887
Jeff Sharkey846318a2014-04-04 12:12:41 -07004888 /** @hide */
4889 @IntDef(flag = true, value = {
4890 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4891 @Retention(RetentionPolicy.SOURCE)
4892 public @interface AccessUriMode {}
4893
4894 /**
4895 * Test if given mode flags specify an access mode, which must be at least
4896 * read and/or write.
4897 *
4898 * @hide
4899 */
4900 public static boolean isAccessUriMode(int modeFlags) {
4901 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4902 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4903 }
4904
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004905 /**
4906 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004907 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004908 * specified in its ClipData. When applying to an Intent's ClipData,
4909 * all URIs as well as recursive traversals through data or other ClipData
4910 * in Intent items will be granted; only the grant flags of the top-level
4911 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004912 */
4913 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4914 /**
4915 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004916 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004917 * specified in its ClipData. When applying to an Intent's ClipData,
4918 * all URIs as well as recursive traversals through data or other ClipData
4919 * in Intent items will be granted; only the grant flags of the top-level
4920 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004921 */
4922 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4923 /**
4924 * Can be set by the caller to indicate that this Intent is coming from
4925 * a background operation, not from direct user interaction.
4926 */
4927 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4928 /**
4929 * A flag you can enable for debugging: when set, log messages will be
4930 * printed during the resolution of this intent to show you what has
4931 * been found to create the final resolved list.
4932 */
4933 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004934 /**
4935 * If set, this intent will not match any components in packages that
4936 * are currently stopped. If this is not set, then the default behavior
4937 * is to include such applications in the result.
4938 */
4939 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4940 /**
4941 * If set, this intent will always match any components in packages that
4942 * are currently stopped. This is the default behavior when
4943 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4944 * flags are set, this one wins (it allows overriding of exclude for
4945 * places where the framework may automatically set the exclude flag).
4946 */
4947 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004948
4949 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004950 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004951 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004952 * persisted across device reboots until explicitly revoked with
4953 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4954 * grant for possible persisting; the receiving application must call
4955 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4956 * actually persist.
4957 *
4958 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4959 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4960 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004961 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004962 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004963 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004964
4965 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004966 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4967 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4968 * applies to any URI that is a prefix match against the original granted
4969 * URI. (Without this flag, the URI must match exactly for access to be
4970 * granted.) Another URI is considered a prefix match only when scheme,
4971 * authority, and all path segments defined by the prefix are an exact
4972 * match.
4973 */
4974 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4975
4976 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004977 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004978 * homework and verified that they correctly handle packages and components
4979 * that come and go over time. In particular:
4980 * <ul>
4981 * <li>Apps installed on external storage, which will appear to be
4982 * uninstalled while the the device is ejected.
4983 * <li>Apps with encryption unaware components, which will appear to not
4984 * exist while the device is locked.
4985 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004986 *
4987 * @hide
4988 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004989 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004990
4991 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004992 * Internal flag used to indicate ephemeral applications should not be
4993 * considered when resolving the intent.
4994 *
4995 * @hide
4996 */
4997 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4998
4999 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005000 * If set, the new activity is not kept in the history stack. As soon as
5001 * the user navigates away from it, the activity is finished. This may also
5002 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5003 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005004 *
5005 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5006 * is never invoked when the current activity starts a new activity which
5007 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005008 */
5009 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5010 /**
5011 * If set, the activity will not be launched if it is already running
5012 * at the top of the history stack.
5013 */
5014 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5015 /**
5016 * If set, this activity will become the start of a new task on this
5017 * history stack. A task (from the activity that started it to the
5018 * next task activity) defines an atomic group of activities that the
5019 * user can move to. Tasks can be moved to the foreground and background;
5020 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005021 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005022 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5023 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005024 *
5025 * <p>This flag is generally used by activities that want
5026 * to present a "launcher" style behavior: they give the user a list of
5027 * separate things that can be done, which otherwise run completely
5028 * independently of the activity launching them.
5029 *
5030 * <p>When using this flag, if a task is already running for the activity
5031 * you are now starting, then a new activity will not be started; instead,
5032 * the current task will simply be brought to the front of the screen with
5033 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5034 * to disable this behavior.
5035 *
5036 * <p>This flag can not be used when the caller is requesting a result from
5037 * the activity being launched.
5038 */
5039 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5040 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005041 * This flag is used to create a new task and launch an activity into it.
5042 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5043 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5044 * search through existing tasks for ones matching this Intent. Only if no such
5045 * task is found would a new task be created. When paired with
5046 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5047 * the search for a matching task and unconditionally start a new task.
5048 *
5049 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5050 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005051 * top-level application launcher.</strong> Used in conjunction with
5052 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5053 * behavior of bringing an existing task to the foreground. When set,
5054 * a new task is <em>always</em> started to host the Activity for the
5055 * Intent, regardless of whether there is already an existing task running
5056 * the same thing.
5057 *
5058 * <p><strong>Because the default system does not include graphical task management,
5059 * you should not use this flag unless you provide some way for a user to
5060 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005061 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005062 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5063 * creating new document tasks.
5064 *
5065 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005066 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005067 *
Scott Main7aee61f2011-02-08 11:25:01 -08005068 * <p>See
5069 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5070 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005071 *
5072 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5073 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005074 */
5075 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5076 /**
5077 * If set, and the activity being launched is already running in the
5078 * current task, then instead of launching a new instance of that activity,
5079 * all of the other activities on top of it will be closed and this Intent
5080 * will be delivered to the (now on top) old activity as a new Intent.
5081 *
5082 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5083 * If D calls startActivity() with an Intent that resolves to the component
5084 * of activity B, then C and D will be finished and B receive the given
5085 * Intent, resulting in the stack now being: A, B.
5086 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005087 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005088 * either receive the new intent you are starting here in its
5089 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005090 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005091 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5092 * the same intent, then it will be finished and re-created; for all other
5093 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5094 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005095 *
5096 * <p>This launch mode can also be used to good effect in conjunction with
5097 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5098 * of a task, it will bring any currently running instance of that task
5099 * to the foreground, and then clear it to its root state. This is
5100 * especially useful, for example, when launching an activity from the
5101 * notification manager.
5102 *
Scott Main7aee61f2011-02-08 11:25:01 -08005103 * <p>See
5104 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5105 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005106 */
5107 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5108 /**
5109 * If set and this intent is being used to launch a new activity from an
5110 * existing one, then the reply target of the existing activity will be
5111 * transfered to the new activity. This way the new activity can call
5112 * {@link android.app.Activity#setResult} and have that result sent back to
5113 * the reply target of the original activity.
5114 */
5115 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5116 /**
5117 * If set and this intent is being used to launch a new activity from an
5118 * existing one, the current activity will not be counted as the top
5119 * activity for deciding whether the new intent should be delivered to
5120 * the top instead of starting a new one. The previous activity will
5121 * be used as the top, with the assumption being that the current activity
5122 * will finish itself immediately.
5123 */
5124 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5125 /**
5126 * If set, the new activity is not kept in the list of recently launched
5127 * activities.
5128 */
5129 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5130 /**
5131 * This flag is not normally set by application code, but set for you by
5132 * the system as described in the
5133 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5134 * launchMode} documentation for the singleTask mode.
5135 */
5136 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5137 /**
5138 * If set, and this activity is either being started in a new task or
5139 * bringing to the top an existing task, then it will be launched as
5140 * the front door of the task. This will result in the application of
5141 * any affinities needed to have that task in the proper state (either
5142 * moving activities to or from it), or simply resetting that task to
5143 * its initial state if needed.
5144 */
5145 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5146 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005147 * This flag is not normally set by application code, but set for you by
5148 * the system if this activity is being launched from history
5149 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005150 */
5151 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005152 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005153 * @deprecated As of API 21 this performs identically to
5154 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005155 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005156 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005157 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005158 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005159 * This flag is used to open a document into a new task rooted at the activity launched
5160 * by this Intent. Through the use of this flag, or its equivalent attribute,
5161 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005162 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005163 *
Craig Mautner026596b2014-05-21 15:35:44 -07005164 * <p>The use of the activity attribute form of this,
5165 * {@link android.R.attr#documentLaunchMode}, is
5166 * preferred over the Intent flag described here. The attribute form allows the
5167 * Activity to specify multiple document behavior for all launchers of the Activity
5168 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005169 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005170 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5171 * it is kept after the activity is finished is different than the use of
5172 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5173 * this flag is being used to create a new recents entry, then by default that entry
5174 * will be removed once the activity is finished. You can modify this behavior with
5175 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5176 *
Craig Mautner026596b2014-05-21 15:35:44 -07005177 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5178 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5179 * equivalent of the Activity manifest specifying {@link
5180 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5181 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5182 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005183 *
Craig Mautner026596b2014-05-21 15:35:44 -07005184 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005185 *
Craig Mautner026596b2014-05-21 15:35:44 -07005186 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005187 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5188 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005189 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005190 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005191 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005192 * callback from occurring on the current frontmost activity before it is
5193 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005194 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005195 * <p>Typically, an activity can rely on that callback to indicate that an
5196 * explicit user action has caused their activity to be moved out of the
5197 * foreground. The callback marks an appropriate point in the activity's
5198 * lifecycle for it to dismiss any notifications that it intends to display
5199 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005200 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005201 * <p>If an activity is ever started via any non-user-driven events such as
5202 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5203 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005204 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005205 */
5206 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005207 /**
5208 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5209 * this flag will cause the launched activity to be brought to the front of its
5210 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005211 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005212 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5213 * If D calls startActivity() with an Intent that resolves to the component
5214 * of activity B, then B will be brought to the front of the history stack,
5215 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005216 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005217 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005218 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005219 */
5220 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005221 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005222 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5223 * this flag will prevent the system from applying an activity transition
5224 * animation to go to the next activity state. This doesn't mean an
5225 * animation will never run -- if another activity change happens that doesn't
5226 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005227 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005228 * when you are going to do a series of activity operations but the
5229 * animation seen by the user shouldn't be driven by the first activity
5230 * change but rather a later one.
5231 */
5232 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5233 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005234 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5235 * this flag will cause any existing task that would be associated with the
5236 * activity to be cleared before the activity is started. That is, the activity
5237 * becomes the new root of an otherwise empty task, and any old activities
5238 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5239 */
5240 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5241 /**
5242 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5243 * this flag will cause a newly launching task to be placed on top of the current
5244 * home activity task (if there is one). That is, pressing back from the task
5245 * will always return the user to home even if that was not the last activity they
5246 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5247 */
5248 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5249 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005250 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5251 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005252 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005253 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005254 * this flag. When set and the task's activity is finished, the recents
5255 * entry will remain in the interface for the user to re-launch it, like a
5256 * recents entry for a top-level application.
5257 * <p>
5258 * The receiving activity can override this request with
5259 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5260 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005261 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005262 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005263 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005264
5265 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005266 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5267 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005268 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5269 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005270 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005271 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005272
5273 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005274 * If set, when sending a broadcast only registered receivers will be
5275 * called -- no BroadcastReceiver components will be launched.
5276 */
5277 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005278 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005279 * If set, when sending a broadcast the new broadcast will replace
5280 * any existing pending broadcast that matches it. Matching is defined
5281 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5282 * true for the intents of the two broadcasts. When a match is found,
5283 * the new broadcast (and receivers associated with it) will replace the
5284 * existing one in the pending broadcast list, remaining at the same
5285 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005286 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005287 * <p>This flag is most typically used with sticky broadcasts, which
5288 * only care about delivering the most recent values of the broadcast
5289 * to their receivers.
5290 */
5291 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5292 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005293 * If set, when sending a broadcast the recipient is allowed to run at
5294 * foreground priority, with a shorter timeout interval. During normal
5295 * broadcasts the receivers are not automatically hoisted out of the
5296 * background priority class.
5297 */
5298 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5299 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005300 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5301 * They can still propagate results through to later receivers, but they can not prevent
5302 * later receivers from seeing the broadcast.
5303 */
5304 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5305 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005306 * If set, when sending a broadcast <i>before boot has completed</i> only
5307 * registered receivers will be called -- no BroadcastReceiver components
5308 * will be launched. Sticky intent state will be recorded properly even
5309 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5310 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005311 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005312 * <p>This flag is only for use by system sevices as a convenience to
5313 * avoid having to implement a more complex mechanism around detection
5314 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005315 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005316 * @hide
5317 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005318 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005319 /**
5320 * Set when this broadcast is for a boot upgrade, a special mode that
5321 * allows the broadcast to be sent before the system is ready and launches
5322 * the app process with no providers running in it.
5323 * @hide
5324 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005325 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005326 /**
5327 * If set, the broadcast will always go to manifest receivers in background (cached
5328 * or not running) apps, regardless of whether that would be done by default. By
5329 * default they will only receive broadcasts if the broadcast has specified an
5330 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005331 *
5332 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5333 * the broadcast code there must also be changed to match.
5334 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005335 * @hide
5336 */
5337 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5338 /**
5339 * If set, the broadcast will never go to manifest receivers in background (cached
5340 * or not running) apps, regardless of whether that would be done by default. By
5341 * default they will receive broadcasts if the broadcast has specified an
5342 * explicit component or package name.
5343 * @hide
5344 */
5345 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005346 /**
5347 * If set, this broadcast is being sent from the shell.
5348 * @hide
5349 */
5350 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005351
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005352 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005353 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5354 * will not receive broadcasts.
5355 *
5356 * <em>This flag has no effect when used by an Instant App.</em>
5357 */
5358 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5359
5360 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005361 * @hide Flags that can't be changed with PendingIntent.
5362 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005363 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5364 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5365 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005366
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005368 // ---------------------------------------------------------------------
5369 // toUri() and parseUri() options.
5370
5371 /**
5372 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5373 * always has the "intent:" scheme. This syntax can be used when you want
5374 * to later disambiguate between URIs that are intended to describe an
5375 * Intent vs. all others that should be treated as raw URIs. When used
5376 * with {@link #parseUri}, any other scheme will result in a generic
5377 * VIEW action for that raw URI.
5378 */
5379 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005380
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005381 /**
5382 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5383 * always has the "android-app:" scheme. This is a variation of
5384 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5385 * http/https URI being delivered to a specific package name. The format
5386 * is:
5387 *
5388 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005389 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005390 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005391 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5392 * you must also include a scheme; including a path also requires both a host and a scheme.
5393 * The final #Intent; fragment can be used without a scheme, host, or path.
5394 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005395 * used with intents that have a {@link #setSelector}, since the base intent
5396 * will always have an explicit package name.</p>
5397 *
5398 * <p>Some examples of how this scheme maps to Intent objects:</p>
5399 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5400 * <colgroup align="left" />
5401 * <colgroup align="left" />
5402 * <thead>
5403 * <tr><th>URI</th> <th>Intent</th></tr>
5404 * </thead>
5405 *
5406 * <tbody>
5407 * <tr><td><code>android-app://com.example.app</code></td>
5408 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5409 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5410 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5411 * </table></td>
5412 * </tr>
5413 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5414 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5415 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5416 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5417 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5418 * </table></td>
5419 * </tr>
5420 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5421 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5422 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5423 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5424 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5425 * </table></td>
5426 * </tr>
5427 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5428 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5429 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5430 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5431 * </table></td>
5432 * </tr>
5433 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5434 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5435 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5436 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5437 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5438 * </table></td>
5439 * </tr>
5440 * <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>
5441 * <td><table border="" style="margin:0" >
5442 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5443 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5444 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5445 * </table></td>
5446 * </tr>
5447 * </tbody>
5448 * </table>
5449 */
5450 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5451
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005452 /**
5453 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5454 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5455 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5456 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5457 * generated Intent can not cause unexpected data access to happen.
5458 *
5459 * <p>If you do not trust the source of the URI being parsed, you should still do further
5460 * processing to protect yourself from it. In particular, when using it to start an
5461 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5462 * that can handle it.</p>
5463 */
5464 public static final int URI_ALLOW_UNSAFE = 1<<2;
5465
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005466 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005467
5468 private String mAction;
5469 private Uri mData;
5470 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005471 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472 private ComponentName mComponent;
5473 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005474 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005475 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005476 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005477 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005478 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005479 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005480 /** Token to track instant app launches. Local only; do not copy cross-process. */
5481 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005482
5483 // ---------------------------------------------------------------------
5484
5485 /**
5486 * Create an empty intent.
5487 */
5488 public Intent() {
5489 }
5490
5491 /**
5492 * Copy constructor.
5493 */
5494 public Intent(Intent o) {
5495 this.mAction = o.mAction;
5496 this.mData = o.mData;
5497 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005498 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005499 this.mComponent = o.mComponent;
5500 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005501 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005502 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005503 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005504 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005505 }
5506 if (o.mExtras != null) {
5507 this.mExtras = new Bundle(o.mExtras);
5508 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005509 if (o.mSourceBounds != null) {
5510 this.mSourceBounds = new Rect(o.mSourceBounds);
5511 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005512 if (o.mSelector != null) {
5513 this.mSelector = new Intent(o.mSelector);
5514 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005515 if (o.mClipData != null) {
5516 this.mClipData = new ClipData(o.mClipData);
5517 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005518 }
5519
5520 @Override
5521 public Object clone() {
5522 return new Intent(this);
5523 }
5524
5525 private Intent(Intent o, boolean all) {
5526 this.mAction = o.mAction;
5527 this.mData = o.mData;
5528 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005529 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005530 this.mComponent = o.mComponent;
5531 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005532 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005533 }
5534 }
5535
5536 /**
5537 * Make a clone of only the parts of the Intent that are relevant for
5538 * filter matching: the action, data, type, component, and categories.
5539 */
5540 public Intent cloneFilter() {
5541 return new Intent(this, false);
5542 }
5543
5544 /**
5545 * Create an intent with a given action. All other fields (data, type,
5546 * class) are null. Note that the action <em>must</em> be in a
5547 * namespace because Intents are used globally in the system -- for
5548 * example the system VIEW action is android.intent.action.VIEW; an
5549 * application's custom action would be something like
5550 * com.google.app.myapp.CUSTOM_ACTION.
5551 *
5552 * @param action The Intent action, such as ACTION_VIEW.
5553 */
5554 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005555 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005556 }
5557
5558 /**
5559 * Create an intent with a given action and for a given data url. Note
5560 * that the action <em>must</em> be in a namespace because Intents are
5561 * used globally in the system -- for example the system VIEW action is
5562 * android.intent.action.VIEW; an application's custom action would be
5563 * something like com.google.app.myapp.CUSTOM_ACTION.
5564 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005565 * <p><em>Note: scheme and host name matching in the Android framework is
5566 * case-sensitive, unlike the formal RFC. As a result,
5567 * you should always ensure that you write your Uri with these elements
5568 * using lower case letters, and normalize any Uris you receive from
5569 * outside of Android to ensure the scheme and host is lower case.</em></p>
5570 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005571 * @param action The Intent action, such as ACTION_VIEW.
5572 * @param uri The Intent data URI.
5573 */
5574 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005575 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005576 mData = uri;
5577 }
5578
5579 /**
5580 * Create an intent for a specific component. All other fields (action, data,
5581 * type, class) are null, though they can be modified later with explicit
5582 * calls. This provides a convenient way to create an intent that is
5583 * intended to execute a hard-coded class name, rather than relying on the
5584 * system to find an appropriate class for you; see {@link #setComponent}
5585 * for more information on the repercussions of this.
5586 *
5587 * @param packageContext A Context of the application package implementing
5588 * this class.
5589 * @param cls The component class that is to be used for the intent.
5590 *
5591 * @see #setClass
5592 * @see #setComponent
5593 * @see #Intent(String, android.net.Uri , Context, Class)
5594 */
5595 public Intent(Context packageContext, Class<?> cls) {
5596 mComponent = new ComponentName(packageContext, cls);
5597 }
5598
5599 /**
5600 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005601 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005602 * construct the Intent and then calling {@link #setClass} to set its
5603 * class.
5604 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005605 * <p><em>Note: scheme and host name matching in the Android framework is
5606 * case-sensitive, unlike the formal RFC. As a result,
5607 * you should always ensure that you write your Uri with these elements
5608 * using lower case letters, and normalize any Uris you receive from
5609 * outside of Android to ensure the scheme and host is lower case.</em></p>
5610 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005611 * @param action The Intent action, such as ACTION_VIEW.
5612 * @param uri The Intent data URI.
5613 * @param packageContext A Context of the application package implementing
5614 * this class.
5615 * @param cls The component class that is to be used for the intent.
5616 *
5617 * @see #Intent(String, android.net.Uri)
5618 * @see #Intent(Context, Class)
5619 * @see #setClass
5620 * @see #setComponent
5621 */
5622 public Intent(String action, Uri uri,
5623 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005624 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005625 mData = uri;
5626 mComponent = new ComponentName(packageContext, cls);
5627 }
5628
5629 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005630 * Create an intent to launch the main (root) activity of a task. This
5631 * is the Intent that is started when the application's is launched from
5632 * Home. For anything else that wants to launch an application in the
5633 * same way, it is important that they use an Intent structured the same
5634 * way, and can use this function to ensure this is the case.
5635 *
5636 * <p>The returned Intent has the given Activity component as its explicit
5637 * component, {@link #ACTION_MAIN} as its action, and includes the
5638 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5639 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5640 * to do that through {@link #addFlags(int)} on the returned Intent.
5641 *
5642 * @param mainActivity The main activity component that this Intent will
5643 * launch.
5644 * @return Returns a newly created Intent that can be used to launch the
5645 * activity as a main application entry.
5646 *
5647 * @see #setClass
5648 * @see #setComponent
5649 */
5650 public static Intent makeMainActivity(ComponentName mainActivity) {
5651 Intent intent = new Intent(ACTION_MAIN);
5652 intent.setComponent(mainActivity);
5653 intent.addCategory(CATEGORY_LAUNCHER);
5654 return intent;
5655 }
5656
5657 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005658 * Make an Intent for the main activity of an application, without
5659 * specifying a specific activity to run but giving a selector to find
5660 * the activity. This results in a final Intent that is structured
5661 * the same as when the application is launched from
5662 * Home. For anything else that wants to launch an application in the
5663 * same way, it is important that they use an Intent structured the same
5664 * way, and can use this function to ensure this is the case.
5665 *
5666 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5667 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5668 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5669 * to do that through {@link #addFlags(int)} on the returned Intent.
5670 *
5671 * @param selectorAction The action name of the Intent's selector.
5672 * @param selectorCategory The name of a category to add to the Intent's
5673 * selector.
5674 * @return Returns a newly created Intent that can be used to launch the
5675 * activity as a main application entry.
5676 *
5677 * @see #setSelector(Intent)
5678 */
5679 public static Intent makeMainSelectorActivity(String selectorAction,
5680 String selectorCategory) {
5681 Intent intent = new Intent(ACTION_MAIN);
5682 intent.addCategory(CATEGORY_LAUNCHER);
5683 Intent selector = new Intent();
5684 selector.setAction(selectorAction);
5685 selector.addCategory(selectorCategory);
5686 intent.setSelector(selector);
5687 return intent;
5688 }
5689
5690 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005691 * Make an Intent that can be used to re-launch an application's task
5692 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5693 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5694 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5695 *
5696 * @param mainActivity The activity component that is the root of the
5697 * task; this is the activity that has been published in the application's
5698 * manifest as the main launcher icon.
5699 *
5700 * @return Returns a newly created Intent that can be used to relaunch the
5701 * activity's task in its root state.
5702 */
5703 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5704 Intent intent = makeMainActivity(mainActivity);
5705 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5706 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5707 return intent;
5708 }
5709
5710 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005711 * Call {@link #parseUri} with 0 flags.
5712 * @deprecated Use {@link #parseUri} instead.
5713 */
5714 @Deprecated
5715 public static Intent getIntent(String uri) throws URISyntaxException {
5716 return parseUri(uri, 0);
5717 }
Tom Taylord4a47292009-12-21 13:59:18 -08005718
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005719 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005720 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005721 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005722 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005723 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005724 *
5725 * <p>The URI given here must not be relative -- that is, it must include
5726 * the scheme and full path.
5727 *
5728 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005729 * @param flags Additional processing flags. Either 0,
5730 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005731 *
5732 * @return Intent The newly created Intent object.
5733 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005734 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5735 * it bad (as parsed by the Uri class) or the Intent data within the
5736 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005737 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005738 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005739 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005740 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005741 int i = 0;
5742 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005743 final boolean androidApp = uri.startsWith("android-app:");
5744
5745 // Validate intent scheme if requested.
5746 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5747 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005748 Intent intent = new Intent(ACTION_VIEW);
5749 try {
5750 intent.setData(Uri.parse(uri));
5751 } catch (IllegalArgumentException e) {
5752 throw new URISyntaxException(uri, e.getMessage());
5753 }
5754 return intent;
5755 }
5756 }
Tom Taylord4a47292009-12-21 13:59:18 -08005757
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005758 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005759 // simple case
5760 if (i == -1) {
5761 if (!androidApp) {
5762 return new Intent(ACTION_VIEW, Uri.parse(uri));
5763 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005764
5765 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005766 } else if (!uri.startsWith("#Intent;", i)) {
5767 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005768 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005769 } else {
5770 i = -1;
5771 }
5772 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005773
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 // new format
5775 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005776 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005777 boolean explicitAction = false;
5778 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005779
5780 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005781 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005782 String data;
5783 if (i >= 0) {
5784 data = uri.substring(0, i);
5785 i += 8; // length of "#Intent;"
5786 } else {
5787 data = uri;
5788 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005789
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005791 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005792 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005793 if (eq < 0) eq = i-1;
5794 int semi = uri.indexOf(';', i);
5795 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005796
5797 // action
5798 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005799 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005800 if (!inSelector) {
5801 explicitAction = true;
5802 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005803 }
5804
5805 // categories
5806 else if (uri.startsWith("category=", i)) {
5807 intent.addCategory(value);
5808 }
5809
5810 // type
5811 else if (uri.startsWith("type=", i)) {
5812 intent.mType = value;
5813 }
5814
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005815 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005816 else if (uri.startsWith("launchFlags=", i)) {
5817 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005818 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5819 intent.mFlags &= ~IMMUTABLE_FLAGS;
5820 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005821 }
5822
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005823 // package
5824 else if (uri.startsWith("package=", i)) {
5825 intent.mPackage = value;
5826 }
5827
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005828 // component
5829 else if (uri.startsWith("component=", i)) {
5830 intent.mComponent = ComponentName.unflattenFromString(value);
5831 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005832
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005833 // scheme
5834 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005835 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005836 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005837 } else {
5838 scheme = value;
5839 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005840 }
5841
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005842 // source bounds
5843 else if (uri.startsWith("sourceBounds=", i)) {
5844 intent.mSourceBounds = Rect.unflattenFromString(value);
5845 }
5846
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005847 // selector
5848 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5849 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005850 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005851 }
5852
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005853 // extra
5854 else {
5855 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005856 // create Bundle if it doesn't already exist
5857 if (intent.mExtras == null) intent.mExtras = new Bundle();
5858 Bundle b = intent.mExtras;
5859 // add EXTRA
5860 if (uri.startsWith("S.", i)) b.putString(key, value);
5861 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5862 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5863 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5864 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5865 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5866 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5867 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5868 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5869 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5870 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005871
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005872 // move to the next item
5873 i = semi + 1;
5874 }
5875
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005876 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005877 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005878 if (baseIntent.mPackage == null) {
5879 baseIntent.setSelector(intent);
5880 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005881 intent = baseIntent;
5882 }
5883
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005884 if (data != null) {
5885 if (data.startsWith("intent:")) {
5886 data = data.substring(7);
5887 if (scheme != null) {
5888 data = scheme + ':' + data;
5889 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005890 } else if (data.startsWith("android-app:")) {
5891 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5892 // Correctly formed android-app, first part is package name.
5893 int end = data.indexOf('/', 14);
5894 if (end < 0) {
5895 // All we have is a package name.
5896 intent.mPackage = data.substring(14);
5897 if (!explicitAction) {
5898 intent.setAction(ACTION_MAIN);
5899 }
5900 data = "";
5901 } else {
5902 // Target the Intent at the given package name always.
5903 String authority = null;
5904 intent.mPackage = data.substring(14, end);
5905 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005906 if ((end+1) < data.length()) {
5907 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5908 // Found a scheme, remember it.
5909 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005910 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005911 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5912 // Found a authority, remember it.
5913 authority = data.substring(end+1, newEnd);
5914 end = newEnd;
5915 }
5916 } else {
5917 // All we have is a scheme.
5918 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005919 }
5920 }
5921 if (scheme == null) {
5922 // If there was no scheme, then this just targets the package.
5923 if (!explicitAction) {
5924 intent.setAction(ACTION_MAIN);
5925 }
5926 data = "";
5927 } else if (authority == null) {
5928 data = scheme + ":";
5929 } else {
5930 data = scheme + "://" + authority + data.substring(end);
5931 }
5932 }
5933 } else {
5934 data = "";
5935 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005936 }
Tom Taylord4a47292009-12-21 13:59:18 -08005937
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005938 if (data.length() > 0) {
5939 try {
5940 intent.mData = Uri.parse(data);
5941 } catch (IllegalArgumentException e) {
5942 throw new URISyntaxException(uri, e.getMessage());
5943 }
5944 }
5945 }
Tom Taylord4a47292009-12-21 13:59:18 -08005946
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005947 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005948
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005949 } catch (IndexOutOfBoundsException e) {
5950 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5951 }
5952 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005954 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005955 return getIntentOld(uri, 0);
5956 }
5957
5958 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005959 Intent intent;
5960
5961 int i = uri.lastIndexOf('#');
5962 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005964 final int intentFragmentStart = i;
5965 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005966
5967 i++;
5968
5969 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005970 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005971 i += 7;
5972 int j = uri.indexOf(')', i);
5973 action = uri.substring(i, j);
5974 i = j + 1;
5975 }
5976
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005977 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005978
5979 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005980 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005981 i += 11;
5982 int j = uri.indexOf(')', i);
5983 while (i < j) {
5984 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005985 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005986 if (i < sep) {
5987 intent.addCategory(uri.substring(i, sep));
5988 }
5989 i = sep + 1;
5990 }
5991 i = j + 1;
5992 }
5993
5994 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005995 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005996 i += 5;
5997 int j = uri.indexOf(')', i);
5998 intent.mType = uri.substring(i, j);
5999 i = j + 1;
6000 }
6001
6002 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006003 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006004 i += 12;
6005 int j = uri.indexOf(')', i);
6006 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006007 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6008 intent.mFlags &= ~IMMUTABLE_FLAGS;
6009 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006010 i = j + 1;
6011 }
6012
6013 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006014 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006015 i += 10;
6016 int j = uri.indexOf(')', i);
6017 int sep = uri.indexOf('!', i);
6018 if (sep >= 0 && sep < j) {
6019 String pkg = uri.substring(i, sep);
6020 String cls = uri.substring(sep + 1, j);
6021 intent.mComponent = new ComponentName(pkg, cls);
6022 }
6023 i = j + 1;
6024 }
6025
6026 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006027 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006028 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006029
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006030 final int closeParen = uri.indexOf(')', i);
6031 if (closeParen == -1) throw new URISyntaxException(uri,
6032 "EXTRA missing trailing ')'", i);
6033
6034 while (i < closeParen) {
6035 // fetch the key value
6036 int j = uri.indexOf('=', i);
6037 if (j <= i + 1 || i >= closeParen) {
6038 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6039 }
6040 char type = uri.charAt(i);
6041 i++;
6042 String key = uri.substring(i, j);
6043 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006044
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006045 // get type-value
6046 j = uri.indexOf('!', i);
6047 if (j == -1 || j >= closeParen) j = closeParen;
6048 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6049 String value = uri.substring(i, j);
6050 i = j;
6051
6052 // create Bundle if it doesn't already exist
6053 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006055 // add item to bundle
6056 try {
6057 switch (type) {
6058 case 'S':
6059 intent.mExtras.putString(key, Uri.decode(value));
6060 break;
6061 case 'B':
6062 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6063 break;
6064 case 'b':
6065 intent.mExtras.putByte(key, Byte.parseByte(value));
6066 break;
6067 case 'c':
6068 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6069 break;
6070 case 'd':
6071 intent.mExtras.putDouble(key, Double.parseDouble(value));
6072 break;
6073 case 'f':
6074 intent.mExtras.putFloat(key, Float.parseFloat(value));
6075 break;
6076 case 'i':
6077 intent.mExtras.putInt(key, Integer.parseInt(value));
6078 break;
6079 case 'l':
6080 intent.mExtras.putLong(key, Long.parseLong(value));
6081 break;
6082 case 's':
6083 intent.mExtras.putShort(key, Short.parseShort(value));
6084 break;
6085 default:
6086 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6087 }
6088 } catch (NumberFormatException e) {
6089 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6090 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006091
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006092 char ch = uri.charAt(i);
6093 if (ch == ')') break;
6094 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6095 i++;
6096 }
6097 }
6098
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006099 if (isIntentFragment) {
6100 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6101 } else {
6102 intent.mData = Uri.parse(uri);
6103 }
Tom Taylord4a47292009-12-21 13:59:18 -08006104
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006105 if (intent.mAction == null) {
6106 // By default, if no action is specified, then use VIEW.
6107 intent.mAction = ACTION_VIEW;
6108 }
6109
6110 } else {
6111 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6112 }
6113
6114 return intent;
6115 }
6116
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006117 /** @hide */
6118 public interface CommandOptionHandler {
6119 boolean handleOption(String opt, ShellCommand cmd);
6120 }
6121
6122 /** @hide */
6123 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6124 throws URISyntaxException {
6125 Intent intent = new Intent();
6126 Intent baseIntent = intent;
6127 boolean hasIntentInfo = false;
6128
6129 Uri data = null;
6130 String type = null;
6131
6132 String opt;
6133 while ((opt=cmd.getNextOption()) != null) {
6134 switch (opt) {
6135 case "-a":
6136 intent.setAction(cmd.getNextArgRequired());
6137 if (intent == baseIntent) {
6138 hasIntentInfo = true;
6139 }
6140 break;
6141 case "-d":
6142 data = Uri.parse(cmd.getNextArgRequired());
6143 if (intent == baseIntent) {
6144 hasIntentInfo = true;
6145 }
6146 break;
6147 case "-t":
6148 type = cmd.getNextArgRequired();
6149 if (intent == baseIntent) {
6150 hasIntentInfo = true;
6151 }
6152 break;
6153 case "-c":
6154 intent.addCategory(cmd.getNextArgRequired());
6155 if (intent == baseIntent) {
6156 hasIntentInfo = true;
6157 }
6158 break;
6159 case "-e":
6160 case "--es": {
6161 String key = cmd.getNextArgRequired();
6162 String value = cmd.getNextArgRequired();
6163 intent.putExtra(key, value);
6164 }
6165 break;
6166 case "--esn": {
6167 String key = cmd.getNextArgRequired();
6168 intent.putExtra(key, (String) null);
6169 }
6170 break;
6171 case "--ei": {
6172 String key = cmd.getNextArgRequired();
6173 String value = cmd.getNextArgRequired();
6174 intent.putExtra(key, Integer.decode(value));
6175 }
6176 break;
6177 case "--eu": {
6178 String key = cmd.getNextArgRequired();
6179 String value = cmd.getNextArgRequired();
6180 intent.putExtra(key, Uri.parse(value));
6181 }
6182 break;
6183 case "--ecn": {
6184 String key = cmd.getNextArgRequired();
6185 String value = cmd.getNextArgRequired();
6186 ComponentName cn = ComponentName.unflattenFromString(value);
6187 if (cn == null)
6188 throw new IllegalArgumentException("Bad component name: " + value);
6189 intent.putExtra(key, cn);
6190 }
6191 break;
6192 case "--eia": {
6193 String key = cmd.getNextArgRequired();
6194 String value = cmd.getNextArgRequired();
6195 String[] strings = value.split(",");
6196 int[] list = new int[strings.length];
6197 for (int i = 0; i < strings.length; i++) {
6198 list[i] = Integer.decode(strings[i]);
6199 }
6200 intent.putExtra(key, list);
6201 }
6202 break;
6203 case "--eial": {
6204 String key = cmd.getNextArgRequired();
6205 String value = cmd.getNextArgRequired();
6206 String[] strings = value.split(",");
6207 ArrayList<Integer> list = new ArrayList<>(strings.length);
6208 for (int i = 0; i < strings.length; i++) {
6209 list.add(Integer.decode(strings[i]));
6210 }
6211 intent.putExtra(key, list);
6212 }
6213 break;
6214 case "--el": {
6215 String key = cmd.getNextArgRequired();
6216 String value = cmd.getNextArgRequired();
6217 intent.putExtra(key, Long.valueOf(value));
6218 }
6219 break;
6220 case "--ela": {
6221 String key = cmd.getNextArgRequired();
6222 String value = cmd.getNextArgRequired();
6223 String[] strings = value.split(",");
6224 long[] list = new long[strings.length];
6225 for (int i = 0; i < strings.length; i++) {
6226 list[i] = Long.valueOf(strings[i]);
6227 }
6228 intent.putExtra(key, list);
6229 hasIntentInfo = true;
6230 }
6231 break;
6232 case "--elal": {
6233 String key = cmd.getNextArgRequired();
6234 String value = cmd.getNextArgRequired();
6235 String[] strings = value.split(",");
6236 ArrayList<Long> list = new ArrayList<>(strings.length);
6237 for (int i = 0; i < strings.length; i++) {
6238 list.add(Long.valueOf(strings[i]));
6239 }
6240 intent.putExtra(key, list);
6241 hasIntentInfo = true;
6242 }
6243 break;
6244 case "--ef": {
6245 String key = cmd.getNextArgRequired();
6246 String value = cmd.getNextArgRequired();
6247 intent.putExtra(key, Float.valueOf(value));
6248 hasIntentInfo = true;
6249 }
6250 break;
6251 case "--efa": {
6252 String key = cmd.getNextArgRequired();
6253 String value = cmd.getNextArgRequired();
6254 String[] strings = value.split(",");
6255 float[] list = new float[strings.length];
6256 for (int i = 0; i < strings.length; i++) {
6257 list[i] = Float.valueOf(strings[i]);
6258 }
6259 intent.putExtra(key, list);
6260 hasIntentInfo = true;
6261 }
6262 break;
6263 case "--efal": {
6264 String key = cmd.getNextArgRequired();
6265 String value = cmd.getNextArgRequired();
6266 String[] strings = value.split(",");
6267 ArrayList<Float> list = new ArrayList<>(strings.length);
6268 for (int i = 0; i < strings.length; i++) {
6269 list.add(Float.valueOf(strings[i]));
6270 }
6271 intent.putExtra(key, list);
6272 hasIntentInfo = true;
6273 }
6274 break;
6275 case "--esa": {
6276 String key = cmd.getNextArgRequired();
6277 String value = cmd.getNextArgRequired();
6278 // Split on commas unless they are preceeded by an escape.
6279 // The escape character must be escaped for the string and
6280 // again for the regex, thus four escape characters become one.
6281 String[] strings = value.split("(?<!\\\\),");
6282 intent.putExtra(key, strings);
6283 hasIntentInfo = true;
6284 }
6285 break;
6286 case "--esal": {
6287 String key = cmd.getNextArgRequired();
6288 String value = cmd.getNextArgRequired();
6289 // Split on commas unless they are preceeded by an escape.
6290 // The escape character must be escaped for the string and
6291 // again for the regex, thus four escape characters become one.
6292 String[] strings = value.split("(?<!\\\\),");
6293 ArrayList<String> list = new ArrayList<>(strings.length);
6294 for (int i = 0; i < strings.length; i++) {
6295 list.add(strings[i]);
6296 }
6297 intent.putExtra(key, list);
6298 hasIntentInfo = true;
6299 }
6300 break;
6301 case "--ez": {
6302 String key = cmd.getNextArgRequired();
6303 String value = cmd.getNextArgRequired().toLowerCase();
6304 // Boolean.valueOf() results in false for anything that is not "true", which is
6305 // error-prone in shell commands
6306 boolean arg;
6307 if ("true".equals(value) || "t".equals(value)) {
6308 arg = true;
6309 } else if ("false".equals(value) || "f".equals(value)) {
6310 arg = false;
6311 } else {
6312 try {
6313 arg = Integer.decode(value) != 0;
6314 } catch (NumberFormatException ex) {
6315 throw new IllegalArgumentException("Invalid boolean value: " + value);
6316 }
6317 }
6318
6319 intent.putExtra(key, arg);
6320 }
6321 break;
6322 case "-n": {
6323 String str = cmd.getNextArgRequired();
6324 ComponentName cn = ComponentName.unflattenFromString(str);
6325 if (cn == null)
6326 throw new IllegalArgumentException("Bad component name: " + str);
6327 intent.setComponent(cn);
6328 if (intent == baseIntent) {
6329 hasIntentInfo = true;
6330 }
6331 }
6332 break;
6333 case "-p": {
6334 String str = cmd.getNextArgRequired();
6335 intent.setPackage(str);
6336 if (intent == baseIntent) {
6337 hasIntentInfo = true;
6338 }
6339 }
6340 break;
6341 case "-f":
6342 String str = cmd.getNextArgRequired();
6343 intent.setFlags(Integer.decode(str).intValue());
6344 break;
6345 case "--grant-read-uri-permission":
6346 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6347 break;
6348 case "--grant-write-uri-permission":
6349 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6350 break;
6351 case "--grant-persistable-uri-permission":
6352 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6353 break;
6354 case "--grant-prefix-uri-permission":
6355 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6356 break;
6357 case "--exclude-stopped-packages":
6358 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6359 break;
6360 case "--include-stopped-packages":
6361 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6362 break;
6363 case "--debug-log-resolution":
6364 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6365 break;
6366 case "--activity-brought-to-front":
6367 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6368 break;
6369 case "--activity-clear-top":
6370 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6371 break;
6372 case "--activity-clear-when-task-reset":
6373 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6374 break;
6375 case "--activity-exclude-from-recents":
6376 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6377 break;
6378 case "--activity-launched-from-history":
6379 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6380 break;
6381 case "--activity-multiple-task":
6382 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6383 break;
6384 case "--activity-no-animation":
6385 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6386 break;
6387 case "--activity-no-history":
6388 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6389 break;
6390 case "--activity-no-user-action":
6391 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6392 break;
6393 case "--activity-previous-is-top":
6394 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6395 break;
6396 case "--activity-reorder-to-front":
6397 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6398 break;
6399 case "--activity-reset-task-if-needed":
6400 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6401 break;
6402 case "--activity-single-top":
6403 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6404 break;
6405 case "--activity-clear-task":
6406 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6407 break;
6408 case "--activity-task-on-home":
6409 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6410 break;
6411 case "--receiver-registered-only":
6412 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6413 break;
6414 case "--receiver-replace-pending":
6415 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6416 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006417 case "--receiver-foreground":
6418 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6419 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006420 case "--receiver-no-abort":
6421 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6422 break;
6423 case "--receiver-include-background":
6424 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6425 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006426 case "--selector":
6427 intent.setDataAndType(data, type);
6428 intent = new Intent();
6429 break;
6430 default:
6431 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6432 // Okay, caller handled this option.
6433 } else {
6434 throw new IllegalArgumentException("Unknown option: " + opt);
6435 }
6436 break;
6437 }
6438 }
6439 intent.setDataAndType(data, type);
6440
6441 final boolean hasSelector = intent != baseIntent;
6442 if (hasSelector) {
6443 // A selector was specified; fix up.
6444 baseIntent.setSelector(intent);
6445 intent = baseIntent;
6446 }
6447
6448 String arg = cmd.getNextArg();
6449 baseIntent = null;
6450 if (arg == null) {
6451 if (hasSelector) {
6452 // If a selector has been specified, and no arguments
6453 // have been supplied for the main Intent, then we can
6454 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6455 // need to have a component name specified yet, the
6456 // selector will take care of that.
6457 baseIntent = new Intent(Intent.ACTION_MAIN);
6458 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6459 }
6460 } else if (arg.indexOf(':') >= 0) {
6461 // The argument is a URI. Fully parse it, and use that result
6462 // to fill in any data not specified so far.
6463 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6464 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6465 } else if (arg.indexOf('/') >= 0) {
6466 // The argument is a component name. Build an Intent to launch
6467 // it.
6468 baseIntent = new Intent(Intent.ACTION_MAIN);
6469 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6470 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6471 } else {
6472 // Assume the argument is a package name.
6473 baseIntent = new Intent(Intent.ACTION_MAIN);
6474 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6475 baseIntent.setPackage(arg);
6476 }
6477 if (baseIntent != null) {
6478 Bundle extras = intent.getExtras();
6479 intent.replaceExtras((Bundle)null);
6480 Bundle uriExtras = baseIntent.getExtras();
6481 baseIntent.replaceExtras((Bundle)null);
6482 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6483 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6484 for (String c : cats) {
6485 baseIntent.removeCategory(c);
6486 }
6487 }
6488 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6489 if (extras == null) {
6490 extras = uriExtras;
6491 } else if (uriExtras != null) {
6492 uriExtras.putAll(extras);
6493 extras = uriExtras;
6494 }
6495 intent.replaceExtras(extras);
6496 hasIntentInfo = true;
6497 }
6498
6499 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6500 return intent;
6501 }
6502
6503 /** @hide */
6504 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6505 final String[] lines = new String[] {
6506 "<INTENT> specifications include these flags and arguments:",
6507 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6508 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6509 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6510 " [--esn <EXTRA_KEY> ...]",
6511 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6512 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6513 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6514 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6515 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6516 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6517 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6518 " (mutiple extras passed as Integer[])",
6519 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6520 " (mutiple extras passed as List<Integer>)",
6521 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6522 " (mutiple extras passed as Long[])",
6523 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6524 " (mutiple extras passed as List<Long>)",
6525 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6526 " (mutiple extras passed as Float[])",
6527 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6528 " (mutiple extras passed as List<Float>)",
6529 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6530 " (mutiple extras passed as String[]; to embed a comma into a string,",
6531 " escape it using \"\\,\")",
6532 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6533 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6534 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006535 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006536 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6537 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6538 " [--debug-log-resolution] [--exclude-stopped-packages]",
6539 " [--include-stopped-packages]",
6540 " [--activity-brought-to-front] [--activity-clear-top]",
6541 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6542 " [--activity-launched-from-history] [--activity-multiple-task]",
6543 " [--activity-no-animation] [--activity-no-history]",
6544 " [--activity-no-user-action] [--activity-previous-is-top]",
6545 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6546 " [--activity-single-top] [--activity-clear-task]",
6547 " [--activity-task-on-home]",
6548 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006549 " [--receiver-foreground] [--receiver-no-abort]",
6550 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006551 " [--selector]",
6552 " [<URI> | <PACKAGE> | <COMPONENT>]"
6553 };
6554 for (String line : lines) {
6555 pw.print(prefix);
6556 pw.println(line);
6557 }
6558 }
6559
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006560 /**
6561 * Retrieve the general action to be performed, such as
6562 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6563 * the information in the intent should be interpreted -- most importantly,
6564 * what to do with the data returned by {@link #getData}.
6565 *
6566 * @return The action of this intent or null if none is specified.
6567 *
6568 * @see #setAction
6569 */
6570 public String getAction() {
6571 return mAction;
6572 }
6573
6574 /**
6575 * Retrieve data this intent is operating on. This URI specifies the name
6576 * of the data; often it uses the content: scheme, specifying data in a
6577 * content provider. Other schemes may be handled by specific activities,
6578 * such as http: by the web browser.
6579 *
6580 * @return The URI of the data this intent is targeting or null.
6581 *
6582 * @see #getScheme
6583 * @see #setData
6584 */
6585 public Uri getData() {
6586 return mData;
6587 }
6588
6589 /**
6590 * The same as {@link #getData()}, but returns the URI as an encoded
6591 * String.
6592 */
6593 public String getDataString() {
6594 return mData != null ? mData.toString() : null;
6595 }
6596
6597 /**
6598 * Return the scheme portion of the intent's data. If the data is null or
6599 * does not include a scheme, null is returned. Otherwise, the scheme
6600 * prefix without the final ':' is returned, i.e. "http".
6601 *
6602 * <p>This is the same as calling getData().getScheme() (and checking for
6603 * null data).
6604 *
6605 * @return The scheme of this intent.
6606 *
6607 * @see #getData
6608 */
6609 public String getScheme() {
6610 return mData != null ? mData.getScheme() : null;
6611 }
6612
6613 /**
6614 * Retrieve any explicit MIME type included in the intent. This is usually
6615 * null, as the type is determined by the intent data.
6616 *
6617 * @return If a type was manually set, it is returned; else null is
6618 * returned.
6619 *
6620 * @see #resolveType(ContentResolver)
6621 * @see #setType
6622 */
6623 public String getType() {
6624 return mType;
6625 }
6626
6627 /**
6628 * Return the MIME data type of this intent. If the type field is
6629 * explicitly set, that is simply returned. Otherwise, if the data is set,
6630 * the type of that data is returned. If neither fields are set, a null is
6631 * returned.
6632 *
6633 * @return The MIME type of this intent.
6634 *
6635 * @see #getType
6636 * @see #resolveType(ContentResolver)
6637 */
6638 public String resolveType(Context context) {
6639 return resolveType(context.getContentResolver());
6640 }
6641
6642 /**
6643 * Return the MIME data type of this intent. If the type field is
6644 * explicitly set, that is simply returned. Otherwise, if the data is set,
6645 * the type of that data is returned. If neither fields are set, a null is
6646 * returned.
6647 *
6648 * @param resolver A ContentResolver that can be used to determine the MIME
6649 * type of the intent's data.
6650 *
6651 * @return The MIME type of this intent.
6652 *
6653 * @see #getType
6654 * @see #resolveType(Context)
6655 */
6656 public String resolveType(ContentResolver resolver) {
6657 if (mType != null) {
6658 return mType;
6659 }
6660 if (mData != null) {
6661 if ("content".equals(mData.getScheme())) {
6662 return resolver.getType(mData);
6663 }
6664 }
6665 return null;
6666 }
6667
6668 /**
6669 * Return the MIME data type of this intent, only if it will be needed for
6670 * intent resolution. This is not generally useful for application code;
6671 * it is used by the frameworks for communicating with back-end system
6672 * services.
6673 *
6674 * @param resolver A ContentResolver that can be used to determine the MIME
6675 * type of the intent's data.
6676 *
6677 * @return The MIME type of this intent, or null if it is unknown or not
6678 * needed.
6679 */
6680 public String resolveTypeIfNeeded(ContentResolver resolver) {
6681 if (mComponent != null) {
6682 return mType;
6683 }
6684 return resolveType(resolver);
6685 }
6686
6687 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006688 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006689 *
6690 * @param category The category to check.
6691 *
6692 * @return boolean True if the intent contains the category, else false.
6693 *
6694 * @see #getCategories
6695 * @see #addCategory
6696 */
6697 public boolean hasCategory(String category) {
6698 return mCategories != null && mCategories.contains(category);
6699 }
6700
6701 /**
6702 * Return the set of all categories in the intent. If there are no categories,
6703 * returns NULL.
6704 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006705 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006706 *
6707 * @see #hasCategory
6708 * @see #addCategory
6709 */
6710 public Set<String> getCategories() {
6711 return mCategories;
6712 }
6713
6714 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006715 * Return the specific selector associated with this Intent. If there is
6716 * none, returns null. See {@link #setSelector} for more information.
6717 *
6718 * @see #setSelector
6719 */
6720 public Intent getSelector() {
6721 return mSelector;
6722 }
6723
6724 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006725 * Return the {@link ClipData} associated with this Intent. If there is
6726 * none, returns null. See {@link #setClipData} for more information.
6727 *
John Spurlock125d1332013-11-25 11:58:37 -05006728 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006729 */
6730 public ClipData getClipData() {
6731 return mClipData;
6732 }
6733
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006734 /** @hide */
6735 public int getContentUserHint() {
6736 return mContentUserHint;
6737 }
6738
Todd Kennedyb3b431302017-03-20 16:05:48 -07006739 /** @hide */
6740 public String getLaunchToken() {
6741 return mLaunchToken;
6742 }
6743
6744 /** @hide */
6745 public void setLaunchToken(String launchToken) {
6746 mLaunchToken = launchToken;
6747 }
6748
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006749 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006750 * Sets the ClassLoader that will be used when unmarshalling
6751 * any Parcelable values from the extras of this Intent.
6752 *
6753 * @param loader a ClassLoader, or null to use the default loader
6754 * at the time of unmarshalling.
6755 */
6756 public void setExtrasClassLoader(ClassLoader loader) {
6757 if (mExtras != null) {
6758 mExtras.setClassLoader(loader);
6759 }
6760 }
6761
6762 /**
6763 * Returns true if an extra value is associated with the given name.
6764 * @param name the extra's name
6765 * @return true if the given extra is present.
6766 */
6767 public boolean hasExtra(String name) {
6768 return mExtras != null && mExtras.containsKey(name);
6769 }
6770
6771 /**
6772 * Returns true if the Intent's extras contain a parcelled file descriptor.
6773 * @return true if the Intent contains a parcelled file descriptor.
6774 */
6775 public boolean hasFileDescriptors() {
6776 return mExtras != null && mExtras.hasFileDescriptors();
6777 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006778
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006779 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006780 public void setAllowFds(boolean allowFds) {
6781 if (mExtras != null) {
6782 mExtras.setAllowFds(allowFds);
6783 }
6784 }
6785
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006786 /** {@hide} */
6787 public void setDefusable(boolean defusable) {
6788 if (mExtras != null) {
6789 mExtras.setDefusable(defusable);
6790 }
6791 }
6792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 /**
6794 * Retrieve extended data from the intent.
6795 *
6796 * @param name The name of the desired item.
6797 *
6798 * @return the value of an item that previously added with putExtra()
6799 * or null if none was found.
6800 *
6801 * @deprecated
6802 * @hide
6803 */
6804 @Deprecated
6805 public Object getExtra(String name) {
6806 return getExtra(name, null);
6807 }
6808
6809 /**
6810 * Retrieve extended data from the intent.
6811 *
6812 * @param name The name of the desired item.
6813 * @param defaultValue the value to be returned if no value of the desired
6814 * type is stored with the given name.
6815 *
6816 * @return the value of an item that previously added with putExtra()
6817 * or the default value if none was found.
6818 *
6819 * @see #putExtra(String, boolean)
6820 */
6821 public boolean getBooleanExtra(String name, boolean defaultValue) {
6822 return mExtras == null ? defaultValue :
6823 mExtras.getBoolean(name, defaultValue);
6824 }
6825
6826 /**
6827 * Retrieve extended data from the intent.
6828 *
6829 * @param name The name of the desired item.
6830 * @param defaultValue the value to be returned if no value of the desired
6831 * type is stored with the given name.
6832 *
6833 * @return the value of an item that previously added with putExtra()
6834 * or the default value if none was found.
6835 *
6836 * @see #putExtra(String, byte)
6837 */
6838 public byte getByteExtra(String name, byte defaultValue) {
6839 return mExtras == null ? defaultValue :
6840 mExtras.getByte(name, defaultValue);
6841 }
6842
6843 /**
6844 * Retrieve extended data from the intent.
6845 *
6846 * @param name The name of the desired item.
6847 * @param defaultValue the value to be returned if no value of the desired
6848 * type is stored with the given name.
6849 *
6850 * @return the value of an item that previously added with putExtra()
6851 * or the default value if none was found.
6852 *
6853 * @see #putExtra(String, short)
6854 */
6855 public short getShortExtra(String name, short defaultValue) {
6856 return mExtras == null ? defaultValue :
6857 mExtras.getShort(name, defaultValue);
6858 }
6859
6860 /**
6861 * Retrieve extended data from the intent.
6862 *
6863 * @param name The name of the desired item.
6864 * @param defaultValue the value to be returned if no value of the desired
6865 * type is stored with the given name.
6866 *
6867 * @return the value of an item that previously added with putExtra()
6868 * or the default value if none was found.
6869 *
6870 * @see #putExtra(String, char)
6871 */
6872 public char getCharExtra(String name, char defaultValue) {
6873 return mExtras == null ? defaultValue :
6874 mExtras.getChar(name, defaultValue);
6875 }
6876
6877 /**
6878 * Retrieve extended data from the intent.
6879 *
6880 * @param name The name of the desired item.
6881 * @param defaultValue the value to be returned if no value of the desired
6882 * type is stored with the given name.
6883 *
6884 * @return the value of an item that previously added with putExtra()
6885 * or the default value if none was found.
6886 *
6887 * @see #putExtra(String, int)
6888 */
6889 public int getIntExtra(String name, int defaultValue) {
6890 return mExtras == null ? defaultValue :
6891 mExtras.getInt(name, defaultValue);
6892 }
6893
6894 /**
6895 * Retrieve extended data from the intent.
6896 *
6897 * @param name The name of the desired item.
6898 * @param defaultValue the value to be returned if no value of the desired
6899 * type is stored with the given name.
6900 *
6901 * @return the value of an item that previously added with putExtra()
6902 * or the default value if none was found.
6903 *
6904 * @see #putExtra(String, long)
6905 */
6906 public long getLongExtra(String name, long defaultValue) {
6907 return mExtras == null ? defaultValue :
6908 mExtras.getLong(name, defaultValue);
6909 }
6910
6911 /**
6912 * Retrieve extended data from the intent.
6913 *
6914 * @param name The name of the desired item.
6915 * @param defaultValue the value to be returned if no value of the desired
6916 * type is stored with the given name.
6917 *
6918 * @return the value of an item that previously added with putExtra(),
6919 * or the default value if no such item is present
6920 *
6921 * @see #putExtra(String, float)
6922 */
6923 public float getFloatExtra(String name, float defaultValue) {
6924 return mExtras == null ? defaultValue :
6925 mExtras.getFloat(name, defaultValue);
6926 }
6927
6928 /**
6929 * Retrieve extended data from the intent.
6930 *
6931 * @param name The name of the desired item.
6932 * @param defaultValue the value to be returned if no value of the desired
6933 * type is stored with the given name.
6934 *
6935 * @return the value of an item that previously added with putExtra()
6936 * or the default value if none was found.
6937 *
6938 * @see #putExtra(String, double)
6939 */
6940 public double getDoubleExtra(String name, double defaultValue) {
6941 return mExtras == null ? defaultValue :
6942 mExtras.getDouble(name, defaultValue);
6943 }
6944
6945 /**
6946 * Retrieve extended data from the intent.
6947 *
6948 * @param name The name of the desired item.
6949 *
6950 * @return the value of an item that previously added with putExtra()
6951 * or null if no String value was found.
6952 *
6953 * @see #putExtra(String, String)
6954 */
6955 public String getStringExtra(String name) {
6956 return mExtras == null ? null : mExtras.getString(name);
6957 }
6958
6959 /**
6960 * Retrieve extended data from the intent.
6961 *
6962 * @param name The name of the desired item.
6963 *
6964 * @return the value of an item that previously added with putExtra()
6965 * or null if no CharSequence value was found.
6966 *
6967 * @see #putExtra(String, CharSequence)
6968 */
6969 public CharSequence getCharSequenceExtra(String name) {
6970 return mExtras == null ? null : mExtras.getCharSequence(name);
6971 }
6972
6973 /**
6974 * Retrieve extended data from the intent.
6975 *
6976 * @param name The name of the desired item.
6977 *
6978 * @return the value of an item that previously added with putExtra()
6979 * or null if no Parcelable value was found.
6980 *
6981 * @see #putExtra(String, Parcelable)
6982 */
6983 public <T extends Parcelable> T getParcelableExtra(String name) {
6984 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6985 }
6986
6987 /**
6988 * Retrieve extended data from the intent.
6989 *
6990 * @param name The name of the desired item.
6991 *
6992 * @return the value of an item that previously added with putExtra()
6993 * or null if no Parcelable[] value was found.
6994 *
6995 * @see #putExtra(String, Parcelable[])
6996 */
6997 public Parcelable[] getParcelableArrayExtra(String name) {
6998 return mExtras == null ? null : mExtras.getParcelableArray(name);
6999 }
7000
7001 /**
7002 * Retrieve extended data from the intent.
7003 *
7004 * @param name The name of the desired item.
7005 *
7006 * @return the value of an item that previously added with putExtra()
7007 * or null if no ArrayList<Parcelable> value was found.
7008 *
7009 * @see #putParcelableArrayListExtra(String, ArrayList)
7010 */
7011 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7012 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7013 }
7014
7015 /**
7016 * Retrieve extended data from the intent.
7017 *
7018 * @param name The name of the desired item.
7019 *
7020 * @return the value of an item that previously added with putExtra()
7021 * or null if no Serializable value was found.
7022 *
7023 * @see #putExtra(String, Serializable)
7024 */
7025 public Serializable getSerializableExtra(String name) {
7026 return mExtras == null ? null : mExtras.getSerializable(name);
7027 }
7028
7029 /**
7030 * Retrieve extended data from the intent.
7031 *
7032 * @param name The name of the desired item.
7033 *
7034 * @return the value of an item that previously added with putExtra()
7035 * or null if no ArrayList<Integer> value was found.
7036 *
7037 * @see #putIntegerArrayListExtra(String, ArrayList)
7038 */
7039 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7040 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7041 }
7042
7043 /**
7044 * Retrieve extended data from the intent.
7045 *
7046 * @param name The name of the desired item.
7047 *
7048 * @return the value of an item that previously added with putExtra()
7049 * or null if no ArrayList<String> value was found.
7050 *
7051 * @see #putStringArrayListExtra(String, ArrayList)
7052 */
7053 public ArrayList<String> getStringArrayListExtra(String name) {
7054 return mExtras == null ? null : mExtras.getStringArrayList(name);
7055 }
7056
7057 /**
7058 * Retrieve extended data from the intent.
7059 *
7060 * @param name The name of the desired item.
7061 *
7062 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007063 * or null if no ArrayList<CharSequence> value was found.
7064 *
7065 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7066 */
7067 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7068 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7069 }
7070
7071 /**
7072 * Retrieve extended data from the intent.
7073 *
7074 * @param name The name of the desired item.
7075 *
7076 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007077 * or null if no boolean array value was found.
7078 *
7079 * @see #putExtra(String, boolean[])
7080 */
7081 public boolean[] getBooleanArrayExtra(String name) {
7082 return mExtras == null ? null : mExtras.getBooleanArray(name);
7083 }
7084
7085 /**
7086 * Retrieve extended data from the intent.
7087 *
7088 * @param name The name of the desired item.
7089 *
7090 * @return the value of an item that previously added with putExtra()
7091 * or null if no byte array value was found.
7092 *
7093 * @see #putExtra(String, byte[])
7094 */
7095 public byte[] getByteArrayExtra(String name) {
7096 return mExtras == null ? null : mExtras.getByteArray(name);
7097 }
7098
7099 /**
7100 * Retrieve extended data from the intent.
7101 *
7102 * @param name The name of the desired item.
7103 *
7104 * @return the value of an item that previously added with putExtra()
7105 * or null if no short array value was found.
7106 *
7107 * @see #putExtra(String, short[])
7108 */
7109 public short[] getShortArrayExtra(String name) {
7110 return mExtras == null ? null : mExtras.getShortArray(name);
7111 }
7112
7113 /**
7114 * Retrieve extended data from the intent.
7115 *
7116 * @param name The name of the desired item.
7117 *
7118 * @return the value of an item that previously added with putExtra()
7119 * or null if no char array value was found.
7120 *
7121 * @see #putExtra(String, char[])
7122 */
7123 public char[] getCharArrayExtra(String name) {
7124 return mExtras == null ? null : mExtras.getCharArray(name);
7125 }
7126
7127 /**
7128 * Retrieve extended data from the intent.
7129 *
7130 * @param name The name of the desired item.
7131 *
7132 * @return the value of an item that previously added with putExtra()
7133 * or null if no int array value was found.
7134 *
7135 * @see #putExtra(String, int[])
7136 */
7137 public int[] getIntArrayExtra(String name) {
7138 return mExtras == null ? null : mExtras.getIntArray(name);
7139 }
7140
7141 /**
7142 * Retrieve extended data from the intent.
7143 *
7144 * @param name The name of the desired item.
7145 *
7146 * @return the value of an item that previously added with putExtra()
7147 * or null if no long array value was found.
7148 *
7149 * @see #putExtra(String, long[])
7150 */
7151 public long[] getLongArrayExtra(String name) {
7152 return mExtras == null ? null : mExtras.getLongArray(name);
7153 }
7154
7155 /**
7156 * Retrieve extended data from the intent.
7157 *
7158 * @param name The name of the desired item.
7159 *
7160 * @return the value of an item that previously added with putExtra()
7161 * or null if no float array value was found.
7162 *
7163 * @see #putExtra(String, float[])
7164 */
7165 public float[] getFloatArrayExtra(String name) {
7166 return mExtras == null ? null : mExtras.getFloatArray(name);
7167 }
7168
7169 /**
7170 * Retrieve extended data from the intent.
7171 *
7172 * @param name The name of the desired item.
7173 *
7174 * @return the value of an item that previously added with putExtra()
7175 * or null if no double array value was found.
7176 *
7177 * @see #putExtra(String, double[])
7178 */
7179 public double[] getDoubleArrayExtra(String name) {
7180 return mExtras == null ? null : mExtras.getDoubleArray(name);
7181 }
7182
7183 /**
7184 * Retrieve extended data from the intent.
7185 *
7186 * @param name The name of the desired item.
7187 *
7188 * @return the value of an item that previously added with putExtra()
7189 * or null if no String array value was found.
7190 *
7191 * @see #putExtra(String, String[])
7192 */
7193 public String[] getStringArrayExtra(String name) {
7194 return mExtras == null ? null : mExtras.getStringArray(name);
7195 }
7196
7197 /**
7198 * Retrieve extended data from the intent.
7199 *
7200 * @param name The name of the desired item.
7201 *
7202 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007203 * or null if no CharSequence array value was found.
7204 *
7205 * @see #putExtra(String, CharSequence[])
7206 */
7207 public CharSequence[] getCharSequenceArrayExtra(String name) {
7208 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7209 }
7210
7211 /**
7212 * Retrieve extended data from the intent.
7213 *
7214 * @param name The name of the desired item.
7215 *
7216 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007217 * or null if no Bundle value was found.
7218 *
7219 * @see #putExtra(String, Bundle)
7220 */
7221 public Bundle getBundleExtra(String name) {
7222 return mExtras == null ? null : mExtras.getBundle(name);
7223 }
7224
7225 /**
7226 * Retrieve extended data from the intent.
7227 *
7228 * @param name The name of the desired item.
7229 *
7230 * @return the value of an item that previously added with putExtra()
7231 * or null if no IBinder value was found.
7232 *
7233 * @see #putExtra(String, IBinder)
7234 *
7235 * @deprecated
7236 * @hide
7237 */
7238 @Deprecated
7239 public IBinder getIBinderExtra(String name) {
7240 return mExtras == null ? null : mExtras.getIBinder(name);
7241 }
7242
7243 /**
7244 * Retrieve extended data from the intent.
7245 *
7246 * @param name The name of the desired item.
7247 * @param defaultValue The default value to return in case no item is
7248 * associated with the key 'name'
7249 *
7250 * @return the value of an item that previously added with putExtra()
7251 * or defaultValue if none was found.
7252 *
7253 * @see #putExtra
7254 *
7255 * @deprecated
7256 * @hide
7257 */
7258 @Deprecated
7259 public Object getExtra(String name, Object defaultValue) {
7260 Object result = defaultValue;
7261 if (mExtras != null) {
7262 Object result2 = mExtras.get(name);
7263 if (result2 != null) {
7264 result = result2;
7265 }
7266 }
7267
7268 return result;
7269 }
7270
7271 /**
7272 * Retrieves a map of extended data from the intent.
7273 *
7274 * @return the map of all extras previously added with putExtra(),
7275 * or null if none have been added.
7276 */
7277 public Bundle getExtras() {
7278 return (mExtras != null)
7279 ? new Bundle(mExtras)
7280 : null;
7281 }
7282
7283 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007284 * Filter extras to only basic types.
7285 * @hide
7286 */
7287 public void removeUnsafeExtras() {
7288 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007289 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007290 }
7291 }
7292
7293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007294 * Retrieve any special flags associated with this intent. You will
7295 * normally just set them with {@link #setFlags} and let the system
7296 * take the appropriate action with them.
7297 *
7298 * @return int The currently set flags.
7299 *
7300 * @see #setFlags
7301 */
7302 public int getFlags() {
7303 return mFlags;
7304 }
7305
Dianne Hackborne7f97212011-02-24 14:40:20 -08007306 /** @hide */
7307 public boolean isExcludingStopped() {
7308 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7309 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7310 }
7311
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007312 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007313 * Retrieve the application package name this Intent is limited to. When
7314 * resolving an Intent, if non-null this limits the resolution to only
7315 * components in the given application package.
7316 *
7317 * @return The name of the application package for the Intent.
7318 *
7319 * @see #resolveActivity
7320 * @see #setPackage
7321 */
7322 public String getPackage() {
7323 return mPackage;
7324 }
7325
7326 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007327 * Retrieve the concrete component associated with the intent. When receiving
7328 * an intent, this is the component that was found to best handle it (that is,
7329 * yourself) and will always be non-null; in all other cases it will be
7330 * null unless explicitly set.
7331 *
7332 * @return The name of the application component to handle the intent.
7333 *
7334 * @see #resolveActivity
7335 * @see #setComponent
7336 */
7337 public ComponentName getComponent() {
7338 return mComponent;
7339 }
7340
7341 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007342 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7343 * used as a hint to the receiver for animations and the like. Null means that there
7344 * is no source bounds.
7345 */
7346 public Rect getSourceBounds() {
7347 return mSourceBounds;
7348 }
7349
7350 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007351 * Return the Activity component that should be used to handle this intent.
7352 * The appropriate component is determined based on the information in the
7353 * intent, evaluated as follows:
7354 *
7355 * <p>If {@link #getComponent} returns an explicit class, that is returned
7356 * without any further consideration.
7357 *
7358 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7359 * category to be considered.
7360 *
7361 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7362 * action.
7363 *
7364 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7365 * this type.
7366 *
7367 * <p>If {@link #addCategory} has added any categories, the activity must
7368 * handle ALL of the categories specified.
7369 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007370 * <p>If {@link #getPackage} is non-NULL, only activity components in
7371 * that application package will be considered.
7372 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007373 * <p>If there are no activities that satisfy all of these conditions, a
7374 * null string is returned.
7375 *
7376 * <p>If multiple activities are found to satisfy the intent, the one with
7377 * the highest priority will be used. If there are multiple activities
7378 * with the same priority, the system will either pick the best activity
7379 * based on user preference, or resolve to a system class that will allow
7380 * the user to pick an activity and forward from there.
7381 *
7382 * <p>This method is implemented simply by calling
7383 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7384 * true.</p>
7385 * <p> This API is called for you as part of starting an activity from an
7386 * intent. You do not normally need to call it yourself.</p>
7387 *
7388 * @param pm The package manager with which to resolve the Intent.
7389 *
7390 * @return Name of the component implementing an activity that can
7391 * display the intent.
7392 *
7393 * @see #setComponent
7394 * @see #getComponent
7395 * @see #resolveActivityInfo
7396 */
7397 public ComponentName resolveActivity(PackageManager pm) {
7398 if (mComponent != null) {
7399 return mComponent;
7400 }
7401
7402 ResolveInfo info = pm.resolveActivity(
7403 this, PackageManager.MATCH_DEFAULT_ONLY);
7404 if (info != null) {
7405 return new ComponentName(
7406 info.activityInfo.applicationInfo.packageName,
7407 info.activityInfo.name);
7408 }
7409
7410 return null;
7411 }
7412
7413 /**
7414 * Resolve the Intent into an {@link ActivityInfo}
7415 * describing the activity that should execute the intent. Resolution
7416 * follows the same rules as described for {@link #resolveActivity}, but
7417 * you get back the completely information about the resolved activity
7418 * instead of just its class name.
7419 *
7420 * @param pm The package manager with which to resolve the Intent.
7421 * @param flags Addition information to retrieve as per
7422 * {@link PackageManager#getActivityInfo(ComponentName, int)
7423 * PackageManager.getActivityInfo()}.
7424 *
7425 * @return PackageManager.ActivityInfo
7426 *
7427 * @see #resolveActivity
7428 */
7429 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7430 ActivityInfo ai = null;
7431 if (mComponent != null) {
7432 try {
7433 ai = pm.getActivityInfo(mComponent, flags);
7434 } catch (PackageManager.NameNotFoundException e) {
7435 // ignore
7436 }
7437 } else {
7438 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007439 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007440 if (info != null) {
7441 ai = info.activityInfo;
7442 }
7443 }
7444
7445 return ai;
7446 }
7447
7448 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007449 * Special function for use by the system to resolve service
7450 * intents to system apps. Throws an exception if there are
7451 * multiple potential matches to the Intent. Returns null if
7452 * there are no matches.
7453 * @hide
7454 */
7455 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7456 if (mComponent != null) {
7457 return mComponent;
7458 }
7459
7460 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7461 if (results == null) {
7462 return null;
7463 }
7464 ComponentName comp = null;
7465 for (int i=0; i<results.size(); i++) {
7466 ResolveInfo ri = results.get(i);
7467 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7468 continue;
7469 }
7470 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7471 ri.serviceInfo.name);
7472 if (comp != null) {
7473 throw new IllegalStateException("Multiple system services handle " + this
7474 + ": " + comp + ", " + foundComp);
7475 }
7476 comp = foundComp;
7477 }
7478 return comp;
7479 }
7480
7481 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007482 * Set the general action to be performed.
7483 *
7484 * @param action An action name, such as ACTION_VIEW. Application-specific
7485 * actions should be prefixed with the vendor's package name.
7486 *
7487 * @return Returns the same Intent object, for chaining multiple calls
7488 * into a single statement.
7489 *
7490 * @see #getAction
7491 */
7492 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007493 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007494 return this;
7495 }
7496
7497 /**
7498 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007499 * clears any type that was previously set by {@link #setType} or
7500 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007501 *
Nick Pellyccae4122012-01-09 14:12:58 -08007502 * <p><em>Note: scheme matching in the Android framework is
7503 * case-sensitive, unlike the formal RFC. As a result,
7504 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007505 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007506 * {@link #setDataAndNormalize}
7507 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007508 *
Nick Pellyccae4122012-01-09 14:12:58 -08007509 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007510 *
7511 * @return Returns the same Intent object, for chaining multiple calls
7512 * into a single statement.
7513 *
7514 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007515 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007516 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007517 */
7518 public Intent setData(Uri data) {
7519 mData = data;
7520 mType = null;
7521 return this;
7522 }
7523
7524 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007525 * Normalize and set the data this intent is operating on.
7526 *
7527 * <p>This method automatically clears any type that was
7528 * previously set (for example, by {@link #setType}).
7529 *
7530 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007531 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007532 * so really this is just a convenience method for
7533 * <pre>
7534 * setData(data.normalize())
7535 * </pre>
7536 *
7537 * @param data The Uri of the data this intent is now targeting.
7538 *
7539 * @return Returns the same Intent object, for chaining multiple calls
7540 * into a single statement.
7541 *
7542 * @see #getData
7543 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007544 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007545 */
7546 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007547 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007548 }
7549
7550 /**
7551 * Set an explicit MIME data type.
7552 *
7553 * <p>This is used to create intents that only specify a type and not data,
7554 * for example to indicate the type of data to return.
7555 *
7556 * <p>This method automatically clears any data that was
7557 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007558 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007559 * <p><em>Note: MIME type matching in the Android framework is
7560 * case-sensitive, unlike formal RFC MIME types. As a result,
7561 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007562 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7563 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007564 *
7565 * @param type The MIME type of the data being handled by this intent.
7566 *
7567 * @return Returns the same Intent object, for chaining multiple calls
7568 * into a single statement.
7569 *
7570 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007571 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007572 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007573 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007574 */
7575 public Intent setType(String type) {
7576 mData = null;
7577 mType = type;
7578 return this;
7579 }
7580
7581 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007582 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007583 *
Nick Pellyccae4122012-01-09 14:12:58 -08007584 * <p>This is used to create intents that only specify a type and not data,
7585 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007586 *
Nick Pellyccae4122012-01-09 14:12:58 -08007587 * <p>This method automatically clears any data that was
7588 * previously set (for example by {@link #setData}).
7589 *
7590 * <p>The MIME type is normalized using
7591 * {@link #normalizeMimeType} before it is set,
7592 * so really this is just a convenience method for
7593 * <pre>
7594 * setType(Intent.normalizeMimeType(type))
7595 * </pre>
7596 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007597 * @param type The MIME type of the data being handled by this intent.
7598 *
7599 * @return Returns the same Intent object, for chaining multiple calls
7600 * into a single statement.
7601 *
Nick Pellyccae4122012-01-09 14:12:58 -08007602 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007603 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007604 * @see #normalizeMimeType
7605 */
7606 public Intent setTypeAndNormalize(String type) {
7607 return setType(normalizeMimeType(type));
7608 }
7609
7610 /**
7611 * (Usually optional) Set the data for the intent along with an explicit
7612 * MIME data type. This method should very rarely be used -- it allows you
7613 * to override the MIME type that would ordinarily be inferred from the
7614 * data with your own type given here.
7615 *
7616 * <p><em>Note: MIME type and Uri scheme matching in the
7617 * Android framework is case-sensitive, unlike the formal RFC definitions.
7618 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007619 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007620 * {@link #setDataAndTypeAndNormalize}
7621 * to ensure that they are converted to lower case.</em>
7622 *
7623 * @param data The Uri of the data this intent is now targeting.
7624 * @param type The MIME type of the data being handled by this intent.
7625 *
7626 * @return Returns the same Intent object, for chaining multiple calls
7627 * into a single statement.
7628 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007629 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007630 * @see #setData
7631 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007632 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007633 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007634 */
7635 public Intent setDataAndType(Uri data, String type) {
7636 mData = data;
7637 mType = type;
7638 return this;
7639 }
7640
7641 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007642 * (Usually optional) Normalize and set both the data Uri and an explicit
7643 * MIME data type. This method should very rarely be used -- it allows you
7644 * to override the MIME type that would ordinarily be inferred from the
7645 * data with your own type given here.
7646 *
7647 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007648 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007649 * before they are set, so really this is just a convenience method for
7650 * <pre>
7651 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7652 * </pre>
7653 *
7654 * @param data The Uri of the data this intent is now targeting.
7655 * @param type The MIME type of the data being handled by this intent.
7656 *
7657 * @return Returns the same Intent object, for chaining multiple calls
7658 * into a single statement.
7659 *
7660 * @see #setType
7661 * @see #setData
7662 * @see #setDataAndType
7663 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007664 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007665 */
7666 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007667 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007668 }
7669
7670 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007671 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007672 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007673 * activities that provide <em>all</em> of the requested categories will be
7674 * used.
7675 *
7676 * @param category The desired category. This can be either one of the
7677 * predefined Intent categories, or a custom category in your own
7678 * namespace.
7679 *
7680 * @return Returns the same Intent object, for chaining multiple calls
7681 * into a single statement.
7682 *
7683 * @see #hasCategory
7684 * @see #removeCategory
7685 */
7686 public Intent addCategory(String category) {
7687 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007688 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007689 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007690 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007691 return this;
7692 }
7693
7694 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007695 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007696 *
7697 * @param category The category to remove.
7698 *
7699 * @see #addCategory
7700 */
7701 public void removeCategory(String category) {
7702 if (mCategories != null) {
7703 mCategories.remove(category);
7704 if (mCategories.size() == 0) {
7705 mCategories = null;
7706 }
7707 }
7708 }
7709
7710 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007711 * Set a selector for this Intent. This is a modification to the kinds of
7712 * things the Intent will match. If the selector is set, it will be used
7713 * when trying to find entities that can handle the Intent, instead of the
7714 * main contents of the Intent. This allows you build an Intent containing
7715 * a generic protocol while targeting it more specifically.
7716 *
7717 * <p>An example of where this may be used is with things like
7718 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7719 * Intent that will launch the Browser application. However, the correct
7720 * main entry point of an application is actually {@link #ACTION_MAIN}
7721 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7722 * used to specify the actual Activity to launch. If you launch the browser
7723 * with something different, undesired behavior may happen if the user has
7724 * previously or later launches it the normal way, since they do not match.
7725 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7726 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7727 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7728 *
7729 * <p>Setting a selector does not impact the behavior of
7730 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7731 * desired behavior of a selector -- it does not impact the base meaning
7732 * of the Intent, just what kinds of things will be matched against it
7733 * when determining who can handle it.</p>
7734 *
7735 * <p>You can not use both a selector and {@link #setPackage(String)} on
7736 * the same base Intent.</p>
7737 *
7738 * @param selector The desired selector Intent; set to null to not use
7739 * a special selector.
7740 */
7741 public void setSelector(Intent selector) {
7742 if (selector == this) {
7743 throw new IllegalArgumentException(
7744 "Intent being set as a selector of itself");
7745 }
7746 if (selector != null && mPackage != null) {
7747 throw new IllegalArgumentException(
7748 "Can't set selector when package name is already set");
7749 }
7750 mSelector = selector;
7751 }
7752
7753 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007754 * Set a {@link ClipData} associated with this Intent. This replaces any
7755 * previously set ClipData.
7756 *
7757 * <p>The ClipData in an intent is not used for Intent matching or other
7758 * such operations. Semantically it is like extras, used to transmit
7759 * additional data with the Intent. The main feature of using this over
7760 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7761 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7762 * items included in the clip data. This is useful, in particular, if
7763 * you want to transmit an Intent containing multiple <code>content:</code>
7764 * URIs for which the recipient may not have global permission to access the
7765 * content provider.
7766 *
7767 * <p>If the ClipData contains items that are themselves Intents, any
7768 * grant flags in those Intents will be ignored. Only the top-level flags
7769 * of the main Intent are respected, and will be applied to all Uri or
7770 * Intent items in the clip (or sub-items of the clip).
7771 *
7772 * <p>The MIME type, label, and icon in the ClipData object are not
7773 * directly used by Intent. Applications should generally rely on the
7774 * MIME type of the Intent itself, not what it may find in the ClipData.
7775 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007776 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007777 *
7778 * @param clip The new clip to set. May be null to clear the current clip.
7779 */
7780 public void setClipData(ClipData clip) {
7781 mClipData = clip;
7782 }
7783
7784 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007785 * This is NOT a secure mechanism to identify the user who sent the intent.
7786 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7787 * who sent the intent.
7788 * @hide
7789 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007790 public void prepareToLeaveUser(int userId) {
7791 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7792 // We want mContentUserHint to refer to the original user, so don't do anything.
7793 if (mContentUserHint == UserHandle.USER_CURRENT) {
7794 mContentUserHint = userId;
7795 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007796 }
7797
7798 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007799 * Add extended data to the intent. The name must include a package
7800 * prefix, for example the app com.android.contacts would use names
7801 * like "com.android.contacts.ShowAll".
7802 *
7803 * @param name The name of the extra data, with package prefix.
7804 * @param value The boolean data value.
7805 *
7806 * @return Returns the same Intent object, for chaining multiple calls
7807 * into a single statement.
7808 *
7809 * @see #putExtras
7810 * @see #removeExtra
7811 * @see #getBooleanExtra(String, boolean)
7812 */
7813 public Intent putExtra(String name, boolean value) {
7814 if (mExtras == null) {
7815 mExtras = new Bundle();
7816 }
7817 mExtras.putBoolean(name, value);
7818 return this;
7819 }
7820
7821 /**
7822 * Add extended data to the intent. The name must include a package
7823 * prefix, for example the app com.android.contacts would use names
7824 * like "com.android.contacts.ShowAll".
7825 *
7826 * @param name The name of the extra data, with package prefix.
7827 * @param value The byte data value.
7828 *
7829 * @return Returns the same Intent object, for chaining multiple calls
7830 * into a single statement.
7831 *
7832 * @see #putExtras
7833 * @see #removeExtra
7834 * @see #getByteExtra(String, byte)
7835 */
7836 public Intent putExtra(String name, byte value) {
7837 if (mExtras == null) {
7838 mExtras = new Bundle();
7839 }
7840 mExtras.putByte(name, value);
7841 return this;
7842 }
7843
7844 /**
7845 * Add extended data to the intent. The name must include a package
7846 * prefix, for example the app com.android.contacts would use names
7847 * like "com.android.contacts.ShowAll".
7848 *
7849 * @param name The name of the extra data, with package prefix.
7850 * @param value The char data value.
7851 *
7852 * @return Returns the same Intent object, for chaining multiple calls
7853 * into a single statement.
7854 *
7855 * @see #putExtras
7856 * @see #removeExtra
7857 * @see #getCharExtra(String, char)
7858 */
7859 public Intent putExtra(String name, char value) {
7860 if (mExtras == null) {
7861 mExtras = new Bundle();
7862 }
7863 mExtras.putChar(name, value);
7864 return this;
7865 }
7866
7867 /**
7868 * Add extended data to the intent. The name must include a package
7869 * prefix, for example the app com.android.contacts would use names
7870 * like "com.android.contacts.ShowAll".
7871 *
7872 * @param name The name of the extra data, with package prefix.
7873 * @param value The short data value.
7874 *
7875 * @return Returns the same Intent object, for chaining multiple calls
7876 * into a single statement.
7877 *
7878 * @see #putExtras
7879 * @see #removeExtra
7880 * @see #getShortExtra(String, short)
7881 */
7882 public Intent putExtra(String name, short value) {
7883 if (mExtras == null) {
7884 mExtras = new Bundle();
7885 }
7886 mExtras.putShort(name, value);
7887 return this;
7888 }
7889
7890 /**
7891 * Add extended data to the intent. The name must include a package
7892 * prefix, for example the app com.android.contacts would use names
7893 * like "com.android.contacts.ShowAll".
7894 *
7895 * @param name The name of the extra data, with package prefix.
7896 * @param value The integer data value.
7897 *
7898 * @return Returns the same Intent object, for chaining multiple calls
7899 * into a single statement.
7900 *
7901 * @see #putExtras
7902 * @see #removeExtra
7903 * @see #getIntExtra(String, int)
7904 */
7905 public Intent putExtra(String name, int value) {
7906 if (mExtras == null) {
7907 mExtras = new Bundle();
7908 }
7909 mExtras.putInt(name, value);
7910 return this;
7911 }
7912
7913 /**
7914 * Add extended data to the intent. The name must include a package
7915 * prefix, for example the app com.android.contacts would use names
7916 * like "com.android.contacts.ShowAll".
7917 *
7918 * @param name The name of the extra data, with package prefix.
7919 * @param value The long data value.
7920 *
7921 * @return Returns the same Intent object, for chaining multiple calls
7922 * into a single statement.
7923 *
7924 * @see #putExtras
7925 * @see #removeExtra
7926 * @see #getLongExtra(String, long)
7927 */
7928 public Intent putExtra(String name, long value) {
7929 if (mExtras == null) {
7930 mExtras = new Bundle();
7931 }
7932 mExtras.putLong(name, value);
7933 return this;
7934 }
7935
7936 /**
7937 * Add extended data to the intent. The name must include a package
7938 * prefix, for example the app com.android.contacts would use names
7939 * like "com.android.contacts.ShowAll".
7940 *
7941 * @param name The name of the extra data, with package prefix.
7942 * @param value The float data value.
7943 *
7944 * @return Returns the same Intent object, for chaining multiple calls
7945 * into a single statement.
7946 *
7947 * @see #putExtras
7948 * @see #removeExtra
7949 * @see #getFloatExtra(String, float)
7950 */
7951 public Intent putExtra(String name, float value) {
7952 if (mExtras == null) {
7953 mExtras = new Bundle();
7954 }
7955 mExtras.putFloat(name, value);
7956 return this;
7957 }
7958
7959 /**
7960 * 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 double 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 #getDoubleExtra(String, double)
7973 */
7974 public Intent putExtra(String name, double value) {
7975 if (mExtras == null) {
7976 mExtras = new Bundle();
7977 }
7978 mExtras.putDouble(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 String 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 #getStringExtra(String)
7996 */
7997 public Intent putExtra(String name, String value) {
7998 if (mExtras == null) {
7999 mExtras = new Bundle();
8000 }
8001 mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
8019 */
8020 public Intent putExtra(String name, CharSequence value) {
8021 if (mExtras == null) {
8022 mExtras = new Bundle();
8023 }
8024 mExtras.putCharSequence(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 Parcelable 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 #getParcelableExtra(String)
8042 */
8043 public Intent putExtra(String name, Parcelable value) {
8044 if (mExtras == null) {
8045 mExtras = new Bundle();
8046 }
8047 mExtras.putParcelable(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 Parcelable[] 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 #getParcelableArrayExtra(String)
8065 */
8066 public Intent putExtra(String name, Parcelable[] value) {
8067 if (mExtras == null) {
8068 mExtras = new Bundle();
8069 }
8070 mExtras.putParcelableArray(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 ArrayList<Parcelable> 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 #getParcelableArrayListExtra(String)
8088 */
8089 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
8090 if (mExtras == null) {
8091 mExtras = new Bundle();
8092 }
8093 mExtras.putParcelableArrayList(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 ArrayList<Integer> 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 #getIntegerArrayListExtra(String)
8111 */
8112 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
8113 if (mExtras == null) {
8114 mExtras = new Bundle();
8115 }
8116 mExtras.putIntegerArrayList(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 ArrayList<String> 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 #getStringArrayListExtra(String)
8134 */
8135 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
8136 if (mExtras == null) {
8137 mExtras = new Bundle();
8138 }
8139 mExtras.putStringArrayList(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.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008149 * @param value The ArrayList<CharSequence> 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 #getCharSequenceArrayListExtra(String)
8157 */
8158 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
8159 if (mExtras == null) {
8160 mExtras = new Bundle();
8161 }
8162 mExtras.putCharSequenceArrayList(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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008172 * @param value The Serializable 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 #getSerializableExtra(String)
8180 */
8181 public Intent putExtra(String name, Serializable value) {
8182 if (mExtras == null) {
8183 mExtras = new Bundle();
8184 }
8185 mExtras.putSerializable(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 boolean array 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 #getBooleanArrayExtra(String)
8203 */
8204 public Intent putExtra(String name, boolean[] value) {
8205 if (mExtras == null) {
8206 mExtras = new Bundle();
8207 }
8208 mExtras.putBooleanArray(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 byte array 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 #getByteArrayExtra(String)
8226 */
8227 public Intent putExtra(String name, byte[] value) {
8228 if (mExtras == null) {
8229 mExtras = new Bundle();
8230 }
8231 mExtras.putByteArray(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 short array 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 #getShortArrayExtra(String)
8249 */
8250 public Intent putExtra(String name, short[] value) {
8251 if (mExtras == null) {
8252 mExtras = new Bundle();
8253 }
8254 mExtras.putShortArray(name, value);
8255 return this;
8256 }
8257
8258 /**
8259 * Add extended data to the intent. The name must include a package
8260 * prefix, for example the app com.android.contacts would use names
8261 * like "com.android.contacts.ShowAll".
8262 *
8263 * @param name The name of the extra data, with package prefix.
8264 * @param value The char array data value.
8265 *
8266 * @return Returns the same Intent object, for chaining multiple calls
8267 * into a single statement.
8268 *
8269 * @see #putExtras
8270 * @see #removeExtra
8271 * @see #getCharArrayExtra(String)
8272 */
8273 public Intent putExtra(String name, char[] value) {
8274 if (mExtras == null) {
8275 mExtras = new Bundle();
8276 }
8277 mExtras.putCharArray(name, value);
8278 return this;
8279 }
8280
8281 /**
8282 * Add extended data to the intent. The name must include a package
8283 * prefix, for example the app com.android.contacts would use names
8284 * like "com.android.contacts.ShowAll".
8285 *
8286 * @param name The name of the extra data, with package prefix.
8287 * @param value The int array data value.
8288 *
8289 * @return Returns the same Intent object, for chaining multiple calls
8290 * into a single statement.
8291 *
8292 * @see #putExtras
8293 * @see #removeExtra
8294 * @see #getIntArrayExtra(String)
8295 */
8296 public Intent putExtra(String name, int[] value) {
8297 if (mExtras == null) {
8298 mExtras = new Bundle();
8299 }
8300 mExtras.putIntArray(name, value);
8301 return this;
8302 }
8303
8304 /**
8305 * Add extended data to the intent. The name must include a package
8306 * prefix, for example the app com.android.contacts would use names
8307 * like "com.android.contacts.ShowAll".
8308 *
8309 * @param name The name of the extra data, with package prefix.
8310 * @param value The byte array data value.
8311 *
8312 * @return Returns the same Intent object, for chaining multiple calls
8313 * into a single statement.
8314 *
8315 * @see #putExtras
8316 * @see #removeExtra
8317 * @see #getLongArrayExtra(String)
8318 */
8319 public Intent putExtra(String name, long[] value) {
8320 if (mExtras == null) {
8321 mExtras = new Bundle();
8322 }
8323 mExtras.putLongArray(name, value);
8324 return this;
8325 }
8326
8327 /**
8328 * Add extended data to the intent. The name must include a package
8329 * prefix, for example the app com.android.contacts would use names
8330 * like "com.android.contacts.ShowAll".
8331 *
8332 * @param name The name of the extra data, with package prefix.
8333 * @param value The float array data value.
8334 *
8335 * @return Returns the same Intent object, for chaining multiple calls
8336 * into a single statement.
8337 *
8338 * @see #putExtras
8339 * @see #removeExtra
8340 * @see #getFloatArrayExtra(String)
8341 */
8342 public Intent putExtra(String name, float[] value) {
8343 if (mExtras == null) {
8344 mExtras = new Bundle();
8345 }
8346 mExtras.putFloatArray(name, value);
8347 return this;
8348 }
8349
8350 /**
8351 * Add extended data to the intent. The name must include a package
8352 * prefix, for example the app com.android.contacts would use names
8353 * like "com.android.contacts.ShowAll".
8354 *
8355 * @param name The name of the extra data, with package prefix.
8356 * @param value The double array data value.
8357 *
8358 * @return Returns the same Intent object, for chaining multiple calls
8359 * into a single statement.
8360 *
8361 * @see #putExtras
8362 * @see #removeExtra
8363 * @see #getDoubleArrayExtra(String)
8364 */
8365 public Intent putExtra(String name, double[] value) {
8366 if (mExtras == null) {
8367 mExtras = new Bundle();
8368 }
8369 mExtras.putDoubleArray(name, value);
8370 return this;
8371 }
8372
8373 /**
8374 * Add extended data to the intent. The name must include a package
8375 * prefix, for example the app com.android.contacts would use names
8376 * like "com.android.contacts.ShowAll".
8377 *
8378 * @param name The name of the extra data, with package prefix.
8379 * @param value The String array data value.
8380 *
8381 * @return Returns the same Intent object, for chaining multiple calls
8382 * into a single statement.
8383 *
8384 * @see #putExtras
8385 * @see #removeExtra
8386 * @see #getStringArrayExtra(String)
8387 */
8388 public Intent putExtra(String name, String[] value) {
8389 if (mExtras == null) {
8390 mExtras = new Bundle();
8391 }
8392 mExtras.putStringArray(name, value);
8393 return this;
8394 }
8395
8396 /**
8397 * Add extended data to the intent. The name must include a package
8398 * prefix, for example the app com.android.contacts would use names
8399 * like "com.android.contacts.ShowAll".
8400 *
8401 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008402 * @param value The CharSequence array data value.
8403 *
8404 * @return Returns the same Intent object, for chaining multiple calls
8405 * into a single statement.
8406 *
8407 * @see #putExtras
8408 * @see #removeExtra
8409 * @see #getCharSequenceArrayExtra(String)
8410 */
8411 public Intent putExtra(String name, CharSequence[] value) {
8412 if (mExtras == null) {
8413 mExtras = new Bundle();
8414 }
8415 mExtras.putCharSequenceArray(name, value);
8416 return this;
8417 }
8418
8419 /**
8420 * Add extended data to the intent. The name must include a package
8421 * prefix, for example the app com.android.contacts would use names
8422 * like "com.android.contacts.ShowAll".
8423 *
8424 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008425 * @param value The Bundle data value.
8426 *
8427 * @return Returns the same Intent object, for chaining multiple calls
8428 * into a single statement.
8429 *
8430 * @see #putExtras
8431 * @see #removeExtra
8432 * @see #getBundleExtra(String)
8433 */
8434 public Intent putExtra(String name, Bundle value) {
8435 if (mExtras == null) {
8436 mExtras = new Bundle();
8437 }
8438 mExtras.putBundle(name, value);
8439 return this;
8440 }
8441
8442 /**
8443 * Add extended data to the intent. The name must include a package
8444 * prefix, for example the app com.android.contacts would use names
8445 * like "com.android.contacts.ShowAll".
8446 *
8447 * @param name The name of the extra data, with package prefix.
8448 * @param value The IBinder data value.
8449 *
8450 * @return Returns the same Intent object, for chaining multiple calls
8451 * into a single statement.
8452 *
8453 * @see #putExtras
8454 * @see #removeExtra
8455 * @see #getIBinderExtra(String)
8456 *
8457 * @deprecated
8458 * @hide
8459 */
8460 @Deprecated
8461 public Intent putExtra(String name, IBinder value) {
8462 if (mExtras == null) {
8463 mExtras = new Bundle();
8464 }
8465 mExtras.putIBinder(name, value);
8466 return this;
8467 }
8468
8469 /**
8470 * Copy all extras in 'src' in to this intent.
8471 *
8472 * @param src Contains the extras to copy.
8473 *
8474 * @see #putExtra
8475 */
8476 public Intent putExtras(Intent src) {
8477 if (src.mExtras != null) {
8478 if (mExtras == null) {
8479 mExtras = new Bundle(src.mExtras);
8480 } else {
8481 mExtras.putAll(src.mExtras);
8482 }
8483 }
8484 return this;
8485 }
8486
8487 /**
8488 * Add a set of extended data to the intent. The keys must include a package
8489 * prefix, for example the app com.android.contacts would use names
8490 * like "com.android.contacts.ShowAll".
8491 *
8492 * @param extras The Bundle of extras to add to this intent.
8493 *
8494 * @see #putExtra
8495 * @see #removeExtra
8496 */
8497 public Intent putExtras(Bundle extras) {
8498 if (mExtras == null) {
8499 mExtras = new Bundle();
8500 }
8501 mExtras.putAll(extras);
8502 return this;
8503 }
8504
8505 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008506 * Completely replace the extras in the Intent with the extras in the
8507 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008508 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008509 * @param src The exact extras contained in this Intent are copied
8510 * into the target intent, replacing any that were previously there.
8511 */
8512 public Intent replaceExtras(Intent src) {
8513 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8514 return this;
8515 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008516
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008517 /**
8518 * Completely replace the extras in the Intent with the given Bundle of
8519 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008520 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008521 * @param extras The new set of extras in the Intent, or null to erase
8522 * all extras.
8523 */
8524 public Intent replaceExtras(Bundle extras) {
8525 mExtras = extras != null ? new Bundle(extras) : null;
8526 return this;
8527 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008528
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008529 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008530 * Remove extended data from the intent.
8531 *
8532 * @see #putExtra
8533 */
8534 public void removeExtra(String name) {
8535 if (mExtras != null) {
8536 mExtras.remove(name);
8537 if (mExtras.size() == 0) {
8538 mExtras = null;
8539 }
8540 }
8541 }
8542
8543 /**
8544 * Set special flags controlling how this intent is handled. Most values
8545 * here depend on the type of component being executed by the Intent,
8546 * specifically the FLAG_ACTIVITY_* flags are all for use with
8547 * {@link Context#startActivity Context.startActivity()} and the
8548 * FLAG_RECEIVER_* flags are all for use with
8549 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8550 *
Scott Main7aee61f2011-02-08 11:25:01 -08008551 * <p>See the
8552 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8553 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008554 * the behavior of your application.
8555 *
8556 * @param flags The desired flags.
8557 *
8558 * @return Returns the same Intent object, for chaining multiple calls
8559 * into a single statement.
8560 *
8561 * @see #getFlags
8562 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008563 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564 *
8565 * @see #FLAG_GRANT_READ_URI_PERMISSION
8566 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008567 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8568 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008569 * @see #FLAG_DEBUG_LOG_RESOLUTION
8570 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008571 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008572 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008573 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008574 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8576 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008577 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008578 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008579 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008580 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008581 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008582 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008583 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008584 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8585 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008586 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008587 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008588 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008589 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8590 */
8591 public Intent setFlags(int flags) {
8592 mFlags = flags;
8593 return this;
8594 }
8595
8596 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008597 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 *
8599 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008600 * @return Returns the same Intent object, for chaining multiple calls into
8601 * a single statement.
8602 * @see #setFlags(int)
8603 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 */
8605 public Intent addFlags(int flags) {
8606 mFlags |= flags;
8607 return this;
8608 }
8609
8610 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008611 * Remove these flags from the intent.
8612 *
8613 * @param flags The flags to remove.
8614 * @see #setFlags(int)
8615 * @see #addFlags(int)
8616 */
8617 public void removeFlags(int flags) {
8618 mFlags &= ~flags;
8619 }
8620
8621 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008622 * (Usually optional) Set an explicit application package name that limits
8623 * the components this Intent will resolve to. If left to the default
8624 * value of null, all components in all applications will considered.
8625 * If non-null, the Intent can only match the components in the given
8626 * application package.
8627 *
8628 * @param packageName The name of the application package to handle the
8629 * intent, or null to allow any application package.
8630 *
8631 * @return Returns the same Intent object, for chaining multiple calls
8632 * into a single statement.
8633 *
8634 * @see #getPackage
8635 * @see #resolveActivity
8636 */
8637 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008638 if (packageName != null && mSelector != null) {
8639 throw new IllegalArgumentException(
8640 "Can't set package name when selector is already set");
8641 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008642 mPackage = packageName;
8643 return this;
8644 }
8645
8646 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008647 * (Usually optional) Explicitly set the component to handle the intent.
8648 * If left with the default value of null, the system will determine the
8649 * appropriate class to use based on the other fields (action, data,
8650 * type, categories) in the Intent. If this class is defined, the
8651 * specified class will always be used regardless of the other fields. You
8652 * should only set this value when you know you absolutely want a specific
8653 * class to be used; otherwise it is better to let the system find the
8654 * appropriate class so that you will respect the installed applications
8655 * and user preferences.
8656 *
8657 * @param component The name of the application component to handle the
8658 * intent, or null to let the system find one for you.
8659 *
8660 * @return Returns the same Intent object, for chaining multiple calls
8661 * into a single statement.
8662 *
8663 * @see #setClass
8664 * @see #setClassName(Context, String)
8665 * @see #setClassName(String, String)
8666 * @see #getComponent
8667 * @see #resolveActivity
8668 */
8669 public Intent setComponent(ComponentName component) {
8670 mComponent = component;
8671 return this;
8672 }
8673
8674 /**
8675 * Convenience for calling {@link #setComponent} with an
8676 * explicit class name.
8677 *
8678 * @param packageContext A Context of the application package implementing
8679 * this class.
8680 * @param className The name of a class inside of the application package
8681 * that will be used as the component for this Intent.
8682 *
8683 * @return Returns the same Intent object, for chaining multiple calls
8684 * into a single statement.
8685 *
8686 * @see #setComponent
8687 * @see #setClass
8688 */
8689 public Intent setClassName(Context packageContext, String className) {
8690 mComponent = new ComponentName(packageContext, className);
8691 return this;
8692 }
8693
8694 /**
8695 * Convenience for calling {@link #setComponent} with an
8696 * explicit application package name and class name.
8697 *
8698 * @param packageName The name of the package implementing the desired
8699 * component.
8700 * @param className The name of a class inside of the application package
8701 * that will be used as the component for this Intent.
8702 *
8703 * @return Returns the same Intent object, for chaining multiple calls
8704 * into a single statement.
8705 *
8706 * @see #setComponent
8707 * @see #setClass
8708 */
8709 public Intent setClassName(String packageName, String className) {
8710 mComponent = new ComponentName(packageName, className);
8711 return this;
8712 }
8713
8714 /**
8715 * Convenience for calling {@link #setComponent(ComponentName)} with the
8716 * name returned by a {@link Class} object.
8717 *
8718 * @param packageContext A Context of the application package implementing
8719 * this class.
8720 * @param cls The class name to set, equivalent to
8721 * <code>setClassName(context, cls.getName())</code>.
8722 *
8723 * @return Returns the same Intent object, for chaining multiple calls
8724 * into a single statement.
8725 *
8726 * @see #setComponent
8727 */
8728 public Intent setClass(Context packageContext, Class<?> cls) {
8729 mComponent = new ComponentName(packageContext, cls);
8730 return this;
8731 }
8732
8733 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008734 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8735 * used as a hint to the receiver for animations and the like. Null means that there
8736 * is no source bounds.
8737 */
8738 public void setSourceBounds(Rect r) {
8739 if (r != null) {
8740 mSourceBounds = new Rect(r);
8741 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008742 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008743 }
8744 }
8745
Tor Norbyed9273d62013-05-30 15:59:53 -07008746 /** @hide */
8747 @IntDef(flag = true,
8748 value = {
8749 FILL_IN_ACTION,
8750 FILL_IN_DATA,
8751 FILL_IN_CATEGORIES,
8752 FILL_IN_COMPONENT,
8753 FILL_IN_PACKAGE,
8754 FILL_IN_SOURCE_BOUNDS,
8755 FILL_IN_SELECTOR,
8756 FILL_IN_CLIP_DATA
8757 })
8758 @Retention(RetentionPolicy.SOURCE)
8759 public @interface FillInFlags {}
8760
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008761 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008762 * Use with {@link #fillIn} to allow the current action value to be
8763 * overwritten, even if it is already set.
8764 */
8765 public static final int FILL_IN_ACTION = 1<<0;
8766
8767 /**
8768 * Use with {@link #fillIn} to allow the current data or type value
8769 * overwritten, even if it is already set.
8770 */
8771 public static final int FILL_IN_DATA = 1<<1;
8772
8773 /**
8774 * Use with {@link #fillIn} to allow the current categories to be
8775 * overwritten, even if they are already set.
8776 */
8777 public static final int FILL_IN_CATEGORIES = 1<<2;
8778
8779 /**
8780 * Use with {@link #fillIn} to allow the current component value to be
8781 * overwritten, even if it is already set.
8782 */
8783 public static final int FILL_IN_COMPONENT = 1<<3;
8784
8785 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008786 * Use with {@link #fillIn} to allow the current package value to be
8787 * overwritten, even if it is already set.
8788 */
8789 public static final int FILL_IN_PACKAGE = 1<<4;
8790
8791 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008792 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008793 * overwritten, even if it is already set.
8794 */
8795 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8796
8797 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008798 * Use with {@link #fillIn} to allow the current selector to be
8799 * overwritten, even if it is already set.
8800 */
8801 public static final int FILL_IN_SELECTOR = 1<<6;
8802
8803 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008804 * Use with {@link #fillIn} to allow the current ClipData to be
8805 * overwritten, even if it is already set.
8806 */
8807 public static final int FILL_IN_CLIP_DATA = 1<<7;
8808
8809 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008810 * Copy the contents of <var>other</var> in to this object, but only
8811 * where fields are not defined by this object. For purposes of a field
8812 * being defined, the following pieces of data in the Intent are
8813 * considered to be separate fields:
8814 *
8815 * <ul>
8816 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008817 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008818 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8819 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008820 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008821 * <li> component, as set by {@link #setComponent(ComponentName)} or
8822 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008823 * <li> source bounds, as set by {@link #setSourceBounds}.
8824 * <li> selector, as set by {@link #setSelector(Intent)}.
8825 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008826 * <li> each top-level name in the associated extras.
8827 * </ul>
8828 *
8829 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008830 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008831 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8832 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8833 * the restriction where the corresponding field will not be replaced if
8834 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008835 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008836 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8837 * is explicitly specified. The selector will only be copied if
8838 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008839 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008840 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8841 * and Intent B with {action="gotit", data-type="some/thing",
8842 * categories="one","two"}.
8843 *
8844 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8845 * containing: {action="gotit", data-type="some/thing",
8846 * categories="bar"}.
8847 *
8848 * @param other Another Intent whose values are to be used to fill in
8849 * the current one.
8850 * @param flags Options to control which fields can be filled in.
8851 *
8852 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008853 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008854 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008855 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008856 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008857 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008858 @FillInFlags
8859 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008860 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008861 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008862 if (other.mAction != null
8863 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008864 mAction = other.mAction;
8865 changes |= FILL_IN_ACTION;
8866 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008867 if ((other.mData != null || other.mType != null)
8868 && ((mData == null && mType == null)
8869 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008870 mData = other.mData;
8871 mType = other.mType;
8872 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008873 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008874 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008875 if (other.mCategories != null
8876 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008877 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008878 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008879 }
8880 changes |= FILL_IN_CATEGORIES;
8881 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008882 if (other.mPackage != null
8883 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008884 // Only do this if mSelector is not set.
8885 if (mSelector == null) {
8886 mPackage = other.mPackage;
8887 changes |= FILL_IN_PACKAGE;
8888 }
8889 }
8890 // Selector is special: it can only be set if explicitly allowed,
8891 // for the same reason as the component name.
8892 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8893 if (mPackage == null) {
8894 mSelector = new Intent(other.mSelector);
8895 mPackage = null;
8896 changes |= FILL_IN_SELECTOR;
8897 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008898 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008899 if (other.mClipData != null
8900 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8901 mClipData = other.mClipData;
8902 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008903 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008904 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008905 // Component is special: it can -only- be set if explicitly allowed,
8906 // since otherwise the sender could force the intent somewhere the
8907 // originator didn't intend.
8908 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008909 mComponent = other.mComponent;
8910 changes |= FILL_IN_COMPONENT;
8911 }
8912 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008913 if (other.mSourceBounds != null
8914 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8915 mSourceBounds = new Rect(other.mSourceBounds);
8916 changes |= FILL_IN_SOURCE_BOUNDS;
8917 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008918 if (mExtras == null) {
8919 if (other.mExtras != null) {
8920 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008921 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008922 }
8923 } else if (other.mExtras != null) {
8924 try {
8925 Bundle newb = new Bundle(other.mExtras);
8926 newb.putAll(mExtras);
8927 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008928 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008929 } catch (RuntimeException e) {
8930 // Modifying the extras can cause us to unparcel the contents
8931 // of the bundle, and if we do this in the system process that
8932 // may fail. We really should handle this (i.e., the Bundle
8933 // impl shouldn't be on top of a plain map), but for now just
8934 // ignore it and keep the original contents. :(
8935 Log.w("Intent", "Failure filling in extras", e);
8936 }
8937 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008938 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8939 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8940 mContentUserHint = other.mContentUserHint;
8941 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008942 return changes;
8943 }
8944
8945 /**
8946 * Wrapper class holding an Intent and implementing comparisons on it for
8947 * the purpose of filtering. The class implements its
8948 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8949 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8950 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8951 * on the wrapped Intent.
8952 */
8953 public static final class FilterComparison {
8954 private final Intent mIntent;
8955 private final int mHashCode;
8956
8957 public FilterComparison(Intent intent) {
8958 mIntent = intent;
8959 mHashCode = intent.filterHashCode();
8960 }
8961
8962 /**
8963 * Return the Intent that this FilterComparison represents.
8964 * @return Returns the Intent held by the FilterComparison. Do
8965 * not modify!
8966 */
8967 public Intent getIntent() {
8968 return mIntent;
8969 }
8970
8971 @Override
8972 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008973 if (obj instanceof FilterComparison) {
8974 Intent other = ((FilterComparison)obj).mIntent;
8975 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008976 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008977 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008978 }
8979
8980 @Override
8981 public int hashCode() {
8982 return mHashCode;
8983 }
8984 }
8985
8986 /**
8987 * Determine if two intents are the same for the purposes of intent
8988 * resolution (filtering). That is, if their action, data, type,
8989 * class, and categories are the same. This does <em>not</em> compare
8990 * any extra data included in the intents.
8991 *
8992 * @param other The other Intent to compare against.
8993 *
8994 * @return Returns true if action, data, type, class, and categories
8995 * are the same.
8996 */
8997 public boolean filterEquals(Intent other) {
8998 if (other == null) {
8999 return false;
9000 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009001 if (!Objects.equals(this.mAction, other.mAction)) return false;
9002 if (!Objects.equals(this.mData, other.mData)) return false;
9003 if (!Objects.equals(this.mType, other.mType)) return false;
9004 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9005 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9006 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009007
9008 return true;
9009 }
9010
9011 /**
9012 * Generate hash code that matches semantics of filterEquals().
9013 *
9014 * @return Returns the hash value of the action, data, type, class, and
9015 * categories.
9016 *
9017 * @see #filterEquals
9018 */
9019 public int filterHashCode() {
9020 int code = 0;
9021 if (mAction != null) {
9022 code += mAction.hashCode();
9023 }
9024 if (mData != null) {
9025 code += mData.hashCode();
9026 }
9027 if (mType != null) {
9028 code += mType.hashCode();
9029 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009030 if (mPackage != null) {
9031 code += mPackage.hashCode();
9032 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009033 if (mComponent != null) {
9034 code += mComponent.hashCode();
9035 }
9036 if (mCategories != null) {
9037 code += mCategories.hashCode();
9038 }
9039 return code;
9040 }
9041
9042 @Override
9043 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009044 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009045
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009046 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009047 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009048 b.append(" }");
9049
9050 return b.toString();
9051 }
9052
9053 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009054 public String toInsecureString() {
9055 StringBuilder b = new StringBuilder(128);
9056
9057 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009058 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009059 b.append(" }");
9060
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009061 return b.toString();
9062 }
Romain Guy4969af72009-06-17 10:53:19 -07009063
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009064 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009065 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009066 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009067
9068 b.append("Intent { ");
9069 toShortString(b, false, true, true, true);
9070 b.append(" }");
9071
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009072 return b.toString();
9073 }
9074
9075 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009076 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9077 StringBuilder b = new StringBuilder(128);
9078 toShortString(b, secure, comp, extras, clip);
9079 return b.toString();
9080 }
9081
9082 /** @hide */
9083 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9084 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009085 boolean first = true;
9086 if (mAction != null) {
9087 b.append("act=").append(mAction);
9088 first = false;
9089 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009091 if (!first) {
9092 b.append(' ');
9093 }
9094 first = false;
9095 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009096 for (int i=0; i<mCategories.size(); i++) {
9097 if (i > 0) b.append(',');
9098 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009099 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009100 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009101 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009102 if (mData != null) {
9103 if (!first) {
9104 b.append(' ');
9105 }
9106 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009107 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009108 if (secure) {
9109 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009110 } else {
9111 b.append(mData);
9112 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009113 }
9114 if (mType != null) {
9115 if (!first) {
9116 b.append(' ');
9117 }
9118 first = false;
9119 b.append("typ=").append(mType);
9120 }
9121 if (mFlags != 0) {
9122 if (!first) {
9123 b.append(' ');
9124 }
9125 first = false;
9126 b.append("flg=0x").append(Integer.toHexString(mFlags));
9127 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009128 if (mPackage != null) {
9129 if (!first) {
9130 b.append(' ');
9131 }
9132 first = false;
9133 b.append("pkg=").append(mPackage);
9134 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009135 if (comp && mComponent != null) {
9136 if (!first) {
9137 b.append(' ');
9138 }
9139 first = false;
9140 b.append("cmp=").append(mComponent.flattenToShortString());
9141 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009142 if (mSourceBounds != null) {
9143 if (!first) {
9144 b.append(' ');
9145 }
9146 first = false;
9147 b.append("bnds=").append(mSourceBounds.toShortString());
9148 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009149 if (mClipData != null) {
9150 if (!first) {
9151 b.append(' ');
9152 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009153 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009154 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009155 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009156 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009157 if (mClipData.getDescription() != null) {
9158 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9159 } else {
9160 first = true;
9161 }
9162 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009163 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009164 first = false;
9165 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009166 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009167 if (extras && mExtras != null) {
9168 if (!first) {
9169 b.append(' ');
9170 }
9171 first = false;
9172 b.append("(has extras)");
9173 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009174 if (mContentUserHint != UserHandle.USER_CURRENT) {
9175 if (!first) {
9176 b.append(' ');
9177 }
9178 first = false;
9179 b.append("u=").append(mContentUserHint);
9180 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009181 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009182 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009183 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009184 b.append("}");
9185 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009186 }
9187
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009188 /**
9189 * Call {@link #toUri} with 0 flags.
9190 * @deprecated Use {@link #toUri} instead.
9191 */
9192 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009193 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009194 return toUri(0);
9195 }
9196
9197 /**
9198 * Convert this Intent into a String holding a URI representation of it.
9199 * The returned URI string has been properly URI encoded, so it can be
9200 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9201 * Intent's data as the base URI, with an additional fragment describing
9202 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009203 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009204 * <p>You can convert the returned string back to an Intent with
9205 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009206 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009207 * @param flags Additional operating flags. Either 0,
9208 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08009209 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009210 * @return Returns a URI encoding URI string describing the entire contents
9211 * of the Intent.
9212 */
9213 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009214 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009215 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9216 if (mPackage == null) {
9217 throw new IllegalArgumentException(
9218 "Intent must include an explicit package name to build an android-app: "
9219 + this);
9220 }
9221 uri.append("android-app://");
9222 uri.append(mPackage);
9223 String scheme = null;
9224 if (mData != null) {
9225 scheme = mData.getScheme();
9226 if (scheme != null) {
9227 uri.append('/');
9228 uri.append(scheme);
9229 String authority = mData.getEncodedAuthority();
9230 if (authority != null) {
9231 uri.append('/');
9232 uri.append(authority);
9233 String path = mData.getEncodedPath();
9234 if (path != null) {
9235 uri.append(path);
9236 }
9237 String queryParams = mData.getEncodedQuery();
9238 if (queryParams != null) {
9239 uri.append('?');
9240 uri.append(queryParams);
9241 }
9242 String fragment = mData.getEncodedFragment();
9243 if (fragment != null) {
9244 uri.append('#');
9245 uri.append(fragment);
9246 }
9247 }
9248 }
9249 }
9250 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9251 mPackage, flags);
9252 return uri.toString();
9253 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009254 String scheme = null;
9255 if (mData != null) {
9256 String data = mData.toString();
9257 if ((flags&URI_INTENT_SCHEME) != 0) {
9258 final int N = data.length();
9259 for (int i=0; i<N; i++) {
9260 char c = data.charAt(i);
9261 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9262 || c == '.' || c == '-') {
9263 continue;
9264 }
9265 if (c == ':' && i > 0) {
9266 // Valid scheme.
9267 scheme = data.substring(0, i);
9268 uri.append("intent:");
9269 data = data.substring(i+1);
9270 break;
9271 }
Tom Taylord4a47292009-12-21 13:59:18 -08009272
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009273 // No scheme.
9274 break;
9275 }
9276 }
9277 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009278
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009279 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9280 uri.append("intent:");
9281 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009282
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009283 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009284
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009285 return uri.toString();
9286 }
9287
9288 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9289 String defPackage, int flags) {
9290 StringBuilder frag = new StringBuilder(128);
9291
9292 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009293 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009294 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009295 // Note that for now we are not going to try to handle the
9296 // data part; not clear how to represent this as a URI, and
9297 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009298 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9299 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009300 }
9301
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009302 if (frag.length() > 0) {
9303 uri.append("#Intent;");
9304 uri.append(frag);
9305 uri.append("end");
9306 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009307 }
9308
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009309 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9310 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009311 if (scheme != null) {
9312 uri.append("scheme=").append(scheme).append(';');
9313 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009314 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009315 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009316 }
9317 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009318 for (int i=0; i<mCategories.size(); i++) {
9319 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009320 }
9321 }
9322 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009323 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009324 }
9325 if (mFlags != 0) {
9326 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9327 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009328 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009329 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9330 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009331 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009332 uri.append("component=").append(Uri.encode(
9333 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009334 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009335 if (mSourceBounds != null) {
9336 uri.append("sourceBounds=")
9337 .append(Uri.encode(mSourceBounds.flattenToString()))
9338 .append(';');
9339 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009340 if (mExtras != null) {
9341 for (String key : mExtras.keySet()) {
9342 final Object value = mExtras.get(key);
9343 char entryType =
9344 value instanceof String ? 'S' :
9345 value instanceof Boolean ? 'B' :
9346 value instanceof Byte ? 'b' :
9347 value instanceof Character ? 'c' :
9348 value instanceof Double ? 'd' :
9349 value instanceof Float ? 'f' :
9350 value instanceof Integer ? 'i' :
9351 value instanceof Long ? 'l' :
9352 value instanceof Short ? 's' :
9353 '\0';
9354
9355 if (entryType != '\0') {
9356 uri.append(entryType);
9357 uri.append('.');
9358 uri.append(Uri.encode(key));
9359 uri.append('=');
9360 uri.append(Uri.encode(value.toString()));
9361 uri.append(';');
9362 }
9363 }
9364 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009365 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009366
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009367 public int describeContents() {
9368 return (mExtras != null) ? mExtras.describeContents() : 0;
9369 }
9370
9371 public void writeToParcel(Parcel out, int flags) {
9372 out.writeString(mAction);
9373 Uri.writeToParcel(out, mData);
9374 out.writeString(mType);
9375 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009376 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009377 ComponentName.writeToParcel(mComponent, out);
9378
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009379 if (mSourceBounds != null) {
9380 out.writeInt(1);
9381 mSourceBounds.writeToParcel(out, flags);
9382 } else {
9383 out.writeInt(0);
9384 }
9385
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009386 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009387 final int N = mCategories.size();
9388 out.writeInt(N);
9389 for (int i=0; i<N; i++) {
9390 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009391 }
9392 } else {
9393 out.writeInt(0);
9394 }
9395
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009396 if (mSelector != null) {
9397 out.writeInt(1);
9398 mSelector.writeToParcel(out, flags);
9399 } else {
9400 out.writeInt(0);
9401 }
9402
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009403 if (mClipData != null) {
9404 out.writeInt(1);
9405 mClipData.writeToParcel(out, flags);
9406 } else {
9407 out.writeInt(0);
9408 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009409 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009410 out.writeBundle(mExtras);
9411 }
9412
9413 public static final Parcelable.Creator<Intent> CREATOR
9414 = new Parcelable.Creator<Intent>() {
9415 public Intent createFromParcel(Parcel in) {
9416 return new Intent(in);
9417 }
9418 public Intent[] newArray(int size) {
9419 return new Intent[size];
9420 }
9421 };
9422
Dianne Hackborneb034652009-09-07 00:49:58 -07009423 /** @hide */
9424 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009425 readFromParcel(in);
9426 }
9427
9428 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009429 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009430 mData = Uri.CREATOR.createFromParcel(in);
9431 mType = in.readString();
9432 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009433 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009434 mComponent = ComponentName.readFromParcel(in);
9435
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009436 if (in.readInt() != 0) {
9437 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9438 }
9439
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009440 int N = in.readInt();
9441 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009442 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009443 int i;
9444 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009445 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009446 }
9447 } else {
9448 mCategories = null;
9449 }
9450
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009451 if (in.readInt() != 0) {
9452 mSelector = new Intent(in);
9453 }
9454
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009455 if (in.readInt() != 0) {
9456 mClipData = new ClipData(in);
9457 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009458 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009459 mExtras = in.readBundle();
9460 }
9461
9462 /**
9463 * Parses the "intent" element (and its children) from XML and instantiates
9464 * an Intent object. The given XML parser should be located at the tag
9465 * where parsing should start (often named "intent"), from which the
9466 * basic action, data, type, and package and class name will be
9467 * retrieved. The function will then parse in to any child elements,
9468 * looking for <category android:name="xxx"> tags to add categories and
9469 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9470 * to the intent.
9471 *
9472 * @param resources The Resources to use when inflating resources.
9473 * @param parser The XML parser pointing at an "intent" tag.
9474 * @param attrs The AttributeSet interface for retrieving extended
9475 * attribute data at the current <var>parser</var> location.
9476 * @return An Intent object matching the XML data.
9477 * @throws XmlPullParserException If there was an XML parsing error.
9478 * @throws IOException If there was an I/O error.
9479 */
9480 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9481 throws XmlPullParserException, IOException {
9482 Intent intent = new Intent();
9483
9484 TypedArray sa = resources.obtainAttributes(attrs,
9485 com.android.internal.R.styleable.Intent);
9486
9487 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9488
9489 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9490 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9491 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9492
9493 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9494 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9495 if (packageName != null && className != null) {
9496 intent.setComponent(new ComponentName(packageName, className));
9497 }
9498
9499 sa.recycle();
9500
9501 int outerDepth = parser.getDepth();
9502 int type;
9503 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9504 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9505 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9506 continue;
9507 }
9508
9509 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009510 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009511 sa = resources.obtainAttributes(attrs,
9512 com.android.internal.R.styleable.IntentCategory);
9513 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9514 sa.recycle();
9515
9516 if (cat != null) {
9517 intent.addCategory(cat);
9518 }
9519 XmlUtils.skipCurrentTag(parser);
9520
Craig Mautner21d24a22014-04-23 11:45:37 -07009521 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009522 if (intent.mExtras == null) {
9523 intent.mExtras = new Bundle();
9524 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009525 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009526 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009527
9528 } else {
9529 XmlUtils.skipCurrentTag(parser);
9530 }
9531 }
9532
9533 return intent;
9534 }
Nick Pellyccae4122012-01-09 14:12:58 -08009535
Craig Mautner21d24a22014-04-23 11:45:37 -07009536 /** @hide */
9537 public void saveToXml(XmlSerializer out) throws IOException {
9538 if (mAction != null) {
9539 out.attribute(null, ATTR_ACTION, mAction);
9540 }
9541 if (mData != null) {
9542 out.attribute(null, ATTR_DATA, mData.toString());
9543 }
9544 if (mType != null) {
9545 out.attribute(null, ATTR_TYPE, mType);
9546 }
9547 if (mComponent != null) {
9548 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9549 }
9550 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9551
9552 if (mCategories != null) {
9553 out.startTag(null, TAG_CATEGORIES);
9554 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9555 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9556 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009557 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009558 }
9559 }
9560
9561 /** @hide */
9562 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9563 XmlPullParserException {
9564 Intent intent = new Intent();
9565 final int outerDepth = in.getDepth();
9566
9567 int attrCount = in.getAttributeCount();
9568 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9569 final String attrName = in.getAttributeName(attrNdx);
9570 final String attrValue = in.getAttributeValue(attrNdx);
9571 if (ATTR_ACTION.equals(attrName)) {
9572 intent.setAction(attrValue);
9573 } else if (ATTR_DATA.equals(attrName)) {
9574 intent.setData(Uri.parse(attrValue));
9575 } else if (ATTR_TYPE.equals(attrName)) {
9576 intent.setType(attrValue);
9577 } else if (ATTR_COMPONENT.equals(attrName)) {
9578 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9579 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009580 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009581 } else {
9582 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9583 }
9584 }
9585
9586 int event;
9587 String name;
9588 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9589 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9590 if (event == XmlPullParser.START_TAG) {
9591 name = in.getName();
9592 if (TAG_CATEGORIES.equals(name)) {
9593 attrCount = in.getAttributeCount();
9594 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9595 intent.addCategory(in.getAttributeValue(attrNdx));
9596 }
9597 } else {
9598 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9599 XmlUtils.skipCurrentTag(in);
9600 }
9601 }
9602 }
9603
9604 return intent;
9605 }
9606
Nick Pellyccae4122012-01-09 14:12:58 -08009607 /**
9608 * Normalize a MIME data type.
9609 *
9610 * <p>A normalized MIME type has white-space trimmed,
9611 * content-type parameters removed, and is lower-case.
9612 * This aligns the type with Android best practices for
9613 * intent filtering.
9614 *
9615 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9616 * "text/x-vCard" becomes "text/x-vcard".
9617 *
9618 * <p>All MIME types received from outside Android (such as user input,
9619 * or external sources like Bluetooth, NFC, or the Internet) should
9620 * be normalized before they are used to create an Intent.
9621 *
9622 * @param type MIME data type to normalize
9623 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009624 * @see #setType
9625 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009626 */
9627 public static String normalizeMimeType(String type) {
9628 if (type == null) {
9629 return null;
9630 }
9631
Elliott Hughescb64d432013-08-02 10:00:44 -07009632 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009633
9634 final int semicolonIndex = type.indexOf(';');
9635 if (semicolonIndex != -1) {
9636 type = type.substring(0, semicolonIndex);
9637 }
9638 return type;
9639 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009640
9641 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009642 * Prepare this {@link Intent} to leave an app process.
9643 *
9644 * @hide
9645 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009646 public void prepareToLeaveProcess(Context context) {
9647 final boolean leavingPackage = (mComponent == null)
9648 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9649 prepareToLeaveProcess(leavingPackage);
9650 }
9651
9652 /**
9653 * Prepare this {@link Intent} to leave an app process.
9654 *
9655 * @hide
9656 */
9657 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009658 setAllowFds(false);
9659
9660 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009661 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009662 }
9663 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009664 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009665 }
9666
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009667 if (mExtras != null && !mExtras.isParcelled()) {
9668 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9669 if (intent instanceof Intent) {
9670 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9671 }
9672 }
9673
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009674 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9675 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009676 switch (mAction) {
9677 case ACTION_MEDIA_REMOVED:
9678 case ACTION_MEDIA_UNMOUNTED:
9679 case ACTION_MEDIA_CHECKING:
9680 case ACTION_MEDIA_NOFS:
9681 case ACTION_MEDIA_MOUNTED:
9682 case ACTION_MEDIA_SHARED:
9683 case ACTION_MEDIA_UNSHARED:
9684 case ACTION_MEDIA_BAD_REMOVAL:
9685 case ACTION_MEDIA_UNMOUNTABLE:
9686 case ACTION_MEDIA_EJECT:
9687 case ACTION_MEDIA_SCANNER_STARTED:
9688 case ACTION_MEDIA_SCANNER_FINISHED:
9689 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009690 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9691 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009692 // Ignore legacy actions
9693 break;
9694 default:
9695 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009696 }
9697 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009698
9699 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9700 && leavingPackage) {
9701 switch (mAction) {
9702 case ACTION_PROVIDER_CHANGED:
9703 // Ignore actions that don't need to grant
9704 break;
9705 default:
9706 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9707 }
9708 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009709 }
9710
9711 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009712 * @hide
9713 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009714 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009715 // We just entered destination process, so we should be able to read all
9716 // parcelables inside.
9717 setDefusable(true);
9718
9719 if (mSelector != null) {
9720 mSelector.prepareToEnterProcess();
9721 }
9722 if (mClipData != null) {
9723 mClipData.prepareToEnterProcess();
9724 }
9725
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009726 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009727 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9728 fixUris(mContentUserHint);
9729 mContentUserHint = UserHandle.USER_CURRENT;
9730 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009731 }
9732 }
9733
9734 /**
9735 * @hide
9736 */
9737 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009738 Uri data = getData();
9739 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009740 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009741 }
9742 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009743 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009744 }
9745 String action = getAction();
9746 if (ACTION_SEND.equals(action)) {
9747 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9748 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009749 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009750 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009751 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009752 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9753 if (streams != null) {
9754 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9755 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009756 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009757 }
9758 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9759 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009760 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9761 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9762 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9763 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9764 if (output != null) {
9765 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9766 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009767 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009768 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009769
9770 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009771 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009772 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9773 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009774 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009775 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009776 * @hide
9777 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009778 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009779 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009780 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009781
9782 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009783 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009784
9785 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009786 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009787 // Inspect contained intents to see if we need to migrate extras. We
9788 // don't promote ClipData to the parent, since ChooserActivity will
9789 // already start the picked item as the caller, and we can't combine
9790 // the flags in a safe way.
9791
9792 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009793 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009794 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9795 if (intent != null) {
9796 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009797 }
9798 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009799 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009800 try {
9801 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9802 if (intents != null) {
9803 for (int i = 0; i < intents.length; i++) {
9804 final Intent intent = (Intent) intents[i];
9805 if (intent != null) {
9806 migrated |= intent.migrateExtraStreamToClipData();
9807 }
9808 }
9809 }
9810 } catch (ClassCastException e) {
9811 }
9812 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009813
9814 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009815 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009816 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9817 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9818 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9819 if (stream != null || text != null || htmlText != null) {
9820 final ClipData clipData = new ClipData(
9821 null, new String[] { getType() },
9822 new ClipData.Item(text, htmlText, null, stream));
9823 setClipData(clipData);
9824 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009825 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009826 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009827 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009828 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009829
9830 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009831 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009832 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9833 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9834 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9835 int num = -1;
9836 if (streams != null) {
9837 num = streams.size();
9838 }
9839 if (texts != null) {
9840 if (num >= 0 && num != texts.size()) {
9841 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009842 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009843 }
9844 num = texts.size();
9845 }
9846 if (htmlTexts != null) {
9847 if (num >= 0 && num != htmlTexts.size()) {
9848 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009849 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009850 }
9851 num = htmlTexts.size();
9852 }
9853 if (num > 0) {
9854 final ClipData clipData = new ClipData(
9855 null, new String[] { getType() },
9856 makeClipItem(streams, texts, htmlTexts, 0));
9857
9858 for (int i = 1; i < num; i++) {
9859 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9860 }
9861
9862 setClipData(clipData);
9863 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009864 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009865 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009866 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009867 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009868 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9869 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9870 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9871 final Uri output;
9872 try {
9873 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9874 } catch (ClassCastException e) {
9875 return false;
9876 }
9877 if (output != null) {
9878 setClipData(ClipData.newRawUri("", output));
9879 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9880 return true;
9881 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009882 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009883
9884 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009885 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009886
9887 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9888 ArrayList<String> htmlTexts, int which) {
9889 Uri uri = streams != null ? streams.get(which) : null;
9890 CharSequence text = texts != null ? texts.get(which) : null;
9891 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9892 return new ClipData.Item(text, htmlText, null, uri);
9893 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009894
9895 /** @hide */
9896 public boolean isDocument() {
9897 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9898 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009899}