blob: 4b76204974757e8097ed7d6569da739c8851b5a2 [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 Brenner880994d2017-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 Brenner880994d2017-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>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001510 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001511 * 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
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001649 * Currently only a system app that hosts the provider authority "downloads" or holds the
1650 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001651 * @hide
1652 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001653 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001654 public static final String EXTRA_ORIGINATING_UID
1655 = "android.intent.extra.ORIGINATING_UID";
1656
1657 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001658 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1659 * package. Tells the installer UI to skip the confirmation with the user
1660 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001661 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1662 * will no longer show an interstitial message about updating existing
1663 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001664 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001665 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001666 public static final String EXTRA_ALLOW_REPLACE
1667 = "android.intent.extra.ALLOW_REPLACE";
1668
1669 /**
1670 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1671 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1672 * return to the application the result code of the install/uninstall. The returned result
1673 * code will be {@link android.app.Activity#RESULT_OK} on success or
1674 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1675 */
1676 public static final String EXTRA_RETURN_RESULT
1677 = "android.intent.extra.RETURN_RESULT";
1678
1679 /**
1680 * Package manager install result code. @hide because result codes are not
1681 * yet ready to be exposed.
1682 */
1683 public static final String EXTRA_INSTALL_RESULT
1684 = "android.intent.extra.INSTALL_RESULT";
1685
1686 /**
1687 * Activity Action: Launch application uninstaller.
1688 * <p>
1689 * Input: The data must be a package: URI whose scheme specific part is
1690 * the package name of the current installed package to be uninstalled.
1691 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1692 * <p>
1693 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1694 * succeeded.
1695 */
1696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1697 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1698
1699 /**
msnider3c191b82017-01-23 14:23:16 -08001700 * Activity Action: Launch application uninstaller.
1701 * <p>
1702 * Input: The data must be a package: URI whose scheme specific part is
1703 * the package name of the current installed package to be uninstalled.
1704 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1705 * <p>
1706 * Output: Nothing.
1707 * </p>
1708 */
1709 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1710 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1711
1712 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001713 * Specify whether the package should be uninstalled for all users.
1714 * @hide because these should not be part of normal application flow.
1715 */
1716 public static final String EXTRA_UNINSTALL_ALL_USERS
1717 = "android.intent.extra.UNINSTALL_ALL_USERS";
1718
1719 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001720 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1721 * describing the last run version of the platform that was setup.
1722 * @hide
1723 */
1724 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1725
Svet Ganov3695b8a2015-03-24 16:30:25 -07001726 /**
1727 * Activity action: Launch UI to manage the permissions of an app.
1728 * <p>
1729 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1730 * will be managed by the launched UI.
1731 * </p>
1732 * <p>
1733 * Output: Nothing.
1734 * </p>
1735 *
1736 * @see #EXTRA_PACKAGE_NAME
1737 *
1738 * @hide
1739 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001740 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1742 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1743 "android.intent.action.MANAGE_APP_PERMISSIONS";
1744
1745 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001746 * Activity action: Launch UI to manage permissions.
1747 * <p>
1748 * Input: Nothing.
1749 * </p>
1750 * <p>
1751 * Output: Nothing.
1752 * </p>
1753 *
1754 * @hide
1755 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001756 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001757 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1758 public static final String ACTION_MANAGE_PERMISSIONS =
1759 "android.intent.action.MANAGE_PERMISSIONS";
1760
1761 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001762 * Activity action: Launch UI to review permissions for an app.
1763 * The system uses this intent if permission review for apps not
1764 * supporting the new runtime permissions model is enabled. In
1765 * this mode a permission review is required before any of the
1766 * app components can run.
1767 * <p>
1768 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1769 * permissions will be reviewed (mandatory).
1770 * </p>
1771 * <p>
1772 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1773 * be fired after the permission review (optional).
1774 * </p>
1775 * <p>
1776 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1777 * be invoked after the permission review (optional).
1778 * </p>
1779 * <p>
1780 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1781 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1782 * </p>
1783 * <p>
1784 * Output: Nothing.
1785 * </p>
1786 *
1787 * @see #EXTRA_PACKAGE_NAME
1788 * @see #EXTRA_INTENT
1789 * @see #EXTRA_REMOTE_CALLBACK
1790 * @see #EXTRA_RESULT_NEEDED
1791 *
1792 * @hide
1793 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001794 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1796 public static final String ACTION_REVIEW_PERMISSIONS =
1797 "android.intent.action.REVIEW_PERMISSIONS";
1798
1799 /**
1800 * Intent extra: A callback for reporting remote result as a bundle.
1801 * <p>
1802 * Type: IRemoteCallback
1803 * </p>
1804 *
1805 * @hide
1806 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001807 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001808 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1809
1810 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001811 * Intent extra: An app package name.
1812 * <p>
1813 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001814 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001815 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001816 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001817 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1818
1819 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001820 * Intent extra: An app split name.
1821 * <p>
1822 * Type: String
1823 * </p>
1824 * @hide
1825 */
1826 @SystemApi
1827 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1828
1829 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001830 * Intent extra: An extra for specifying whether a result is needed.
1831 * <p>
1832 * Type: boolean
1833 * </p>
1834 *
1835 * @hide
1836 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001837 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001838 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1839
1840 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001841 * Activity action: Launch UI to manage which apps have a given permission.
1842 * <p>
1843 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1844 * to which will be managed by the launched UI.
1845 * </p>
1846 * <p>
1847 * Output: Nothing.
1848 * </p>
1849 *
1850 * @see #EXTRA_PERMISSION_NAME
1851 *
1852 * @hide
1853 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001854 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001855 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1856 public static final String ACTION_MANAGE_PERMISSION_APPS =
1857 "android.intent.action.MANAGE_PERMISSION_APPS";
1858
1859 /**
1860 * Intent extra: The name of a permission.
1861 * <p>
1862 * Type: String
1863 * </p>
1864 *
1865 * @hide
1866 */
1867 @SystemApi
1868 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1869
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001870 // ---------------------------------------------------------------------
1871 // ---------------------------------------------------------------------
1872 // Standard intent broadcast actions (see action variable).
1873
1874 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001875 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1876 * <p>
1877 * For historical reasons, the name of this broadcast action refers to the power
1878 * state of the screen but it is actually sent in response to changes in the
1879 * overall interactive state of the device.
1880 * </p><p>
1881 * This broadcast is sent when the device becomes non-interactive which may have
1882 * nothing to do with the screen turning off. To determine the
1883 * actual state of the screen, use {@link android.view.Display#getState}.
1884 * </p><p>
1885 * See {@link android.os.PowerManager#isInteractive} for details.
1886 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001887 * You <em>cannot</em> receive this through components declared in
1888 * manifests, only by explicitly registering for it with
1889 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1890 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001891 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001892 * <p class="note">This is a protected intent that can only be sent
1893 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001894 */
1895 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1896 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001897
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001898 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001899 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1900 * <p>
1901 * For historical reasons, the name of this broadcast action refers to the power
1902 * state of the screen but it is actually sent in response to changes in the
1903 * overall interactive state of the device.
1904 * </p><p>
1905 * This broadcast is sent when the device becomes interactive which may have
1906 * nothing to do with the screen turning on. To determine the
1907 * actual state of the screen, use {@link android.view.Display#getState}.
1908 * </p><p>
1909 * See {@link android.os.PowerManager#isInteractive} for details.
1910 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001911 * You <em>cannot</em> receive this through components declared in
1912 * manifests, only by explicitly registering for it with
1913 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1914 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001915 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001916 * <p class="note">This is a protected intent that can only be sent
1917 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001921
1922 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001923 * Broadcast Action: Sent after the system stops dreaming.
1924 *
1925 * <p class="note">This is a protected intent that can only be sent by the system.
1926 * It is only sent to registered receivers.</p>
1927 */
1928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1929 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1930
1931 /**
1932 * Broadcast Action: Sent after the system starts dreaming.
1933 *
1934 * <p class="note">This is a protected intent that can only be sent by the system.
1935 * It is only sent to registered receivers.</p>
1936 */
1937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1938 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1939
1940 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001941 * 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 -07001942 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001943 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001944 * <p class="note">This is a protected intent that can only be sent
1945 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001946 */
1947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001948 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001949
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 /**
1951 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001952 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001953 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001954 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1955 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001956 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001957 * <p class="note">This is a protected intent that can only be sent
1958 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1962 /**
1963 * Broadcast Action: The time was set.
1964 */
1965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1966 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1967 /**
1968 * Broadcast Action: The date has changed.
1969 */
1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1971 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1972 /**
1973 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1974 * <ul>
1975 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1976 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001977 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001978 * <p class="note">This is a protected intent that can only be sent
1979 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001980 */
1981 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1982 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1983 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001984 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1985 * DNS entries should be tossed.
1986 * @hide
1987 */
1988 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1989 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1990 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 * Alarm Changed Action: This is broadcast when the AlarmClock
1992 * application's alarm is set or unset. It is used by the
1993 * AlarmClock application and the StatusBar service.
1994 * @hide
1995 */
1996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1997 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001998
1999 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002000 * Broadcast Action: This is broadcast once, after the user has finished
2001 * booting, but while still in the "locked" state. It can be used to perform
2002 * application-specific initialization, such as installing alarms. You must
2003 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2004 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002005 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002006 * This broadcast is sent immediately at boot by all devices (regardless of
2007 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2008 * higher. Upon receipt of this broadcast, the user is still locked and only
2009 * device-protected storage can be accessed safely. If you want to access
2010 * credential-protected storage, you need to wait for the user to be
2011 * unlocked (typically by entering their lock pattern or PIN for the first
2012 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2013 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2014 * <p>
2015 * To receive this broadcast, your receiver component must be marked as
2016 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002017 * <p class="note">
2018 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002019 *
2020 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2024
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002025 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002026 * Broadcast Action: This is broadcast once, after the user has finished
2027 * booting. It can be used to perform application-specific initialization,
2028 * such as installing alarms. You must hold the
2029 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2030 * order to receive this broadcast.
2031 * <p>
2032 * This broadcast is sent at boot by all devices (both with and without
2033 * direct boot support). Upon receipt of this broadcast, the user is
2034 * unlocked and both device-protected and credential-protected storage can
2035 * accessed safely.
2036 * <p>
2037 * If you need to run while the user is still locked (before they've entered
2038 * their lock pattern or PIN for the first time), you can listen for the
2039 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2040 * <p class="note">
2041 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002042 */
2043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002044 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002046
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002047 /**
2048 * Broadcast Action: This is broadcast when a user action should request a
2049 * temporary system dialog to dismiss. Some examples of temporary system
2050 * dialogs are the notification window-shade and the recent tasks dialog.
2051 */
2052 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2053 /**
2054 * Broadcast Action: Trigger the download and eventual installation
2055 * of a package.
2056 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002057 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002058 * <p class="note">This is a protected intent that can only be sent
2059 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002060 *
2061 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002062 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002063 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002064 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2065 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2066 /**
2067 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002068 * device. The data contains the name of the package. Note that the
2069 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002070 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002071 * <ul>
2072 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2073 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2074 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2075 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002076 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002077 * <p class="note">This is a protected intent that can only be sent
2078 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 */
2080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2081 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2082 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002083 * Broadcast Action: A new version of an application package has been
2084 * installed, replacing an existing version that was previously installed.
2085 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002086 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002087 * <ul>
2088 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2089 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002090 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002091 * <p class="note">This is a protected intent that can only be sent
2092 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002093 */
2094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2095 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2096 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002097 * Broadcast Action: A new version of your application has been installed
2098 * over an existing one. This is only sent to the application that was
2099 * replaced. It does not contain any additional data; to receive it, just
2100 * use an intent filter for this action.
2101 *
2102 * <p class="note">This is a protected intent that can only be sent
2103 * by the system.
2104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2106 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2107 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002108 * Broadcast Action: An existing application package has been removed from
2109 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002110 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002111 * <ul>
2112 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2113 * to the package.
2114 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2115 * application -- data and code -- is being removed.
2116 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2117 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2118 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002119 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002120 * <p class="note">This is a protected intent that can only be sent
2121 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002122 */
2123 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2124 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2125 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002126 * Broadcast Action: An existing application package has been completely
2127 * removed from the device. The data contains the name of the package.
2128 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2129 * {@link #EXTRA_DATA_REMOVED} is true and
2130 * {@link #EXTRA_REPLACING} is false of that broadcast.
2131 *
2132 * <ul>
2133 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2134 * to the package.
2135 * </ul>
2136 *
2137 * <p class="note">This is a protected intent that can only be sent
2138 * by the system.
2139 */
2140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2141 public static final String ACTION_PACKAGE_FULLY_REMOVED
2142 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2143 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002144 * Broadcast Action: An existing application package has been changed (for
2145 * example, a component has been enabled or disabled). The data contains
2146 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002147 * <ul>
2148 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002149 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002150 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002151 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2152 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002153 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002154 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002155 * <p class="note">This is a protected intent that can only be sent
2156 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002157 */
2158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2159 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2160 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002161 * @hide
2162 * Broadcast Action: Ask system services if there is any reason to
2163 * restart the given package. The data contains the name of the
2164 * package.
2165 * <ul>
2166 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2167 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2168 * </ul>
2169 *
2170 * <p class="note">This is a protected intent that can only be sent
2171 * by the system.
2172 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002173 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2175 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2176 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002177 * Broadcast Action: The user has restarted a package, and all of its
2178 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002179 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002180 * be removed. Note that the restarted package does <em>not</em>
2181 * receive this broadcast.
2182 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002183 * <ul>
2184 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2185 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002186 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002187 * <p class="note">This is a protected intent that can only be sent
2188 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002189 */
2190 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2191 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2192 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002193 * Broadcast Action: The user has cleared the data of a package. This should
2194 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002195 * its persistent data is erased and this broadcast sent.
2196 * Note that the cleared package does <em>not</em>
2197 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002198 * <ul>
2199 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2200 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002201 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002202 * <p class="note">This is a protected intent that can only be sent
2203 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2207 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002208 * Broadcast Action: Packages have been suspended.
2209 * <p>Includes the following extras:
2210 * <ul>
2211 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2212 * </ul>
2213 *
2214 * <p class="note">This is a protected intent that can only be sent
2215 * by the system. It is only sent to registered receivers.
2216 */
2217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2219 /**
2220 * Broadcast Action: Packages have been unsuspended.
2221 * <p>Includes the following extras:
2222 * <ul>
2223 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2224 * </ul>
2225 *
2226 * <p class="note">This is a protected intent that can only be sent
2227 * by the system. It is only sent to registered receivers.
2228 */
2229 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2230 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2231 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002232 * Broadcast Action: A user ID has been removed from the system. The user
2233 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002234 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002235 * <p class="note">This is a protected intent that can only be sent
2236 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002240
2241 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002242 * Broadcast Action: Sent to the installer package of an application when
2243 * that application is first launched (that is the first time it is moved
2244 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002245 *
2246 * <p class="note">This is a protected intent that can only be sent
2247 * by the system.
2248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2250 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2251
2252 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002253 * Broadcast Action: Sent to the system package verifier when a package
2254 * needs to be verified. The data contains the package URI.
2255 * <p class="note">
2256 * This is a protected intent that can only be sent by the system.
2257 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002258 */
2259 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2260 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2261
2262 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002263 * Broadcast Action: Sent to the system package verifier when a package is
2264 * verified. The data contains the package URI.
2265 * <p class="note">
2266 * This is a protected intent that can only be sent by the system.
2267 */
2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2269 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2270
2271 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002272 * Broadcast Action: Sent to the system intent filter verifier when an
2273 * intent filter needs to be verified. The data contains the filter data
2274 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002275 * <p class="note">
2276 * This is a protected intent that can only be sent by the system.
2277 * </p>
2278 *
2279 * @hide
2280 */
2281 @SystemApi
2282 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2283 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2284
2285 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002286 * Broadcast Action: Resources for a set of packages (which were
2287 * previously unavailable) are currently
2288 * available since the media on which they exist is available.
2289 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2290 * list of packages whose availability changed.
2291 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2292 * list of uids of packages whose availability changed.
2293 * Note that the
2294 * packages in this list do <em>not</em> receive this broadcast.
2295 * The specified set of packages are now available on the system.
2296 * <p>Includes the following extras:
2297 * <ul>
2298 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2299 * whose resources(were previously unavailable) are currently available.
2300 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2301 * packages whose resources(were previously unavailable)
2302 * are currently available.
2303 * </ul>
2304 *
2305 * <p class="note">This is a protected intent that can only be sent
2306 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002307 */
2308 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002309 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2310 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002311
2312 /**
2313 * Broadcast Action: Resources for a set of packages are currently
2314 * unavailable since the media on which they exist is unavailable.
2315 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2316 * list of packages whose availability changed.
2317 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2318 * list of uids of packages whose availability changed.
2319 * The specified set of packages can no longer be
2320 * launched and are practically unavailable on the system.
2321 * <p>Inclues the following extras:
2322 * <ul>
2323 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2324 * whose resources are no longer available.
2325 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2326 * whose resources are no longer available.
2327 * </ul>
2328 *
2329 * <p class="note">This is a protected intent that can only be sent
2330 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002331 */
2332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002333 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002334 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002335
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002336 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002337 * Broadcast Action: preferred activities have changed *explicitly*.
2338 *
2339 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2340 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2341 * be sent.
2342 *
2343 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2344 *
2345 * @hide
2346 */
2347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2348 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2349 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2350
2351
2352 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002353 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002354 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002355 * This should <em>only</em> be used to determine when the wallpaper
2356 * has changed to show the new wallpaper to the user. You should certainly
2357 * never, in response to this, change the wallpaper or other attributes of
2358 * it such as the suggested size. That would be crazy, right? You'd cause
2359 * all kinds of loops, especially if other apps are doing similar things,
2360 * right? Of course. So please don't do this.
2361 *
2362 * @deprecated Modern applications should use
2363 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2364 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2365 * shown behind their UI, rather than watching for this broadcast and
2366 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002367 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002368 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2370 /**
2371 * Broadcast Action: The current device {@link android.content.res.Configuration}
2372 * (orientation, locale, etc) has changed. When such a change happens, the
2373 * UIs (view hierarchy) will need to be rebuilt based on this new
2374 * information; for the most part, applications don't need to worry about
2375 * this, because the system will take care of stopping and restarting the
2376 * application to make sure it sees the new changes. Some system code that
2377 * can not be restarted will need to watch for this action and handle it
2378 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002379 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002380 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002381 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002382 * in manifests, only by explicitly registering for it with
2383 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2384 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002385 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002386 * <p class="note">This is a protected intent that can only be sent
2387 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002388 *
2389 * @see android.content.res.Configuration
2390 */
2391 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2392 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2393 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002394 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002395 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002396 * <p class="note">This is a protected intent that can only be sent
2397 * by the system.
2398 */
2399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2400 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2401 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002402 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2403 * charging state, level, and other information about the battery.
2404 * See {@link android.os.BatteryManager} for documentation on the
2405 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002406 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002407 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002408 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002409 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002410 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002411 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2412 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2413 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2414 * broadcasts that are sent and can be received through manifest
2415 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002416 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002417 * <p class="note">This is a protected intent that can only be sent
2418 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002419 */
2420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2421 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2422 /**
2423 * Broadcast Action: Indicates low battery condition on the device.
2424 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002425 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002426 * <p class="note">This is a protected intent that can only be sent
2427 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002428 */
2429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2430 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2431 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002432 * Broadcast Action: Indicates the battery is now okay after being low.
2433 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2434 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002435 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002436 * <p class="note">This is a protected intent that can only be sent
2437 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002438 */
2439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2440 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2441 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002442 * Broadcast Action: External power has been connected to the device.
2443 * This is intended for applications that wish to register specifically to this notification.
2444 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2445 * stay active to receive this notification. This action can be used to implement actions
2446 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002447 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002448 * <p class="note">This is a protected intent that can only be sent
2449 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002452 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002453 /**
2454 * Broadcast Action: External power has been removed from the device.
2455 * This is intended for applications that wish to register specifically to this notification.
2456 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2457 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002458 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002459 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002460 * <p class="note">This is a protected intent that can only be sent
2461 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002462 */
2463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002464 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002465 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002466 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002467 * Broadcast Action: Device is shutting down.
2468 * This is broadcast when the device is being shut down (completely turned
2469 * off, not sleeping). Once the broadcast is complete, the final shutdown
2470 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002471 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002472 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002473 * <p class="note">This is a protected intent that can only be sent
2474 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002475 * <p>May include the following extras:
2476 * <ul>
2477 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2478 * shutdown is only for userspace processes. If not set, assumed to be false.
2479 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002480 */
2481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002482 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002483 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002484 * Activity Action: Start this activity to request system shutdown.
2485 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002486 * to request confirmation from the user before shutting down. The optional boolean
2487 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2488 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002489 *
2490 * <p class="note">This is a protected intent that can only be sent
2491 * by the system.
2492 *
2493 * {@hide}
2494 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002495 public static final String ACTION_REQUEST_SHUTDOWN
2496 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002497 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002498 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002499 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002500 * <p class="note">
2501 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002502 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002503 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2504 * or above, this broadcast will no longer be delivered to any
2505 * {@link BroadcastReceiver} defined in your manifest. Instead,
2506 * apps are strongly encouraged to use the improved
2507 * {@link Context#getCacheDir()} behavior so the system can
2508 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002509 */
2510 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002511 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002512 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2513 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002514 * Broadcast Action: Indicates low storage space condition on the device no
2515 * longer exists
2516 * <p class="note">
2517 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002518 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002519 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2520 * or above, this broadcast will no longer be delivered to any
2521 * {@link BroadcastReceiver} defined in your manifest. Instead,
2522 * apps are strongly encouraged to use the improved
2523 * {@link Context#getCacheDir()} behavior so the system can
2524 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002525 */
2526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002527 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002528 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2529 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002530 * Broadcast Action: A sticky broadcast that indicates a storage space full
2531 * condition on the device. This is intended for activities that want to be
2532 * able to fill the data partition completely, leaving only enough free
2533 * space to prevent system-wide SQLite failures.
2534 * <p class="note">
2535 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002536 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002537 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2538 * or above, this broadcast will no longer be delivered to any
2539 * {@link BroadcastReceiver} defined in your manifest. Instead,
2540 * apps are strongly encouraged to use the improved
2541 * {@link Context#getCacheDir()} behavior so the system can
2542 * automatically free up storage when needed.
2543 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002546 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002547 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2548 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 * Broadcast Action: Indicates storage space full condition on the device no
2550 * longer exists.
2551 * <p class="note">
2552 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002553 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002554 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2555 * or above, this broadcast will no longer be delivered to any
2556 * {@link BroadcastReceiver} defined in your manifest. Instead,
2557 * apps are strongly encouraged to use the improved
2558 * {@link Context#getCacheDir()} behavior so the system can
2559 * automatically free up storage when needed.
2560 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002561 */
2562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002563 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002564 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2565 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002566 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2567 * and package management should be started.
2568 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2569 * notification.
2570 */
2571 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2572 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2573 /**
2574 * Broadcast Action: The device has entered USB Mass Storage mode.
2575 * This is used mainly for the USB Settings panel.
2576 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2577 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002578 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002580 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002581 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2582
2583 /**
2584 * Broadcast Action: The device has exited USB Mass Storage mode.
2585 * This is used mainly for the USB Settings panel.
2586 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2587 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002588 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002590 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002591 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2592
2593 /**
2594 * Broadcast Action: External media has been removed.
2595 * The path to the mount point for the removed media is contained in the Intent.mData field.
2596 */
2597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2598 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2599
2600 /**
2601 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002602 * 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 -07002603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2606
2607 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002608 * Broadcast Action: External media is present, and being disk-checked
2609 * 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 -08002610 */
2611 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2612 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2613
2614 /**
2615 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2616 * 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 -08002617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2619 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2620
2621 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002622 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002623 * 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 -07002624 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2625 * media was mounted read only.
2626 */
2627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2629
2630 /**
2631 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002632 * 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 -07002633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2636
2637 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002638 * Broadcast Action: External media is no longer being shared via USB mass storage.
2639 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2640 *
2641 * @hide
2642 */
2643 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2644
2645 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002646 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2647 * The path to the mount point for the removed media is contained in the Intent.mData field.
2648 */
2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2651
2652 /**
2653 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002654 * 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 -07002655 */
2656 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2657 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2658
2659 /**
2660 * Broadcast Action: User has expressed the desire to remove the external storage media.
2661 * Applications should close all files they have open within the mount point when they receive this intent.
2662 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2666
2667 /**
2668 * Broadcast Action: The media scanner has started scanning a directory.
2669 * The path to the directory being scanned is contained in the Intent.mData field.
2670 */
2671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2672 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2673
2674 /**
2675 * Broadcast Action: The media scanner has finished scanning a directory.
2676 * The path to the scanned directory is contained in the Intent.mData field.
2677 */
2678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2679 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2680
2681 /**
2682 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2683 * The path to the file is contained in the Intent.mData field.
2684 */
2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2686 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2687
2688 /**
2689 * Broadcast Action: The "Media Button" was pressed. Includes a single
2690 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2691 * caused the broadcast.
2692 */
2693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2695
2696 /**
2697 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2698 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2699 * caused the broadcast.
2700 */
2701 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2702 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2703
2704 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2705 // location; they are not general-purpose actions.
2706
2707 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002708 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002709 */
2710 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2711 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2712 "android.intent.action.GTALK_CONNECTED";
2713
2714 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002715 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002716 */
2717 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2718 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2719 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002720
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002721 /**
2722 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002723 */
2724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2725 public static final String ACTION_INPUT_METHOD_CHANGED =
2726 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727
2728 /**
2729 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2730 * more radios have been turned off or on. The intent will have the following extra value:</p>
2731 * <ul>
2732 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2733 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2734 * turned off</li>
2735 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002736 *
Peng Xua35b5532016-01-20 00:05:45 -08002737 * <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 -07002738 */
2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2741
2742 /**
2743 * Broadcast Action: Some content providers have parts of their namespace
2744 * where they publish new events or items that the user may be especially
2745 * interested in. For these things, they may broadcast this action when the
2746 * set of interesting items change.
2747 *
2748 * For example, GmailProvider sends this notification when the set of unread
2749 * mail in the inbox changes.
2750 *
2751 * <p>The data of the intent identifies which part of which provider
2752 * changed. When queried through the content resolver, the data URI will
2753 * return the data set in question.
2754 *
2755 * <p>The intent will have the following extra values:
2756 * <ul>
2757 * <li><em>count</em> - The number of items in the data set. This is the
2758 * same as the number of items in the cursor returned by querying the
2759 * data URI. </li>
2760 * </ul>
2761 *
2762 * This intent will be sent at boot (if the count is non-zero) and when the
2763 * data set changes. It is possible for the data set to change without the
2764 * count changing (for example, if a new unread message arrives in the same
2765 * sync operation in which a message is archived). The phone should still
2766 * ring/vibrate/etc as normal in this case.
2767 */
2768 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2769 public static final String ACTION_PROVIDER_CHANGED =
2770 "android.intent.action.PROVIDER_CHANGED";
2771
2772 /**
2773 * Broadcast Action: Wired Headset plugged in or unplugged.
2774 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002775 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2776 * and documentation.
2777 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002778 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002779 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002780 */
2781 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002782 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002783
2784 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002785 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2786 * <ul>
2787 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2788 * </ul>
2789 *
2790 * <p class="note">This is a protected intent that can only be sent
2791 * by the system.
2792 *
2793 * @hide
2794 */
2795 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2796 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2797 = "android.intent.action.ADVANCED_SETTINGS";
2798
2799 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002800 * Broadcast Action: Sent after application restrictions are changed.
2801 *
2802 * <p class="note">This is a protected intent that can only be sent
2803 * by the system.</p>
2804 */
2805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2806 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2807 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2808
2809 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002810 * Broadcast Action: An outgoing call is about to be placed.
2811 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002812 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002814 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002815 * the phone number originally intended to be dialed.</li>
2816 * </ul>
2817 * <p>Once the broadcast is finished, the resultData is used as the actual
2818 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002819 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002820 * outgoing call in turn: for example, a parental control application
2821 * might verify that the user is authorized to place the call at that
2822 * time, then a number-rewriting application might add an area code if
2823 * one was not specified.</p>
2824 * <p>For consistency, any receiver whose purpose is to prohibit phone
2825 * calls should have a priority of 0, to ensure it will see the final
2826 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002827 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002828 * should have a positive priority.
2829 * Negative priorities are reserved for the system for this broadcast;
2830 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002831 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2832 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002833 * <p>Emergency calls cannot be intercepted using this mechanism, and
2834 * other calls cannot be modified to call emergency numbers using this
2835 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002836 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2837 * call to use their own service instead. Those apps should first prevent
2838 * the call from being placed by setting resultData to <code>null</code>
2839 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002840 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002841 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2842 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002843 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002844 * <p class="note">This is a protected intent that can only be sent
2845 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002846 */
2847 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2848 public static final String ACTION_NEW_OUTGOING_CALL =
2849 "android.intent.action.NEW_OUTGOING_CALL";
2850
2851 /**
2852 * Broadcast Action: Have the device reboot. This is only for use by
2853 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002854 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002855 * <p class="note">This is a protected intent that can only be sent
2856 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002857 */
2858 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2859 public static final String ACTION_REBOOT =
2860 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002861
Wei Huang97ecc9c2009-05-11 17:44:20 -07002862 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002863 * Broadcast Action: A sticky broadcast for changes in the physical
2864 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002865 *
2866 * <p>The intent will have the following extra values:
2867 * <ul>
2868 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002869 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002870 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002871 * <p>This is intended for monitoring the current physical dock state.
2872 * See {@link android.app.UiModeManager} for the normal API dealing with
2873 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002874 */
2875 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2876 public static final String ACTION_DOCK_EVENT =
2877 "android.intent.action.DOCK_EVENT";
2878
2879 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002880 * Broadcast Action: A broadcast when idle maintenance can be started.
2881 * This means that the user is not interacting with the device and is
2882 * not expected to do so soon. Typical use of the idle maintenance is
2883 * to perform somehow expensive tasks that can be postponed at a moment
2884 * when they will not degrade user experience.
2885 * <p>
2886 * <p class="note">In order to keep the device responsive in case of an
2887 * unexpected user interaction, implementations of a maintenance task
2888 * should be interruptible. In such a scenario a broadcast with action
2889 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2890 * should not do the maintenance work in
2891 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2892 * maintenance service by {@link Context#startService(Intent)}. Also
2893 * you should hold a wake lock while your maintenance service is running
2894 * to prevent the device going to sleep.
2895 * </p>
2896 * <p>
2897 * <p class="note">This is a protected intent that can only be sent by
2898 * the system.
2899 * </p>
2900 *
2901 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002902 *
2903 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002904 */
2905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2906 public static final String ACTION_IDLE_MAINTENANCE_START =
2907 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2908
2909 /**
2910 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2911 * This means that the user was not interacting with the device as a result
2912 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2913 * was sent and now the user started interacting with the device. Typical
2914 * use of the idle maintenance is to perform somehow expensive tasks that
2915 * can be postponed at a moment when they will not degrade user experience.
2916 * <p>
2917 * <p class="note">In order to keep the device responsive in case of an
2918 * unexpected user interaction, implementations of a maintenance task
2919 * should be interruptible. Hence, on receiving a broadcast with this
2920 * action, the maintenance task should be interrupted as soon as possible.
2921 * In other words, you should not do the maintenance work in
2922 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2923 * maintenance service that was started on receiving of
2924 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2925 * lock you acquired when your maintenance service started.
2926 * </p>
2927 * <p class="note">This is a protected intent that can only be sent
2928 * by the system.
2929 *
2930 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002931 *
2932 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002933 */
2934 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2935 public static final String ACTION_IDLE_MAINTENANCE_END =
2936 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2937
2938 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002939 * Broadcast Action: a remote intent is to be broadcasted.
2940 *
2941 * A remote intent is used for remote RPC between devices. The remote intent
2942 * is serialized and sent from one device to another device. The receiving
2943 * device parses the remote intent and broadcasts it. Note that anyone can
2944 * broadcast a remote intent. However, if the intent receiver of the remote intent
2945 * does not trust intent broadcasts from arbitrary intent senders, it should require
2946 * the sender to hold certain permissions so only trusted sender's broadcast will be
2947 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002948 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002949 */
2950 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002951 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002952
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002953 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002954 * Broadcast Action: This is broadcast once when the user is booting after a
2955 * system update. It can be used to perform cleanup or upgrades after a
2956 * system update.
2957 * <p>
2958 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2959 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2960 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2961 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002962 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002963 * @hide
2964 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002965 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002966 public static final String ACTION_PRE_BOOT_COMPLETED =
2967 "android.intent.action.PRE_BOOT_COMPLETED";
2968
Amith Yamasani13593602012-03-22 16:16:17 -07002969 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002970 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002971 * on restricted users. The broadcast intent contains an extra
2972 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2973 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2974 * String[] depending on the restriction type.<p/>
2975 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002976 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2977 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2978 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002979 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2980 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002981 * @see RestrictionEntry
2982 */
2983 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2984 "android.intent.action.GET_RESTRICTION_ENTRIES";
2985
2986 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002987 * Sent the first time a user is starting, to allow system apps to
2988 * perform one time initialization. (This will not be seen by third
2989 * party applications because a newly initialized user does not have any
2990 * third party applications installed for it.) This is sent early in
2991 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002992 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2993 * broadcast, since it is part of a visible user interaction; be as quick
2994 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002995 */
2996 public static final String ACTION_USER_INITIALIZE =
2997 "android.intent.action.USER_INITIALIZE";
2998
2999 /**
3000 * Sent when a user switch is happening, causing the process's user to be
3001 * brought to the foreground. This is only sent to receivers registered
3002 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3003 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003004 * foreground. This is sent as a foreground
3005 * broadcast, since it is part of a visible user interaction; be as quick
3006 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003007 */
3008 public static final String ACTION_USER_FOREGROUND =
3009 "android.intent.action.USER_FOREGROUND";
3010
3011 /**
3012 * Sent when a user switch is happening, causing the process's user to be
3013 * sent to the background. This is only sent to receivers registered
3014 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3015 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003016 * background. This is sent as a foreground
3017 * broadcast, since it is part of a visible user interaction; be as quick
3018 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003019 */
3020 public static final String ACTION_USER_BACKGROUND =
3021 "android.intent.action.USER_BACKGROUND";
3022
3023 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003024 * Broadcast sent to the system when a user is added. Carries an extra
3025 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3026 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003027 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003028 * @hide
3029 */
3030 public static final String ACTION_USER_ADDED =
3031 "android.intent.action.USER_ADDED";
3032
3033 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003034 * Broadcast sent by the system when a user is started. Carries an extra
3035 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003036 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003037 * that has been started. This is sent as a foreground
3038 * broadcast, since it is part of a visible user interaction; be as quick
3039 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003040 * @hide
3041 */
3042 public static final String ACTION_USER_STARTED =
3043 "android.intent.action.USER_STARTED";
3044
3045 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003046 * Broadcast sent when a user is in the process of starting. Carries an extra
3047 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3048 * sent to registered receivers, not manifest receivers. It is sent to all
3049 * users (including the one that is being started). You must hold
3050 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3051 * this broadcast. This is sent as a background broadcast, since
3052 * its result is not part of the primary UX flow; to safely keep track of
3053 * started/stopped state of a user you can use this in conjunction with
3054 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3055 * other user state broadcasts since those are foreground broadcasts so can
3056 * execute in a different order.
3057 * @hide
3058 */
3059 public static final String ACTION_USER_STARTING =
3060 "android.intent.action.USER_STARTING";
3061
3062 /**
3063 * Broadcast sent when a user is going to be stopped. Carries an extra
3064 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3065 * sent to registered receivers, not manifest receivers. It is sent to all
3066 * users (including the one that is being stopped). You must hold
3067 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3068 * this broadcast. The user will not stop until all receivers have
3069 * handled the broadcast. This is sent as a background broadcast, since
3070 * its result is not part of the primary UX flow; to safely keep track of
3071 * started/stopped state of a user you can use this in conjunction with
3072 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3073 * other user state broadcasts since those are foreground broadcasts so can
3074 * execute in a different order.
3075 * @hide
3076 */
3077 public static final String ACTION_USER_STOPPING =
3078 "android.intent.action.USER_STOPPING";
3079
3080 /**
3081 * Broadcast sent to the system when a user is stopped. Carries an extra
3082 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3083 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3084 * specific package. This is only sent to registered receivers, not manifest
3085 * receivers. It is sent to all running users <em>except</em> the one that
3086 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003087 * @hide
3088 */
3089 public static final String ACTION_USER_STOPPED =
3090 "android.intent.action.USER_STOPPED";
3091
3092 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003093 * 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 -07003094 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003095 * one that has been removed. The user will not be completely removed until all receivers have
3096 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003097 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003098 * @hide
3099 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003100 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003101 public static final String ACTION_USER_REMOVED =
3102 "android.intent.action.USER_REMOVED";
3103
3104 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003105 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003106 * the userHandle of the user to become the current one. This is only sent to
3107 * registered receivers, not manifest receivers. It is sent to all running users.
3108 * You must hold
3109 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003110 * @hide
3111 */
3112 public static final String ACTION_USER_SWITCHED =
3113 "android.intent.action.USER_SWITCHED";
3114
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003115 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003116 * Broadcast Action: Sent when the credential-encrypted private storage has
3117 * become unlocked for the target user. This is only sent to registered
3118 * receivers, not manifest receivers.
3119 */
3120 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3121 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3122
3123 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003124 * Broadcast sent to the system when a user's information changes. Carries an extra
3125 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003126 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003127 * @hide
3128 */
3129 public static final String ACTION_USER_INFO_CHANGED =
3130 "android.intent.action.USER_INFO_CHANGED";
3131
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003132 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003133 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3134 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003135 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3136 * that need to display merged content across both primary and managed profiles need to
3137 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003138 * not manifest receivers.
3139 */
3140 public static final String ACTION_MANAGED_PROFILE_ADDED =
3141 "android.intent.action.MANAGED_PROFILE_ADDED";
3142
3143 /**
3144 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003145 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3146 * Only applications (for example Launchers) that need to display merged content across both
3147 * primary and managed profiles need to worry about this broadcast. This is only sent to
3148 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003149 */
3150 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3151 "android.intent.action.MANAGED_PROFILE_REMOVED";
3152
3153 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003154 * Broadcast sent to the primary user when the credential-encrypted private storage for
3155 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3156 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3157 * Launchers) that need to display merged content across both primary and managed profiles
3158 * need to worry about this broadcast. This is only sent to registered receivers,
3159 * not manifest receivers.
3160 */
3161 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3162 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3163
3164 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003165 * Broadcast sent to the primary user when an associated managed profile has become available.
3166 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003167 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3168 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3169 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003170 */
Rubin Xue95057a2016-04-01 16:49:25 +01003171 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3172 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3173
3174 /**
3175 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3176 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3177 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3178 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3179 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3180 */
3181 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3182 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003183
3184 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003185 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3186 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3187 * the device was locked or unlocked.
3188 *
3189 * This is only sent to registered receivers.
3190 *
3191 * @hide
3192 */
3193 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3194 "android.intent.action.DEVICE_LOCKED_CHANGED";
3195
3196 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003197 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3198 */
3199 public static final String ACTION_QUICK_CLOCK =
3200 "android.intent.action.QUICK_CLOCK";
3201
Michael Wright0087a142013-02-05 16:29:39 -08003202 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003203 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003204 * @hide
3205 */
3206 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003207 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003208
Justin Kohd378ad72013-04-01 12:18:26 -07003209 /**
3210 * Broadcast Action: A global button was pressed. Includes a single
3211 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3212 * caused the broadcast.
3213 * @hide
3214 */
3215 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3216
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003217 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003218 * Broadcast Action: Sent when media resource is granted.
3219 * <p>
3220 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3221 * granted.
3222 * </p>
3223 * <p class="note">
3224 * This is a protected intent that can only be sent by the system.
3225 * </p>
3226 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003227 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003228 * </p>
3229 *
3230 * @hide
3231 */
3232 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3233 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3234
3235 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003236 * Broadcast Action: An overlay package has changed. The data contains the
3237 * name of the overlay package which has changed. This is broadcast on all
3238 * changes to the OverlayInfo returned by {@link
3239 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3240 * most common change is a state change that will change whether the
3241 * overlay is enabled or not.
3242 * @hide
3243 */
3244 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3245
3246 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003247 * Activity Action: Allow the user to select and return one or more existing
3248 * documents. When invoked, the system will display the various
3249 * {@link DocumentsProvider} instances installed on the device, letting the
3250 * user interactively navigate through them. These documents include local
3251 * media, such as photos and video, and documents provided by installed
3252 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003253 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003254 * Each document is represented as a {@code content://} URI backed by a
3255 * {@link DocumentsProvider}, which can be opened as a stream with
3256 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3257 * {@link android.provider.DocumentsContract.Document} metadata.
3258 * <p>
3259 * All selected documents are returned to the calling application with
3260 * persistable read and write permission grants. If you want to maintain
3261 * access to the documents across device reboots, you need to explicitly
3262 * take the persistable permissions using
3263 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3264 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003265 * Callers must indicate the acceptable document MIME types through
3266 * {@link #setType(String)}. For example, to select photos, use
3267 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3268 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3269 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003270 * <p>
3271 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003272 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3273 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003274 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003275 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3276 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003277 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003278 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003279 * Callers can set a document URI through
3280 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3281 * location of documents navigator. System will do its best to launch the
3282 * navigator in the specified document if it's a folder, or the folder that
3283 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003284 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003285 * Output: The URI of the item that was picked, returned in
3286 * {@link #getData()}. This must be a {@code content://} URI so that any
3287 * receiver can access it. If multiple documents were selected, they are
3288 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003289 *
3290 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003291 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003292 * @see #ACTION_CREATE_DOCUMENT
3293 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003294 */
3295 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3296 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3297
3298 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003299 * Activity Action: Allow the user to create a new document. When invoked,
3300 * the system will display the various {@link DocumentsProvider} instances
3301 * installed on the device, letting the user navigate through them. The
3302 * returned document may be a newly created document with no content, or it
3303 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003304 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003305 * Each document is represented as a {@code content://} URI backed by a
3306 * {@link DocumentsProvider}, which can be opened as a stream with
3307 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3308 * {@link android.provider.DocumentsContract.Document} metadata.
3309 * <p>
3310 * Callers must indicate the concrete MIME type of the document being
3311 * created by setting {@link #setType(String)}. This MIME type cannot be
3312 * changed after the document is created.
3313 * <p>
3314 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3315 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003316 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003317 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3318 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003319 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003320 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003321 * Callers can set a document URI through
3322 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3323 * location of documents navigator. System will do its best to launch the
3324 * navigator in the specified document if it's a folder, or the folder that
3325 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003326 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003327 * Output: The URI of the item that was created. This must be a
3328 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003329 *
3330 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003331 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003332 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003333 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003334 */
3335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3336 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3337
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003338 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003339 * Activity Action: Allow the user to pick a directory subtree. When
3340 * invoked, the system will display the various {@link DocumentsProvider}
3341 * instances installed on the device, letting the user navigate through
3342 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003343 * <p>
3344 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003345 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3346 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3347 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003348 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003349 * Callers can set a document URI through
3350 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3351 * location of documents navigator. System will do its best to launch the
3352 * navigator in the specified document if it's a folder, or the folder that
3353 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003354 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003355 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003356 *
3357 * @see DocumentsContract
3358 */
3359 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003360 public static final String
3361 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003362
Felipe Lemec7b1f892016-01-15 15:02:31 -08003363 /**
Peng Xua35b5532016-01-20 00:05:45 -08003364 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3365 * exisiting sensor being disconnected.
3366 *
3367 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3368 *
3369 * {@hide}
3370 */
3371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3372 public static final String
3373 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3374
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003375 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003376 * Broadcast Action: The default subscription has changed. This has the following
3377 * extra values:</p>
3378 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3379 */
3380 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3381 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3382 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3383
3384 /**
3385 * Broadcast Action: The default sms subscription has changed. This has the following
3386 * extra values:</p>
3387 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3388 * subscription index
3389 */
3390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3391 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3392 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3393
3394 /**
3395 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3396 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3397 * which has changed.
3398 */
3399 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3400
3401 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003402 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3403 *
3404 * {@hide}
3405 */
3406 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003407 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3408
Christopher Tate6597e342015-02-17 12:15:25 -08003409 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003410 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3411 * is about to be performed.
3412 * @hide
3413 */
3414 @SystemApi
3415 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3416 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3417 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3418
3419 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003420 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3421 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3422 *
3423 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3424 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003425 * @hide
3426 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003427 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003428 public static final String EXTRA_FORCE_MASTER_CLEAR =
3429 "android.intent.extra.FORCE_MASTER_CLEAR";
3430
3431 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003432 * A broadcast action to trigger a factory reset.
3433 *
3434 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3435 *
3436 * <p>Not for use by third-party applications.
3437 *
3438 * @see #EXTRA_FORCE_MASTER_CLEAR
3439 *
3440 * {@hide}
3441 */
3442 @SystemApi
3443 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3444 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3445
3446 /**
3447 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3448 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3449 *
3450 * <p>Not for use by third-party applications.
3451 *
3452 * @hide
3453 */
3454 @SystemApi
3455 public static final String EXTRA_FORCE_FACTORY_RESET =
3456 "android.intent.extra.FORCE_FACTORY_RESET";
3457
3458 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003459 * Broadcast action: report that a settings element is being restored from backup. The intent
3460 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3461 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3462 * is the value of that settings entry prior to the restore operation. All of these values are
3463 * represented as strings.
3464 *
3465 * <p>This broadcast is sent only for settings provider entries known to require special handling
3466 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3467 * the provider's backup agent implementation.
3468 *
3469 * @see #EXTRA_SETTING_NAME
3470 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3471 * @see #EXTRA_SETTING_NEW_VALUE
3472 * {@hide}
3473 */
3474 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3475
3476 /** {@hide} */
3477 public static final String EXTRA_SETTING_NAME = "setting_name";
3478 /** {@hide} */
3479 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3480 /** {@hide} */
3481 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3482
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003483 /**
3484 * Activity Action: Process a piece of text.
3485 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3486 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3487 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3488 */
3489 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3490 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003491
3492 /**
3493 * Broadcast Action: The sim card state has changed.
3494 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3495 * because TelephonyIntents is an internal class.
3496 * @hide
3497 */
3498 @SystemApi
3499 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3500 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3501
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003502 /**
fionaxu90fee272017-03-31 12:45:12 -07003503 * Broadcast Action: indicate that the phone service state has changed.
3504 * The intent will have the following extra values:</p>
3505 * <p>
3506 * @see #EXTRA_VOICE_REG_STATE
3507 * @see #EXTRA_DATA_REG_STATE
3508 * @see #EXTRA_VOICE_ROAMING_TYPE
3509 * @see #EXTRA_DATA_ROAMING_TYPE
3510 * @see #EXTRA_OPERATOR_ALPHA_LONG
3511 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3512 * @see #EXTRA_OPERATOR_NUMERIC
3513 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3514 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3515 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3516 * @see #EXTRA_MANUAL
3517 * @see #EXTRA_VOICE_RADIO_TECH
3518 * @see #EXTRA_DATA_RADIO_TECH
3519 * @see #EXTRA_CSS_INDICATOR
3520 * @see #EXTRA_NETWORK_ID
3521 * @see #EXTRA_SYSTEM_ID
3522 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3523 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3524 * @see #EXTRA_EMERGENCY_ONLY
3525 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3526 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3527 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3528 *
3529 * <p class="note">
3530 * Requires the READ_PHONE_STATE permission.
3531 *
3532 * <p class="note">This is a protected intent that can only be sent by the system.
3533 * @hide
3534 */
3535 @Deprecated
3536 @SystemApi
3537 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3538 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3539
3540 /**
3541 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3542 * state.
3543 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3544 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3545 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3546 * @see android.telephony.ServiceState#STATE_POWER_OFF
3547 * @hide
3548 */
3549 @Deprecated
3550 @SystemApi
3551 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3552
3553 /**
3554 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3555 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3556 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3557 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3558 * @see android.telephony.ServiceState#STATE_POWER_OFF
3559 * @hide
3560 */
3561 @Deprecated
3562 @SystemApi
3563 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3564
3565 /**
3566 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3567 * type.
3568 * @hide
3569 */
3570 @Deprecated
3571 @SystemApi
3572 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3573
3574 /**
3575 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3576 * type.
3577 * @hide
3578 */
3579 @Deprecated
3580 @SystemApi
3581 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3582
3583 /**
3584 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3585 * registered voice operator name in long alphanumeric format.
3586 * {@code null} if the operator name is not known or unregistered.
3587 * @hide
3588 */
3589 @Deprecated
3590 @SystemApi
3591 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3592
3593 /**
3594 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3595 * registered voice operator name in short alphanumeric format.
3596 * {@code null} if the operator name is not known or unregistered.
3597 * @hide
3598 */
3599 @Deprecated
3600 @SystemApi
3601 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3602
3603 /**
3604 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3605 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3606 * network.
3607 * @hide
3608 */
3609 @Deprecated
3610 @SystemApi
3611 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3612
3613 /**
3614 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3615 * registered data operator name in long alphanumeric format.
3616 * {@code null} if the operator name is not known or unregistered.
3617 * @hide
3618 */
3619 @Deprecated
3620 @SystemApi
3621 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3622
3623 /**
3624 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3625 * registered data operator name in short alphanumeric format.
3626 * {@code null} if the operator name is not known or unregistered.
3627 * @hide
3628 */
3629 @Deprecated
3630 @SystemApi
3631 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3632
3633 /**
3634 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3635 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3636 * data operator.
3637 * @hide
3638 */
3639 @Deprecated
3640 @SystemApi
3641 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3642
3643 /**
3644 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3645 * network selection mode is manual.
3646 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3647 * @hide
3648 */
3649 @Deprecated
3650 @SystemApi
3651 public static final String EXTRA_MANUAL = "manual";
3652
3653 /**
3654 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3655 * radio technology.
3656 * @hide
3657 */
3658 @Deprecated
3659 @SystemApi
3660 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3661
3662 /**
3663 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3664 * radio technology.
3665 * @hide
3666 */
3667 @Deprecated
3668 @SystemApi
3669 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3670
3671 /**
3672 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3673 * support on CDMA network.
3674 * Will be {@code true} if support, {@code false} otherwise.
3675 * @hide
3676 */
3677 @Deprecated
3678 @SystemApi
3679 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3680
3681 /**
3682 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3683 * id. {@code Integer.MAX_VALUE} if unknown.
3684 * @hide
3685 */
3686 @Deprecated
3687 @SystemApi
3688 public static final String EXTRA_NETWORK_ID = "networkId";
3689
3690 /**
3691 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3692 * {@code Integer.MAX_VALUE} if unknown.
3693 * @hide
3694 */
3695 @Deprecated
3696 @SystemApi
3697 public static final String EXTRA_SYSTEM_ID = "systemId";
3698
3699 /**
3700 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3701 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3702 * @hide
3703 */
3704 @Deprecated
3705 @SystemApi
3706 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3707
3708 /**
3709 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3710 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3711 * @hide
3712 */
3713 @Deprecated
3714 @SystemApi
3715 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3716
3717 /**
3718 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3719 * only mode.
3720 * {@code true} if in emergency only mode, {@code false} otherwise.
3721 * @hide
3722 */
3723 @Deprecated
3724 @SystemApi
3725 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3726
3727 /**
3728 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3729 * registration state is roaming.
3730 * {@code true} if registration indicates roaming, {@code false} otherwise
3731 * @hide
3732 */
3733 @Deprecated
3734 @SystemApi
3735 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3736 "isDataRoamingFromRegistration";
3737
3738 /**
3739 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3740 * aggregation is in use.
3741 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3742 * @hide
3743 */
3744 @Deprecated
3745 @SystemApi
3746 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3747
3748 /**
3749 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3750 * is reduced from the rsrp threshold while calculating signal strength level.
3751 * @hide
3752 */
3753 @Deprecated
3754 @SystemApi
3755 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3756
3757 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003758 * The name of the extra used to define the text to be processed, as a
3759 * CharSequence. Note that this may be a styled CharSequence, so you must use
3760 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003761 */
3762 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3763 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003764 * 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 +00003765 */
3766 public static final String EXTRA_PROCESS_TEXT_READONLY =
3767 "android.intent.extra.PROCESS_TEXT_READONLY";
3768
Bryce Leebc58f592015-09-25 16:43:01 -07003769 /**
3770 * Broadcast action: reports when a new thermal event has been reached. When the device
3771 * is reaching its maximum temperatue, the thermal level reported
3772 * {@hide}
3773 */
3774 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3775 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3776
3777 /** {@hide} */
3778 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3779
3780 /**
3781 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003782 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003783 * {@hide}
3784 */
3785 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3786
3787 /**
3788 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003789 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003790 * {@hide}
3791 */
3792 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3793
3794 /**
3795 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003796 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003797 * {@hide}
3798 */
3799 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3800
3801
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003802 // ---------------------------------------------------------------------
3803 // ---------------------------------------------------------------------
3804 // Standard intent categories (see addCategory()).
3805
3806 /**
3807 * Set if the activity should be an option for the default action
3808 * (center press) to perform on a piece of data. Setting this will
3809 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003810 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003811 * Intent when initiating an action -- it is for use in intent filters
3812 * specified in packages.
3813 */
3814 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3815 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3816 /**
3817 * Activities that can be safely invoked from a browser must support this
3818 * category. For example, if the user is viewing a web page or an e-mail
3819 * and clicks on a link in the text, the Intent generated execute that
3820 * link will require the BROWSABLE category, so that only activities
3821 * supporting this category will be considered as possible actions. By
3822 * supporting this category, you are promising that there is nothing
3823 * damaging (without user intervention) that can happen by invoking any
3824 * matching Intent.
3825 */
3826 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3827 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3828 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003829 * Categories for activities that can participate in voice interaction.
3830 * An activity that supports this category must be prepared to run with
3831 * no UI shown at all (though in some case it may have a UI shown), and
3832 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3833 */
3834 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3835 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3836 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003837 * Set if the activity should be considered as an alternative action to
3838 * the data the user is currently viewing. See also
3839 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3840 * applies to the selection in a list of items.
3841 *
3842 * <p>Supporting this category means that you would like your activity to be
3843 * displayed in the set of alternative things the user can do, usually as
3844 * part of the current activity's options menu. You will usually want to
3845 * include a specific label in the &lt;intent-filter&gt; of this action
3846 * describing to the user what it does.
3847 *
3848 * <p>The action of IntentFilter with this category is important in that it
3849 * describes the specific action the target will perform. This generally
3850 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3851 * a specific name such as "com.android.camera.action.CROP. Only one
3852 * alternative of any particular action will be shown to the user, so using
3853 * a specific action like this makes sure that your alternative will be
3854 * displayed while also allowing other applications to provide their own
3855 * overrides of that particular action.
3856 */
3857 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3858 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3859 /**
3860 * Set if the activity should be considered as an alternative selection
3861 * action to the data the user has currently selected. This is like
3862 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3863 * of items from which the user can select, giving them alternatives to the
3864 * default action that will be performed on it.
3865 */
3866 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3867 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3868 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003869 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003870 */
3871 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3872 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3873 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003874 * Should be displayed in the top-level launcher.
3875 */
3876 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3877 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3878 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003879 * Indicates an activity optimized for Leanback mode, and that should
3880 * be displayed in the Leanback launcher.
3881 */
3882 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3883 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3884 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003885 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3886 * @hide
3887 */
3888 @SystemApi
3889 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3890 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003891 * Provides information about the package it is in; typically used if
3892 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3893 * a front-door to the user without having to be shown in the all apps list.
3894 */
3895 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3896 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3897 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003898 * This is the home activity, that is the first activity that is displayed
3899 * when the device boots.
3900 */
3901 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3902 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3903 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003904 * This is the home activity that is displayed when the device is finished setting up and ready
3905 * for use.
3906 * @hide
3907 */
3908 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3909 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3910 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003911 * This is the setup wizard activity, that is the first activity that is displayed
3912 * when the user sets up the device for the first time.
3913 * @hide
3914 */
3915 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3916 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3917 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003918 * This activity is a preference panel.
3919 */
3920 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3921 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3922 /**
3923 * This activity is a development preference panel.
3924 */
3925 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3926 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3927 /**
3928 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003929 */
3930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3931 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3932 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003933 * This activity allows the user to browse and download new applications.
3934 */
3935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3936 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3937 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003938 * This activity may be exercised by the monkey or other automated test tools.
3939 */
3940 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3941 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3942 /**
3943 * To be used as a test (not part of the normal user experience).
3944 */
3945 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3946 /**
3947 * To be used as a unit test (run through the Test Harness).
3948 */
3949 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3950 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003951 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003952 * experience).
3953 */
3954 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003955
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003956 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003957 * Used to indicate that an intent only wants URIs that can be opened with
3958 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3959 * must support at least the columns defined in {@link OpenableColumns} when
3960 * queried.
3961 *
3962 * @see #ACTION_GET_CONTENT
3963 * @see #ACTION_OPEN_DOCUMENT
3964 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003965 */
3966 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3967 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3968
3969 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003970 * Used to indicate that an intent filter can accept files which are not necessarily
3971 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3972 * at least streamable via
3973 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3974 * using one of the stream types exposed via
3975 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3976 *
3977 * @see #ACTION_SEND
3978 * @see #ACTION_SEND_MULTIPLE
3979 */
3980 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3981 public static final String CATEGORY_TYPED_OPENABLE =
3982 "android.intent.category.TYPED_OPENABLE";
3983
3984 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003985 * To be used as code under test for framework instrumentation tests.
3986 */
3987 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3988 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003989 /**
3990 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003991 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3992 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003993 */
3994 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3995 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3996 /**
3997 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003998 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3999 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004000 */
4001 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4002 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004003 /**
4004 * An activity to run when device is inserted into a analog (low end) dock.
4005 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4006 * information, see {@link android.app.UiModeManager}.
4007 */
4008 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4009 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4010
4011 /**
4012 * An activity to run when device is inserted into a digital (high end) dock.
4013 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4014 * information, see {@link android.app.UiModeManager}.
4015 */
4016 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4017 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004018
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004019 /**
4020 * Used to indicate that the activity can be used in a car environment.
4021 */
4022 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4023 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4024
Zak Cohendb6ca492017-01-26 14:09:00 -08004025 /**
4026 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4027 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4028 * information, see {@link android.app.UiModeManager}.
4029 */
4030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4031 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004032 // ---------------------------------------------------------------------
4033 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004034 // Application launch intent categories (see addCategory()).
4035
4036 /**
4037 * Used with {@link #ACTION_MAIN} to launch the browser application.
4038 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004039 * <p>NOTE: This should not be used as the primary key of an Intent,
4040 * since it will not result in the app launching with the correct
4041 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004042 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004043 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004044 */
4045 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4046 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4047
4048 /**
4049 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4050 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004051 * <p>NOTE: This should not be used as the primary key of an Intent,
4052 * since it will not result in the app launching with the correct
4053 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004054 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004055 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004056 */
4057 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4058 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4059
4060 /**
4061 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4062 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004063 * <p>NOTE: This should not be used as the primary key of an Intent,
4064 * since it will not result in the app launching with the correct
4065 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004066 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004067 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004068 */
4069 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4070 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4071
4072 /**
4073 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4074 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004075 * <p>NOTE: This should not be used as the primary key of an Intent,
4076 * since it will not result in the app launching with the correct
4077 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004078 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004079 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004080 */
4081 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4082 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4083
4084 /**
4085 * Used with {@link #ACTION_MAIN} to launch the email application.
4086 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004087 * <p>NOTE: This should not be used as the primary key of an Intent,
4088 * since it will not result in the app launching with the correct
4089 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004090 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004091 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004092 */
4093 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4094 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4095
4096 /**
4097 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4098 * The activity should be able to view and manipulate image and video files
4099 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004100 * <p>NOTE: This should not be used as the primary key of an Intent,
4101 * since it will not result in the app launching with the correct
4102 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004103 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004104 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004105 */
4106 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4107 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4108
4109 /**
4110 * Used with {@link #ACTION_MAIN} to launch the maps application.
4111 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004112 * <p>NOTE: This should not be used as the primary key of an Intent,
4113 * since it will not result in the app launching with the correct
4114 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004115 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004116 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004117 */
4118 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4119 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4120
4121 /**
4122 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4123 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004124 * <p>NOTE: This should not be used as the primary key of an Intent,
4125 * since it will not result in the app launching with the correct
4126 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004127 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004128 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004129 */
4130 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4131 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4132
4133 /**
4134 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004135 * The activity should be able to play, browse, or manipulate music files
4136 * stored on the device.
4137 * <p>NOTE: This should not be used as the primary key of an Intent,
4138 * since it will not result in the app launching with the correct
4139 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004140 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004141 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004142 */
4143 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4144 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4145
4146 // ---------------------------------------------------------------------
4147 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004148 // Standard extra data keys.
4149
4150 /**
4151 * The initial data to place in a newly created record. Use with
4152 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4153 * fields as would be given to the underlying ContentProvider.insert()
4154 * call.
4155 */
4156 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4157
4158 /**
4159 * A constant CharSequence that is associated with the Intent, used with
4160 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4161 * this may be a styled CharSequence, so you must use
4162 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4163 * retrieve it.
4164 */
4165 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4166
4167 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004168 * A constant String that is associated with the Intent, used with
4169 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4170 * as HTML formatted text. Note that you <em>must</em> also supply
4171 * {@link #EXTRA_TEXT}.
4172 */
4173 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4174
4175 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004176 * A content: URI holding a stream of data associated with the Intent,
4177 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004178 */
4179 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4180
4181 /**
4182 * A String[] holding e-mail addresses that should be delivered to.
4183 */
4184 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4185
4186 /**
4187 * A String[] holding e-mail addresses that should be carbon copied.
4188 */
4189 public static final String EXTRA_CC = "android.intent.extra.CC";
4190
4191 /**
4192 * A String[] holding e-mail addresses that should be blind carbon copied.
4193 */
4194 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4195
4196 /**
4197 * A constant string holding the desired subject line of a message.
4198 */
4199 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4200
4201 /**
4202 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004203 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004204 */
4205 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4206
4207 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004208 * An int representing the user id to be used.
4209 *
4210 * @hide
4211 */
4212 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4213
4214 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004215 * An int representing the task id to be retrieved. This is used when a launch from recents is
4216 * intercepted by another action such as credentials confirmation to remember which task should
4217 * be resumed when complete.
4218 *
4219 * @hide
4220 */
4221 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4222
4223 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004224 * An Intent[] describing additional, alternate choices you would like shown with
4225 * {@link #ACTION_CHOOSER}.
4226 *
4227 * <p>An app may be capable of providing several different payload types to complete a
4228 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4229 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4230 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4231 * photo data or a hosted link where the photos can be viewed.</p>
4232 *
4233 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4234 * first/primary/preferred intent in the set. Additional intents specified in
4235 * this extra are ordered; by default intents that appear earlier in the array will be
4236 * preferred over intents that appear later in the array as matches for the same
4237 * target component. To alter this preference, a calling app may also supply
4238 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4239 */
4240 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4241
4242 /**
Adam Powell52c39212016-04-07 15:14:18 -07004243 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4244 * and omitted from a list of components presented to the user.
4245 *
4246 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4247 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4248 * from your own package or other apps from your organization if the idea of sending to those
4249 * targets would be redundant with other app functionality. Filtered components will not
4250 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4251 */
4252 public static final String EXTRA_EXCLUDE_COMPONENTS
4253 = "android.intent.extra.EXCLUDE_COMPONENTS";
4254
4255 /**
4256 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4257 * describing additional high-priority deep-link targets for the chooser to present to the user.
4258 *
4259 * <p>Targets provided in this way will be presented inline with all other targets provided
4260 * by services from other apps. They will be prioritized before other service targets, but
4261 * after those targets provided by sources that the user has manually pinned to the front.</p>
4262 *
4263 * @see #ACTION_CHOOSER
4264 */
4265 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4266
4267 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004268 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4269 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4270 *
4271 * <p>An app preparing an action for another app to complete may wish to allow the user to
4272 * disambiguate between several options for completing the action based on the chosen target
4273 * or otherwise refine the action before it is invoked.
4274 * </p>
4275 *
4276 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4277 * <ul>
4278 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4279 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4280 * chosen target beyond the first</li>
4281 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4282 * should fill in and send once the disambiguation is complete</li>
4283 * </ul>
4284 */
4285 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4286 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4287
4288 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004289 * An {@code ArrayList} of {@code String} annotations describing content for
4290 * {@link #ACTION_CHOOSER}.
4291 *
4292 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4293 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4294 *
4295 * <p>Annotations should describe the major components or topics of the content. It is up to
4296 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4297 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4298 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4299 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4300 * use the following annotations when applicable:</p>
4301 * <ul>
4302 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4303 * health & beauty, and office supplies.</li>
4304 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4305 * happy, and sad.</li>
4306 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4307 * face, finger, standing, and walking.</li>
4308 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4309 * child, and baby.</li>
4310 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4311 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4312 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4313 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4314 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4315 * flowers.</li>
4316 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4317 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4318 * sunglasses, jewelry, handbags and clothing.</li>
4319 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4320 * paper, and silk.</li>
4321 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4322 * cars, and boats.</li>
4323 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4324 * posters.</li>
4325 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4326 * and designs of houses.</li>
4327 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4328 * Christmas and Thanksgiving.</li>
4329 * </ul>
4330 */
4331 public static final String EXTRA_CONTENT_ANNOTATIONS
4332 = "android.intent.extra.CONTENT_ANNOTATIONS";
4333
4334 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004335 * A {@link ResultReceiver} used to return data back to the sender.
4336 *
4337 * <p>Used to complete an app-specific
4338 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4339 *
4340 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4341 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4342 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4343 * when the user selects a target component from the chooser. It is up to the recipient
4344 * to send a result to this ResultReceiver to signal that disambiguation is complete
4345 * and that the chooser should invoke the user's choice.</p>
4346 *
4347 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4348 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4349 * to match and fill in the final Intent or ChooserTarget before starting it.
4350 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4351 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4352 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4353 *
4354 * <p>The result code passed to the ResultReceiver should be
4355 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4356 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4357 * the chooser should finish without starting a target.</p>
4358 */
4359 public static final String EXTRA_RESULT_RECEIVER
4360 = "android.intent.extra.RESULT_RECEIVER";
4361
4362 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004364 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004365 */
4366 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4367
4368 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004369 * A Parcelable[] of {@link Intent} or
4370 * {@link android.content.pm.LabeledIntent} objects as set with
4371 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4372 * a the front of the list of choices, when shown to the user with a
4373 * {@link #ACTION_CHOOSER}.
4374 */
4375 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4376
4377 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004378 * A {@link IntentSender} to start after ephemeral installation success.
4379 * @hide
4380 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004381 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4382
4383 /**
4384 * A {@link IntentSender} to start after ephemeral installation failure.
4385 * @hide
4386 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004387 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4388
4389 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004390 * The host name that triggered an ephemeral resolution.
4391 * @hide
4392 */
4393 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4394
4395 /**
4396 * An opaque token to track ephemeral resolution.
4397 * @hide
4398 */
4399 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4400
4401 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004402 * The version code of the app to install components from.
4403 * @hide
4404 */
4405 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4406
4407 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004408 * A Bundle forming a mapping of potential target package names to different extras Bundles
4409 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4410 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4411 * be currently installed on the device.
4412 *
4413 * <p>An application may choose to provide alternate extras for the case where a user
4414 * selects an activity from a predetermined set of target packages. If the activity
4415 * the user selects from the chooser belongs to a package with its package name as
4416 * a key in this bundle, the corresponding extras for that package will be merged with
4417 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4418 * extra has the same key as an extra already present in the intent it will overwrite
4419 * the extra from the intent.</p>
4420 *
4421 * <p><em>Examples:</em>
4422 * <ul>
4423 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4424 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4425 * parameters for that target.</li>
4426 * <li>An application may offer additional metadata for known targets of a given intent
4427 * to pass along information only relevant to that target such as account or content
4428 * identifiers already known to that application.</li>
4429 * </ul></p>
4430 */
4431 public static final String EXTRA_REPLACEMENT_EXTRAS =
4432 "android.intent.extra.REPLACEMENT_EXTRAS";
4433
4434 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004435 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4436 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4437 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4438 * {@link ComponentName} of the chosen component.
4439 *
4440 * <p>In some situations this callback may never come, for example if the user abandons
4441 * the chooser, switches to another task or any number of other reasons. Apps should not
4442 * be written assuming that this callback will always occur.</p>
4443 */
4444 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4445 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4446
4447 /**
4448 * The {@link ComponentName} chosen by the user to complete an action.
4449 *
4450 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4451 */
4452 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4453
4454 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004455 * A {@link android.view.KeyEvent} object containing the event that
4456 * triggered the creation of the Intent it is in.
4457 */
4458 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4459
4460 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004461 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4462 * before shutting down.
4463 *
4464 * {@hide}
4465 */
4466 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4467
4468 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004469 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4470 * requested by the user.
4471 *
4472 * {@hide}
4473 */
4474 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4475 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4476
4477 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004478 * 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 -07004479 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4480 * of restarting the application.
4481 */
4482 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4483
4484 /**
4485 * A String holding the phone number originally entered in
4486 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4487 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4488 */
4489 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004490
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004491 /**
4492 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4493 * intents to supply the uid the package had been assigned. Also an optional
4494 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4495 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4496 * purpose.
4497 */
4498 public static final String EXTRA_UID = "android.intent.extra.UID";
4499
4500 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004501 * @hide String array of package names.
4502 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004503 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004504 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4505
4506 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004507 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4508 * intents to indicate whether this represents a full uninstall (removing
4509 * both the code and its data) or a partial uninstall (leaving its data,
4510 * implying that this is an update).
4511 */
4512 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004513
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004514 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004515 * @hide
4516 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4517 * intents to indicate that at this point the package has been removed for
4518 * all users on the device.
4519 */
4520 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4521 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4522
4523 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004524 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4525 * intents to indicate that this is a replacement of the package, so this
4526 * broadcast will immediately be followed by an add broadcast for a
4527 * different version of the same package.
4528 */
4529 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004530
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004531 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 * Used as an int extra field in {@link android.app.AlarmManager} intents
4533 * to tell the application being invoked how many pending alarms are being
4534 * delievered with the intent. For one-shot alarms this will always be 1.
4535 * For recurring alarms, this might be greater than 1 if the device was
4536 * asleep or powered off at the time an earlier alarm would have been
4537 * delivered.
4538 */
4539 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004540
Jacek Surazski86b6c532009-05-13 14:38:28 +02004541 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004542 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4543 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004544 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4545 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004546 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4547 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4548 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004549 */
4550 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4551
4552 /**
4553 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4554 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004555 */
4556 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4557
4558 /**
4559 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4560 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004561 */
4562 public static final int EXTRA_DOCK_STATE_DESK = 1;
4563
4564 /**
4565 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4566 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004567 */
4568 public static final int EXTRA_DOCK_STATE_CAR = 2;
4569
4570 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004571 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4572 * to represent that the phone is in a analog (low end) dock.
4573 */
4574 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4575
4576 /**
4577 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4578 * to represent that the phone is in a digital (high end) dock.
4579 */
4580 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4581
4582 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004583 * Boolean that can be supplied as meta-data with a dock activity, to
4584 * indicate that the dock should take over the home key when it is active.
4585 */
4586 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004587
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004588 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004589 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4590 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004591 */
4592 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4593
4594 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004595 * Used in the extra field in the remote intent. It's astring token passed with the
4596 * remote intent.
4597 */
4598 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4599 "android.intent.extra.remote_intent_token";
4600
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004601 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004602 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004603 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004604 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004605 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004606 "android.intent.extra.changed_component_name";
4607
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004608 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004609 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004610 * and contains a string array of all of the components that have changed. If
4611 * the state of the overall package has changed, then it will contain an entry
4612 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004613 */
4614 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4615 "android.intent.extra.changed_component_name_list";
4616
4617 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004618 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004619 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004620 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4621 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4622 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004623 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004624 */
4625 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4626 "android.intent.extra.changed_package_list";
4627
4628 /**
4629 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004630 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4631 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004632 * and contains an integer array of uids of all of the components
4633 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004634 */
4635 public static final String EXTRA_CHANGED_UID_LIST =
4636 "android.intent.extra.changed_uid_list";
4637
4638 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004639 * @hide
4640 * Magic extra system code can use when binding, to give a label for
4641 * who it is that has bound to a service. This is an integer giving
4642 * a framework string resource that can be displayed to the user.
4643 */
4644 public static final String EXTRA_CLIENT_LABEL =
4645 "android.intent.extra.client_label";
4646
4647 /**
4648 * @hide
4649 * Magic extra system code can use when binding, to give a PendingIntent object
4650 * that can be launched for the user to disable the system's use of this
4651 * service.
4652 */
4653 public static final String EXTRA_CLIENT_INTENT =
4654 "android.intent.extra.client_intent";
4655
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004656 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004657 * Extra used to indicate that an intent should only return data that is on
4658 * the local device. This is a boolean extra; the default is false. If true,
4659 * an implementation should only allow the user to select data that is
4660 * already on the device, not requiring it be downloaded from a remote
4661 * service when opened.
4662 *
4663 * @see #ACTION_GET_CONTENT
4664 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004665 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004666 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004667 */
4668 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004669 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004670
Amith Yamasani13593602012-03-22 16:16:17 -07004671 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004672 * Extra used to indicate that an intent can allow the user to select and
4673 * return multiple items. This is a boolean extra; the default is false. If
4674 * true, an implementation is allowed to present the user with a UI where
4675 * they can pick multiple items that are all returned to the caller. When
4676 * this happens, they should be returned as the {@link #getClipData()} part
4677 * of the result Intent.
4678 *
4679 * @see #ACTION_GET_CONTENT
4680 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004681 */
4682 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004683 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004684
4685 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004686 * The integer userHandle carried with broadcast intents related to addition, removal and
4687 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4688 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4689 *
Amith Yamasani13593602012-03-22 16:16:17 -07004690 * @hide
4691 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004692 public static final String EXTRA_USER_HANDLE =
4693 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004694
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004695 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004696 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4697 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4698 */
4699 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004700 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004701
4702 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004703 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004704 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4705 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004706 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004707 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4708
4709 /**
4710 * Extra sent in the intent to the BroadcastReceiver that handles
4711 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4712 * the restrictions as key/value pairs.
4713 */
4714 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4715 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004716
Amith Yamasani86118ba2013-03-28 14:33:16 -07004717 /**
4718 * Extra used in the response from a BroadcastReceiver that handles
4719 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4720 */
4721 public static final String EXTRA_RESTRICTIONS_INTENT =
4722 "android.intent.extra.restrictions_intent";
4723
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004724 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004725 * Extra used to communicate a set of acceptable MIME types. The type of the
4726 * extra is {@code String[]}. Values may be a combination of concrete MIME
4727 * types (such as "image/png") and/or partial MIME types (such as
4728 * "audio/*").
4729 *
4730 * @see #ACTION_GET_CONTENT
4731 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004732 */
4733 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4734
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004735 /**
4736 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4737 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004738 * When this is true, hardware devices can use this information to determine that
4739 * they shouldn't do a complete shutdown of their device since this is not a
4740 * complete shutdown down to the kernel, but only user space restarting.
4741 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004742 */
4743 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4744 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4745
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004746 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004747 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4748 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4749 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4750 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004751 *
4752 * @hide for internal use only.
4753 */
4754 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4755 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004756 /** @hide */
4757 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4758 /** @hide */
4759 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4760 /** @hide */
4761 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004762
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004763 /** {@hide} */
4764 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4765
Rubin Xue8490f12015-06-25 12:17:48 +01004766 /** {@hide} */
4767 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4768
Santos Cordon15a13782015-03-31 18:32:31 -07004769 /**
4770 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4771 * activation request.
4772 * TODO: Add information about the structure and response data used with the pending intent.
4773 * @hide
4774 */
4775 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4776 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4777
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004778 /**
4779 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004780 *
4781 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004782 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004783 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004784 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4785
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004786 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004787 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4788 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4789 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004790 *
4791 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004792 * @see #ACTION_QUICK_VIEW
4793 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004794 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004795 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004796 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4797 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004798
4799 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004800 * An optional extra of {@code String[]} indicating which quick view features should be made
4801 * available to the user in the quick view UI while handing a
4802 * {@link Intent#ACTION_QUICK_VIEW} intent.
4803 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4804 * Quick viewer can implement features not listed below.
4805 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4806 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4807 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4808 * <p>
4809 * Requirements:
4810 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4811 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4812 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4813 * internal policies.
4814 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4815 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4816 * disable or hide features.
4817 *
4818 * @see #ACTION_QUICK_VIEW
4819 */
4820 public static final String EXTRA_QUICK_VIEW_FEATURES =
4821 "android.intent.extra.QUICK_VIEW_FEATURES";
4822
4823 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004824 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004825 * When a profile goes into quiet mode, all apps in the profile are killed and the
4826 * profile user is stopped. Widgets originating from the profile are masked, and app
4827 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004828 */
4829 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004830
4831 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004832 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004833 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004834 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4835 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004836 *
4837 * @hide
4838 */
4839 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4840 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4841
4842 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004843 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4844 * whether to show the chooser or not when there is only one application available
4845 * to choose from.
4846 *
4847 * @hide
4848 */
4849 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4850 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4851
4852 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004853 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004854 * to represent that a video codec is allowed to use.
4855 *
4856 * @hide
4857 */
4858 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4859
4860 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004861 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004862 * to represent that a audio codec is allowed to use.
4863 *
4864 * @hide
4865 */
4866 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4867
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004868 // ---------------------------------------------------------------------
4869 // ---------------------------------------------------------------------
4870 // Intent flags (see mFlags variable).
4871
Tor Norbyed9273d62013-05-30 15:59:53 -07004872 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004873 @IntDef(flag = true, value = {
4874 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4875 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004876 @Retention(RetentionPolicy.SOURCE)
4877 public @interface GrantUriMode {}
4878
Jeff Sharkey846318a2014-04-04 12:12:41 -07004879 /** @hide */
4880 @IntDef(flag = true, value = {
4881 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4882 @Retention(RetentionPolicy.SOURCE)
4883 public @interface AccessUriMode {}
4884
4885 /**
4886 * Test if given mode flags specify an access mode, which must be at least
4887 * read and/or write.
4888 *
4889 * @hide
4890 */
4891 public static boolean isAccessUriMode(int modeFlags) {
4892 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4893 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4894 }
4895
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004896 /**
4897 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004898 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004899 * specified in its ClipData. When applying to an Intent's ClipData,
4900 * all URIs as well as recursive traversals through data or other ClipData
4901 * in Intent items will be granted; only the grant flags of the top-level
4902 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004903 */
4904 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4905 /**
4906 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004907 * perform write 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_WRITE_URI_PERMISSION = 0x00000002;
4914 /**
4915 * Can be set by the caller to indicate that this Intent is coming from
4916 * a background operation, not from direct user interaction.
4917 */
4918 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4919 /**
4920 * A flag you can enable for debugging: when set, log messages will be
4921 * printed during the resolution of this intent to show you what has
4922 * been found to create the final resolved list.
4923 */
4924 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004925 /**
4926 * If set, this intent will not match any components in packages that
4927 * are currently stopped. If this is not set, then the default behavior
4928 * is to include such applications in the result.
4929 */
4930 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4931 /**
4932 * If set, this intent will always match any components in packages that
4933 * are currently stopped. This is the default behavior when
4934 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4935 * flags are set, this one wins (it allows overriding of exclude for
4936 * places where the framework may automatically set the exclude flag).
4937 */
4938 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004939
4940 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004941 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004942 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004943 * persisted across device reboots until explicitly revoked with
4944 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4945 * grant for possible persisting; the receiving application must call
4946 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4947 * actually persist.
4948 *
4949 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4950 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4951 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004952 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004953 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004954 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004955
4956 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004957 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4958 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4959 * applies to any URI that is a prefix match against the original granted
4960 * URI. (Without this flag, the URI must match exactly for access to be
4961 * granted.) Another URI is considered a prefix match only when scheme,
4962 * authority, and all path segments defined by the prefix are an exact
4963 * match.
4964 */
4965 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4966
4967 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004968 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004969 * homework and verified that they correctly handle packages and components
4970 * that come and go over time. In particular:
4971 * <ul>
4972 * <li>Apps installed on external storage, which will appear to be
4973 * uninstalled while the the device is ejected.
4974 * <li>Apps with encryption unaware components, which will appear to not
4975 * exist while the device is locked.
4976 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004977 *
4978 * @hide
4979 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004980 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004981
4982 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004983 * Internal flag used to indicate ephemeral applications should not be
4984 * considered when resolving the intent.
4985 *
4986 * @hide
4987 */
4988 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4989
4990 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004991 * If set, the new activity is not kept in the history stack. As soon as
4992 * the user navigates away from it, the activity is finished. This may also
4993 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4994 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004995 *
4996 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4997 * is never invoked when the current activity starts a new activity which
4998 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004999 */
5000 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5001 /**
5002 * If set, the activity will not be launched if it is already running
5003 * at the top of the history stack.
5004 */
5005 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5006 /**
5007 * If set, this activity will become the start of a new task on this
5008 * history stack. A task (from the activity that started it to the
5009 * next task activity) defines an atomic group of activities that the
5010 * user can move to. Tasks can be moved to the foreground and background;
5011 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005012 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005013 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5014 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005015 *
5016 * <p>This flag is generally used by activities that want
5017 * to present a "launcher" style behavior: they give the user a list of
5018 * separate things that can be done, which otherwise run completely
5019 * independently of the activity launching them.
5020 *
5021 * <p>When using this flag, if a task is already running for the activity
5022 * you are now starting, then a new activity will not be started; instead,
5023 * the current task will simply be brought to the front of the screen with
5024 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5025 * to disable this behavior.
5026 *
5027 * <p>This flag can not be used when the caller is requesting a result from
5028 * the activity being launched.
5029 */
5030 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5031 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005032 * This flag is used to create a new task and launch an activity into it.
5033 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5034 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5035 * search through existing tasks for ones matching this Intent. Only if no such
5036 * task is found would a new task be created. When paired with
5037 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5038 * the search for a matching task and unconditionally start a new task.
5039 *
5040 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5041 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005042 * top-level application launcher.</strong> Used in conjunction with
5043 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5044 * behavior of bringing an existing task to the foreground. When set,
5045 * a new task is <em>always</em> started to host the Activity for the
5046 * Intent, regardless of whether there is already an existing task running
5047 * the same thing.
5048 *
5049 * <p><strong>Because the default system does not include graphical task management,
5050 * you should not use this flag unless you provide some way for a user to
5051 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005052 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005053 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5054 * creating new document tasks.
5055 *
5056 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005057 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005058 *
Scott Main7aee61f2011-02-08 11:25:01 -08005059 * <p>See
5060 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5061 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005062 *
5063 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5064 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005065 */
5066 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5067 /**
5068 * If set, and the activity being launched is already running in the
5069 * current task, then instead of launching a new instance of that activity,
5070 * all of the other activities on top of it will be closed and this Intent
5071 * will be delivered to the (now on top) old activity as a new Intent.
5072 *
5073 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5074 * If D calls startActivity() with an Intent that resolves to the component
5075 * of activity B, then C and D will be finished and B receive the given
5076 * Intent, resulting in the stack now being: A, B.
5077 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005078 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005079 * either receive the new intent you are starting here in its
5080 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005081 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005082 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5083 * the same intent, then it will be finished and re-created; for all other
5084 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5085 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005086 *
5087 * <p>This launch mode can also be used to good effect in conjunction with
5088 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5089 * of a task, it will bring any currently running instance of that task
5090 * to the foreground, and then clear it to its root state. This is
5091 * especially useful, for example, when launching an activity from the
5092 * notification manager.
5093 *
Scott Main7aee61f2011-02-08 11:25:01 -08005094 * <p>See
5095 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5096 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005097 */
5098 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5099 /**
5100 * If set and this intent is being used to launch a new activity from an
5101 * existing one, then the reply target of the existing activity will be
5102 * transfered to the new activity. This way the new activity can call
5103 * {@link android.app.Activity#setResult} and have that result sent back to
5104 * the reply target of the original activity.
5105 */
5106 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5107 /**
5108 * If set and this intent is being used to launch a new activity from an
5109 * existing one, the current activity will not be counted as the top
5110 * activity for deciding whether the new intent should be delivered to
5111 * the top instead of starting a new one. The previous activity will
5112 * be used as the top, with the assumption being that the current activity
5113 * will finish itself immediately.
5114 */
5115 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5116 /**
5117 * If set, the new activity is not kept in the list of recently launched
5118 * activities.
5119 */
5120 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5121 /**
5122 * This flag is not normally set by application code, but set for you by
5123 * the system as described in the
5124 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5125 * launchMode} documentation for the singleTask mode.
5126 */
5127 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5128 /**
5129 * If set, and this activity is either being started in a new task or
5130 * bringing to the top an existing task, then it will be launched as
5131 * the front door of the task. This will result in the application of
5132 * any affinities needed to have that task in the proper state (either
5133 * moving activities to or from it), or simply resetting that task to
5134 * its initial state if needed.
5135 */
5136 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5137 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005138 * This flag is not normally set by application code, but set for you by
5139 * the system if this activity is being launched from history
5140 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005141 */
5142 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005143 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005144 * @deprecated As of API 21 this performs identically to
5145 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005146 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005147 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005148 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005149 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005150 * This flag is used to open a document into a new task rooted at the activity launched
5151 * by this Intent. Through the use of this flag, or its equivalent attribute,
5152 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005153 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005154 *
Craig Mautner026596b2014-05-21 15:35:44 -07005155 * <p>The use of the activity attribute form of this,
5156 * {@link android.R.attr#documentLaunchMode}, is
5157 * preferred over the Intent flag described here. The attribute form allows the
5158 * Activity to specify multiple document behavior for all launchers of the Activity
5159 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005160 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005161 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5162 * it is kept after the activity is finished is different than the use of
5163 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5164 * this flag is being used to create a new recents entry, then by default that entry
5165 * will be removed once the activity is finished. You can modify this behavior with
5166 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5167 *
Craig Mautner026596b2014-05-21 15:35:44 -07005168 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5169 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5170 * equivalent of the Activity manifest specifying {@link
5171 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5172 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5173 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005174 *
Craig Mautner026596b2014-05-21 15:35:44 -07005175 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005176 *
Craig Mautner026596b2014-05-21 15:35:44 -07005177 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005178 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5179 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005180 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005181 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005182 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005183 * callback from occurring on the current frontmost activity before it is
5184 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005185 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005186 * <p>Typically, an activity can rely on that callback to indicate that an
5187 * explicit user action has caused their activity to be moved out of the
5188 * foreground. The callback marks an appropriate point in the activity's
5189 * lifecycle for it to dismiss any notifications that it intends to display
5190 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005191 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005192 * <p>If an activity is ever started via any non-user-driven events such as
5193 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5194 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005195 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005196 */
5197 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005198 /**
5199 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5200 * this flag will cause the launched activity to be brought to the front of its
5201 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005202 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005203 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5204 * If D calls startActivity() with an Intent that resolves to the component
5205 * of activity B, then B will be brought to the front of the history stack,
5206 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005207 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005208 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005209 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005210 */
5211 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005212 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005213 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5214 * this flag will prevent the system from applying an activity transition
5215 * animation to go to the next activity state. This doesn't mean an
5216 * animation will never run -- if another activity change happens that doesn't
5217 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005218 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005219 * when you are going to do a series of activity operations but the
5220 * animation seen by the user shouldn't be driven by the first activity
5221 * change but rather a later one.
5222 */
5223 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5224 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005225 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5226 * this flag will cause any existing task that would be associated with the
5227 * activity to be cleared before the activity is started. That is, the activity
5228 * becomes the new root of an otherwise empty task, and any old activities
5229 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5230 */
5231 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5232 /**
5233 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5234 * this flag will cause a newly launching task to be placed on top of the current
5235 * home activity task (if there is one). That is, pressing back from the task
5236 * will always return the user to home even if that was not the last activity they
5237 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5238 */
5239 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5240 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005241 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5242 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005243 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005244 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005245 * this flag. When set and the task's activity is finished, the recents
5246 * entry will remain in the interface for the user to re-launch it, like a
5247 * recents entry for a top-level application.
5248 * <p>
5249 * The receiving activity can override this request with
5250 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5251 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005252 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005253 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005254 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005255
5256 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005257 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5258 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005259 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5260 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005261 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005262 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005263
5264 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005265 * If set, when sending a broadcast only registered receivers will be
5266 * called -- no BroadcastReceiver components will be launched.
5267 */
5268 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005269 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005270 * If set, when sending a broadcast the new broadcast will replace
5271 * any existing pending broadcast that matches it. Matching is defined
5272 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5273 * true for the intents of the two broadcasts. When a match is found,
5274 * the new broadcast (and receivers associated with it) will replace the
5275 * existing one in the pending broadcast list, remaining at the same
5276 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005277 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005278 * <p>This flag is most typically used with sticky broadcasts, which
5279 * only care about delivering the most recent values of the broadcast
5280 * to their receivers.
5281 */
5282 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5283 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005284 * If set, when sending a broadcast the recipient is allowed to run at
5285 * foreground priority, with a shorter timeout interval. During normal
5286 * broadcasts the receivers are not automatically hoisted out of the
5287 * background priority class.
5288 */
5289 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5290 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005291 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5292 * They can still propagate results through to later receivers, but they can not prevent
5293 * later receivers from seeing the broadcast.
5294 */
5295 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5296 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005297 * If set, when sending a broadcast <i>before boot has completed</i> only
5298 * registered receivers will be called -- no BroadcastReceiver components
5299 * will be launched. Sticky intent state will be recorded properly even
5300 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5301 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005302 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005303 * <p>This flag is only for use by system sevices as a convenience to
5304 * avoid having to implement a more complex mechanism around detection
5305 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005306 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005307 * @hide
5308 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005309 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005310 /**
5311 * Set when this broadcast is for a boot upgrade, a special mode that
5312 * allows the broadcast to be sent before the system is ready and launches
5313 * the app process with no providers running in it.
5314 * @hide
5315 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005316 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005317 /**
5318 * If set, the broadcast will always go to manifest receivers in background (cached
5319 * or not running) apps, regardless of whether that would be done by default. By
5320 * default they will only receive broadcasts if the broadcast has specified an
5321 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005322 *
5323 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5324 * the broadcast code there must also be changed to match.
5325 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005326 * @hide
5327 */
5328 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5329 /**
5330 * If set, the broadcast will never go to manifest receivers in background (cached
5331 * or not running) apps, regardless of whether that would be done by default. By
5332 * default they will receive broadcasts if the broadcast has specified an
5333 * explicit component or package name.
5334 * @hide
5335 */
5336 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005337 /**
5338 * If set, this broadcast is being sent from the shell.
5339 * @hide
5340 */
5341 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005342
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005343 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005344 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5345 * will not receive broadcasts.
5346 *
5347 * <em>This flag has no effect when used by an Instant App.</em>
5348 */
5349 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5350
5351 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005352 * @hide Flags that can't be changed with PendingIntent.
5353 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005354 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5355 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5356 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005357
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005358 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005359 // ---------------------------------------------------------------------
5360 // toUri() and parseUri() options.
5361
5362 /**
5363 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5364 * always has the "intent:" scheme. This syntax can be used when you want
5365 * to later disambiguate between URIs that are intended to describe an
5366 * Intent vs. all others that should be treated as raw URIs. When used
5367 * with {@link #parseUri}, any other scheme will result in a generic
5368 * VIEW action for that raw URI.
5369 */
5370 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005371
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005372 /**
5373 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5374 * always has the "android-app:" scheme. This is a variation of
5375 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5376 * http/https URI being delivered to a specific package name. The format
5377 * is:
5378 *
5379 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005380 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005381 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005382 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5383 * you must also include a scheme; including a path also requires both a host and a scheme.
5384 * The final #Intent; fragment can be used without a scheme, host, or path.
5385 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005386 * used with intents that have a {@link #setSelector}, since the base intent
5387 * will always have an explicit package name.</p>
5388 *
5389 * <p>Some examples of how this scheme maps to Intent objects:</p>
5390 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5391 * <colgroup align="left" />
5392 * <colgroup align="left" />
5393 * <thead>
5394 * <tr><th>URI</th> <th>Intent</th></tr>
5395 * </thead>
5396 *
5397 * <tbody>
5398 * <tr><td><code>android-app://com.example.app</code></td>
5399 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5400 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5401 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5402 * </table></td>
5403 * </tr>
5404 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5405 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5406 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5407 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5408 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5409 * </table></td>
5410 * </tr>
5411 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5412 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5413 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5414 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5415 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5416 * </table></td>
5417 * </tr>
5418 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5419 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5420 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5421 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5422 * </table></td>
5423 * </tr>
5424 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5425 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5426 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5427 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5428 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5429 * </table></td>
5430 * </tr>
5431 * <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>
5432 * <td><table border="" style="margin:0" >
5433 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5434 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5435 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5436 * </table></td>
5437 * </tr>
5438 * </tbody>
5439 * </table>
5440 */
5441 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5442
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005443 /**
5444 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5445 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5446 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5447 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5448 * generated Intent can not cause unexpected data access to happen.
5449 *
5450 * <p>If you do not trust the source of the URI being parsed, you should still do further
5451 * processing to protect yourself from it. In particular, when using it to start an
5452 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5453 * that can handle it.</p>
5454 */
5455 public static final int URI_ALLOW_UNSAFE = 1<<2;
5456
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005457 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005458
5459 private String mAction;
5460 private Uri mData;
5461 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005462 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005463 private ComponentName mComponent;
5464 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005465 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005467 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005468 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005469 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005470 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005471 /** Token to track instant app launches. Local only; do not copy cross-process. */
5472 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005473
5474 // ---------------------------------------------------------------------
5475
5476 /**
5477 * Create an empty intent.
5478 */
5479 public Intent() {
5480 }
5481
5482 /**
5483 * Copy constructor.
5484 */
5485 public Intent(Intent o) {
5486 this.mAction = o.mAction;
5487 this.mData = o.mData;
5488 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005489 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005490 this.mComponent = o.mComponent;
5491 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005492 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005493 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005494 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005495 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005496 }
5497 if (o.mExtras != null) {
5498 this.mExtras = new Bundle(o.mExtras);
5499 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005500 if (o.mSourceBounds != null) {
5501 this.mSourceBounds = new Rect(o.mSourceBounds);
5502 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005503 if (o.mSelector != null) {
5504 this.mSelector = new Intent(o.mSelector);
5505 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005506 if (o.mClipData != null) {
5507 this.mClipData = new ClipData(o.mClipData);
5508 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509 }
5510
5511 @Override
5512 public Object clone() {
5513 return new Intent(this);
5514 }
5515
5516 private Intent(Intent o, boolean all) {
5517 this.mAction = o.mAction;
5518 this.mData = o.mData;
5519 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005520 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005521 this.mComponent = o.mComponent;
5522 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005523 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005524 }
5525 }
5526
5527 /**
5528 * Make a clone of only the parts of the Intent that are relevant for
5529 * filter matching: the action, data, type, component, and categories.
5530 */
5531 public Intent cloneFilter() {
5532 return new Intent(this, false);
5533 }
5534
5535 /**
5536 * Create an intent with a given action. All other fields (data, type,
5537 * class) are null. Note that the action <em>must</em> be in a
5538 * namespace because Intents are used globally in the system -- for
5539 * example the system VIEW action is android.intent.action.VIEW; an
5540 * application's custom action would be something like
5541 * com.google.app.myapp.CUSTOM_ACTION.
5542 *
5543 * @param action The Intent action, such as ACTION_VIEW.
5544 */
5545 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005546 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005547 }
5548
5549 /**
5550 * Create an intent with a given action and for a given data url. Note
5551 * that the action <em>must</em> be in a namespace because Intents are
5552 * used globally in the system -- for example the system VIEW action is
5553 * android.intent.action.VIEW; an application's custom action would be
5554 * something like com.google.app.myapp.CUSTOM_ACTION.
5555 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005556 * <p><em>Note: scheme and host name matching in the Android framework is
5557 * case-sensitive, unlike the formal RFC. As a result,
5558 * you should always ensure that you write your Uri with these elements
5559 * using lower case letters, and normalize any Uris you receive from
5560 * outside of Android to ensure the scheme and host is lower case.</em></p>
5561 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005562 * @param action The Intent action, such as ACTION_VIEW.
5563 * @param uri The Intent data URI.
5564 */
5565 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005566 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005567 mData = uri;
5568 }
5569
5570 /**
5571 * Create an intent for a specific component. All other fields (action, data,
5572 * type, class) are null, though they can be modified later with explicit
5573 * calls. This provides a convenient way to create an intent that is
5574 * intended to execute a hard-coded class name, rather than relying on the
5575 * system to find an appropriate class for you; see {@link #setComponent}
5576 * for more information on the repercussions of this.
5577 *
5578 * @param packageContext A Context of the application package implementing
5579 * this class.
5580 * @param cls The component class that is to be used for the intent.
5581 *
5582 * @see #setClass
5583 * @see #setComponent
5584 * @see #Intent(String, android.net.Uri , Context, Class)
5585 */
5586 public Intent(Context packageContext, Class<?> cls) {
5587 mComponent = new ComponentName(packageContext, cls);
5588 }
5589
5590 /**
5591 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005592 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005593 * construct the Intent and then calling {@link #setClass} to set its
5594 * class.
5595 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005596 * <p><em>Note: scheme and host name matching in the Android framework is
5597 * case-sensitive, unlike the formal RFC. As a result,
5598 * you should always ensure that you write your Uri with these elements
5599 * using lower case letters, and normalize any Uris you receive from
5600 * outside of Android to ensure the scheme and host is lower case.</em></p>
5601 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005602 * @param action The Intent action, such as ACTION_VIEW.
5603 * @param uri The Intent data URI.
5604 * @param packageContext A Context of the application package implementing
5605 * this class.
5606 * @param cls The component class that is to be used for the intent.
5607 *
5608 * @see #Intent(String, android.net.Uri)
5609 * @see #Intent(Context, Class)
5610 * @see #setClass
5611 * @see #setComponent
5612 */
5613 public Intent(String action, Uri uri,
5614 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005615 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005616 mData = uri;
5617 mComponent = new ComponentName(packageContext, cls);
5618 }
5619
5620 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005621 * Create an intent to launch the main (root) activity of a task. This
5622 * is the Intent that is started when the application's is launched from
5623 * Home. For anything else that wants to launch an application in the
5624 * same way, it is important that they use an Intent structured the same
5625 * way, and can use this function to ensure this is the case.
5626 *
5627 * <p>The returned Intent has the given Activity component as its explicit
5628 * component, {@link #ACTION_MAIN} as its action, and includes the
5629 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5630 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5631 * to do that through {@link #addFlags(int)} on the returned Intent.
5632 *
5633 * @param mainActivity The main activity component that this Intent will
5634 * launch.
5635 * @return Returns a newly created Intent that can be used to launch the
5636 * activity as a main application entry.
5637 *
5638 * @see #setClass
5639 * @see #setComponent
5640 */
5641 public static Intent makeMainActivity(ComponentName mainActivity) {
5642 Intent intent = new Intent(ACTION_MAIN);
5643 intent.setComponent(mainActivity);
5644 intent.addCategory(CATEGORY_LAUNCHER);
5645 return intent;
5646 }
5647
5648 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005649 * Make an Intent for the main activity of an application, without
5650 * specifying a specific activity to run but giving a selector to find
5651 * the activity. This results in a final Intent that is structured
5652 * the same as when the application is launched from
5653 * Home. For anything else that wants to launch an application in the
5654 * same way, it is important that they use an Intent structured the same
5655 * way, and can use this function to ensure this is the case.
5656 *
5657 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5658 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5659 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5660 * to do that through {@link #addFlags(int)} on the returned Intent.
5661 *
5662 * @param selectorAction The action name of the Intent's selector.
5663 * @param selectorCategory The name of a category to add to the Intent's
5664 * selector.
5665 * @return Returns a newly created Intent that can be used to launch the
5666 * activity as a main application entry.
5667 *
5668 * @see #setSelector(Intent)
5669 */
5670 public static Intent makeMainSelectorActivity(String selectorAction,
5671 String selectorCategory) {
5672 Intent intent = new Intent(ACTION_MAIN);
5673 intent.addCategory(CATEGORY_LAUNCHER);
5674 Intent selector = new Intent();
5675 selector.setAction(selectorAction);
5676 selector.addCategory(selectorCategory);
5677 intent.setSelector(selector);
5678 return intent;
5679 }
5680
5681 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005682 * Make an Intent that can be used to re-launch an application's task
5683 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5684 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5685 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5686 *
5687 * @param mainActivity The activity component that is the root of the
5688 * task; this is the activity that has been published in the application's
5689 * manifest as the main launcher icon.
5690 *
5691 * @return Returns a newly created Intent that can be used to relaunch the
5692 * activity's task in its root state.
5693 */
5694 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5695 Intent intent = makeMainActivity(mainActivity);
5696 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5697 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5698 return intent;
5699 }
5700
5701 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005702 * Call {@link #parseUri} with 0 flags.
5703 * @deprecated Use {@link #parseUri} instead.
5704 */
5705 @Deprecated
5706 public static Intent getIntent(String uri) throws URISyntaxException {
5707 return parseUri(uri, 0);
5708 }
Tom Taylord4a47292009-12-21 13:59:18 -08005709
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005710 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005711 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005712 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005713 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005714 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005715 *
5716 * <p>The URI given here must not be relative -- that is, it must include
5717 * the scheme and full path.
5718 *
5719 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005720 * @param flags Additional processing flags. Either 0,
5721 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005722 *
5723 * @return Intent The newly created Intent object.
5724 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005725 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5726 * it bad (as parsed by the Uri class) or the Intent data within the
5727 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005728 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005729 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005730 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005731 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 int i = 0;
5733 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005734 final boolean androidApp = uri.startsWith("android-app:");
5735
5736 // Validate intent scheme if requested.
5737 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5738 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005739 Intent intent = new Intent(ACTION_VIEW);
5740 try {
5741 intent.setData(Uri.parse(uri));
5742 } catch (IllegalArgumentException e) {
5743 throw new URISyntaxException(uri, e.getMessage());
5744 }
5745 return intent;
5746 }
5747 }
Tom Taylord4a47292009-12-21 13:59:18 -08005748
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005749 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005750 // simple case
5751 if (i == -1) {
5752 if (!androidApp) {
5753 return new Intent(ACTION_VIEW, Uri.parse(uri));
5754 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005755
5756 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005757 } else if (!uri.startsWith("#Intent;", i)) {
5758 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005759 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005760 } else {
5761 i = -1;
5762 }
5763 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005764
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005765 // new format
5766 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005767 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005768 boolean explicitAction = false;
5769 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005770
5771 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005772 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005773 String data;
5774 if (i >= 0) {
5775 data = uri.substring(0, i);
5776 i += 8; // length of "#Intent;"
5777 } else {
5778 data = uri;
5779 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005780
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005781 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005782 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005783 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005784 if (eq < 0) eq = i-1;
5785 int semi = uri.indexOf(';', i);
5786 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005787
5788 // action
5789 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005790 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005791 if (!inSelector) {
5792 explicitAction = true;
5793 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005794 }
5795
5796 // categories
5797 else if (uri.startsWith("category=", i)) {
5798 intent.addCategory(value);
5799 }
5800
5801 // type
5802 else if (uri.startsWith("type=", i)) {
5803 intent.mType = value;
5804 }
5805
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005806 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005807 else if (uri.startsWith("launchFlags=", i)) {
5808 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005809 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5810 intent.mFlags &= ~IMMUTABLE_FLAGS;
5811 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005812 }
5813
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005814 // package
5815 else if (uri.startsWith("package=", i)) {
5816 intent.mPackage = value;
5817 }
5818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005819 // component
5820 else if (uri.startsWith("component=", i)) {
5821 intent.mComponent = ComponentName.unflattenFromString(value);
5822 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005823
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005824 // scheme
5825 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005826 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005827 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005828 } else {
5829 scheme = value;
5830 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005831 }
5832
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005833 // source bounds
5834 else if (uri.startsWith("sourceBounds=", i)) {
5835 intent.mSourceBounds = Rect.unflattenFromString(value);
5836 }
5837
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005838 // selector
5839 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5840 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005841 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005842 }
5843
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005844 // extra
5845 else {
5846 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005847 // create Bundle if it doesn't already exist
5848 if (intent.mExtras == null) intent.mExtras = new Bundle();
5849 Bundle b = intent.mExtras;
5850 // add EXTRA
5851 if (uri.startsWith("S.", i)) b.putString(key, value);
5852 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5853 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5854 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5855 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5856 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5857 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5858 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5859 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5860 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5861 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005862
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005863 // move to the next item
5864 i = semi + 1;
5865 }
5866
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005867 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005868 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005869 if (baseIntent.mPackage == null) {
5870 baseIntent.setSelector(intent);
5871 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005872 intent = baseIntent;
5873 }
5874
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005875 if (data != null) {
5876 if (data.startsWith("intent:")) {
5877 data = data.substring(7);
5878 if (scheme != null) {
5879 data = scheme + ':' + data;
5880 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005881 } else if (data.startsWith("android-app:")) {
5882 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5883 // Correctly formed android-app, first part is package name.
5884 int end = data.indexOf('/', 14);
5885 if (end < 0) {
5886 // All we have is a package name.
5887 intent.mPackage = data.substring(14);
5888 if (!explicitAction) {
5889 intent.setAction(ACTION_MAIN);
5890 }
5891 data = "";
5892 } else {
5893 // Target the Intent at the given package name always.
5894 String authority = null;
5895 intent.mPackage = data.substring(14, end);
5896 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005897 if ((end+1) < data.length()) {
5898 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5899 // Found a scheme, remember it.
5900 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005901 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005902 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5903 // Found a authority, remember it.
5904 authority = data.substring(end+1, newEnd);
5905 end = newEnd;
5906 }
5907 } else {
5908 // All we have is a scheme.
5909 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005910 }
5911 }
5912 if (scheme == null) {
5913 // If there was no scheme, then this just targets the package.
5914 if (!explicitAction) {
5915 intent.setAction(ACTION_MAIN);
5916 }
5917 data = "";
5918 } else if (authority == null) {
5919 data = scheme + ":";
5920 } else {
5921 data = scheme + "://" + authority + data.substring(end);
5922 }
5923 }
5924 } else {
5925 data = "";
5926 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005927 }
Tom Taylord4a47292009-12-21 13:59:18 -08005928
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005929 if (data.length() > 0) {
5930 try {
5931 intent.mData = Uri.parse(data);
5932 } catch (IllegalArgumentException e) {
5933 throw new URISyntaxException(uri, e.getMessage());
5934 }
5935 }
5936 }
Tom Taylord4a47292009-12-21 13:59:18 -08005937
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005938 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005939
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005940 } catch (IndexOutOfBoundsException e) {
5941 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5942 }
5943 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005944
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005945 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005946 return getIntentOld(uri, 0);
5947 }
5948
5949 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005950 Intent intent;
5951
5952 int i = uri.lastIndexOf('#');
5953 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005954 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005955 final int intentFragmentStart = i;
5956 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005957
5958 i++;
5959
5960 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005961 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005962 i += 7;
5963 int j = uri.indexOf(')', i);
5964 action = uri.substring(i, j);
5965 i = j + 1;
5966 }
5967
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005968 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005969
5970 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005971 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005972 i += 11;
5973 int j = uri.indexOf(')', i);
5974 while (i < j) {
5975 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005976 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977 if (i < sep) {
5978 intent.addCategory(uri.substring(i, sep));
5979 }
5980 i = sep + 1;
5981 }
5982 i = j + 1;
5983 }
5984
5985 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005986 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005987 i += 5;
5988 int j = uri.indexOf(')', i);
5989 intent.mType = uri.substring(i, j);
5990 i = j + 1;
5991 }
5992
5993 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005994 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005995 i += 12;
5996 int j = uri.indexOf(')', i);
5997 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005998 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5999 intent.mFlags &= ~IMMUTABLE_FLAGS;
6000 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006001 i = j + 1;
6002 }
6003
6004 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006005 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006006 i += 10;
6007 int j = uri.indexOf(')', i);
6008 int sep = uri.indexOf('!', i);
6009 if (sep >= 0 && sep < j) {
6010 String pkg = uri.substring(i, sep);
6011 String cls = uri.substring(sep + 1, j);
6012 intent.mComponent = new ComponentName(pkg, cls);
6013 }
6014 i = j + 1;
6015 }
6016
6017 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006018 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006019 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006020
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006021 final int closeParen = uri.indexOf(')', i);
6022 if (closeParen == -1) throw new URISyntaxException(uri,
6023 "EXTRA missing trailing ')'", i);
6024
6025 while (i < closeParen) {
6026 // fetch the key value
6027 int j = uri.indexOf('=', i);
6028 if (j <= i + 1 || i >= closeParen) {
6029 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6030 }
6031 char type = uri.charAt(i);
6032 i++;
6033 String key = uri.substring(i, j);
6034 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006036 // get type-value
6037 j = uri.indexOf('!', i);
6038 if (j == -1 || j >= closeParen) j = closeParen;
6039 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6040 String value = uri.substring(i, j);
6041 i = j;
6042
6043 // create Bundle if it doesn't already exist
6044 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006045
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006046 // add item to bundle
6047 try {
6048 switch (type) {
6049 case 'S':
6050 intent.mExtras.putString(key, Uri.decode(value));
6051 break;
6052 case 'B':
6053 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6054 break;
6055 case 'b':
6056 intent.mExtras.putByte(key, Byte.parseByte(value));
6057 break;
6058 case 'c':
6059 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6060 break;
6061 case 'd':
6062 intent.mExtras.putDouble(key, Double.parseDouble(value));
6063 break;
6064 case 'f':
6065 intent.mExtras.putFloat(key, Float.parseFloat(value));
6066 break;
6067 case 'i':
6068 intent.mExtras.putInt(key, Integer.parseInt(value));
6069 break;
6070 case 'l':
6071 intent.mExtras.putLong(key, Long.parseLong(value));
6072 break;
6073 case 's':
6074 intent.mExtras.putShort(key, Short.parseShort(value));
6075 break;
6076 default:
6077 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6078 }
6079 } catch (NumberFormatException e) {
6080 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6081 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006082
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006083 char ch = uri.charAt(i);
6084 if (ch == ')') break;
6085 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6086 i++;
6087 }
6088 }
6089
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006090 if (isIntentFragment) {
6091 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6092 } else {
6093 intent.mData = Uri.parse(uri);
6094 }
Tom Taylord4a47292009-12-21 13:59:18 -08006095
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006096 if (intent.mAction == null) {
6097 // By default, if no action is specified, then use VIEW.
6098 intent.mAction = ACTION_VIEW;
6099 }
6100
6101 } else {
6102 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6103 }
6104
6105 return intent;
6106 }
6107
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006108 /** @hide */
6109 public interface CommandOptionHandler {
6110 boolean handleOption(String opt, ShellCommand cmd);
6111 }
6112
6113 /** @hide */
6114 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6115 throws URISyntaxException {
6116 Intent intent = new Intent();
6117 Intent baseIntent = intent;
6118 boolean hasIntentInfo = false;
6119
6120 Uri data = null;
6121 String type = null;
6122
6123 String opt;
6124 while ((opt=cmd.getNextOption()) != null) {
6125 switch (opt) {
6126 case "-a":
6127 intent.setAction(cmd.getNextArgRequired());
6128 if (intent == baseIntent) {
6129 hasIntentInfo = true;
6130 }
6131 break;
6132 case "-d":
6133 data = Uri.parse(cmd.getNextArgRequired());
6134 if (intent == baseIntent) {
6135 hasIntentInfo = true;
6136 }
6137 break;
6138 case "-t":
6139 type = cmd.getNextArgRequired();
6140 if (intent == baseIntent) {
6141 hasIntentInfo = true;
6142 }
6143 break;
6144 case "-c":
6145 intent.addCategory(cmd.getNextArgRequired());
6146 if (intent == baseIntent) {
6147 hasIntentInfo = true;
6148 }
6149 break;
6150 case "-e":
6151 case "--es": {
6152 String key = cmd.getNextArgRequired();
6153 String value = cmd.getNextArgRequired();
6154 intent.putExtra(key, value);
6155 }
6156 break;
6157 case "--esn": {
6158 String key = cmd.getNextArgRequired();
6159 intent.putExtra(key, (String) null);
6160 }
6161 break;
6162 case "--ei": {
6163 String key = cmd.getNextArgRequired();
6164 String value = cmd.getNextArgRequired();
6165 intent.putExtra(key, Integer.decode(value));
6166 }
6167 break;
6168 case "--eu": {
6169 String key = cmd.getNextArgRequired();
6170 String value = cmd.getNextArgRequired();
6171 intent.putExtra(key, Uri.parse(value));
6172 }
6173 break;
6174 case "--ecn": {
6175 String key = cmd.getNextArgRequired();
6176 String value = cmd.getNextArgRequired();
6177 ComponentName cn = ComponentName.unflattenFromString(value);
6178 if (cn == null)
6179 throw new IllegalArgumentException("Bad component name: " + value);
6180 intent.putExtra(key, cn);
6181 }
6182 break;
6183 case "--eia": {
6184 String key = cmd.getNextArgRequired();
6185 String value = cmd.getNextArgRequired();
6186 String[] strings = value.split(",");
6187 int[] list = new int[strings.length];
6188 for (int i = 0; i < strings.length; i++) {
6189 list[i] = Integer.decode(strings[i]);
6190 }
6191 intent.putExtra(key, list);
6192 }
6193 break;
6194 case "--eial": {
6195 String key = cmd.getNextArgRequired();
6196 String value = cmd.getNextArgRequired();
6197 String[] strings = value.split(",");
6198 ArrayList<Integer> list = new ArrayList<>(strings.length);
6199 for (int i = 0; i < strings.length; i++) {
6200 list.add(Integer.decode(strings[i]));
6201 }
6202 intent.putExtra(key, list);
6203 }
6204 break;
6205 case "--el": {
6206 String key = cmd.getNextArgRequired();
6207 String value = cmd.getNextArgRequired();
6208 intent.putExtra(key, Long.valueOf(value));
6209 }
6210 break;
6211 case "--ela": {
6212 String key = cmd.getNextArgRequired();
6213 String value = cmd.getNextArgRequired();
6214 String[] strings = value.split(",");
6215 long[] list = new long[strings.length];
6216 for (int i = 0; i < strings.length; i++) {
6217 list[i] = Long.valueOf(strings[i]);
6218 }
6219 intent.putExtra(key, list);
6220 hasIntentInfo = true;
6221 }
6222 break;
6223 case "--elal": {
6224 String key = cmd.getNextArgRequired();
6225 String value = cmd.getNextArgRequired();
6226 String[] strings = value.split(",");
6227 ArrayList<Long> list = new ArrayList<>(strings.length);
6228 for (int i = 0; i < strings.length; i++) {
6229 list.add(Long.valueOf(strings[i]));
6230 }
6231 intent.putExtra(key, list);
6232 hasIntentInfo = true;
6233 }
6234 break;
6235 case "--ef": {
6236 String key = cmd.getNextArgRequired();
6237 String value = cmd.getNextArgRequired();
6238 intent.putExtra(key, Float.valueOf(value));
6239 hasIntentInfo = true;
6240 }
6241 break;
6242 case "--efa": {
6243 String key = cmd.getNextArgRequired();
6244 String value = cmd.getNextArgRequired();
6245 String[] strings = value.split(",");
6246 float[] list = new float[strings.length];
6247 for (int i = 0; i < strings.length; i++) {
6248 list[i] = Float.valueOf(strings[i]);
6249 }
6250 intent.putExtra(key, list);
6251 hasIntentInfo = true;
6252 }
6253 break;
6254 case "--efal": {
6255 String key = cmd.getNextArgRequired();
6256 String value = cmd.getNextArgRequired();
6257 String[] strings = value.split(",");
6258 ArrayList<Float> list = new ArrayList<>(strings.length);
6259 for (int i = 0; i < strings.length; i++) {
6260 list.add(Float.valueOf(strings[i]));
6261 }
6262 intent.putExtra(key, list);
6263 hasIntentInfo = true;
6264 }
6265 break;
6266 case "--esa": {
6267 String key = cmd.getNextArgRequired();
6268 String value = cmd.getNextArgRequired();
6269 // Split on commas unless they are preceeded by an escape.
6270 // The escape character must be escaped for the string and
6271 // again for the regex, thus four escape characters become one.
6272 String[] strings = value.split("(?<!\\\\),");
6273 intent.putExtra(key, strings);
6274 hasIntentInfo = true;
6275 }
6276 break;
6277 case "--esal": {
6278 String key = cmd.getNextArgRequired();
6279 String value = cmd.getNextArgRequired();
6280 // Split on commas unless they are preceeded by an escape.
6281 // The escape character must be escaped for the string and
6282 // again for the regex, thus four escape characters become one.
6283 String[] strings = value.split("(?<!\\\\),");
6284 ArrayList<String> list = new ArrayList<>(strings.length);
6285 for (int i = 0; i < strings.length; i++) {
6286 list.add(strings[i]);
6287 }
6288 intent.putExtra(key, list);
6289 hasIntentInfo = true;
6290 }
6291 break;
6292 case "--ez": {
6293 String key = cmd.getNextArgRequired();
6294 String value = cmd.getNextArgRequired().toLowerCase();
6295 // Boolean.valueOf() results in false for anything that is not "true", which is
6296 // error-prone in shell commands
6297 boolean arg;
6298 if ("true".equals(value) || "t".equals(value)) {
6299 arg = true;
6300 } else if ("false".equals(value) || "f".equals(value)) {
6301 arg = false;
6302 } else {
6303 try {
6304 arg = Integer.decode(value) != 0;
6305 } catch (NumberFormatException ex) {
6306 throw new IllegalArgumentException("Invalid boolean value: " + value);
6307 }
6308 }
6309
6310 intent.putExtra(key, arg);
6311 }
6312 break;
6313 case "-n": {
6314 String str = cmd.getNextArgRequired();
6315 ComponentName cn = ComponentName.unflattenFromString(str);
6316 if (cn == null)
6317 throw new IllegalArgumentException("Bad component name: " + str);
6318 intent.setComponent(cn);
6319 if (intent == baseIntent) {
6320 hasIntentInfo = true;
6321 }
6322 }
6323 break;
6324 case "-p": {
6325 String str = cmd.getNextArgRequired();
6326 intent.setPackage(str);
6327 if (intent == baseIntent) {
6328 hasIntentInfo = true;
6329 }
6330 }
6331 break;
6332 case "-f":
6333 String str = cmd.getNextArgRequired();
6334 intent.setFlags(Integer.decode(str).intValue());
6335 break;
6336 case "--grant-read-uri-permission":
6337 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6338 break;
6339 case "--grant-write-uri-permission":
6340 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6341 break;
6342 case "--grant-persistable-uri-permission":
6343 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6344 break;
6345 case "--grant-prefix-uri-permission":
6346 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6347 break;
6348 case "--exclude-stopped-packages":
6349 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6350 break;
6351 case "--include-stopped-packages":
6352 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6353 break;
6354 case "--debug-log-resolution":
6355 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6356 break;
6357 case "--activity-brought-to-front":
6358 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6359 break;
6360 case "--activity-clear-top":
6361 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6362 break;
6363 case "--activity-clear-when-task-reset":
6364 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6365 break;
6366 case "--activity-exclude-from-recents":
6367 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6368 break;
6369 case "--activity-launched-from-history":
6370 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6371 break;
6372 case "--activity-multiple-task":
6373 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6374 break;
6375 case "--activity-no-animation":
6376 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6377 break;
6378 case "--activity-no-history":
6379 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6380 break;
6381 case "--activity-no-user-action":
6382 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6383 break;
6384 case "--activity-previous-is-top":
6385 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6386 break;
6387 case "--activity-reorder-to-front":
6388 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6389 break;
6390 case "--activity-reset-task-if-needed":
6391 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6392 break;
6393 case "--activity-single-top":
6394 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6395 break;
6396 case "--activity-clear-task":
6397 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6398 break;
6399 case "--activity-task-on-home":
6400 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6401 break;
6402 case "--receiver-registered-only":
6403 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6404 break;
6405 case "--receiver-replace-pending":
6406 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6407 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006408 case "--receiver-foreground":
6409 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6410 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006411 case "--receiver-no-abort":
6412 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6413 break;
6414 case "--receiver-include-background":
6415 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6416 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006417 case "--selector":
6418 intent.setDataAndType(data, type);
6419 intent = new Intent();
6420 break;
6421 default:
6422 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6423 // Okay, caller handled this option.
6424 } else {
6425 throw new IllegalArgumentException("Unknown option: " + opt);
6426 }
6427 break;
6428 }
6429 }
6430 intent.setDataAndType(data, type);
6431
6432 final boolean hasSelector = intent != baseIntent;
6433 if (hasSelector) {
6434 // A selector was specified; fix up.
6435 baseIntent.setSelector(intent);
6436 intent = baseIntent;
6437 }
6438
6439 String arg = cmd.getNextArg();
6440 baseIntent = null;
6441 if (arg == null) {
6442 if (hasSelector) {
6443 // If a selector has been specified, and no arguments
6444 // have been supplied for the main Intent, then we can
6445 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6446 // need to have a component name specified yet, the
6447 // selector will take care of that.
6448 baseIntent = new Intent(Intent.ACTION_MAIN);
6449 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6450 }
6451 } else if (arg.indexOf(':') >= 0) {
6452 // The argument is a URI. Fully parse it, and use that result
6453 // to fill in any data not specified so far.
6454 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6455 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6456 } else if (arg.indexOf('/') >= 0) {
6457 // The argument is a component name. Build an Intent to launch
6458 // it.
6459 baseIntent = new Intent(Intent.ACTION_MAIN);
6460 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6461 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6462 } else {
6463 // Assume the argument is a package name.
6464 baseIntent = new Intent(Intent.ACTION_MAIN);
6465 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6466 baseIntent.setPackage(arg);
6467 }
6468 if (baseIntent != null) {
6469 Bundle extras = intent.getExtras();
6470 intent.replaceExtras((Bundle)null);
6471 Bundle uriExtras = baseIntent.getExtras();
6472 baseIntent.replaceExtras((Bundle)null);
6473 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6474 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6475 for (String c : cats) {
6476 baseIntent.removeCategory(c);
6477 }
6478 }
6479 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6480 if (extras == null) {
6481 extras = uriExtras;
6482 } else if (uriExtras != null) {
6483 uriExtras.putAll(extras);
6484 extras = uriExtras;
6485 }
6486 intent.replaceExtras(extras);
6487 hasIntentInfo = true;
6488 }
6489
6490 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6491 return intent;
6492 }
6493
6494 /** @hide */
6495 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6496 final String[] lines = new String[] {
6497 "<INTENT> specifications include these flags and arguments:",
6498 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6499 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6500 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6501 " [--esn <EXTRA_KEY> ...]",
6502 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6503 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6504 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6505 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6506 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6507 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6508 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6509 " (mutiple extras passed as Integer[])",
6510 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6511 " (mutiple extras passed as List<Integer>)",
6512 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6513 " (mutiple extras passed as Long[])",
6514 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6515 " (mutiple extras passed as List<Long>)",
6516 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6517 " (mutiple extras passed as Float[])",
6518 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6519 " (mutiple extras passed as List<Float>)",
6520 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6521 " (mutiple extras passed as String[]; to embed a comma into a string,",
6522 " escape it using \"\\,\")",
6523 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6524 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6525 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006526 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006527 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6528 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6529 " [--debug-log-resolution] [--exclude-stopped-packages]",
6530 " [--include-stopped-packages]",
6531 " [--activity-brought-to-front] [--activity-clear-top]",
6532 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6533 " [--activity-launched-from-history] [--activity-multiple-task]",
6534 " [--activity-no-animation] [--activity-no-history]",
6535 " [--activity-no-user-action] [--activity-previous-is-top]",
6536 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6537 " [--activity-single-top] [--activity-clear-task]",
6538 " [--activity-task-on-home]",
6539 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006540 " [--receiver-foreground] [--receiver-no-abort]",
6541 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006542 " [--selector]",
6543 " [<URI> | <PACKAGE> | <COMPONENT>]"
6544 };
6545 for (String line : lines) {
6546 pw.print(prefix);
6547 pw.println(line);
6548 }
6549 }
6550
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006551 /**
6552 * Retrieve the general action to be performed, such as
6553 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6554 * the information in the intent should be interpreted -- most importantly,
6555 * what to do with the data returned by {@link #getData}.
6556 *
6557 * @return The action of this intent or null if none is specified.
6558 *
6559 * @see #setAction
6560 */
6561 public String getAction() {
6562 return mAction;
6563 }
6564
6565 /**
6566 * Retrieve data this intent is operating on. This URI specifies the name
6567 * of the data; often it uses the content: scheme, specifying data in a
6568 * content provider. Other schemes may be handled by specific activities,
6569 * such as http: by the web browser.
6570 *
6571 * @return The URI of the data this intent is targeting or null.
6572 *
6573 * @see #getScheme
6574 * @see #setData
6575 */
6576 public Uri getData() {
6577 return mData;
6578 }
6579
6580 /**
6581 * The same as {@link #getData()}, but returns the URI as an encoded
6582 * String.
6583 */
6584 public String getDataString() {
6585 return mData != null ? mData.toString() : null;
6586 }
6587
6588 /**
6589 * Return the scheme portion of the intent's data. If the data is null or
6590 * does not include a scheme, null is returned. Otherwise, the scheme
6591 * prefix without the final ':' is returned, i.e. "http".
6592 *
6593 * <p>This is the same as calling getData().getScheme() (and checking for
6594 * null data).
6595 *
6596 * @return The scheme of this intent.
6597 *
6598 * @see #getData
6599 */
6600 public String getScheme() {
6601 return mData != null ? mData.getScheme() : null;
6602 }
6603
6604 /**
6605 * Retrieve any explicit MIME type included in the intent. This is usually
6606 * null, as the type is determined by the intent data.
6607 *
6608 * @return If a type was manually set, it is returned; else null is
6609 * returned.
6610 *
6611 * @see #resolveType(ContentResolver)
6612 * @see #setType
6613 */
6614 public String getType() {
6615 return mType;
6616 }
6617
6618 /**
6619 * Return the MIME data type of this intent. If the type field is
6620 * explicitly set, that is simply returned. Otherwise, if the data is set,
6621 * the type of that data is returned. If neither fields are set, a null is
6622 * returned.
6623 *
6624 * @return The MIME type of this intent.
6625 *
6626 * @see #getType
6627 * @see #resolveType(ContentResolver)
6628 */
6629 public String resolveType(Context context) {
6630 return resolveType(context.getContentResolver());
6631 }
6632
6633 /**
6634 * Return the MIME data type of this intent. If the type field is
6635 * explicitly set, that is simply returned. Otherwise, if the data is set,
6636 * the type of that data is returned. If neither fields are set, a null is
6637 * returned.
6638 *
6639 * @param resolver A ContentResolver that can be used to determine the MIME
6640 * type of the intent's data.
6641 *
6642 * @return The MIME type of this intent.
6643 *
6644 * @see #getType
6645 * @see #resolveType(Context)
6646 */
6647 public String resolveType(ContentResolver resolver) {
6648 if (mType != null) {
6649 return mType;
6650 }
6651 if (mData != null) {
6652 if ("content".equals(mData.getScheme())) {
6653 return resolver.getType(mData);
6654 }
6655 }
6656 return null;
6657 }
6658
6659 /**
6660 * Return the MIME data type of this intent, only if it will be needed for
6661 * intent resolution. This is not generally useful for application code;
6662 * it is used by the frameworks for communicating with back-end system
6663 * services.
6664 *
6665 * @param resolver A ContentResolver that can be used to determine the MIME
6666 * type of the intent's data.
6667 *
6668 * @return The MIME type of this intent, or null if it is unknown or not
6669 * needed.
6670 */
6671 public String resolveTypeIfNeeded(ContentResolver resolver) {
6672 if (mComponent != null) {
6673 return mType;
6674 }
6675 return resolveType(resolver);
6676 }
6677
6678 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006679 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006680 *
6681 * @param category The category to check.
6682 *
6683 * @return boolean True if the intent contains the category, else false.
6684 *
6685 * @see #getCategories
6686 * @see #addCategory
6687 */
6688 public boolean hasCategory(String category) {
6689 return mCategories != null && mCategories.contains(category);
6690 }
6691
6692 /**
6693 * Return the set of all categories in the intent. If there are no categories,
6694 * returns NULL.
6695 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006696 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006697 *
6698 * @see #hasCategory
6699 * @see #addCategory
6700 */
6701 public Set<String> getCategories() {
6702 return mCategories;
6703 }
6704
6705 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006706 * Return the specific selector associated with this Intent. If there is
6707 * none, returns null. See {@link #setSelector} for more information.
6708 *
6709 * @see #setSelector
6710 */
6711 public Intent getSelector() {
6712 return mSelector;
6713 }
6714
6715 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006716 * Return the {@link ClipData} associated with this Intent. If there is
6717 * none, returns null. See {@link #setClipData} for more information.
6718 *
John Spurlock125d1332013-11-25 11:58:37 -05006719 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006720 */
6721 public ClipData getClipData() {
6722 return mClipData;
6723 }
6724
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006725 /** @hide */
6726 public int getContentUserHint() {
6727 return mContentUserHint;
6728 }
6729
Todd Kennedyb3b431302017-03-20 16:05:48 -07006730 /** @hide */
6731 public String getLaunchToken() {
6732 return mLaunchToken;
6733 }
6734
6735 /** @hide */
6736 public void setLaunchToken(String launchToken) {
6737 mLaunchToken = launchToken;
6738 }
6739
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006740 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006741 * Sets the ClassLoader that will be used when unmarshalling
6742 * any Parcelable values from the extras of this Intent.
6743 *
6744 * @param loader a ClassLoader, or null to use the default loader
6745 * at the time of unmarshalling.
6746 */
6747 public void setExtrasClassLoader(ClassLoader loader) {
6748 if (mExtras != null) {
6749 mExtras.setClassLoader(loader);
6750 }
6751 }
6752
6753 /**
6754 * Returns true if an extra value is associated with the given name.
6755 * @param name the extra's name
6756 * @return true if the given extra is present.
6757 */
6758 public boolean hasExtra(String name) {
6759 return mExtras != null && mExtras.containsKey(name);
6760 }
6761
6762 /**
6763 * Returns true if the Intent's extras contain a parcelled file descriptor.
6764 * @return true if the Intent contains a parcelled file descriptor.
6765 */
6766 public boolean hasFileDescriptors() {
6767 return mExtras != null && mExtras.hasFileDescriptors();
6768 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006769
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006770 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006771 public void setAllowFds(boolean allowFds) {
6772 if (mExtras != null) {
6773 mExtras.setAllowFds(allowFds);
6774 }
6775 }
6776
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006777 /** {@hide} */
6778 public void setDefusable(boolean defusable) {
6779 if (mExtras != null) {
6780 mExtras.setDefusable(defusable);
6781 }
6782 }
6783
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006784 /**
6785 * Retrieve extended data from the intent.
6786 *
6787 * @param name The name of the desired item.
6788 *
6789 * @return the value of an item that previously added with putExtra()
6790 * or null if none was found.
6791 *
6792 * @deprecated
6793 * @hide
6794 */
6795 @Deprecated
6796 public Object getExtra(String name) {
6797 return getExtra(name, null);
6798 }
6799
6800 /**
6801 * Retrieve extended data from the intent.
6802 *
6803 * @param name The name of the desired item.
6804 * @param defaultValue the value to be returned if no value of the desired
6805 * type is stored with the given name.
6806 *
6807 * @return the value of an item that previously added with putExtra()
6808 * or the default value if none was found.
6809 *
6810 * @see #putExtra(String, boolean)
6811 */
6812 public boolean getBooleanExtra(String name, boolean defaultValue) {
6813 return mExtras == null ? defaultValue :
6814 mExtras.getBoolean(name, defaultValue);
6815 }
6816
6817 /**
6818 * Retrieve extended data from the intent.
6819 *
6820 * @param name The name of the desired item.
6821 * @param defaultValue the value to be returned if no value of the desired
6822 * type is stored with the given name.
6823 *
6824 * @return the value of an item that previously added with putExtra()
6825 * or the default value if none was found.
6826 *
6827 * @see #putExtra(String, byte)
6828 */
6829 public byte getByteExtra(String name, byte defaultValue) {
6830 return mExtras == null ? defaultValue :
6831 mExtras.getByte(name, defaultValue);
6832 }
6833
6834 /**
6835 * Retrieve extended data from the intent.
6836 *
6837 * @param name The name of the desired item.
6838 * @param defaultValue the value to be returned if no value of the desired
6839 * type is stored with the given name.
6840 *
6841 * @return the value of an item that previously added with putExtra()
6842 * or the default value if none was found.
6843 *
6844 * @see #putExtra(String, short)
6845 */
6846 public short getShortExtra(String name, short defaultValue) {
6847 return mExtras == null ? defaultValue :
6848 mExtras.getShort(name, defaultValue);
6849 }
6850
6851 /**
6852 * Retrieve extended data from the intent.
6853 *
6854 * @param name The name of the desired item.
6855 * @param defaultValue the value to be returned if no value of the desired
6856 * type is stored with the given name.
6857 *
6858 * @return the value of an item that previously added with putExtra()
6859 * or the default value if none was found.
6860 *
6861 * @see #putExtra(String, char)
6862 */
6863 public char getCharExtra(String name, char defaultValue) {
6864 return mExtras == null ? defaultValue :
6865 mExtras.getChar(name, defaultValue);
6866 }
6867
6868 /**
6869 * Retrieve extended data from the intent.
6870 *
6871 * @param name The name of the desired item.
6872 * @param defaultValue the value to be returned if no value of the desired
6873 * type is stored with the given name.
6874 *
6875 * @return the value of an item that previously added with putExtra()
6876 * or the default value if none was found.
6877 *
6878 * @see #putExtra(String, int)
6879 */
6880 public int getIntExtra(String name, int defaultValue) {
6881 return mExtras == null ? defaultValue :
6882 mExtras.getInt(name, defaultValue);
6883 }
6884
6885 /**
6886 * Retrieve extended data from the intent.
6887 *
6888 * @param name The name of the desired item.
6889 * @param defaultValue the value to be returned if no value of the desired
6890 * type is stored with the given name.
6891 *
6892 * @return the value of an item that previously added with putExtra()
6893 * or the default value if none was found.
6894 *
6895 * @see #putExtra(String, long)
6896 */
6897 public long getLongExtra(String name, long defaultValue) {
6898 return mExtras == null ? defaultValue :
6899 mExtras.getLong(name, defaultValue);
6900 }
6901
6902 /**
6903 * Retrieve extended data from the intent.
6904 *
6905 * @param name The name of the desired item.
6906 * @param defaultValue the value to be returned if no value of the desired
6907 * type is stored with the given name.
6908 *
6909 * @return the value of an item that previously added with putExtra(),
6910 * or the default value if no such item is present
6911 *
6912 * @see #putExtra(String, float)
6913 */
6914 public float getFloatExtra(String name, float defaultValue) {
6915 return mExtras == null ? defaultValue :
6916 mExtras.getFloat(name, defaultValue);
6917 }
6918
6919 /**
6920 * Retrieve extended data from the intent.
6921 *
6922 * @param name The name of the desired item.
6923 * @param defaultValue the value to be returned if no value of the desired
6924 * type is stored with the given name.
6925 *
6926 * @return the value of an item that previously added with putExtra()
6927 * or the default value if none was found.
6928 *
6929 * @see #putExtra(String, double)
6930 */
6931 public double getDoubleExtra(String name, double defaultValue) {
6932 return mExtras == null ? defaultValue :
6933 mExtras.getDouble(name, defaultValue);
6934 }
6935
6936 /**
6937 * Retrieve extended data from the intent.
6938 *
6939 * @param name The name of the desired item.
6940 *
6941 * @return the value of an item that previously added with putExtra()
6942 * or null if no String value was found.
6943 *
6944 * @see #putExtra(String, String)
6945 */
6946 public String getStringExtra(String name) {
6947 return mExtras == null ? null : mExtras.getString(name);
6948 }
6949
6950 /**
6951 * Retrieve extended data from the intent.
6952 *
6953 * @param name The name of the desired item.
6954 *
6955 * @return the value of an item that previously added with putExtra()
6956 * or null if no CharSequence value was found.
6957 *
6958 * @see #putExtra(String, CharSequence)
6959 */
6960 public CharSequence getCharSequenceExtra(String name) {
6961 return mExtras == null ? null : mExtras.getCharSequence(name);
6962 }
6963
6964 /**
6965 * Retrieve extended data from the intent.
6966 *
6967 * @param name The name of the desired item.
6968 *
6969 * @return the value of an item that previously added with putExtra()
6970 * or null if no Parcelable value was found.
6971 *
6972 * @see #putExtra(String, Parcelable)
6973 */
6974 public <T extends Parcelable> T getParcelableExtra(String name) {
6975 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6976 }
6977
6978 /**
6979 * Retrieve extended data from the intent.
6980 *
6981 * @param name The name of the desired item.
6982 *
6983 * @return the value of an item that previously added with putExtra()
6984 * or null if no Parcelable[] value was found.
6985 *
6986 * @see #putExtra(String, Parcelable[])
6987 */
6988 public Parcelable[] getParcelableArrayExtra(String name) {
6989 return mExtras == null ? null : mExtras.getParcelableArray(name);
6990 }
6991
6992 /**
6993 * Retrieve extended data from the intent.
6994 *
6995 * @param name The name of the desired item.
6996 *
6997 * @return the value of an item that previously added with putExtra()
6998 * or null if no ArrayList<Parcelable> value was found.
6999 *
7000 * @see #putParcelableArrayListExtra(String, ArrayList)
7001 */
7002 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7003 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7004 }
7005
7006 /**
7007 * Retrieve extended data from the intent.
7008 *
7009 * @param name The name of the desired item.
7010 *
7011 * @return the value of an item that previously added with putExtra()
7012 * or null if no Serializable value was found.
7013 *
7014 * @see #putExtra(String, Serializable)
7015 */
7016 public Serializable getSerializableExtra(String name) {
7017 return mExtras == null ? null : mExtras.getSerializable(name);
7018 }
7019
7020 /**
7021 * Retrieve extended data from the intent.
7022 *
7023 * @param name The name of the desired item.
7024 *
7025 * @return the value of an item that previously added with putExtra()
7026 * or null if no ArrayList<Integer> value was found.
7027 *
7028 * @see #putIntegerArrayListExtra(String, ArrayList)
7029 */
7030 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7031 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7032 }
7033
7034 /**
7035 * Retrieve extended data from the intent.
7036 *
7037 * @param name The name of the desired item.
7038 *
7039 * @return the value of an item that previously added with putExtra()
7040 * or null if no ArrayList<String> value was found.
7041 *
7042 * @see #putStringArrayListExtra(String, ArrayList)
7043 */
7044 public ArrayList<String> getStringArrayListExtra(String name) {
7045 return mExtras == null ? null : mExtras.getStringArrayList(name);
7046 }
7047
7048 /**
7049 * Retrieve extended data from the intent.
7050 *
7051 * @param name The name of the desired item.
7052 *
7053 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007054 * or null if no ArrayList<CharSequence> value was found.
7055 *
7056 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7057 */
7058 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7059 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7060 }
7061
7062 /**
7063 * Retrieve extended data from the intent.
7064 *
7065 * @param name The name of the desired item.
7066 *
7067 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007068 * or null if no boolean array value was found.
7069 *
7070 * @see #putExtra(String, boolean[])
7071 */
7072 public boolean[] getBooleanArrayExtra(String name) {
7073 return mExtras == null ? null : mExtras.getBooleanArray(name);
7074 }
7075
7076 /**
7077 * Retrieve extended data from the intent.
7078 *
7079 * @param name The name of the desired item.
7080 *
7081 * @return the value of an item that previously added with putExtra()
7082 * or null if no byte array value was found.
7083 *
7084 * @see #putExtra(String, byte[])
7085 */
7086 public byte[] getByteArrayExtra(String name) {
7087 return mExtras == null ? null : mExtras.getByteArray(name);
7088 }
7089
7090 /**
7091 * Retrieve extended data from the intent.
7092 *
7093 * @param name The name of the desired item.
7094 *
7095 * @return the value of an item that previously added with putExtra()
7096 * or null if no short array value was found.
7097 *
7098 * @see #putExtra(String, short[])
7099 */
7100 public short[] getShortArrayExtra(String name) {
7101 return mExtras == null ? null : mExtras.getShortArray(name);
7102 }
7103
7104 /**
7105 * Retrieve extended data from the intent.
7106 *
7107 * @param name The name of the desired item.
7108 *
7109 * @return the value of an item that previously added with putExtra()
7110 * or null if no char array value was found.
7111 *
7112 * @see #putExtra(String, char[])
7113 */
7114 public char[] getCharArrayExtra(String name) {
7115 return mExtras == null ? null : mExtras.getCharArray(name);
7116 }
7117
7118 /**
7119 * Retrieve extended data from the intent.
7120 *
7121 * @param name The name of the desired item.
7122 *
7123 * @return the value of an item that previously added with putExtra()
7124 * or null if no int array value was found.
7125 *
7126 * @see #putExtra(String, int[])
7127 */
7128 public int[] getIntArrayExtra(String name) {
7129 return mExtras == null ? null : mExtras.getIntArray(name);
7130 }
7131
7132 /**
7133 * Retrieve extended data from the intent.
7134 *
7135 * @param name The name of the desired item.
7136 *
7137 * @return the value of an item that previously added with putExtra()
7138 * or null if no long array value was found.
7139 *
7140 * @see #putExtra(String, long[])
7141 */
7142 public long[] getLongArrayExtra(String name) {
7143 return mExtras == null ? null : mExtras.getLongArray(name);
7144 }
7145
7146 /**
7147 * Retrieve extended data from the intent.
7148 *
7149 * @param name The name of the desired item.
7150 *
7151 * @return the value of an item that previously added with putExtra()
7152 * or null if no float array value was found.
7153 *
7154 * @see #putExtra(String, float[])
7155 */
7156 public float[] getFloatArrayExtra(String name) {
7157 return mExtras == null ? null : mExtras.getFloatArray(name);
7158 }
7159
7160 /**
7161 * Retrieve extended data from the intent.
7162 *
7163 * @param name The name of the desired item.
7164 *
7165 * @return the value of an item that previously added with putExtra()
7166 * or null if no double array value was found.
7167 *
7168 * @see #putExtra(String, double[])
7169 */
7170 public double[] getDoubleArrayExtra(String name) {
7171 return mExtras == null ? null : mExtras.getDoubleArray(name);
7172 }
7173
7174 /**
7175 * Retrieve extended data from the intent.
7176 *
7177 * @param name The name of the desired item.
7178 *
7179 * @return the value of an item that previously added with putExtra()
7180 * or null if no String array value was found.
7181 *
7182 * @see #putExtra(String, String[])
7183 */
7184 public String[] getStringArrayExtra(String name) {
7185 return mExtras == null ? null : mExtras.getStringArray(name);
7186 }
7187
7188 /**
7189 * Retrieve extended data from the intent.
7190 *
7191 * @param name The name of the desired item.
7192 *
7193 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007194 * or null if no CharSequence array value was found.
7195 *
7196 * @see #putExtra(String, CharSequence[])
7197 */
7198 public CharSequence[] getCharSequenceArrayExtra(String name) {
7199 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7200 }
7201
7202 /**
7203 * Retrieve extended data from the intent.
7204 *
7205 * @param name The name of the desired item.
7206 *
7207 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007208 * or null if no Bundle value was found.
7209 *
7210 * @see #putExtra(String, Bundle)
7211 */
7212 public Bundle getBundleExtra(String name) {
7213 return mExtras == null ? null : mExtras.getBundle(name);
7214 }
7215
7216 /**
7217 * Retrieve extended data from the intent.
7218 *
7219 * @param name The name of the desired item.
7220 *
7221 * @return the value of an item that previously added with putExtra()
7222 * or null if no IBinder value was found.
7223 *
7224 * @see #putExtra(String, IBinder)
7225 *
7226 * @deprecated
7227 * @hide
7228 */
7229 @Deprecated
7230 public IBinder getIBinderExtra(String name) {
7231 return mExtras == null ? null : mExtras.getIBinder(name);
7232 }
7233
7234 /**
7235 * Retrieve extended data from the intent.
7236 *
7237 * @param name The name of the desired item.
7238 * @param defaultValue The default value to return in case no item is
7239 * associated with the key 'name'
7240 *
7241 * @return the value of an item that previously added with putExtra()
7242 * or defaultValue if none was found.
7243 *
7244 * @see #putExtra
7245 *
7246 * @deprecated
7247 * @hide
7248 */
7249 @Deprecated
7250 public Object getExtra(String name, Object defaultValue) {
7251 Object result = defaultValue;
7252 if (mExtras != null) {
7253 Object result2 = mExtras.get(name);
7254 if (result2 != null) {
7255 result = result2;
7256 }
7257 }
7258
7259 return result;
7260 }
7261
7262 /**
7263 * Retrieves a map of extended data from the intent.
7264 *
7265 * @return the map of all extras previously added with putExtra(),
7266 * or null if none have been added.
7267 */
7268 public Bundle getExtras() {
7269 return (mExtras != null)
7270 ? new Bundle(mExtras)
7271 : null;
7272 }
7273
7274 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007275 * Filter extras to only basic types.
7276 * @hide
7277 */
7278 public void removeUnsafeExtras() {
7279 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007280 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007281 }
7282 }
7283
7284 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007285 * Retrieve any special flags associated with this intent. You will
7286 * normally just set them with {@link #setFlags} and let the system
7287 * take the appropriate action with them.
7288 *
7289 * @return int The currently set flags.
7290 *
7291 * @see #setFlags
7292 */
7293 public int getFlags() {
7294 return mFlags;
7295 }
7296
Dianne Hackborne7f97212011-02-24 14:40:20 -08007297 /** @hide */
7298 public boolean isExcludingStopped() {
7299 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7300 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7301 }
7302
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007303 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007304 * Retrieve the application package name this Intent is limited to. When
7305 * resolving an Intent, if non-null this limits the resolution to only
7306 * components in the given application package.
7307 *
7308 * @return The name of the application package for the Intent.
7309 *
7310 * @see #resolveActivity
7311 * @see #setPackage
7312 */
7313 public String getPackage() {
7314 return mPackage;
7315 }
7316
7317 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 * Retrieve the concrete component associated with the intent. When receiving
7319 * an intent, this is the component that was found to best handle it (that is,
7320 * yourself) and will always be non-null; in all other cases it will be
7321 * null unless explicitly set.
7322 *
7323 * @return The name of the application component to handle the intent.
7324 *
7325 * @see #resolveActivity
7326 * @see #setComponent
7327 */
7328 public ComponentName getComponent() {
7329 return mComponent;
7330 }
7331
7332 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007333 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7334 * used as a hint to the receiver for animations and the like. Null means that there
7335 * is no source bounds.
7336 */
7337 public Rect getSourceBounds() {
7338 return mSourceBounds;
7339 }
7340
7341 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007342 * Return the Activity component that should be used to handle this intent.
7343 * The appropriate component is determined based on the information in the
7344 * intent, evaluated as follows:
7345 *
7346 * <p>If {@link #getComponent} returns an explicit class, that is returned
7347 * without any further consideration.
7348 *
7349 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7350 * category to be considered.
7351 *
7352 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7353 * action.
7354 *
7355 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7356 * this type.
7357 *
7358 * <p>If {@link #addCategory} has added any categories, the activity must
7359 * handle ALL of the categories specified.
7360 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007361 * <p>If {@link #getPackage} is non-NULL, only activity components in
7362 * that application package will be considered.
7363 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007364 * <p>If there are no activities that satisfy all of these conditions, a
7365 * null string is returned.
7366 *
7367 * <p>If multiple activities are found to satisfy the intent, the one with
7368 * the highest priority will be used. If there are multiple activities
7369 * with the same priority, the system will either pick the best activity
7370 * based on user preference, or resolve to a system class that will allow
7371 * the user to pick an activity and forward from there.
7372 *
7373 * <p>This method is implemented simply by calling
7374 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7375 * true.</p>
7376 * <p> This API is called for you as part of starting an activity from an
7377 * intent. You do not normally need to call it yourself.</p>
7378 *
7379 * @param pm The package manager with which to resolve the Intent.
7380 *
7381 * @return Name of the component implementing an activity that can
7382 * display the intent.
7383 *
7384 * @see #setComponent
7385 * @see #getComponent
7386 * @see #resolveActivityInfo
7387 */
7388 public ComponentName resolveActivity(PackageManager pm) {
7389 if (mComponent != null) {
7390 return mComponent;
7391 }
7392
7393 ResolveInfo info = pm.resolveActivity(
7394 this, PackageManager.MATCH_DEFAULT_ONLY);
7395 if (info != null) {
7396 return new ComponentName(
7397 info.activityInfo.applicationInfo.packageName,
7398 info.activityInfo.name);
7399 }
7400
7401 return null;
7402 }
7403
7404 /**
7405 * Resolve the Intent into an {@link ActivityInfo}
7406 * describing the activity that should execute the intent. Resolution
7407 * follows the same rules as described for {@link #resolveActivity}, but
7408 * you get back the completely information about the resolved activity
7409 * instead of just its class name.
7410 *
7411 * @param pm The package manager with which to resolve the Intent.
7412 * @param flags Addition information to retrieve as per
7413 * {@link PackageManager#getActivityInfo(ComponentName, int)
7414 * PackageManager.getActivityInfo()}.
7415 *
7416 * @return PackageManager.ActivityInfo
7417 *
7418 * @see #resolveActivity
7419 */
7420 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7421 ActivityInfo ai = null;
7422 if (mComponent != null) {
7423 try {
7424 ai = pm.getActivityInfo(mComponent, flags);
7425 } catch (PackageManager.NameNotFoundException e) {
7426 // ignore
7427 }
7428 } else {
7429 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007430 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007431 if (info != null) {
7432 ai = info.activityInfo;
7433 }
7434 }
7435
7436 return ai;
7437 }
7438
7439 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007440 * Special function for use by the system to resolve service
7441 * intents to system apps. Throws an exception if there are
7442 * multiple potential matches to the Intent. Returns null if
7443 * there are no matches.
7444 * @hide
7445 */
7446 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7447 if (mComponent != null) {
7448 return mComponent;
7449 }
7450
7451 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7452 if (results == null) {
7453 return null;
7454 }
7455 ComponentName comp = null;
7456 for (int i=0; i<results.size(); i++) {
7457 ResolveInfo ri = results.get(i);
7458 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7459 continue;
7460 }
7461 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7462 ri.serviceInfo.name);
7463 if (comp != null) {
7464 throw new IllegalStateException("Multiple system services handle " + this
7465 + ": " + comp + ", " + foundComp);
7466 }
7467 comp = foundComp;
7468 }
7469 return comp;
7470 }
7471
7472 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007473 * Set the general action to be performed.
7474 *
7475 * @param action An action name, such as ACTION_VIEW. Application-specific
7476 * actions should be prefixed with the vendor's package name.
7477 *
7478 * @return Returns the same Intent object, for chaining multiple calls
7479 * into a single statement.
7480 *
7481 * @see #getAction
7482 */
7483 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007484 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007485 return this;
7486 }
7487
7488 /**
7489 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007490 * clears any type that was previously set by {@link #setType} or
7491 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007492 *
Nick Pellyccae4122012-01-09 14:12:58 -08007493 * <p><em>Note: scheme matching in the Android framework is
7494 * case-sensitive, unlike the formal RFC. As a result,
7495 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007496 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007497 * {@link #setDataAndNormalize}
7498 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007499 *
Nick Pellyccae4122012-01-09 14:12:58 -08007500 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007501 *
7502 * @return Returns the same Intent object, for chaining multiple calls
7503 * into a single statement.
7504 *
7505 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007506 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007507 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007508 */
7509 public Intent setData(Uri data) {
7510 mData = data;
7511 mType = null;
7512 return this;
7513 }
7514
7515 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007516 * Normalize and set the data this intent is operating on.
7517 *
7518 * <p>This method automatically clears any type that was
7519 * previously set (for example, by {@link #setType}).
7520 *
7521 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007522 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007523 * so really this is just a convenience method for
7524 * <pre>
7525 * setData(data.normalize())
7526 * </pre>
7527 *
7528 * @param data The Uri of the data this intent is now targeting.
7529 *
7530 * @return Returns the same Intent object, for chaining multiple calls
7531 * into a single statement.
7532 *
7533 * @see #getData
7534 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007535 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007536 */
7537 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007538 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007539 }
7540
7541 /**
7542 * Set an explicit MIME data type.
7543 *
7544 * <p>This is used to create intents that only specify a type and not data,
7545 * for example to indicate the type of data to return.
7546 *
7547 * <p>This method automatically clears any data that was
7548 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007549 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007550 * <p><em>Note: MIME type matching in the Android framework is
7551 * case-sensitive, unlike formal RFC MIME types. As a result,
7552 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007553 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7554 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007555 *
7556 * @param type The MIME type of the data being handled by this intent.
7557 *
7558 * @return Returns the same Intent object, for chaining multiple calls
7559 * into a single statement.
7560 *
7561 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007562 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007563 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007564 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007565 */
7566 public Intent setType(String type) {
7567 mData = null;
7568 mType = type;
7569 return this;
7570 }
7571
7572 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007573 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007574 *
Nick Pellyccae4122012-01-09 14:12:58 -08007575 * <p>This is used to create intents that only specify a type and not data,
7576 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007577 *
Nick Pellyccae4122012-01-09 14:12:58 -08007578 * <p>This method automatically clears any data that was
7579 * previously set (for example by {@link #setData}).
7580 *
7581 * <p>The MIME type is normalized using
7582 * {@link #normalizeMimeType} before it is set,
7583 * so really this is just a convenience method for
7584 * <pre>
7585 * setType(Intent.normalizeMimeType(type))
7586 * </pre>
7587 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007588 * @param type The MIME type of the data being handled by this intent.
7589 *
7590 * @return Returns the same Intent object, for chaining multiple calls
7591 * into a single statement.
7592 *
Nick Pellyccae4122012-01-09 14:12:58 -08007593 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007594 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007595 * @see #normalizeMimeType
7596 */
7597 public Intent setTypeAndNormalize(String type) {
7598 return setType(normalizeMimeType(type));
7599 }
7600
7601 /**
7602 * (Usually optional) Set the data for the intent along with an explicit
7603 * MIME data type. This method should very rarely be used -- it allows you
7604 * to override the MIME type that would ordinarily be inferred from the
7605 * data with your own type given here.
7606 *
7607 * <p><em>Note: MIME type and Uri scheme matching in the
7608 * Android framework is case-sensitive, unlike the formal RFC definitions.
7609 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007610 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007611 * {@link #setDataAndTypeAndNormalize}
7612 * to ensure that they are converted to lower case.</em>
7613 *
7614 * @param data The Uri of the data this intent is now targeting.
7615 * @param type The MIME type of the data being handled by this intent.
7616 *
7617 * @return Returns the same Intent object, for chaining multiple calls
7618 * into a single statement.
7619 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007620 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007621 * @see #setData
7622 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007623 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007624 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007625 */
7626 public Intent setDataAndType(Uri data, String type) {
7627 mData = data;
7628 mType = type;
7629 return this;
7630 }
7631
7632 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007633 * (Usually optional) Normalize and set both the data Uri and an explicit
7634 * MIME data type. This method should very rarely be used -- it allows you
7635 * to override the MIME type that would ordinarily be inferred from the
7636 * data with your own type given here.
7637 *
7638 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007639 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007640 * before they are set, so really this is just a convenience method for
7641 * <pre>
7642 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7643 * </pre>
7644 *
7645 * @param data The Uri of the data this intent is now targeting.
7646 * @param type The MIME type of the data being handled by this intent.
7647 *
7648 * @return Returns the same Intent object, for chaining multiple calls
7649 * into a single statement.
7650 *
7651 * @see #setType
7652 * @see #setData
7653 * @see #setDataAndType
7654 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007655 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007656 */
7657 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007658 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007659 }
7660
7661 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007662 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007663 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007664 * activities that provide <em>all</em> of the requested categories will be
7665 * used.
7666 *
7667 * @param category The desired category. This can be either one of the
7668 * predefined Intent categories, or a custom category in your own
7669 * namespace.
7670 *
7671 * @return Returns the same Intent object, for chaining multiple calls
7672 * into a single statement.
7673 *
7674 * @see #hasCategory
7675 * @see #removeCategory
7676 */
7677 public Intent addCategory(String category) {
7678 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007679 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007680 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007681 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007682 return this;
7683 }
7684
7685 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007686 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007687 *
7688 * @param category The category to remove.
7689 *
7690 * @see #addCategory
7691 */
7692 public void removeCategory(String category) {
7693 if (mCategories != null) {
7694 mCategories.remove(category);
7695 if (mCategories.size() == 0) {
7696 mCategories = null;
7697 }
7698 }
7699 }
7700
7701 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007702 * Set a selector for this Intent. This is a modification to the kinds of
7703 * things the Intent will match. If the selector is set, it will be used
7704 * when trying to find entities that can handle the Intent, instead of the
7705 * main contents of the Intent. This allows you build an Intent containing
7706 * a generic protocol while targeting it more specifically.
7707 *
7708 * <p>An example of where this may be used is with things like
7709 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7710 * Intent that will launch the Browser application. However, the correct
7711 * main entry point of an application is actually {@link #ACTION_MAIN}
7712 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7713 * used to specify the actual Activity to launch. If you launch the browser
7714 * with something different, undesired behavior may happen if the user has
7715 * previously or later launches it the normal way, since they do not match.
7716 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7717 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7718 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7719 *
7720 * <p>Setting a selector does not impact the behavior of
7721 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7722 * desired behavior of a selector -- it does not impact the base meaning
7723 * of the Intent, just what kinds of things will be matched against it
7724 * when determining who can handle it.</p>
7725 *
7726 * <p>You can not use both a selector and {@link #setPackage(String)} on
7727 * the same base Intent.</p>
7728 *
7729 * @param selector The desired selector Intent; set to null to not use
7730 * a special selector.
7731 */
7732 public void setSelector(Intent selector) {
7733 if (selector == this) {
7734 throw new IllegalArgumentException(
7735 "Intent being set as a selector of itself");
7736 }
7737 if (selector != null && mPackage != null) {
7738 throw new IllegalArgumentException(
7739 "Can't set selector when package name is already set");
7740 }
7741 mSelector = selector;
7742 }
7743
7744 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007745 * Set a {@link ClipData} associated with this Intent. This replaces any
7746 * previously set ClipData.
7747 *
7748 * <p>The ClipData in an intent is not used for Intent matching or other
7749 * such operations. Semantically it is like extras, used to transmit
7750 * additional data with the Intent. The main feature of using this over
7751 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7752 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7753 * items included in the clip data. This is useful, in particular, if
7754 * you want to transmit an Intent containing multiple <code>content:</code>
7755 * URIs for which the recipient may not have global permission to access the
7756 * content provider.
7757 *
7758 * <p>If the ClipData contains items that are themselves Intents, any
7759 * grant flags in those Intents will be ignored. Only the top-level flags
7760 * of the main Intent are respected, and will be applied to all Uri or
7761 * Intent items in the clip (or sub-items of the clip).
7762 *
7763 * <p>The MIME type, label, and icon in the ClipData object are not
7764 * directly used by Intent. Applications should generally rely on the
7765 * MIME type of the Intent itself, not what it may find in the ClipData.
7766 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007767 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007768 *
7769 * @param clip The new clip to set. May be null to clear the current clip.
7770 */
7771 public void setClipData(ClipData clip) {
7772 mClipData = clip;
7773 }
7774
7775 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007776 * This is NOT a secure mechanism to identify the user who sent the intent.
7777 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7778 * who sent the intent.
7779 * @hide
7780 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007781 public void prepareToLeaveUser(int userId) {
7782 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7783 // We want mContentUserHint to refer to the original user, so don't do anything.
7784 if (mContentUserHint == UserHandle.USER_CURRENT) {
7785 mContentUserHint = userId;
7786 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007787 }
7788
7789 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007790 * Add extended data to the intent. The name must include a package
7791 * prefix, for example the app com.android.contacts would use names
7792 * like "com.android.contacts.ShowAll".
7793 *
7794 * @param name The name of the extra data, with package prefix.
7795 * @param value The boolean data value.
7796 *
7797 * @return Returns the same Intent object, for chaining multiple calls
7798 * into a single statement.
7799 *
7800 * @see #putExtras
7801 * @see #removeExtra
7802 * @see #getBooleanExtra(String, boolean)
7803 */
7804 public Intent putExtra(String name, boolean value) {
7805 if (mExtras == null) {
7806 mExtras = new Bundle();
7807 }
7808 mExtras.putBoolean(name, value);
7809 return this;
7810 }
7811
7812 /**
7813 * Add extended data to the intent. The name must include a package
7814 * prefix, for example the app com.android.contacts would use names
7815 * like "com.android.contacts.ShowAll".
7816 *
7817 * @param name The name of the extra data, with package prefix.
7818 * @param value The byte data value.
7819 *
7820 * @return Returns the same Intent object, for chaining multiple calls
7821 * into a single statement.
7822 *
7823 * @see #putExtras
7824 * @see #removeExtra
7825 * @see #getByteExtra(String, byte)
7826 */
7827 public Intent putExtra(String name, byte value) {
7828 if (mExtras == null) {
7829 mExtras = new Bundle();
7830 }
7831 mExtras.putByte(name, value);
7832 return this;
7833 }
7834
7835 /**
7836 * Add extended data to the intent. The name must include a package
7837 * prefix, for example the app com.android.contacts would use names
7838 * like "com.android.contacts.ShowAll".
7839 *
7840 * @param name The name of the extra data, with package prefix.
7841 * @param value The char data value.
7842 *
7843 * @return Returns the same Intent object, for chaining multiple calls
7844 * into a single statement.
7845 *
7846 * @see #putExtras
7847 * @see #removeExtra
7848 * @see #getCharExtra(String, char)
7849 */
7850 public Intent putExtra(String name, char value) {
7851 if (mExtras == null) {
7852 mExtras = new Bundle();
7853 }
7854 mExtras.putChar(name, value);
7855 return this;
7856 }
7857
7858 /**
7859 * Add extended data to the intent. The name must include a package
7860 * prefix, for example the app com.android.contacts would use names
7861 * like "com.android.contacts.ShowAll".
7862 *
7863 * @param name The name of the extra data, with package prefix.
7864 * @param value The short data value.
7865 *
7866 * @return Returns the same Intent object, for chaining multiple calls
7867 * into a single statement.
7868 *
7869 * @see #putExtras
7870 * @see #removeExtra
7871 * @see #getShortExtra(String, short)
7872 */
7873 public Intent putExtra(String name, short value) {
7874 if (mExtras == null) {
7875 mExtras = new Bundle();
7876 }
7877 mExtras.putShort(name, value);
7878 return this;
7879 }
7880
7881 /**
7882 * Add extended data to the intent. The name must include a package
7883 * prefix, for example the app com.android.contacts would use names
7884 * like "com.android.contacts.ShowAll".
7885 *
7886 * @param name The name of the extra data, with package prefix.
7887 * @param value The integer data value.
7888 *
7889 * @return Returns the same Intent object, for chaining multiple calls
7890 * into a single statement.
7891 *
7892 * @see #putExtras
7893 * @see #removeExtra
7894 * @see #getIntExtra(String, int)
7895 */
7896 public Intent putExtra(String name, int value) {
7897 if (mExtras == null) {
7898 mExtras = new Bundle();
7899 }
7900 mExtras.putInt(name, value);
7901 return this;
7902 }
7903
7904 /**
7905 * Add extended data to the intent. The name must include a package
7906 * prefix, for example the app com.android.contacts would use names
7907 * like "com.android.contacts.ShowAll".
7908 *
7909 * @param name The name of the extra data, with package prefix.
7910 * @param value The long data value.
7911 *
7912 * @return Returns the same Intent object, for chaining multiple calls
7913 * into a single statement.
7914 *
7915 * @see #putExtras
7916 * @see #removeExtra
7917 * @see #getLongExtra(String, long)
7918 */
7919 public Intent putExtra(String name, long value) {
7920 if (mExtras == null) {
7921 mExtras = new Bundle();
7922 }
7923 mExtras.putLong(name, value);
7924 return this;
7925 }
7926
7927 /**
7928 * Add extended data to the intent. The name must include a package
7929 * prefix, for example the app com.android.contacts would use names
7930 * like "com.android.contacts.ShowAll".
7931 *
7932 * @param name The name of the extra data, with package prefix.
7933 * @param value The float data value.
7934 *
7935 * @return Returns the same Intent object, for chaining multiple calls
7936 * into a single statement.
7937 *
7938 * @see #putExtras
7939 * @see #removeExtra
7940 * @see #getFloatExtra(String, float)
7941 */
7942 public Intent putExtra(String name, float value) {
7943 if (mExtras == null) {
7944 mExtras = new Bundle();
7945 }
7946 mExtras.putFloat(name, value);
7947 return this;
7948 }
7949
7950 /**
7951 * Add extended data to the intent. The name must include a package
7952 * prefix, for example the app com.android.contacts would use names
7953 * like "com.android.contacts.ShowAll".
7954 *
7955 * @param name The name of the extra data, with package prefix.
7956 * @param value The double data value.
7957 *
7958 * @return Returns the same Intent object, for chaining multiple calls
7959 * into a single statement.
7960 *
7961 * @see #putExtras
7962 * @see #removeExtra
7963 * @see #getDoubleExtra(String, double)
7964 */
7965 public Intent putExtra(String name, double value) {
7966 if (mExtras == null) {
7967 mExtras = new Bundle();
7968 }
7969 mExtras.putDouble(name, value);
7970 return this;
7971 }
7972
7973 /**
7974 * Add extended data to the intent. The name must include a package
7975 * prefix, for example the app com.android.contacts would use names
7976 * like "com.android.contacts.ShowAll".
7977 *
7978 * @param name The name of the extra data, with package prefix.
7979 * @param value The String data value.
7980 *
7981 * @return Returns the same Intent object, for chaining multiple calls
7982 * into a single statement.
7983 *
7984 * @see #putExtras
7985 * @see #removeExtra
7986 * @see #getStringExtra(String)
7987 */
7988 public Intent putExtra(String name, String value) {
7989 if (mExtras == null) {
7990 mExtras = new Bundle();
7991 }
7992 mExtras.putString(name, value);
7993 return this;
7994 }
7995
7996 /**
7997 * Add extended data to the intent. The name must include a package
7998 * prefix, for example the app com.android.contacts would use names
7999 * like "com.android.contacts.ShowAll".
8000 *
8001 * @param name The name of the extra data, with package prefix.
8002 * @param value The CharSequence data value.
8003 *
8004 * @return Returns the same Intent object, for chaining multiple calls
8005 * into a single statement.
8006 *
8007 * @see #putExtras
8008 * @see #removeExtra
8009 * @see #getCharSequenceExtra(String)
8010 */
8011 public Intent putExtra(String name, CharSequence value) {
8012 if (mExtras == null) {
8013 mExtras = new Bundle();
8014 }
8015 mExtras.putCharSequence(name, value);
8016 return this;
8017 }
8018
8019 /**
8020 * Add extended data to the intent. The name must include a package
8021 * prefix, for example the app com.android.contacts would use names
8022 * like "com.android.contacts.ShowAll".
8023 *
8024 * @param name The name of the extra data, with package prefix.
8025 * @param value The Parcelable data value.
8026 *
8027 * @return Returns the same Intent object, for chaining multiple calls
8028 * into a single statement.
8029 *
8030 * @see #putExtras
8031 * @see #removeExtra
8032 * @see #getParcelableExtra(String)
8033 */
8034 public Intent putExtra(String name, Parcelable value) {
8035 if (mExtras == null) {
8036 mExtras = new Bundle();
8037 }
8038 mExtras.putParcelable(name, value);
8039 return this;
8040 }
8041
8042 /**
8043 * Add extended data to the intent. The name must include a package
8044 * prefix, for example the app com.android.contacts would use names
8045 * like "com.android.contacts.ShowAll".
8046 *
8047 * @param name The name of the extra data, with package prefix.
8048 * @param value The Parcelable[] data value.
8049 *
8050 * @return Returns the same Intent object, for chaining multiple calls
8051 * into a single statement.
8052 *
8053 * @see #putExtras
8054 * @see #removeExtra
8055 * @see #getParcelableArrayExtra(String)
8056 */
8057 public Intent putExtra(String name, Parcelable[] value) {
8058 if (mExtras == null) {
8059 mExtras = new Bundle();
8060 }
8061 mExtras.putParcelableArray(name, value);
8062 return this;
8063 }
8064
8065 /**
8066 * Add extended data to the intent. The name must include a package
8067 * prefix, for example the app com.android.contacts would use names
8068 * like "com.android.contacts.ShowAll".
8069 *
8070 * @param name The name of the extra data, with package prefix.
8071 * @param value The ArrayList<Parcelable> data value.
8072 *
8073 * @return Returns the same Intent object, for chaining multiple calls
8074 * into a single statement.
8075 *
8076 * @see #putExtras
8077 * @see #removeExtra
8078 * @see #getParcelableArrayListExtra(String)
8079 */
8080 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
8081 if (mExtras == null) {
8082 mExtras = new Bundle();
8083 }
8084 mExtras.putParcelableArrayList(name, value);
8085 return this;
8086 }
8087
8088 /**
8089 * Add extended data to the intent. The name must include a package
8090 * prefix, for example the app com.android.contacts would use names
8091 * like "com.android.contacts.ShowAll".
8092 *
8093 * @param name The name of the extra data, with package prefix.
8094 * @param value The ArrayList<Integer> data value.
8095 *
8096 * @return Returns the same Intent object, for chaining multiple calls
8097 * into a single statement.
8098 *
8099 * @see #putExtras
8100 * @see #removeExtra
8101 * @see #getIntegerArrayListExtra(String)
8102 */
8103 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
8104 if (mExtras == null) {
8105 mExtras = new Bundle();
8106 }
8107 mExtras.putIntegerArrayList(name, value);
8108 return this;
8109 }
8110
8111 /**
8112 * Add extended data to the intent. The name must include a package
8113 * prefix, for example the app com.android.contacts would use names
8114 * like "com.android.contacts.ShowAll".
8115 *
8116 * @param name The name of the extra data, with package prefix.
8117 * @param value The ArrayList<String> data value.
8118 *
8119 * @return Returns the same Intent object, for chaining multiple calls
8120 * into a single statement.
8121 *
8122 * @see #putExtras
8123 * @see #removeExtra
8124 * @see #getStringArrayListExtra(String)
8125 */
8126 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
8127 if (mExtras == null) {
8128 mExtras = new Bundle();
8129 }
8130 mExtras.putStringArrayList(name, value);
8131 return this;
8132 }
8133
8134 /**
8135 * Add extended data to the intent. The name must include a package
8136 * prefix, for example the app com.android.contacts would use names
8137 * like "com.android.contacts.ShowAll".
8138 *
8139 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008140 * @param value The ArrayList<CharSequence> data value.
8141 *
8142 * @return Returns the same Intent object, for chaining multiple calls
8143 * into a single statement.
8144 *
8145 * @see #putExtras
8146 * @see #removeExtra
8147 * @see #getCharSequenceArrayListExtra(String)
8148 */
8149 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
8150 if (mExtras == null) {
8151 mExtras = new Bundle();
8152 }
8153 mExtras.putCharSequenceArrayList(name, value);
8154 return this;
8155 }
8156
8157 /**
8158 * Add extended data to the intent. The name must include a package
8159 * prefix, for example the app com.android.contacts would use names
8160 * like "com.android.contacts.ShowAll".
8161 *
8162 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008163 * @param value The Serializable data value.
8164 *
8165 * @return Returns the same Intent object, for chaining multiple calls
8166 * into a single statement.
8167 *
8168 * @see #putExtras
8169 * @see #removeExtra
8170 * @see #getSerializableExtra(String)
8171 */
8172 public Intent putExtra(String name, Serializable value) {
8173 if (mExtras == null) {
8174 mExtras = new Bundle();
8175 }
8176 mExtras.putSerializable(name, value);
8177 return this;
8178 }
8179
8180 /**
8181 * Add extended data to the intent. The name must include a package
8182 * prefix, for example the app com.android.contacts would use names
8183 * like "com.android.contacts.ShowAll".
8184 *
8185 * @param name The name of the extra data, with package prefix.
8186 * @param value The boolean array data value.
8187 *
8188 * @return Returns the same Intent object, for chaining multiple calls
8189 * into a single statement.
8190 *
8191 * @see #putExtras
8192 * @see #removeExtra
8193 * @see #getBooleanArrayExtra(String)
8194 */
8195 public Intent putExtra(String name, boolean[] value) {
8196 if (mExtras == null) {
8197 mExtras = new Bundle();
8198 }
8199 mExtras.putBooleanArray(name, value);
8200 return this;
8201 }
8202
8203 /**
8204 * Add extended data to the intent. The name must include a package
8205 * prefix, for example the app com.android.contacts would use names
8206 * like "com.android.contacts.ShowAll".
8207 *
8208 * @param name The name of the extra data, with package prefix.
8209 * @param value The byte array data value.
8210 *
8211 * @return Returns the same Intent object, for chaining multiple calls
8212 * into a single statement.
8213 *
8214 * @see #putExtras
8215 * @see #removeExtra
8216 * @see #getByteArrayExtra(String)
8217 */
8218 public Intent putExtra(String name, byte[] value) {
8219 if (mExtras == null) {
8220 mExtras = new Bundle();
8221 }
8222 mExtras.putByteArray(name, value);
8223 return this;
8224 }
8225
8226 /**
8227 * Add extended data to the intent. The name must include a package
8228 * prefix, for example the app com.android.contacts would use names
8229 * like "com.android.contacts.ShowAll".
8230 *
8231 * @param name The name of the extra data, with package prefix.
8232 * @param value The short array data value.
8233 *
8234 * @return Returns the same Intent object, for chaining multiple calls
8235 * into a single statement.
8236 *
8237 * @see #putExtras
8238 * @see #removeExtra
8239 * @see #getShortArrayExtra(String)
8240 */
8241 public Intent putExtra(String name, short[] value) {
8242 if (mExtras == null) {
8243 mExtras = new Bundle();
8244 }
8245 mExtras.putShortArray(name, value);
8246 return this;
8247 }
8248
8249 /**
8250 * Add extended data to the intent. The name must include a package
8251 * prefix, for example the app com.android.contacts would use names
8252 * like "com.android.contacts.ShowAll".
8253 *
8254 * @param name The name of the extra data, with package prefix.
8255 * @param value The char array data value.
8256 *
8257 * @return Returns the same Intent object, for chaining multiple calls
8258 * into a single statement.
8259 *
8260 * @see #putExtras
8261 * @see #removeExtra
8262 * @see #getCharArrayExtra(String)
8263 */
8264 public Intent putExtra(String name, char[] value) {
8265 if (mExtras == null) {
8266 mExtras = new Bundle();
8267 }
8268 mExtras.putCharArray(name, value);
8269 return this;
8270 }
8271
8272 /**
8273 * Add extended data to the intent. The name must include a package
8274 * prefix, for example the app com.android.contacts would use names
8275 * like "com.android.contacts.ShowAll".
8276 *
8277 * @param name The name of the extra data, with package prefix.
8278 * @param value The int array data value.
8279 *
8280 * @return Returns the same Intent object, for chaining multiple calls
8281 * into a single statement.
8282 *
8283 * @see #putExtras
8284 * @see #removeExtra
8285 * @see #getIntArrayExtra(String)
8286 */
8287 public Intent putExtra(String name, int[] value) {
8288 if (mExtras == null) {
8289 mExtras = new Bundle();
8290 }
8291 mExtras.putIntArray(name, value);
8292 return this;
8293 }
8294
8295 /**
8296 * Add extended data to the intent. The name must include a package
8297 * prefix, for example the app com.android.contacts would use names
8298 * like "com.android.contacts.ShowAll".
8299 *
8300 * @param name The name of the extra data, with package prefix.
8301 * @param value The byte array data value.
8302 *
8303 * @return Returns the same Intent object, for chaining multiple calls
8304 * into a single statement.
8305 *
8306 * @see #putExtras
8307 * @see #removeExtra
8308 * @see #getLongArrayExtra(String)
8309 */
8310 public Intent putExtra(String name, long[] value) {
8311 if (mExtras == null) {
8312 mExtras = new Bundle();
8313 }
8314 mExtras.putLongArray(name, value);
8315 return this;
8316 }
8317
8318 /**
8319 * Add extended data to the intent. The name must include a package
8320 * prefix, for example the app com.android.contacts would use names
8321 * like "com.android.contacts.ShowAll".
8322 *
8323 * @param name The name of the extra data, with package prefix.
8324 * @param value The float array data value.
8325 *
8326 * @return Returns the same Intent object, for chaining multiple calls
8327 * into a single statement.
8328 *
8329 * @see #putExtras
8330 * @see #removeExtra
8331 * @see #getFloatArrayExtra(String)
8332 */
8333 public Intent putExtra(String name, float[] value) {
8334 if (mExtras == null) {
8335 mExtras = new Bundle();
8336 }
8337 mExtras.putFloatArray(name, value);
8338 return this;
8339 }
8340
8341 /**
8342 * Add extended data to the intent. The name must include a package
8343 * prefix, for example the app com.android.contacts would use names
8344 * like "com.android.contacts.ShowAll".
8345 *
8346 * @param name The name of the extra data, with package prefix.
8347 * @param value The double array data value.
8348 *
8349 * @return Returns the same Intent object, for chaining multiple calls
8350 * into a single statement.
8351 *
8352 * @see #putExtras
8353 * @see #removeExtra
8354 * @see #getDoubleArrayExtra(String)
8355 */
8356 public Intent putExtra(String name, double[] value) {
8357 if (mExtras == null) {
8358 mExtras = new Bundle();
8359 }
8360 mExtras.putDoubleArray(name, value);
8361 return this;
8362 }
8363
8364 /**
8365 * Add extended data to the intent. The name must include a package
8366 * prefix, for example the app com.android.contacts would use names
8367 * like "com.android.contacts.ShowAll".
8368 *
8369 * @param name The name of the extra data, with package prefix.
8370 * @param value The String array data value.
8371 *
8372 * @return Returns the same Intent object, for chaining multiple calls
8373 * into a single statement.
8374 *
8375 * @see #putExtras
8376 * @see #removeExtra
8377 * @see #getStringArrayExtra(String)
8378 */
8379 public Intent putExtra(String name, String[] value) {
8380 if (mExtras == null) {
8381 mExtras = new Bundle();
8382 }
8383 mExtras.putStringArray(name, value);
8384 return this;
8385 }
8386
8387 /**
8388 * Add extended data to the intent. The name must include a package
8389 * prefix, for example the app com.android.contacts would use names
8390 * like "com.android.contacts.ShowAll".
8391 *
8392 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008393 * @param value The CharSequence array data value.
8394 *
8395 * @return Returns the same Intent object, for chaining multiple calls
8396 * into a single statement.
8397 *
8398 * @see #putExtras
8399 * @see #removeExtra
8400 * @see #getCharSequenceArrayExtra(String)
8401 */
8402 public Intent putExtra(String name, CharSequence[] value) {
8403 if (mExtras == null) {
8404 mExtras = new Bundle();
8405 }
8406 mExtras.putCharSequenceArray(name, value);
8407 return this;
8408 }
8409
8410 /**
8411 * Add extended data to the intent. The name must include a package
8412 * prefix, for example the app com.android.contacts would use names
8413 * like "com.android.contacts.ShowAll".
8414 *
8415 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008416 * @param value The Bundle data value.
8417 *
8418 * @return Returns the same Intent object, for chaining multiple calls
8419 * into a single statement.
8420 *
8421 * @see #putExtras
8422 * @see #removeExtra
8423 * @see #getBundleExtra(String)
8424 */
8425 public Intent putExtra(String name, Bundle value) {
8426 if (mExtras == null) {
8427 mExtras = new Bundle();
8428 }
8429 mExtras.putBundle(name, value);
8430 return this;
8431 }
8432
8433 /**
8434 * Add extended data to the intent. The name must include a package
8435 * prefix, for example the app com.android.contacts would use names
8436 * like "com.android.contacts.ShowAll".
8437 *
8438 * @param name The name of the extra data, with package prefix.
8439 * @param value The IBinder data value.
8440 *
8441 * @return Returns the same Intent object, for chaining multiple calls
8442 * into a single statement.
8443 *
8444 * @see #putExtras
8445 * @see #removeExtra
8446 * @see #getIBinderExtra(String)
8447 *
8448 * @deprecated
8449 * @hide
8450 */
8451 @Deprecated
8452 public Intent putExtra(String name, IBinder value) {
8453 if (mExtras == null) {
8454 mExtras = new Bundle();
8455 }
8456 mExtras.putIBinder(name, value);
8457 return this;
8458 }
8459
8460 /**
8461 * Copy all extras in 'src' in to this intent.
8462 *
8463 * @param src Contains the extras to copy.
8464 *
8465 * @see #putExtra
8466 */
8467 public Intent putExtras(Intent src) {
8468 if (src.mExtras != null) {
8469 if (mExtras == null) {
8470 mExtras = new Bundle(src.mExtras);
8471 } else {
8472 mExtras.putAll(src.mExtras);
8473 }
8474 }
8475 return this;
8476 }
8477
8478 /**
8479 * Add a set of extended data to the intent. The keys must include a package
8480 * prefix, for example the app com.android.contacts would use names
8481 * like "com.android.contacts.ShowAll".
8482 *
8483 * @param extras The Bundle of extras to add to this intent.
8484 *
8485 * @see #putExtra
8486 * @see #removeExtra
8487 */
8488 public Intent putExtras(Bundle extras) {
8489 if (mExtras == null) {
8490 mExtras = new Bundle();
8491 }
8492 mExtras.putAll(extras);
8493 return this;
8494 }
8495
8496 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008497 * Completely replace the extras in the Intent with the extras in the
8498 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008499 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008500 * @param src The exact extras contained in this Intent are copied
8501 * into the target intent, replacing any that were previously there.
8502 */
8503 public Intent replaceExtras(Intent src) {
8504 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8505 return this;
8506 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008507
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008508 /**
8509 * Completely replace the extras in the Intent with the given Bundle of
8510 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008511 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008512 * @param extras The new set of extras in the Intent, or null to erase
8513 * all extras.
8514 */
8515 public Intent replaceExtras(Bundle extras) {
8516 mExtras = extras != null ? new Bundle(extras) : null;
8517 return this;
8518 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008519
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008520 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008521 * Remove extended data from the intent.
8522 *
8523 * @see #putExtra
8524 */
8525 public void removeExtra(String name) {
8526 if (mExtras != null) {
8527 mExtras.remove(name);
8528 if (mExtras.size() == 0) {
8529 mExtras = null;
8530 }
8531 }
8532 }
8533
8534 /**
8535 * Set special flags controlling how this intent is handled. Most values
8536 * here depend on the type of component being executed by the Intent,
8537 * specifically the FLAG_ACTIVITY_* flags are all for use with
8538 * {@link Context#startActivity Context.startActivity()} and the
8539 * FLAG_RECEIVER_* flags are all for use with
8540 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8541 *
Scott Main7aee61f2011-02-08 11:25:01 -08008542 * <p>See the
8543 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8544 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008545 * the behavior of your application.
8546 *
8547 * @param flags The desired flags.
8548 *
8549 * @return Returns the same Intent object, for chaining multiple calls
8550 * into a single statement.
8551 *
8552 * @see #getFlags
8553 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008554 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 *
8556 * @see #FLAG_GRANT_READ_URI_PERMISSION
8557 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008558 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8559 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008560 * @see #FLAG_DEBUG_LOG_RESOLUTION
8561 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008562 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008563 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008565 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008566 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8567 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008568 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008569 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008570 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008571 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008572 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008573 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008574 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008575 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8576 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008577 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008578 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008579 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008580 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8581 */
8582 public Intent setFlags(int flags) {
8583 mFlags = flags;
8584 return this;
8585 }
8586
8587 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008588 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008589 *
8590 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008591 * @return Returns the same Intent object, for chaining multiple calls into
8592 * a single statement.
8593 * @see #setFlags(int)
8594 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008595 */
8596 public Intent addFlags(int flags) {
8597 mFlags |= flags;
8598 return this;
8599 }
8600
8601 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008602 * Remove these flags from the intent.
8603 *
8604 * @param flags The flags to remove.
8605 * @see #setFlags(int)
8606 * @see #addFlags(int)
8607 */
8608 public void removeFlags(int flags) {
8609 mFlags &= ~flags;
8610 }
8611
8612 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008613 * (Usually optional) Set an explicit application package name that limits
8614 * the components this Intent will resolve to. If left to the default
8615 * value of null, all components in all applications will considered.
8616 * If non-null, the Intent can only match the components in the given
8617 * application package.
8618 *
8619 * @param packageName The name of the application package to handle the
8620 * intent, or null to allow any application package.
8621 *
8622 * @return Returns the same Intent object, for chaining multiple calls
8623 * into a single statement.
8624 *
8625 * @see #getPackage
8626 * @see #resolveActivity
8627 */
8628 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008629 if (packageName != null && mSelector != null) {
8630 throw new IllegalArgumentException(
8631 "Can't set package name when selector is already set");
8632 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008633 mPackage = packageName;
8634 return this;
8635 }
8636
8637 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008638 * (Usually optional) Explicitly set the component to handle the intent.
8639 * If left with the default value of null, the system will determine the
8640 * appropriate class to use based on the other fields (action, data,
8641 * type, categories) in the Intent. If this class is defined, the
8642 * specified class will always be used regardless of the other fields. You
8643 * should only set this value when you know you absolutely want a specific
8644 * class to be used; otherwise it is better to let the system find the
8645 * appropriate class so that you will respect the installed applications
8646 * and user preferences.
8647 *
8648 * @param component The name of the application component to handle the
8649 * intent, or null to let the system find one for you.
8650 *
8651 * @return Returns the same Intent object, for chaining multiple calls
8652 * into a single statement.
8653 *
8654 * @see #setClass
8655 * @see #setClassName(Context, String)
8656 * @see #setClassName(String, String)
8657 * @see #getComponent
8658 * @see #resolveActivity
8659 */
8660 public Intent setComponent(ComponentName component) {
8661 mComponent = component;
8662 return this;
8663 }
8664
8665 /**
8666 * Convenience for calling {@link #setComponent} with an
8667 * explicit class name.
8668 *
8669 * @param packageContext A Context of the application package implementing
8670 * this class.
8671 * @param className The name of a class inside of the application package
8672 * that will be used as the component for this Intent.
8673 *
8674 * @return Returns the same Intent object, for chaining multiple calls
8675 * into a single statement.
8676 *
8677 * @see #setComponent
8678 * @see #setClass
8679 */
8680 public Intent setClassName(Context packageContext, String className) {
8681 mComponent = new ComponentName(packageContext, className);
8682 return this;
8683 }
8684
8685 /**
8686 * Convenience for calling {@link #setComponent} with an
8687 * explicit application package name and class name.
8688 *
8689 * @param packageName The name of the package implementing the desired
8690 * component.
8691 * @param className The name of a class inside of the application package
8692 * that will be used as the component for this Intent.
8693 *
8694 * @return Returns the same Intent object, for chaining multiple calls
8695 * into a single statement.
8696 *
8697 * @see #setComponent
8698 * @see #setClass
8699 */
8700 public Intent setClassName(String packageName, String className) {
8701 mComponent = new ComponentName(packageName, className);
8702 return this;
8703 }
8704
8705 /**
8706 * Convenience for calling {@link #setComponent(ComponentName)} with the
8707 * name returned by a {@link Class} object.
8708 *
8709 * @param packageContext A Context of the application package implementing
8710 * this class.
8711 * @param cls The class name to set, equivalent to
8712 * <code>setClassName(context, cls.getName())</code>.
8713 *
8714 * @return Returns the same Intent object, for chaining multiple calls
8715 * into a single statement.
8716 *
8717 * @see #setComponent
8718 */
8719 public Intent setClass(Context packageContext, Class<?> cls) {
8720 mComponent = new ComponentName(packageContext, cls);
8721 return this;
8722 }
8723
8724 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008725 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8726 * used as a hint to the receiver for animations and the like. Null means that there
8727 * is no source bounds.
8728 */
8729 public void setSourceBounds(Rect r) {
8730 if (r != null) {
8731 mSourceBounds = new Rect(r);
8732 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008733 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008734 }
8735 }
8736
Tor Norbyed9273d62013-05-30 15:59:53 -07008737 /** @hide */
8738 @IntDef(flag = true,
8739 value = {
8740 FILL_IN_ACTION,
8741 FILL_IN_DATA,
8742 FILL_IN_CATEGORIES,
8743 FILL_IN_COMPONENT,
8744 FILL_IN_PACKAGE,
8745 FILL_IN_SOURCE_BOUNDS,
8746 FILL_IN_SELECTOR,
8747 FILL_IN_CLIP_DATA
8748 })
8749 @Retention(RetentionPolicy.SOURCE)
8750 public @interface FillInFlags {}
8751
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008752 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008753 * Use with {@link #fillIn} to allow the current action value to be
8754 * overwritten, even if it is already set.
8755 */
8756 public static final int FILL_IN_ACTION = 1<<0;
8757
8758 /**
8759 * Use with {@link #fillIn} to allow the current data or type value
8760 * overwritten, even if it is already set.
8761 */
8762 public static final int FILL_IN_DATA = 1<<1;
8763
8764 /**
8765 * Use with {@link #fillIn} to allow the current categories to be
8766 * overwritten, even if they are already set.
8767 */
8768 public static final int FILL_IN_CATEGORIES = 1<<2;
8769
8770 /**
8771 * Use with {@link #fillIn} to allow the current component value to be
8772 * overwritten, even if it is already set.
8773 */
8774 public static final int FILL_IN_COMPONENT = 1<<3;
8775
8776 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008777 * Use with {@link #fillIn} to allow the current package value to be
8778 * overwritten, even if it is already set.
8779 */
8780 public static final int FILL_IN_PACKAGE = 1<<4;
8781
8782 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008783 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008784 * overwritten, even if it is already set.
8785 */
8786 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8787
8788 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008789 * Use with {@link #fillIn} to allow the current selector to be
8790 * overwritten, even if it is already set.
8791 */
8792 public static final int FILL_IN_SELECTOR = 1<<6;
8793
8794 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008795 * Use with {@link #fillIn} to allow the current ClipData to be
8796 * overwritten, even if it is already set.
8797 */
8798 public static final int FILL_IN_CLIP_DATA = 1<<7;
8799
8800 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008801 * Copy the contents of <var>other</var> in to this object, but only
8802 * where fields are not defined by this object. For purposes of a field
8803 * being defined, the following pieces of data in the Intent are
8804 * considered to be separate fields:
8805 *
8806 * <ul>
8807 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008808 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008809 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8810 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008811 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008812 * <li> component, as set by {@link #setComponent(ComponentName)} or
8813 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008814 * <li> source bounds, as set by {@link #setSourceBounds}.
8815 * <li> selector, as set by {@link #setSelector(Intent)}.
8816 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008817 * <li> each top-level name in the associated extras.
8818 * </ul>
8819 *
8820 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008821 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008822 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8823 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8824 * the restriction where the corresponding field will not be replaced if
8825 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008826 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008827 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8828 * is explicitly specified. The selector will only be copied if
8829 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008830 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008831 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8832 * and Intent B with {action="gotit", data-type="some/thing",
8833 * categories="one","two"}.
8834 *
8835 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8836 * containing: {action="gotit", data-type="some/thing",
8837 * categories="bar"}.
8838 *
8839 * @param other Another Intent whose values are to be used to fill in
8840 * the current one.
8841 * @param flags Options to control which fields can be filled in.
8842 *
8843 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008844 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008845 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008846 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008847 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008848 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008849 @FillInFlags
8850 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008851 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008852 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008853 if (other.mAction != null
8854 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008855 mAction = other.mAction;
8856 changes |= FILL_IN_ACTION;
8857 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008858 if ((other.mData != null || other.mType != null)
8859 && ((mData == null && mType == null)
8860 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008861 mData = other.mData;
8862 mType = other.mType;
8863 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008864 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008865 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008866 if (other.mCategories != null
8867 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008868 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008869 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008870 }
8871 changes |= FILL_IN_CATEGORIES;
8872 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008873 if (other.mPackage != null
8874 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008875 // Only do this if mSelector is not set.
8876 if (mSelector == null) {
8877 mPackage = other.mPackage;
8878 changes |= FILL_IN_PACKAGE;
8879 }
8880 }
8881 // Selector is special: it can only be set if explicitly allowed,
8882 // for the same reason as the component name.
8883 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8884 if (mPackage == null) {
8885 mSelector = new Intent(other.mSelector);
8886 mPackage = null;
8887 changes |= FILL_IN_SELECTOR;
8888 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008889 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008890 if (other.mClipData != null
8891 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8892 mClipData = other.mClipData;
8893 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008894 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008895 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008896 // Component is special: it can -only- be set if explicitly allowed,
8897 // since otherwise the sender could force the intent somewhere the
8898 // originator didn't intend.
8899 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008900 mComponent = other.mComponent;
8901 changes |= FILL_IN_COMPONENT;
8902 }
8903 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008904 if (other.mSourceBounds != null
8905 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8906 mSourceBounds = new Rect(other.mSourceBounds);
8907 changes |= FILL_IN_SOURCE_BOUNDS;
8908 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008909 if (mExtras == null) {
8910 if (other.mExtras != null) {
8911 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008912 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008913 }
8914 } else if (other.mExtras != null) {
8915 try {
8916 Bundle newb = new Bundle(other.mExtras);
8917 newb.putAll(mExtras);
8918 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008919 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008920 } catch (RuntimeException e) {
8921 // Modifying the extras can cause us to unparcel the contents
8922 // of the bundle, and if we do this in the system process that
8923 // may fail. We really should handle this (i.e., the Bundle
8924 // impl shouldn't be on top of a plain map), but for now just
8925 // ignore it and keep the original contents. :(
8926 Log.w("Intent", "Failure filling in extras", e);
8927 }
8928 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008929 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8930 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8931 mContentUserHint = other.mContentUserHint;
8932 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008933 return changes;
8934 }
8935
8936 /**
8937 * Wrapper class holding an Intent and implementing comparisons on it for
8938 * the purpose of filtering. The class implements its
8939 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8940 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8941 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8942 * on the wrapped Intent.
8943 */
8944 public static final class FilterComparison {
8945 private final Intent mIntent;
8946 private final int mHashCode;
8947
8948 public FilterComparison(Intent intent) {
8949 mIntent = intent;
8950 mHashCode = intent.filterHashCode();
8951 }
8952
8953 /**
8954 * Return the Intent that this FilterComparison represents.
8955 * @return Returns the Intent held by the FilterComparison. Do
8956 * not modify!
8957 */
8958 public Intent getIntent() {
8959 return mIntent;
8960 }
8961
8962 @Override
8963 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008964 if (obj instanceof FilterComparison) {
8965 Intent other = ((FilterComparison)obj).mIntent;
8966 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008967 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008968 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008969 }
8970
8971 @Override
8972 public int hashCode() {
8973 return mHashCode;
8974 }
8975 }
8976
8977 /**
8978 * Determine if two intents are the same for the purposes of intent
8979 * resolution (filtering). That is, if their action, data, type,
8980 * class, and categories are the same. This does <em>not</em> compare
8981 * any extra data included in the intents.
8982 *
8983 * @param other The other Intent to compare against.
8984 *
8985 * @return Returns true if action, data, type, class, and categories
8986 * are the same.
8987 */
8988 public boolean filterEquals(Intent other) {
8989 if (other == null) {
8990 return false;
8991 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008992 if (!Objects.equals(this.mAction, other.mAction)) return false;
8993 if (!Objects.equals(this.mData, other.mData)) return false;
8994 if (!Objects.equals(this.mType, other.mType)) return false;
8995 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8996 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8997 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008998
8999 return true;
9000 }
9001
9002 /**
9003 * Generate hash code that matches semantics of filterEquals().
9004 *
9005 * @return Returns the hash value of the action, data, type, class, and
9006 * categories.
9007 *
9008 * @see #filterEquals
9009 */
9010 public int filterHashCode() {
9011 int code = 0;
9012 if (mAction != null) {
9013 code += mAction.hashCode();
9014 }
9015 if (mData != null) {
9016 code += mData.hashCode();
9017 }
9018 if (mType != null) {
9019 code += mType.hashCode();
9020 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009021 if (mPackage != null) {
9022 code += mPackage.hashCode();
9023 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009024 if (mComponent != null) {
9025 code += mComponent.hashCode();
9026 }
9027 if (mCategories != null) {
9028 code += mCategories.hashCode();
9029 }
9030 return code;
9031 }
9032
9033 @Override
9034 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009035 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009036
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009037 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009038 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009039 b.append(" }");
9040
9041 return b.toString();
9042 }
9043
9044 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009045 public String toInsecureString() {
9046 StringBuilder b = new StringBuilder(128);
9047
9048 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009049 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009050 b.append(" }");
9051
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009052 return b.toString();
9053 }
Romain Guy4969af72009-06-17 10:53:19 -07009054
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009055 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009056 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009057 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009058
9059 b.append("Intent { ");
9060 toShortString(b, false, true, true, true);
9061 b.append(" }");
9062
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009063 return b.toString();
9064 }
9065
9066 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009067 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9068 StringBuilder b = new StringBuilder(128);
9069 toShortString(b, secure, comp, extras, clip);
9070 return b.toString();
9071 }
9072
9073 /** @hide */
9074 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9075 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009076 boolean first = true;
9077 if (mAction != null) {
9078 b.append("act=").append(mAction);
9079 first = false;
9080 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009081 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009082 if (!first) {
9083 b.append(' ');
9084 }
9085 first = false;
9086 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009087 for (int i=0; i<mCategories.size(); i++) {
9088 if (i > 0) b.append(',');
9089 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009091 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009092 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009093 if (mData != null) {
9094 if (!first) {
9095 b.append(' ');
9096 }
9097 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009098 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009099 if (secure) {
9100 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009101 } else {
9102 b.append(mData);
9103 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009104 }
9105 if (mType != null) {
9106 if (!first) {
9107 b.append(' ');
9108 }
9109 first = false;
9110 b.append("typ=").append(mType);
9111 }
9112 if (mFlags != 0) {
9113 if (!first) {
9114 b.append(' ');
9115 }
9116 first = false;
9117 b.append("flg=0x").append(Integer.toHexString(mFlags));
9118 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009119 if (mPackage != null) {
9120 if (!first) {
9121 b.append(' ');
9122 }
9123 first = false;
9124 b.append("pkg=").append(mPackage);
9125 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009126 if (comp && mComponent != null) {
9127 if (!first) {
9128 b.append(' ');
9129 }
9130 first = false;
9131 b.append("cmp=").append(mComponent.flattenToShortString());
9132 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009133 if (mSourceBounds != null) {
9134 if (!first) {
9135 b.append(' ');
9136 }
9137 first = false;
9138 b.append("bnds=").append(mSourceBounds.toShortString());
9139 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009140 if (mClipData != null) {
9141 if (!first) {
9142 b.append(' ');
9143 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009144 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009145 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009146 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009147 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009148 if (mClipData.getDescription() != null) {
9149 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9150 } else {
9151 first = true;
9152 }
9153 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009154 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009155 first = false;
9156 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009157 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009158 if (extras && mExtras != null) {
9159 if (!first) {
9160 b.append(' ');
9161 }
9162 first = false;
9163 b.append("(has extras)");
9164 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009165 if (mContentUserHint != UserHandle.USER_CURRENT) {
9166 if (!first) {
9167 b.append(' ');
9168 }
9169 first = false;
9170 b.append("u=").append(mContentUserHint);
9171 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009172 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009173 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009174 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009175 b.append("}");
9176 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009177 }
9178
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009179 /**
9180 * Call {@link #toUri} with 0 flags.
9181 * @deprecated Use {@link #toUri} instead.
9182 */
9183 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009184 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009185 return toUri(0);
9186 }
9187
9188 /**
9189 * Convert this Intent into a String holding a URI representation of it.
9190 * The returned URI string has been properly URI encoded, so it can be
9191 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9192 * Intent's data as the base URI, with an additional fragment describing
9193 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009194 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009195 * <p>You can convert the returned string back to an Intent with
9196 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009197 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009198 * @param flags Additional operating flags. Either 0,
9199 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08009200 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009201 * @return Returns a URI encoding URI string describing the entire contents
9202 * of the Intent.
9203 */
9204 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009205 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009206 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9207 if (mPackage == null) {
9208 throw new IllegalArgumentException(
9209 "Intent must include an explicit package name to build an android-app: "
9210 + this);
9211 }
9212 uri.append("android-app://");
9213 uri.append(mPackage);
9214 String scheme = null;
9215 if (mData != null) {
9216 scheme = mData.getScheme();
9217 if (scheme != null) {
9218 uri.append('/');
9219 uri.append(scheme);
9220 String authority = mData.getEncodedAuthority();
9221 if (authority != null) {
9222 uri.append('/');
9223 uri.append(authority);
9224 String path = mData.getEncodedPath();
9225 if (path != null) {
9226 uri.append(path);
9227 }
9228 String queryParams = mData.getEncodedQuery();
9229 if (queryParams != null) {
9230 uri.append('?');
9231 uri.append(queryParams);
9232 }
9233 String fragment = mData.getEncodedFragment();
9234 if (fragment != null) {
9235 uri.append('#');
9236 uri.append(fragment);
9237 }
9238 }
9239 }
9240 }
9241 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9242 mPackage, flags);
9243 return uri.toString();
9244 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009245 String scheme = null;
9246 if (mData != null) {
9247 String data = mData.toString();
9248 if ((flags&URI_INTENT_SCHEME) != 0) {
9249 final int N = data.length();
9250 for (int i=0; i<N; i++) {
9251 char c = data.charAt(i);
9252 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9253 || c == '.' || c == '-') {
9254 continue;
9255 }
9256 if (c == ':' && i > 0) {
9257 // Valid scheme.
9258 scheme = data.substring(0, i);
9259 uri.append("intent:");
9260 data = data.substring(i+1);
9261 break;
9262 }
Tom Taylord4a47292009-12-21 13:59:18 -08009263
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009264 // No scheme.
9265 break;
9266 }
9267 }
9268 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009269
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009270 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9271 uri.append("intent:");
9272 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009273
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009274 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009275
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009276 return uri.toString();
9277 }
9278
9279 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9280 String defPackage, int flags) {
9281 StringBuilder frag = new StringBuilder(128);
9282
9283 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009284 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009285 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009286 // Note that for now we are not going to try to handle the
9287 // data part; not clear how to represent this as a URI, and
9288 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009289 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9290 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009291 }
9292
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009293 if (frag.length() > 0) {
9294 uri.append("#Intent;");
9295 uri.append(frag);
9296 uri.append("end");
9297 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009298 }
9299
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009300 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9301 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009302 if (scheme != null) {
9303 uri.append("scheme=").append(scheme).append(';');
9304 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009305 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009306 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009307 }
9308 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009309 for (int i=0; i<mCategories.size(); i++) {
9310 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009311 }
9312 }
9313 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009314 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009315 }
9316 if (mFlags != 0) {
9317 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9318 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009319 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009320 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9321 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009322 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009323 uri.append("component=").append(Uri.encode(
9324 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009325 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009326 if (mSourceBounds != null) {
9327 uri.append("sourceBounds=")
9328 .append(Uri.encode(mSourceBounds.flattenToString()))
9329 .append(';');
9330 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009331 if (mExtras != null) {
9332 for (String key : mExtras.keySet()) {
9333 final Object value = mExtras.get(key);
9334 char entryType =
9335 value instanceof String ? 'S' :
9336 value instanceof Boolean ? 'B' :
9337 value instanceof Byte ? 'b' :
9338 value instanceof Character ? 'c' :
9339 value instanceof Double ? 'd' :
9340 value instanceof Float ? 'f' :
9341 value instanceof Integer ? 'i' :
9342 value instanceof Long ? 'l' :
9343 value instanceof Short ? 's' :
9344 '\0';
9345
9346 if (entryType != '\0') {
9347 uri.append(entryType);
9348 uri.append('.');
9349 uri.append(Uri.encode(key));
9350 uri.append('=');
9351 uri.append(Uri.encode(value.toString()));
9352 uri.append(';');
9353 }
9354 }
9355 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009356 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009357
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009358 public int describeContents() {
9359 return (mExtras != null) ? mExtras.describeContents() : 0;
9360 }
9361
9362 public void writeToParcel(Parcel out, int flags) {
9363 out.writeString(mAction);
9364 Uri.writeToParcel(out, mData);
9365 out.writeString(mType);
9366 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009367 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009368 ComponentName.writeToParcel(mComponent, out);
9369
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009370 if (mSourceBounds != null) {
9371 out.writeInt(1);
9372 mSourceBounds.writeToParcel(out, flags);
9373 } else {
9374 out.writeInt(0);
9375 }
9376
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009377 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009378 final int N = mCategories.size();
9379 out.writeInt(N);
9380 for (int i=0; i<N; i++) {
9381 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009382 }
9383 } else {
9384 out.writeInt(0);
9385 }
9386
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009387 if (mSelector != null) {
9388 out.writeInt(1);
9389 mSelector.writeToParcel(out, flags);
9390 } else {
9391 out.writeInt(0);
9392 }
9393
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009394 if (mClipData != null) {
9395 out.writeInt(1);
9396 mClipData.writeToParcel(out, flags);
9397 } else {
9398 out.writeInt(0);
9399 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009400 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009401 out.writeBundle(mExtras);
9402 }
9403
9404 public static final Parcelable.Creator<Intent> CREATOR
9405 = new Parcelable.Creator<Intent>() {
9406 public Intent createFromParcel(Parcel in) {
9407 return new Intent(in);
9408 }
9409 public Intent[] newArray(int size) {
9410 return new Intent[size];
9411 }
9412 };
9413
Dianne Hackborneb034652009-09-07 00:49:58 -07009414 /** @hide */
9415 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009416 readFromParcel(in);
9417 }
9418
9419 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009420 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009421 mData = Uri.CREATOR.createFromParcel(in);
9422 mType = in.readString();
9423 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009424 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009425 mComponent = ComponentName.readFromParcel(in);
9426
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009427 if (in.readInt() != 0) {
9428 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9429 }
9430
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009431 int N = in.readInt();
9432 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009433 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009434 int i;
9435 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009436 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009437 }
9438 } else {
9439 mCategories = null;
9440 }
9441
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009442 if (in.readInt() != 0) {
9443 mSelector = new Intent(in);
9444 }
9445
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009446 if (in.readInt() != 0) {
9447 mClipData = new ClipData(in);
9448 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009449 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009450 mExtras = in.readBundle();
9451 }
9452
9453 /**
9454 * Parses the "intent" element (and its children) from XML and instantiates
9455 * an Intent object. The given XML parser should be located at the tag
9456 * where parsing should start (often named "intent"), from which the
9457 * basic action, data, type, and package and class name will be
9458 * retrieved. The function will then parse in to any child elements,
9459 * looking for <category android:name="xxx"> tags to add categories and
9460 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9461 * to the intent.
9462 *
9463 * @param resources The Resources to use when inflating resources.
9464 * @param parser The XML parser pointing at an "intent" tag.
9465 * @param attrs The AttributeSet interface for retrieving extended
9466 * attribute data at the current <var>parser</var> location.
9467 * @return An Intent object matching the XML data.
9468 * @throws XmlPullParserException If there was an XML parsing error.
9469 * @throws IOException If there was an I/O error.
9470 */
9471 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9472 throws XmlPullParserException, IOException {
9473 Intent intent = new Intent();
9474
9475 TypedArray sa = resources.obtainAttributes(attrs,
9476 com.android.internal.R.styleable.Intent);
9477
9478 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9479
9480 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9481 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9482 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9483
9484 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9485 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9486 if (packageName != null && className != null) {
9487 intent.setComponent(new ComponentName(packageName, className));
9488 }
9489
9490 sa.recycle();
9491
9492 int outerDepth = parser.getDepth();
9493 int type;
9494 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9495 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9496 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9497 continue;
9498 }
9499
9500 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009501 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009502 sa = resources.obtainAttributes(attrs,
9503 com.android.internal.R.styleable.IntentCategory);
9504 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9505 sa.recycle();
9506
9507 if (cat != null) {
9508 intent.addCategory(cat);
9509 }
9510 XmlUtils.skipCurrentTag(parser);
9511
Craig Mautner21d24a22014-04-23 11:45:37 -07009512 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009513 if (intent.mExtras == null) {
9514 intent.mExtras = new Bundle();
9515 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009516 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009517 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009518
9519 } else {
9520 XmlUtils.skipCurrentTag(parser);
9521 }
9522 }
9523
9524 return intent;
9525 }
Nick Pellyccae4122012-01-09 14:12:58 -08009526
Craig Mautner21d24a22014-04-23 11:45:37 -07009527 /** @hide */
9528 public void saveToXml(XmlSerializer out) throws IOException {
9529 if (mAction != null) {
9530 out.attribute(null, ATTR_ACTION, mAction);
9531 }
9532 if (mData != null) {
9533 out.attribute(null, ATTR_DATA, mData.toString());
9534 }
9535 if (mType != null) {
9536 out.attribute(null, ATTR_TYPE, mType);
9537 }
9538 if (mComponent != null) {
9539 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9540 }
9541 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9542
9543 if (mCategories != null) {
9544 out.startTag(null, TAG_CATEGORIES);
9545 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9546 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9547 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009548 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009549 }
9550 }
9551
9552 /** @hide */
9553 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9554 XmlPullParserException {
9555 Intent intent = new Intent();
9556 final int outerDepth = in.getDepth();
9557
9558 int attrCount = in.getAttributeCount();
9559 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9560 final String attrName = in.getAttributeName(attrNdx);
9561 final String attrValue = in.getAttributeValue(attrNdx);
9562 if (ATTR_ACTION.equals(attrName)) {
9563 intent.setAction(attrValue);
9564 } else if (ATTR_DATA.equals(attrName)) {
9565 intent.setData(Uri.parse(attrValue));
9566 } else if (ATTR_TYPE.equals(attrName)) {
9567 intent.setType(attrValue);
9568 } else if (ATTR_COMPONENT.equals(attrName)) {
9569 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9570 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009571 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009572 } else {
9573 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9574 }
9575 }
9576
9577 int event;
9578 String name;
9579 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9580 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9581 if (event == XmlPullParser.START_TAG) {
9582 name = in.getName();
9583 if (TAG_CATEGORIES.equals(name)) {
9584 attrCount = in.getAttributeCount();
9585 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9586 intent.addCategory(in.getAttributeValue(attrNdx));
9587 }
9588 } else {
9589 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9590 XmlUtils.skipCurrentTag(in);
9591 }
9592 }
9593 }
9594
9595 return intent;
9596 }
9597
Nick Pellyccae4122012-01-09 14:12:58 -08009598 /**
9599 * Normalize a MIME data type.
9600 *
9601 * <p>A normalized MIME type has white-space trimmed,
9602 * content-type parameters removed, and is lower-case.
9603 * This aligns the type with Android best practices for
9604 * intent filtering.
9605 *
9606 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9607 * "text/x-vCard" becomes "text/x-vcard".
9608 *
9609 * <p>All MIME types received from outside Android (such as user input,
9610 * or external sources like Bluetooth, NFC, or the Internet) should
9611 * be normalized before they are used to create an Intent.
9612 *
9613 * @param type MIME data type to normalize
9614 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009615 * @see #setType
9616 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009617 */
9618 public static String normalizeMimeType(String type) {
9619 if (type == null) {
9620 return null;
9621 }
9622
Elliott Hughescb64d432013-08-02 10:00:44 -07009623 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009624
9625 final int semicolonIndex = type.indexOf(';');
9626 if (semicolonIndex != -1) {
9627 type = type.substring(0, semicolonIndex);
9628 }
9629 return type;
9630 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009631
9632 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009633 * Prepare this {@link Intent} to leave an app process.
9634 *
9635 * @hide
9636 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009637 public void prepareToLeaveProcess(Context context) {
9638 final boolean leavingPackage = (mComponent == null)
9639 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9640 prepareToLeaveProcess(leavingPackage);
9641 }
9642
9643 /**
9644 * Prepare this {@link Intent} to leave an app process.
9645 *
9646 * @hide
9647 */
9648 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009649 setAllowFds(false);
9650
9651 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009652 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009653 }
9654 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009655 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009656 }
9657
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009658 if (mExtras != null && !mExtras.isParcelled()) {
9659 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9660 if (intent instanceof Intent) {
9661 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9662 }
9663 }
9664
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009665 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9666 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009667 switch (mAction) {
9668 case ACTION_MEDIA_REMOVED:
9669 case ACTION_MEDIA_UNMOUNTED:
9670 case ACTION_MEDIA_CHECKING:
9671 case ACTION_MEDIA_NOFS:
9672 case ACTION_MEDIA_MOUNTED:
9673 case ACTION_MEDIA_SHARED:
9674 case ACTION_MEDIA_UNSHARED:
9675 case ACTION_MEDIA_BAD_REMOVAL:
9676 case ACTION_MEDIA_UNMOUNTABLE:
9677 case ACTION_MEDIA_EJECT:
9678 case ACTION_MEDIA_SCANNER_STARTED:
9679 case ACTION_MEDIA_SCANNER_FINISHED:
9680 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009681 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9682 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009683 // Ignore legacy actions
9684 break;
9685 default:
9686 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009687 }
9688 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009689
9690 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9691 && leavingPackage) {
9692 switch (mAction) {
9693 case ACTION_PROVIDER_CHANGED:
9694 // Ignore actions that don't need to grant
9695 break;
9696 default:
9697 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9698 }
9699 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009700 }
9701
9702 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009703 * @hide
9704 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009705 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009706 // We just entered destination process, so we should be able to read all
9707 // parcelables inside.
9708 setDefusable(true);
9709
9710 if (mSelector != null) {
9711 mSelector.prepareToEnterProcess();
9712 }
9713 if (mClipData != null) {
9714 mClipData.prepareToEnterProcess();
9715 }
9716
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009717 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009718 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9719 fixUris(mContentUserHint);
9720 mContentUserHint = UserHandle.USER_CURRENT;
9721 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009722 }
9723 }
9724
9725 /**
9726 * @hide
9727 */
9728 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009729 Uri data = getData();
9730 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009731 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009732 }
9733 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009734 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009735 }
9736 String action = getAction();
9737 if (ACTION_SEND.equals(action)) {
9738 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9739 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009740 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009741 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009742 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009743 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9744 if (streams != null) {
9745 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9746 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009747 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009748 }
9749 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9750 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009751 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9752 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9753 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9754 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9755 if (output != null) {
9756 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9757 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009758 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009759 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009760
9761 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009762 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009763 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9764 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009765 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009766 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009767 * @hide
9768 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009769 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009770 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009771 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009772
9773 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009774 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009775
9776 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009777 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009778 // Inspect contained intents to see if we need to migrate extras. We
9779 // don't promote ClipData to the parent, since ChooserActivity will
9780 // already start the picked item as the caller, and we can't combine
9781 // the flags in a safe way.
9782
9783 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009784 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009785 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9786 if (intent != null) {
9787 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009788 }
9789 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009790 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009791 try {
9792 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9793 if (intents != null) {
9794 for (int i = 0; i < intents.length; i++) {
9795 final Intent intent = (Intent) intents[i];
9796 if (intent != null) {
9797 migrated |= intent.migrateExtraStreamToClipData();
9798 }
9799 }
9800 }
9801 } catch (ClassCastException e) {
9802 }
9803 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009804
9805 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009806 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009807 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9808 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9809 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9810 if (stream != null || text != null || htmlText != null) {
9811 final ClipData clipData = new ClipData(
9812 null, new String[] { getType() },
9813 new ClipData.Item(text, htmlText, null, stream));
9814 setClipData(clipData);
9815 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009816 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009817 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009818 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009819 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009820
9821 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009822 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009823 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9824 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9825 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9826 int num = -1;
9827 if (streams != null) {
9828 num = streams.size();
9829 }
9830 if (texts != null) {
9831 if (num >= 0 && num != texts.size()) {
9832 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009833 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009834 }
9835 num = texts.size();
9836 }
9837 if (htmlTexts != null) {
9838 if (num >= 0 && num != htmlTexts.size()) {
9839 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009840 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009841 }
9842 num = htmlTexts.size();
9843 }
9844 if (num > 0) {
9845 final ClipData clipData = new ClipData(
9846 null, new String[] { getType() },
9847 makeClipItem(streams, texts, htmlTexts, 0));
9848
9849 for (int i = 1; i < num; i++) {
9850 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9851 }
9852
9853 setClipData(clipData);
9854 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009855 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009856 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009857 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009858 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009859 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9860 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9861 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9862 final Uri output;
9863 try {
9864 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9865 } catch (ClassCastException e) {
9866 return false;
9867 }
9868 if (output != null) {
9869 setClipData(ClipData.newRawUri("", output));
9870 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9871 return true;
9872 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009873 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009874
9875 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009876 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009877
9878 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9879 ArrayList<String> htmlTexts, int which) {
9880 Uri uri = streams != null ? streams.get(which) : null;
9881 CharSequence text = texts != null ? texts.get(which) : null;
9882 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9883 return new ClipData.Item(text, htmlText, null, uri);
9884 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009885
9886 /** @hide */
9887 public boolean isDocument() {
9888 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9889 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009890}