blob: e7fce34c97bffd46a241b3266d7b77691bcf4605 [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 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700660 * Extra that can be included on activity intents coming from the storage UI
661 * when it launches sub-activities to manage various types of storage. For example,
662 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
663 * the images on the device, and in that case also include this extra to tell the
664 * app it is coming from the storage UI so should help the user manage storage of
665 * this type.
666 */
667 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
668
669 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
671 * performed on a piece of data.
672 */
673 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800674
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900676 * Activity Action: Quick view the data. Launches a quick viewer for
677 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900678 * <p>Activities handling this intent action should handle the vast majority of
679 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700680 * <p>Quick viewers must render the quick view image locally, and must not send
681 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900682 * <p>Input: {@link #getData} is a mandatory content URI of the item to
683 * preview. {@link #getClipData} contains an optional list of content URIs
684 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
685 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700686 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
687 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700688 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900689 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700690 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700691 */
692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
693 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
694
695 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 * Used to indicate that some piece of data should be attached to some other
697 * place. For example, image data could be attached to a contact. It is up
698 * to the recipient to decide where the data should be attached; the intent
699 * does not specify the ultimate destination.
700 * <p>Input: {@link #getData} is URI of data to be attached.
701 * <p>Output: nothing.
702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 /**
707 * Activity Action: Provide explicit editable access to the given data.
708 * <p>Input: {@link #getData} is URI of data to be edited.
709 * <p>Output: nothing.
710 */
711 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
712 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 /**
715 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
716 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
717 * The extras can contain type specific data to pass through to the editing/creating
718 * activity.
719 * <p>Output: The URI of the item that was picked. This must be a content:
720 * URI so that any receiver can access it.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Pick an item from the data, returning what was selected.
727 * <p>Input: {@link #getData} is URI containing a directory of data
728 * (vnd.android.cursor.dir/*) from which to pick an item.
729 * <p>Output: The URI of the item that was picked.
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 /**
735 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800736 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800737 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
738 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700739 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
740 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741 * (value: ShortcutIconResource).</p>
742 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800743 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 * @see #EXTRA_SHORTCUT_INTENT
745 * @see #EXTRA_SHORTCUT_NAME
746 * @see #EXTRA_SHORTCUT_ICON
747 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
748 * @see android.content.Intent.ShortcutIconResource
749 */
750 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
751 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
752
753 /**
754 * The name of the extra used to define the Intent of a shortcut.
755 *
756 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800759 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700760 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
761 /**
762 * The name of the extra used to define the name of a shortcut.
763 *
764 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
769 /**
770 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
771 *
772 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
777 /**
778 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
779 *
780 * @see #ACTION_CREATE_SHORTCUT
781 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800782 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
786 "android.intent.extra.shortcut.ICON_RESOURCE";
787
788 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500789 * An activity that provides a user interface for adjusting application preferences.
790 * Optional but recommended settings for all applications which have settings.
791 */
792 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
793 public static final String ACTION_APPLICATION_PREFERENCES
794 = "android.intent.action.APPLICATION_PREFERENCES";
795
796 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700797 * Activity Action: Launch an activity showing the app information.
798 * For applications which install other applications (such as app stores), it is recommended
799 * to handle this action for providing the app information to the user.
800 *
801 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
802 * to be displayed.
803 * <p>Output: Nothing.
804 */
805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
806 public static final String ACTION_SHOW_APP_INFO
807 = "android.intent.action.SHOW_APP_INFO";
808
809 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800810 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700811 *
812 * @see Intent#ACTION_CREATE_SHORTCUT
813 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800814 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
815 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700816 */
817 public static class ShortcutIconResource implements Parcelable {
818 /**
819 * The package name of the application containing the icon.
820 */
821 public String packageName;
822
823 /**
824 * The resource name of the icon, including package, name and type.
825 */
826 public String resourceName;
827
828 /**
829 * Creates a new ShortcutIconResource for the specified context and resource
830 * identifier.
831 *
832 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700833 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700834 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700835 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700836 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700837 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700838 ShortcutIconResource icon = new ShortcutIconResource();
839 icon.packageName = context.getPackageName();
840 icon.resourceName = context.getResources().getResourceName(resourceId);
841 return icon;
842 }
843
844 /**
845 * Used to read a ShortcutIconResource from a Parcel.
846 */
847 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
848 new Parcelable.Creator<ShortcutIconResource>() {
849
850 public ShortcutIconResource createFromParcel(Parcel source) {
851 ShortcutIconResource icon = new ShortcutIconResource();
852 icon.packageName = source.readString();
853 icon.resourceName = source.readString();
854 return icon;
855 }
856
857 public ShortcutIconResource[] newArray(int size) {
858 return new ShortcutIconResource[size];
859 }
860 };
861
862 /**
863 * No special parcel contents.
864 */
865 public int describeContents() {
866 return 0;
867 }
868
869 public void writeToParcel(Parcel dest, int flags) {
870 dest.writeString(packageName);
871 dest.writeString(resourceName);
872 }
873
874 @Override
875 public String toString() {
876 return resourceName;
877 }
878 }
879
880 /**
881 * Activity Action: Display an activity chooser, allowing the user to pick
882 * what they want to before proceeding. This can be used as an alternative
883 * to the standard activity picker that is displayed by the system when
884 * you try to start an activity with multiple possible matches, with these
885 * differences in behavior:
886 * <ul>
887 * <li>You can specify the title that will appear in the activity chooser.
888 * <li>The user does not have the option to make one of the matching
889 * activities a preferred activity, and all possible activities will
890 * always be shown even if one of them is currently marked as the
891 * preferred activity.
892 * </ul>
893 * <p>
894 * This action should be used when the user will naturally expect to
895 * select an activity in order to proceed. An example if when not to use
896 * it is when the user clicks on a "mailto:" link. They would naturally
897 * expect to go directly to their mail app, so startActivity() should be
898 * called directly: it will
899 * either launch the current preferred app, or put up a dialog allowing the
900 * user to pick an app to use and optionally marking that as preferred.
901 * <p>
902 * In contrast, if the user is selecting a menu item to send a picture
903 * they are viewing to someone else, there are many different things they
904 * may want to do at this point: send it through e-mail, upload it to a
905 * web service, etc. In this case the CHOOSER action should be used, to
906 * always present to the user a list of the things they can do, with a
907 * nice title given by the caller such as "Send this photo with:".
908 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700909 * If you need to grant URI permissions through a chooser, you must specify
910 * the permissions to be granted on the ACTION_CHOOSER Intent
911 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
912 * {@link #setClipData} to specify the URIs to be granted as well as
913 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
914 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
915 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700916 * As a convenience, an Intent of this form can be created with the
917 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700918 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700919 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700920 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
921 * and can optionally have a {@link #EXTRA_TITLE} field containing the
922 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700923 * <p>
924 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 */
926 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
927 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
928
929 /**
930 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
931 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700932 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
933 * target intent, also optionally supplying a title. If the target
934 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
935 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
936 * set in the returned chooser intent, with its ClipData set appropriately:
937 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500938 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700939 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700940 * @param target The Intent that the user will be selecting an activity
941 * to perform.
942 * @param title Optional title that will be displayed in the chooser.
943 * @return Return a new Intent object that you can hand to
944 * {@link Context#startActivity(Intent) Context.startActivity()} and
945 * related methods.
946 */
947 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700948 return createChooser(target, title, null);
949 }
950
951 /**
952 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
953 *
954 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
955 * target intent, also optionally supplying a title. If the target
956 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
957 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
958 * set in the returned chooser intent, with its ClipData set appropriately:
959 * either a direct reflection of {@link #getClipData()} if that is non-null,
960 * or a new ClipData built from {@link #getData()}.</p>
961 *
962 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
963 * when the user makes a choice. This can be useful if the calling application wants
964 * to remember the last chosen target and surface it as a more prominent or one-touch
965 * affordance elsewhere in the UI for next time.</p>
966 *
967 * @param target The Intent that the user will be selecting an activity
968 * to perform.
969 * @param title Optional title that will be displayed in the chooser.
970 * @param sender Optional IntentSender to be called when a choice is made.
971 * @return Return a new Intent object that you can hand to
972 * {@link Context#startActivity(Intent) Context.startActivity()} and
973 * related methods.
974 */
975 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700976 Intent intent = new Intent(ACTION_CHOOSER);
977 intent.putExtra(EXTRA_INTENT, target);
978 if (title != null) {
979 intent.putExtra(EXTRA_TITLE, title);
980 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700981
Adam Powell0b3c1122014-10-09 12:50:14 -0700982 if (sender != null) {
983 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
984 }
985
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700986 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700987 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
988 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
989 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700990 if (permFlags != 0) {
991 ClipData targetClipData = target.getClipData();
992 if (targetClipData == null && target.getData() != null) {
993 ClipData.Item item = new ClipData.Item(target.getData());
994 String[] mimeTypes;
995 if (target.getType() != null) {
996 mimeTypes = new String[] { target.getType() };
997 } else {
998 mimeTypes = new String[] { };
999 }
1000 targetClipData = new ClipData(null, mimeTypes, item);
1001 }
1002 if (targetClipData != null) {
1003 intent.setClipData(targetClipData);
1004 intent.addFlags(permFlags);
1005 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001006 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001007
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 return intent;
1009 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001010
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 /**
1012 * Activity Action: Allow the user to select a particular kind of data and
1013 * return it. This is different than {@link #ACTION_PICK} in that here we
1014 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001015 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001017 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 * etc.
1019 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001020 * 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 -07001021 * of data, such as a person contact, you set the MIME type to the kind of
1022 * data you want and launch it with {@link Context#startActivity(Intent)}.
1023 * The system will then launch the best application to select that kind
1024 * of data for you.
1025 * <p>
1026 * You may also be interested in any of a set of types of content the user
1027 * can pick. For example, an e-mail application that wants to allow the
1028 * user to add an attachment to an e-mail message can use this action to
1029 * bring up a list of all of the types of content the user can attach.
1030 * <p>
1031 * In this case, you should wrap the GET_CONTENT intent with a chooser
1032 * (through {@link #createChooser}), which will give the proper interface
1033 * for the user to pick how to send your data and allow you to specify
1034 * a prompt indicating what they are doing. You will usually specify a
1035 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1036 * broad range of content types the user can select from.
1037 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001038 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001039 * only pick from data that can be represented as a stream. This is
1040 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1041 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001042 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001043 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001044 * is locally available on the device. For example, if this extra is set
1045 * to true then an image picker should not show any pictures that are available
1046 * from a remote server but not already on the local device (thus requiring
1047 * they be downloaded when opened).
1048 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001049 * If the caller can handle multiple returned items (the user performing
1050 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1051 * to indicate this.
1052 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001053 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1054 * that no URI is supplied in the intent, as there are no constraints on
1055 * where the returned data originally comes from. You may also include the
1056 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001057 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001058 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1059 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001060 * <p>
1061 * Output: The URI of the item that was picked. This must be a content:
1062 * URI so that any receiver can access it.
1063 */
1064 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1065 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1066 /**
1067 * Activity Action: Dial a number as specified by the data. This shows a
1068 * UI with the number being dialed, allowing the user to explicitly
1069 * initiate the call.
1070 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1071 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1072 * number.
1073 * <p>Output: nothing.
1074 */
1075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1076 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1077 /**
1078 * Activity Action: Perform a call to someone specified by the data.
1079 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1080 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1081 * number.
1082 * <p>Output: nothing.
1083 *
1084 * <p>Note: there will be restrictions on which applications can initiate a
1085 * call; most applications should use the {@link #ACTION_DIAL}.
1086 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1087 * numbers. Applications can <strong>dial</strong> emergency numbers using
1088 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001089 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001090 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001091 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001092 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001093 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001094 */
1095 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1096 public static final String ACTION_CALL = "android.intent.action.CALL";
1097 /**
1098 * Activity Action: Perform a call to an emergency number specified by the
1099 * data.
1100 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1101 * tel: URI of an explicit phone number.
1102 * <p>Output: nothing.
1103 * @hide
1104 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001105 @SystemApi
1106 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001107 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1108 /**
1109 * Activity action: Perform a call to any number (emergency or not)
1110 * specified by the data.
1111 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1112 * tel: URI of an explicit phone number.
1113 * <p>Output: nothing.
1114 * @hide
1115 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001116 @SystemApi
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001118 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001119
Santos Cordon15a13782015-03-31 18:32:31 -07001120 /**
fionaxuadfe7002017-02-17 17:20:46 -08001121 * Activity Action: Main entry point for carrier setup apps.
1122 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1123 * carrier service and typically require
1124 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1125 * fulfill their duties.
1126 */
1127 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1128 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1129 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001130 * Activity Action: Send a message to someone specified by the data.
1131 * <p>Input: {@link #getData} is URI describing the target.
1132 * <p>Output: nothing.
1133 */
1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1135 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1136 /**
1137 * Activity Action: Deliver some data to someone else. Who the data is
1138 * being delivered to is not specified; it is up to the receiver of this
1139 * action to ask the user where the data should be sent.
1140 * <p>
1141 * When launching a SEND intent, you should usually wrap it in a chooser
1142 * (through {@link #createChooser}), which will give the proper interface
1143 * for the user to pick how to send your data and allow you to specify
1144 * a prompt indicating what they are doing.
1145 * <p>
1146 * Input: {@link #getType} is the MIME type of the data being sent.
1147 * get*Extra can have either a {@link #EXTRA_TEXT}
1148 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1149 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1150 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1151 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001152 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1153 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1154 * your text with HTML formatting.
1155 * <p>
1156 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1157 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1158 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1159 * content: URIs and other advanced features of {@link ClipData}. If
1160 * using this approach, you still must supply the same data through the
1161 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1162 * for compatibility with old applications. If you don't set a ClipData,
1163 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001164 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001165 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1166 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1167 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1168 * be openable only as asset typed files using
1169 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1170 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001171 * Optional standard extras, which may be interpreted by some recipients as
1172 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1173 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1174 * <p>
1175 * Output: nothing.
1176 */
1177 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1178 public static final String ACTION_SEND = "android.intent.action.SEND";
1179 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001180 * Activity Action: Deliver multiple data to someone else.
1181 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001182 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001183 * <p>
1184 * Input: {@link #getType} is the MIME type of the data being sent.
1185 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001186 * #EXTRA_STREAM} field, containing the data to be sent. If using
1187 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1188 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001189 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001190 * Multiple types are supported, and receivers should handle mixed types
1191 * whenever possible. The right way for the receiver to check them is to
1192 * use the content resolver on each URI. The intent sender should try to
1193 * put the most concrete mime type in the intent type, but it can fall
1194 * back to {@literal <type>/*} or {@literal *}/* as needed.
1195 * <p>
1196 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1197 * be image/jpg, but if you are sending image/jpg and image/png, then the
1198 * intent's type should be image/*.
1199 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001200 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1201 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1202 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1203 * content: URIs and other advanced features of {@link ClipData}. If
1204 * using this approach, you still must supply the same data through the
1205 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1206 * for compatibility with old applications. If you don't set a ClipData,
1207 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1208 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001209 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1210 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1211 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1212 * be openable only as asset typed files using
1213 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1214 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001215 * Optional standard extras, which may be interpreted by some recipients as
1216 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1217 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1218 * <p>
1219 * Output: nothing.
1220 */
1221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1222 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1223 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001224 * Activity Action: Handle an incoming phone call.
1225 * <p>Input: nothing.
1226 * <p>Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1230 /**
1231 * Activity Action: Insert an empty item into the given container.
1232 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1233 * in which to place the data.
1234 * <p>Output: URI of the new data that was created.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1238 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001239 * Activity Action: Create a new item in the given container, initializing it
1240 * from the current contents of the clipboard.
1241 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1242 * in which to place the data.
1243 * <p>Output: URI of the new data that was created.
1244 */
1245 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1246 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1247 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001248 * Activity Action: Delete the given data from its container.
1249 * <p>Input: {@link #getData} is URI of data to be deleted.
1250 * <p>Output: nothing.
1251 */
1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1253 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1254 /**
1255 * Activity Action: Run the data, whatever that means.
1256 * <p>Input: ? (Note: this is currently specific to the test harness.)
1257 * <p>Output: nothing.
1258 */
1259 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1260 public static final String ACTION_RUN = "android.intent.action.RUN";
1261 /**
1262 * Activity Action: Perform a data synchronization.
1263 * <p>Input: ?
1264 * <p>Output: ?
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1268 /**
1269 * Activity Action: Pick an activity given an intent, returning the class
1270 * selected.
1271 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1272 * used with {@link PackageManager#queryIntentActivities} to determine the
1273 * set of activities from which to pick.
1274 * <p>Output: Class name of the activity that was selected.
1275 */
1276 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1277 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1278 /**
1279 * Activity Action: Perform a search.
1280 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1281 * is the text to search for. If empty, simply
1282 * enter your search results Activity with the search UI activated.
1283 * <p>Output: nothing.
1284 */
1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1286 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1287 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001288 * Activity Action: Start the platform-defined tutorial
1289 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1290 * is the text to search for. If empty, simply
1291 * enter your search results Activity with the search UI activated.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1296 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001297 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001298 * <p>
1299 * Input: {@link android.app.SearchManager#QUERY
1300 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1301 * a url starts with http or https, the site will be opened. If it is plain
1302 * text, Google search will be applied.
1303 * <p>
1304 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001308
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001309 /**
Jim Miller07994402012-05-02 14:22:27 -07001310 * Activity Action: Perform assist action.
1311 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001312 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1313 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001314 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1315 * information.
Jim Miller07994402012-05-02 14:22:27 -07001316 * Output: nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001320
1321 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001322 * Activity Action: Perform voice assist action.
1323 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001324 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1325 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001326 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001327 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001328 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001329 */
Amith Yamasani16452032017-03-03 10:15:57 -08001330 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1333
1334 /**
Adam Skory7140a252013-09-11 12:04:58 +01001335 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1336 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001337 */
1338 public static final String EXTRA_ASSIST_PACKAGE
1339 = "android.intent.extra.ASSIST_PACKAGE";
1340
1341 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001342 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1343 * application package at the time the assist was invoked.
1344 */
1345 public static final String EXTRA_ASSIST_UID
1346 = "android.intent.extra.ASSIST_UID";
1347
1348 /**
Adam Skory7140a252013-09-11 12:04:58 +01001349 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1350 * information supplied by the current foreground app at the time of the assist request.
1351 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001352 */
1353 public static final String EXTRA_ASSIST_CONTEXT
1354 = "android.intent.extra.ASSIST_CONTEXT";
1355
Jim Miller07994402012-05-02 14:22:27 -07001356 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001357 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1358 * keyboard as the primary input device for assistance.
1359 */
1360 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1361 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1362
1363 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001364 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1365 * that was used to invoke the assist.
1366 */
1367 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1368 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1369
1370 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001371 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001372 * <p>Input: Nothing.
1373 * <p>Output: nothing.
1374 */
1375 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1376 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1377 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001378 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001379 * <p>Input: Nothing.
1380 * <p>Output: Nothing.
1381 */
1382 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1383 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1384
1385 /**
1386 * Activity Action: Show activity for reporting a bug.
1387 * <p>Input: Nothing.
1388 * <p>Output: Nothing.
1389 */
1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1392
1393 /**
1394 * Activity Action: Main entry point for factory tests. Only used when
1395 * the device is booting in factory test node. The implementing package
1396 * must be installed in the system image.
1397 * <p>Input: nothing
1398 * <p>Output: nothing
1399 */
1400 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1401
1402 /**
1403 * Activity Action: The user pressed the "call" button to go to the dialer
1404 * or other appropriate UI for placing a call.
1405 * <p>Input: Nothing.
1406 * <p>Output: Nothing.
1407 */
1408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1409 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1410
1411 /**
1412 * Activity Action: Start Voice Command.
1413 * <p>Input: Nothing.
1414 * <p>Output: Nothing.
1415 */
1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1417 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001418
1419 /**
1420 * Activity Action: Start action associated with long pressing on the
1421 * search key.
1422 * <p>Input: Nothing.
1423 * <p>Output: Nothing.
1424 */
1425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1426 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001427
Jacek Surazski86b6c532009-05-13 14:38:28 +02001428 /**
1429 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1430 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001431 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001432 * <p>Input: No data is specified. The bug report is passed in using
1433 * an {@link #EXTRA_BUG_REPORT} field.
1434 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001435 *
1436 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001437 */
1438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1439 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001440
1441 /**
1442 * Activity Action: Show power usage information to the user.
1443 * <p>Input: Nothing.
1444 * <p>Output: Nothing.
1445 */
1446 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1447 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001448
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001449 /**
Russell Brenner880994d2017-02-24 11:11:47 -08001450 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1451 * to run.
1452 * <p>Input: Nothing.
1453 * <p>Output: Nothing.
1454 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1455 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1456 * @hide
1457 */
1458 @Deprecated
1459 @SystemApi
1460 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1461 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1462
1463 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001464 * Activity Action: Setup wizard to launch after a platform update. This
1465 * activity should have a string meta-data field associated with it,
1466 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1467 * the platform for setup. The activity will be launched only if
1468 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1469 * same value.
1470 * <p>Input: Nothing.
1471 * <p>Output: Nothing.
1472 * @hide
1473 */
Russell Brenner880994d2017-02-24 11:11:47 -08001474 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001475 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1476 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001477
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001478 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001479 * Activity Action: Start 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_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001486 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001487
1488 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001489 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1490 * <p>Input: Nothing.
1491 * <p>Output: Nothing.
1492 * @hide
1493 */
1494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1495 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001496 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001497
1498 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001499 * Activity Action: Show settings for managing network data usage of a
1500 * specific application. Applications should define an activity that offers
1501 * options to control data usage.
1502 */
1503 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1504 public static final String ACTION_MANAGE_NETWORK_USAGE =
1505 "android.intent.action.MANAGE_NETWORK_USAGE";
1506
1507 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001508 * Activity Action: Launch application installer.
1509 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001510 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001511 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1512 * you can also use "package:<package-name>" to install an application for the
1513 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001514 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1515 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1516 * <p>
1517 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1518 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001519 * <p>
1520 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1521 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1522 * in order to launch the application installer.
1523 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001524 *
1525 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1526 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1527 * @see #EXTRA_RETURN_RESULT
1528 */
1529 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1530 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1531
1532 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001533 * @hide
1534 * @deprecated Do not use. This will go away.
1535 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1536 */
1537 @SystemApi
1538 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1539 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1540 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1541 /**
1542 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001543 * <p class="note">
1544 * This is a protected intent that can only be sent by the system.
1545 * </p>
1546 *
1547 * @hide
1548 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001549 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001551 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1552 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001553
1554 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001555 * @hide
1556 * @deprecated Do not use. This will go away.
1557 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1558 */
1559 @SystemApi
1560 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1561 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1562 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1563 /**
1564 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001565 * <p>
1566 * The system will have a persistent connection to this service.
1567 * This is a protected intent that can only be sent by the system.
1568 * </p>
1569 *
1570 * @hide
1571 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1575 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576
1577 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 * @hide
1579 * @deprecated Do not use. This will go away.
1580 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1581 */
1582 @SystemApi
1583 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1584 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1585 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1586 /**
1587 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001588 *
1589 * <p class="note">
1590 * This is a protected intent that can only be sent by the system.
1591 * </p>
1592 *
1593 * @hide
1594 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001595 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001596 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1598 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001599
1600 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001601 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1602 * package. Specifies the installer package name; this package will receive the
1603 * {@link #ACTION_APP_ERROR} intent.
1604 */
1605 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1606 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1607
1608 /**
1609 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1610 * package. Specifies that the application being installed should not be
1611 * treated as coming from an unknown source, but as coming from the app
1612 * invoking the Intent. For this to work you must start the installer with
1613 * startActivityForResult().
1614 */
1615 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1616 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1617
1618 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001619 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1620 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001621 * data field originated from.
1622 */
rich cannings706e8ba2012-08-20 13:20:14 -07001623 public static final String EXTRA_ORIGINATING_URI
1624 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001625
1626 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001627 * This extra can be used with any Intent used to launch an activity, supplying information
1628 * about who is launching that activity. This field contains a {@link android.net.Uri}
1629 * object, typically an http: or https: URI of the web site that the referral came from;
1630 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1631 * a native application that it came from.
1632 *
1633 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1634 * instead of directly retrieving the extra. It is also valid for applications to
1635 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1636 * a string, not a Uri; the field here, if supplied, will always take precedence,
1637 * however.</p>
1638 *
1639 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001640 */
1641 public static final String EXTRA_REFERRER
1642 = "android.intent.extra.REFERRER";
1643
1644 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001645 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1646 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1647 * not be created, in particular when Intent extras are supplied through the
1648 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1649 * schemes.
1650 *
1651 * @see #EXTRA_REFERRER
1652 */
1653 public static final String EXTRA_REFERRER_NAME
1654 = "android.intent.extra.REFERRER_NAME";
1655
1656 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001657 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001658 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001659 * @hide
1660 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001661 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001662 public static final String EXTRA_ORIGINATING_UID
1663 = "android.intent.extra.ORIGINATING_UID";
1664
1665 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001666 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1667 * package. Tells the installer UI to skip the confirmation with the user
1668 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001669 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1670 * will no longer show an interstitial message about updating existing
1671 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001672 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001673 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001674 public static final String EXTRA_ALLOW_REPLACE
1675 = "android.intent.extra.ALLOW_REPLACE";
1676
1677 /**
1678 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1679 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1680 * return to the application the result code of the install/uninstall. The returned result
1681 * code will be {@link android.app.Activity#RESULT_OK} on success or
1682 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1683 */
1684 public static final String EXTRA_RETURN_RESULT
1685 = "android.intent.extra.RETURN_RESULT";
1686
1687 /**
1688 * Package manager install result code. @hide because result codes are not
1689 * yet ready to be exposed.
1690 */
1691 public static final String EXTRA_INSTALL_RESULT
1692 = "android.intent.extra.INSTALL_RESULT";
1693
1694 /**
1695 * Activity Action: Launch application uninstaller.
1696 * <p>
1697 * Input: The data must be a package: URI whose scheme specific part is
1698 * the package name of the current installed package to be uninstalled.
1699 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1700 * <p>
1701 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1702 * succeeded.
1703 */
1704 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1705 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1706
1707 /**
msnider3c191b82017-01-23 14:23:16 -08001708 * Activity Action: Launch application uninstaller.
1709 * <p>
1710 * Input: The data must be a package: URI whose scheme specific part is
1711 * the package name of the current installed package to be uninstalled.
1712 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1713 * <p>
1714 * Output: Nothing.
1715 * </p>
1716 */
1717 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1718 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1719
1720 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001721 * Specify whether the package should be uninstalled for all users.
1722 * @hide because these should not be part of normal application flow.
1723 */
1724 public static final String EXTRA_UNINSTALL_ALL_USERS
1725 = "android.intent.extra.UNINSTALL_ALL_USERS";
1726
1727 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001728 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1729 * describing the last run version of the platform that was setup.
1730 * @hide
1731 */
1732 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1733
Svet Ganov3695b8a2015-03-24 16:30:25 -07001734 /**
1735 * Activity action: Launch UI to manage the permissions of an app.
1736 * <p>
1737 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1738 * will be managed by the launched UI.
1739 * </p>
1740 * <p>
1741 * Output: Nothing.
1742 * </p>
1743 *
1744 * @see #EXTRA_PACKAGE_NAME
1745 *
1746 * @hide
1747 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001748 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001749 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1750 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1751 "android.intent.action.MANAGE_APP_PERMISSIONS";
1752
1753 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001754 * Activity action: Launch UI to manage permissions.
1755 * <p>
1756 * Input: Nothing.
1757 * </p>
1758 * <p>
1759 * Output: Nothing.
1760 * </p>
1761 *
1762 * @hide
1763 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001764 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001765 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1766 public static final String ACTION_MANAGE_PERMISSIONS =
1767 "android.intent.action.MANAGE_PERMISSIONS";
1768
1769 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001770 * Activity action: Launch UI to review permissions for an app.
1771 * The system uses this intent if permission review for apps not
1772 * supporting the new runtime permissions model is enabled. In
1773 * this mode a permission review is required before any of the
1774 * app components can run.
1775 * <p>
1776 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1777 * permissions will be reviewed (mandatory).
1778 * </p>
1779 * <p>
1780 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1781 * be fired after the permission review (optional).
1782 * </p>
1783 * <p>
1784 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1785 * be invoked after the permission review (optional).
1786 * </p>
1787 * <p>
1788 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1789 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1790 * </p>
1791 * <p>
1792 * Output: Nothing.
1793 * </p>
1794 *
1795 * @see #EXTRA_PACKAGE_NAME
1796 * @see #EXTRA_INTENT
1797 * @see #EXTRA_REMOTE_CALLBACK
1798 * @see #EXTRA_RESULT_NEEDED
1799 *
1800 * @hide
1801 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001802 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001803 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1804 public static final String ACTION_REVIEW_PERMISSIONS =
1805 "android.intent.action.REVIEW_PERMISSIONS";
1806
1807 /**
1808 * Intent extra: A callback for reporting remote result as a bundle.
1809 * <p>
1810 * Type: IRemoteCallback
1811 * </p>
1812 *
1813 * @hide
1814 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001815 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001816 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1817
1818 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001819 * Intent extra: An app package name.
1820 * <p>
1821 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001822 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001823 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001824 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001825 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1826
1827 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001828 * Intent extra: An app split name.
1829 * <p>
1830 * Type: String
1831 * </p>
1832 * @hide
1833 */
1834 @SystemApi
1835 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1836
1837 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001838 * Intent extra: An extra for specifying whether a result is needed.
1839 * <p>
1840 * Type: boolean
1841 * </p>
1842 *
1843 * @hide
1844 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001845 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001846 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1847
1848 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001849 * Activity action: Launch UI to manage which apps have a given permission.
1850 * <p>
1851 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1852 * to which will be managed by the launched UI.
1853 * </p>
1854 * <p>
1855 * Output: Nothing.
1856 * </p>
1857 *
1858 * @see #EXTRA_PERMISSION_NAME
1859 *
1860 * @hide
1861 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001862 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001863 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1864 public static final String ACTION_MANAGE_PERMISSION_APPS =
1865 "android.intent.action.MANAGE_PERMISSION_APPS";
1866
1867 /**
1868 * Intent extra: The name of a permission.
1869 * <p>
1870 * Type: String
1871 * </p>
1872 *
1873 * @hide
1874 */
1875 @SystemApi
1876 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1877
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001878 // ---------------------------------------------------------------------
1879 // ---------------------------------------------------------------------
1880 // Standard intent broadcast actions (see action variable).
1881
1882 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001883 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1884 * <p>
1885 * For historical reasons, the name of this broadcast action refers to the power
1886 * state of the screen but it is actually sent in response to changes in the
1887 * overall interactive state of the device.
1888 * </p><p>
1889 * This broadcast is sent when the device becomes non-interactive which may have
1890 * nothing to do with the screen turning off. To determine the
1891 * actual state of the screen, use {@link android.view.Display#getState}.
1892 * </p><p>
1893 * See {@link android.os.PowerManager#isInteractive} for details.
1894 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001895 * You <em>cannot</em> receive this through components declared in
1896 * manifests, only by explicitly registering for it with
1897 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1898 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001899 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001900 * <p class="note">This is a protected intent that can only be sent
1901 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001906 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001907 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1908 * <p>
1909 * For historical reasons, the name of this broadcast action refers to the power
1910 * state of the screen but it is actually sent in response to changes in the
1911 * overall interactive state of the device.
1912 * </p><p>
1913 * This broadcast is sent when the device becomes interactive which may have
1914 * nothing to do with the screen turning on. To determine the
1915 * actual state of the screen, use {@link android.view.Display#getState}.
1916 * </p><p>
1917 * See {@link android.os.PowerManager#isInteractive} for details.
1918 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001919 * You <em>cannot</em> receive this through components declared in
1920 * manifests, only by explicitly registering for it with
1921 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1922 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001923 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001924 * <p class="note">This is a protected intent that can only be sent
1925 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001929
1930 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001931 * Broadcast Action: Sent after the system stops dreaming.
1932 *
1933 * <p class="note">This is a protected intent that can only be sent by the system.
1934 * It is only sent to registered receivers.</p>
1935 */
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1938
1939 /**
1940 * Broadcast Action: Sent after the system starts dreaming.
1941 *
1942 * <p class="note">This is a protected intent that can only be sent by the system.
1943 * It is only sent to registered receivers.</p>
1944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1947
1948 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001949 * 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 -07001950 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001951 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001952 * <p class="note">This is a protected intent that can only be sent
1953 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001954 */
1955 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001956 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001958 /**
1959 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001960 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001961 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1963 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001964 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001965 * <p class="note">This is a protected intent that can only be sent
1966 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001967 */
1968 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1969 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1970 /**
1971 * Broadcast Action: The time was set.
1972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1975 /**
1976 * Broadcast Action: The date has changed.
1977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1979 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1980 /**
1981 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1982 * <ul>
1983 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1984 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001985 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001986 * <p class="note">This is a protected intent that can only be sent
1987 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001988 */
1989 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1990 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1991 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001992 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1993 * DNS entries should be tossed.
1994 * @hide
1995 */
1996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1997 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1998 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001999 * Alarm Changed Action: This is broadcast when the AlarmClock
2000 * application's alarm is set or unset. It is used by the
2001 * AlarmClock application and the StatusBar service.
2002 * @hide
2003 */
2004 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2005 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002006
2007 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002008 * Broadcast Action: This is broadcast once, after the user has finished
2009 * booting, but while still in the "locked" state. It can be used to perform
2010 * application-specific initialization, such as installing alarms. You must
2011 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2012 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002013 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002014 * This broadcast is sent immediately at boot by all devices (regardless of
2015 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2016 * higher. Upon receipt of this broadcast, the user is still locked and only
2017 * device-protected storage can be accessed safely. If you want to access
2018 * credential-protected storage, you need to wait for the user to be
2019 * unlocked (typically by entering their lock pattern or PIN for the first
2020 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2021 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2022 * <p>
2023 * To receive this broadcast, your receiver component must be marked as
2024 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002025 * <p class="note">
2026 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002027 *
2028 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002029 */
2030 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2031 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002033 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002034 * Broadcast Action: This is broadcast once, after the user has finished
2035 * booting. It can be used to perform application-specific initialization,
2036 * such as installing alarms. You must hold the
2037 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2038 * order to receive this broadcast.
2039 * <p>
2040 * This broadcast is sent at boot by all devices (both with and without
2041 * direct boot support). Upon receipt of this broadcast, the user is
2042 * unlocked and both device-protected and credential-protected storage can
2043 * accessed safely.
2044 * <p>
2045 * If you need to run while the user is still locked (before they've entered
2046 * their lock pattern or PIN for the first time), you can listen for the
2047 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2048 * <p class="note">
2049 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002050 */
2051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002052 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002053 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002055 /**
2056 * Broadcast Action: This is broadcast when a user action should request a
2057 * temporary system dialog to dismiss. Some examples of temporary system
2058 * dialogs are the notification window-shade and the recent tasks dialog.
2059 */
2060 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2061 /**
2062 * Broadcast Action: Trigger the download and eventual installation
2063 * of a package.
2064 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002065 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002066 * <p class="note">This is a protected intent that can only be sent
2067 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002068 *
2069 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002070 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002071 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2073 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2074 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002075 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002076 * device. The data contains the name of the package. Note that the
2077 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002078 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002079 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002080 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2081 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002082 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2083 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002084 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002085 * <p class="note">This is a protected intent that can only be sent
2086 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002087 */
2088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2089 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2090 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002091 * Broadcast Action: A new version of an application package has been
2092 * installed, replacing an existing version that was previously installed.
2093 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002094 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002095 * <ul>
2096 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2097 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002098 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002099 * <p class="note">This is a protected intent that can only be sent
2100 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002101 */
2102 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2103 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2104 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002105 * Broadcast Action: A new version of your application has been installed
2106 * over an existing one. This is only sent to the application that was
2107 * replaced. It does not contain any additional data; to receive it, just
2108 * use an intent filter for this action.
2109 *
2110 * <p class="note">This is a protected intent that can only be sent
2111 * by the system.
2112 */
2113 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2114 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002116 * Broadcast Action: An existing application package has been removed from
2117 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002118 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002119 * <ul>
2120 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2121 * to the package.
2122 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2123 * application -- data and code -- is being removed.
2124 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2125 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2126 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002127 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002128 * <p class="note">This is a protected intent that can only be sent
2129 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002130 */
2131 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2132 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2133 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002134 * Broadcast Action: An existing application package has been completely
2135 * removed from the device. The data contains the name of the package.
2136 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2137 * {@link #EXTRA_DATA_REMOVED} is true and
2138 * {@link #EXTRA_REPLACING} is false of that broadcast.
2139 *
2140 * <ul>
2141 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2142 * to the package.
2143 * </ul>
2144 *
2145 * <p class="note">This is a protected intent that can only be sent
2146 * by the system.
2147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_PACKAGE_FULLY_REMOVED
2150 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2151 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002152 * Broadcast Action: An existing application package has been changed (for
2153 * example, a component has been enabled or disabled). The data contains
2154 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 * <ul>
2156 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002157 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002158 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002159 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2160 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002161 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002162 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002163 * <p class="note">This is a protected intent that can only be sent
2164 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2168 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002169 * @hide
2170 * Broadcast Action: Ask system services if there is any reason to
2171 * restart the given package. The data contains the name of the
2172 * package.
2173 * <ul>
2174 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2175 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2176 * </ul>
2177 *
2178 * <p class="note">This is a protected intent that can only be sent
2179 * by the system.
2180 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002181 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2183 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2184 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002185 * Broadcast Action: The user has restarted a package, and all of its
2186 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002188 * be removed. Note that the restarted package does <em>not</em>
2189 * receive this broadcast.
2190 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002191 * <ul>
2192 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2193 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002194 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002195 * <p class="note">This is a protected intent that can only be sent
2196 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002197 */
2198 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2199 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2200 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002201 * Broadcast Action: The user has cleared the data of a package. This should
2202 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002203 * its persistent data is erased and this broadcast sent.
2204 * Note that the cleared package does <em>not</em>
2205 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002206 * <ul>
2207 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2208 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002209 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002210 * <p class="note">This is a protected intent that can only be sent
2211 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002212 */
2213 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2214 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2215 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002216 * Broadcast Action: Packages have been suspended.
2217 * <p>Includes the following extras:
2218 * <ul>
2219 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2220 * </ul>
2221 *
2222 * <p class="note">This is a protected intent that can only be sent
2223 * by the system. It is only sent to registered receivers.
2224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2227 /**
2228 * Broadcast Action: Packages have been unsuspended.
2229 * <p>Includes the following extras:
2230 * <ul>
2231 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2232 * </ul>
2233 *
2234 * <p class="note">This is a protected intent that can only be sent
2235 * by the system. It is only sent to registered receivers.
2236 */
2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2238 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2239 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002240 * Broadcast Action: A user ID has been removed from the system. The user
2241 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002242 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002243 * <p class="note">This is a protected intent that can only be sent
2244 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002245 */
2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2247 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002248
2249 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002250 * Broadcast Action: Sent to the installer package of an application when
2251 * that application is first launched (that is the first time it is moved
2252 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002253 *
2254 * <p class="note">This is a protected intent that can only be sent
2255 * by the system.
2256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2259
2260 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002261 * Broadcast Action: Sent to the system package verifier when a package
2262 * needs to be verified. The data contains the package URI.
2263 * <p class="note">
2264 * This is a protected intent that can only be sent by the system.
2265 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002266 */
2267 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2268 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2269
2270 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002271 * Broadcast Action: Sent to the system package verifier when a package is
2272 * verified. The data contains the package URI.
2273 * <p class="note">
2274 * This is a protected intent that can only be sent by the system.
2275 */
2276 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2277 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2278
2279 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002280 * Broadcast Action: Sent to the system intent filter verifier when an
2281 * intent filter needs to be verified. The data contains the filter data
2282 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002283 * <p class="note">
2284 * This is a protected intent that can only be sent by the system.
2285 * </p>
2286 *
2287 * @hide
2288 */
2289 @SystemApi
2290 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2291 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2292
2293 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002294 * Broadcast Action: Resources for a set of packages (which were
2295 * previously unavailable) are currently
2296 * available since the media on which they exist is available.
2297 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2298 * list of packages whose availability changed.
2299 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2300 * list of uids of packages whose availability changed.
2301 * Note that the
2302 * packages in this list do <em>not</em> receive this broadcast.
2303 * The specified set of packages are now available on the system.
2304 * <p>Includes the following extras:
2305 * <ul>
2306 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2307 * whose resources(were previously unavailable) are currently available.
2308 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2309 * packages whose resources(were previously unavailable)
2310 * are currently available.
2311 * </ul>
2312 *
2313 * <p class="note">This is a protected intent that can only be sent
2314 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002315 */
2316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002317 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2318 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002319
2320 /**
2321 * Broadcast Action: Resources for a set of packages are currently
2322 * unavailable since the media on which they exist is unavailable.
2323 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2324 * list of packages whose availability changed.
2325 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2326 * list of uids of packages whose availability changed.
2327 * The specified set of packages can no longer be
2328 * launched and are practically unavailable on the system.
2329 * <p>Inclues the following extras:
2330 * <ul>
2331 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2332 * whose resources are no longer available.
2333 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2334 * whose resources are no longer available.
2335 * </ul>
2336 *
2337 * <p class="note">This is a protected intent that can only be sent
2338 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002341 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002342 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002343
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002344 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002345 * Broadcast Action: preferred activities have changed *explicitly*.
2346 *
2347 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2348 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2349 * be sent.
2350 *
2351 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2352 *
2353 * @hide
2354 */
2355 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2356 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2357 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2358
2359
2360 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002361 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002362 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002363 * This should <em>only</em> be used to determine when the wallpaper
2364 * has changed to show the new wallpaper to the user. You should certainly
2365 * never, in response to this, change the wallpaper or other attributes of
2366 * it such as the suggested size. That would be crazy, right? You'd cause
2367 * all kinds of loops, especially if other apps are doing similar things,
2368 * right? Of course. So please don't do this.
2369 *
2370 * @deprecated Modern applications should use
2371 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2372 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2373 * shown behind their UI, rather than watching for this broadcast and
2374 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002375 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002376 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002377 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2378 /**
2379 * Broadcast Action: The current device {@link android.content.res.Configuration}
2380 * (orientation, locale, etc) has changed. When such a change happens, the
2381 * UIs (view hierarchy) will need to be rebuilt based on this new
2382 * information; for the most part, applications don't need to worry about
2383 * this, because the system will take care of stopping and restarting the
2384 * application to make sure it sees the new changes. Some system code that
2385 * can not be restarted will need to watch for this action and handle it
2386 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002387 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002388 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002389 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002390 * in manifests, only by explicitly registering for it with
2391 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2392 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002393 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002394 * <p class="note">This is a protected intent that can only be sent
2395 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002396 *
2397 * @see android.content.res.Configuration
2398 */
2399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2400 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2401 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002402 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002403 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002404 * <p class="note">This is a protected intent that can only be sent
2405 * by the system.
2406 */
2407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2408 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2409 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002410 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2411 * charging state, level, and other information about the battery.
2412 * See {@link android.os.BatteryManager} for documentation on the
2413 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002414 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002415 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002416 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002417 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002418 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002419 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2420 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2421 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2422 * broadcasts that are sent and can be received through manifest
2423 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002424 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002425 * <p class="note">This is a protected intent that can only be sent
2426 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002427 */
2428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2429 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2430 /**
2431 * Broadcast Action: Indicates low battery condition on the device.
2432 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002433 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2438 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2439 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002440 * Broadcast Action: Indicates the battery is now okay after being low.
2441 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2442 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002443 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002444 * <p class="note">This is a protected intent that can only be sent
2445 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002446 */
2447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2448 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2449 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002450 * Broadcast Action: External power has been connected to the device.
2451 * This is intended for applications that wish to register specifically to this notification.
2452 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2453 * stay active to receive this notification. This action can be used to implement actions
2454 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002455 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002456 * <p class="note">This is a protected intent that can only be sent
2457 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002458 */
2459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002460 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002461 /**
2462 * Broadcast Action: External power has been removed from the device.
2463 * This is intended for applications that wish to register specifically to this notification.
2464 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2465 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002466 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002467 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002468 * <p class="note">This is a protected intent that can only be sent
2469 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002470 */
2471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002472 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002473 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002474 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002475 * Broadcast Action: Device is shutting down.
2476 * This is broadcast when the device is being shut down (completely turned
2477 * off, not sleeping). Once the broadcast is complete, the final shutdown
2478 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002479 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002480 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002481 * <p class="note">This is a protected intent that can only be sent
2482 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002483 * <p>May include the following extras:
2484 * <ul>
2485 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2486 * shutdown is only for userspace processes. If not set, assumed to be false.
2487 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002488 */
2489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002490 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002491 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002492 * Activity Action: Start this activity to request system shutdown.
2493 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002494 * to request confirmation from the user before shutting down. The optional boolean
2495 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2496 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002497 *
2498 * <p class="note">This is a protected intent that can only be sent
2499 * by the system.
2500 *
2501 * {@hide}
2502 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002503 public static final String ACTION_REQUEST_SHUTDOWN
2504 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002505 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002506 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002507 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002508 * <p class="note">
2509 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002510 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002511 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2512 * or above, this broadcast will no longer be delivered to any
2513 * {@link BroadcastReceiver} defined in your manifest. Instead,
2514 * apps are strongly encouraged to use the improved
2515 * {@link Context#getCacheDir()} behavior so the system can
2516 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002517 */
2518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002519 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002520 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2521 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002522 * Broadcast Action: Indicates low storage space condition on the device no
2523 * longer exists
2524 * <p class="note">
2525 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002526 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002527 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2528 * or above, this broadcast will no longer be delivered to any
2529 * {@link BroadcastReceiver} defined in your manifest. Instead,
2530 * apps are strongly encouraged to use the improved
2531 * {@link Context#getCacheDir()} behavior so the system can
2532 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002535 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002536 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2537 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002538 * Broadcast Action: A sticky broadcast that indicates a storage space full
2539 * condition on the device. This is intended for activities that want to be
2540 * able to fill the data partition completely, leaving only enough free
2541 * space to prevent system-wide SQLite failures.
2542 * <p class="note">
2543 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002544 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002545 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2546 * or above, this broadcast will no longer be delivered to any
2547 * {@link BroadcastReceiver} defined in your manifest. Instead,
2548 * apps are strongly encouraged to use the improved
2549 * {@link Context#getCacheDir()} behavior so the system can
2550 * automatically free up storage when needed.
2551 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002554 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002555 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2556 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002557 * Broadcast Action: Indicates storage space full condition on the device no
2558 * longer exists.
2559 * <p class="note">
2560 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002561 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002562 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2563 * or above, this broadcast will no longer be delivered to any
2564 * {@link BroadcastReceiver} defined in your manifest. Instead,
2565 * apps are strongly encouraged to use the improved
2566 * {@link Context#getCacheDir()} behavior so the system can
2567 * automatically free up storage when needed.
2568 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002569 */
2570 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002571 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002572 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2573 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002574 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2575 * and package management should be started.
2576 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2577 * notification.
2578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2580 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2581 /**
2582 * Broadcast Action: The device has entered USB Mass Storage mode.
2583 * This is used mainly for the USB Settings panel.
2584 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2585 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002586 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002587 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002588 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2590
2591 /**
2592 * Broadcast Action: The device has exited USB Mass Storage mode.
2593 * This is used mainly for the USB Settings panel.
2594 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2595 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002596 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002597 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002598 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002599 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2600
2601 /**
2602 * Broadcast Action: External media has been removed.
2603 * The path to the mount point for the removed media is contained in the Intent.mData field.
2604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2607
2608 /**
2609 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002610 * 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 -07002611 */
2612 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2613 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2614
2615 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002616 * Broadcast Action: External media is present, and being disk-checked
2617 * 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 -08002618 */
2619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2620 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2621
2622 /**
2623 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2624 * 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 -08002625 */
2626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2627 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2628
2629 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002630 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002631 * 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 -07002632 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2633 * media was mounted read only.
2634 */
2635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2636 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2637
2638 /**
2639 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002640 * 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 -07002641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2644
2645 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002646 * Broadcast Action: External media is no longer being shared via USB mass storage.
2647 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2648 *
2649 * @hide
2650 */
2651 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2652
2653 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002654 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2655 * The path to the mount point for the removed media is contained in the Intent.mData field.
2656 */
2657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2658 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2659
2660 /**
2661 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002662 * 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 -07002663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2666
2667 /**
2668 * Broadcast Action: User has expressed the desire to remove the external storage media.
2669 * Applications should close all files they have open within the mount point when they receive this intent.
2670 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2671 */
2672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2673 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2674
2675 /**
2676 * Broadcast Action: The media scanner has started scanning a directory.
2677 * The path to the directory being scanned is contained in the Intent.mData field.
2678 */
2679 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2680 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2681
2682 /**
2683 * Broadcast Action: The media scanner has finished scanning a directory.
2684 * The path to the scanned directory is contained in the Intent.mData field.
2685 */
2686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2687 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2688
2689 /**
2690 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2691 * The path to the file is contained in the Intent.mData field.
2692 */
2693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2695
2696 /**
2697 * Broadcast Action: The "Media 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_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2703
2704 /**
2705 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2706 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2707 * caused the broadcast.
2708 */
2709 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2710 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2711
2712 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2713 // location; they are not general-purpose actions.
2714
2715 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002716 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002717 */
2718 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2719 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2720 "android.intent.action.GTALK_CONNECTED";
2721
2722 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002723 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2727 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002728
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002729 /**
2730 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002731 */
2732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2733 public static final String ACTION_INPUT_METHOD_CHANGED =
2734 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002735
2736 /**
2737 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2738 * more radios have been turned off or on. The intent will have the following extra value:</p>
2739 * <ul>
2740 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2741 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2742 * turned off</li>
2743 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002744 *
Peng Xua35b5532016-01-20 00:05:45 -08002745 * <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 -07002746 */
2747 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2748 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2749
2750 /**
2751 * Broadcast Action: Some content providers have parts of their namespace
2752 * where they publish new events or items that the user may be especially
2753 * interested in. For these things, they may broadcast this action when the
2754 * set of interesting items change.
2755 *
2756 * For example, GmailProvider sends this notification when the set of unread
2757 * mail in the inbox changes.
2758 *
2759 * <p>The data of the intent identifies which part of which provider
2760 * changed. When queried through the content resolver, the data URI will
2761 * return the data set in question.
2762 *
2763 * <p>The intent will have the following extra values:
2764 * <ul>
2765 * <li><em>count</em> - The number of items in the data set. This is the
2766 * same as the number of items in the cursor returned by querying the
2767 * data URI. </li>
2768 * </ul>
2769 *
2770 * This intent will be sent at boot (if the count is non-zero) and when the
2771 * data set changes. It is possible for the data set to change without the
2772 * count changing (for example, if a new unread message arrives in the same
2773 * sync operation in which a message is archived). The phone should still
2774 * ring/vibrate/etc as normal in this case.
2775 */
2776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2777 public static final String ACTION_PROVIDER_CHANGED =
2778 "android.intent.action.PROVIDER_CHANGED";
2779
2780 /**
2781 * Broadcast Action: Wired Headset plugged in or unplugged.
2782 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002783 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2784 * and documentation.
2785 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002786 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002787 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002788 */
2789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002790 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002791
2792 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002793 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2794 * <ul>
2795 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2796 * </ul>
2797 *
2798 * <p class="note">This is a protected intent that can only be sent
2799 * by the system.
2800 *
2801 * @hide
2802 */
2803 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2804 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2805 = "android.intent.action.ADVANCED_SETTINGS";
2806
2807 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002808 * Broadcast Action: Sent after application restrictions are changed.
2809 *
2810 * <p class="note">This is a protected intent that can only be sent
2811 * by the system.</p>
2812 */
2813 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2814 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2815 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2816
2817 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 * Broadcast Action: An outgoing call is about to be placed.
2819 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002820 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002821 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002822 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002823 * the phone number originally intended to be dialed.</li>
2824 * </ul>
2825 * <p>Once the broadcast is finished, the resultData is used as the actual
2826 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002827 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002828 * outgoing call in turn: for example, a parental control application
2829 * might verify that the user is authorized to place the call at that
2830 * time, then a number-rewriting application might add an area code if
2831 * one was not specified.</p>
2832 * <p>For consistency, any receiver whose purpose is to prohibit phone
2833 * calls should have a priority of 0, to ensure it will see the final
2834 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002835 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002836 * should have a positive priority.
2837 * Negative priorities are reserved for the system for this broadcast;
2838 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002839 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2840 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002841 * <p>Emergency calls cannot be intercepted using this mechanism, and
2842 * other calls cannot be modified to call emergency numbers using this
2843 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002844 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2845 * call to use their own service instead. Those apps should first prevent
2846 * the call from being placed by setting resultData to <code>null</code>
2847 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002848 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002849 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2850 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002851 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002852 * <p class="note">This is a protected intent that can only be sent
2853 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002854 */
2855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2856 public static final String ACTION_NEW_OUTGOING_CALL =
2857 "android.intent.action.NEW_OUTGOING_CALL";
2858
2859 /**
2860 * Broadcast Action: Have the device reboot. This is only for use by
2861 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002862 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002863 * <p class="note">This is a protected intent that can only be sent
2864 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 */
2866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2867 public static final String ACTION_REBOOT =
2868 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002869
Wei Huang97ecc9c2009-05-11 17:44:20 -07002870 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002871 * Broadcast Action: A sticky broadcast for changes in the physical
2872 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002873 *
2874 * <p>The intent will have the following extra values:
2875 * <ul>
2876 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002877 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002878 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002879 * <p>This is intended for monitoring the current physical dock state.
2880 * See {@link android.app.UiModeManager} for the normal API dealing with
2881 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002882 */
2883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2884 public static final String ACTION_DOCK_EVENT =
2885 "android.intent.action.DOCK_EVENT";
2886
2887 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002888 * Broadcast Action: A broadcast when idle maintenance can be started.
2889 * This means that the user is not interacting with the device and is
2890 * not expected to do so soon. Typical use of the idle maintenance is
2891 * to perform somehow expensive tasks that can be postponed at a moment
2892 * when they will not degrade user experience.
2893 * <p>
2894 * <p class="note">In order to keep the device responsive in case of an
2895 * unexpected user interaction, implementations of a maintenance task
2896 * should be interruptible. In such a scenario a broadcast with action
2897 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2898 * should not do the maintenance work in
2899 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2900 * maintenance service by {@link Context#startService(Intent)}. Also
2901 * you should hold a wake lock while your maintenance service is running
2902 * to prevent the device going to sleep.
2903 * </p>
2904 * <p>
2905 * <p class="note">This is a protected intent that can only be sent by
2906 * the system.
2907 * </p>
2908 *
2909 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002910 *
2911 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002912 */
2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914 public static final String ACTION_IDLE_MAINTENANCE_START =
2915 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2916
2917 /**
2918 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2919 * This means that the user was not interacting with the device as a result
2920 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2921 * was sent and now the user started interacting with the device. Typical
2922 * use of the idle maintenance is to perform somehow expensive tasks that
2923 * can be postponed at a moment when they will not degrade user experience.
2924 * <p>
2925 * <p class="note">In order to keep the device responsive in case of an
2926 * unexpected user interaction, implementations of a maintenance task
2927 * should be interruptible. Hence, on receiving a broadcast with this
2928 * action, the maintenance task should be interrupted as soon as possible.
2929 * In other words, you should not do the maintenance work in
2930 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2931 * maintenance service that was started on receiving of
2932 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2933 * lock you acquired when your maintenance service started.
2934 * </p>
2935 * <p class="note">This is a protected intent that can only be sent
2936 * by the system.
2937 *
2938 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002939 *
2940 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002941 */
2942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2943 public static final String ACTION_IDLE_MAINTENANCE_END =
2944 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2945
2946 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002947 * Broadcast Action: a remote intent is to be broadcasted.
2948 *
2949 * A remote intent is used for remote RPC between devices. The remote intent
2950 * is serialized and sent from one device to another device. The receiving
2951 * device parses the remote intent and broadcasts it. Note that anyone can
2952 * broadcast a remote intent. However, if the intent receiver of the remote intent
2953 * does not trust intent broadcasts from arbitrary intent senders, it should require
2954 * the sender to hold certain permissions so only trusted sender's broadcast will be
2955 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002956 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002957 */
2958 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002959 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002960
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002961 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002962 * Broadcast Action: This is broadcast once when the user is booting after a
2963 * system update. It can be used to perform cleanup or upgrades after a
2964 * system update.
2965 * <p>
2966 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2967 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2968 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2969 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002970 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002971 * @hide
2972 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002973 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002974 public static final String ACTION_PRE_BOOT_COMPLETED =
2975 "android.intent.action.PRE_BOOT_COMPLETED";
2976
Amith Yamasani13593602012-03-22 16:16:17 -07002977 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002978 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002979 * on restricted users. The broadcast intent contains an extra
2980 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2981 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2982 * String[] depending on the restriction type.<p/>
2983 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002984 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2985 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2986 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002987 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2988 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002989 * @see RestrictionEntry
2990 */
2991 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2992 "android.intent.action.GET_RESTRICTION_ENTRIES";
2993
2994 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002995 * Sent the first time a user is starting, to allow system apps to
2996 * perform one time initialization. (This will not be seen by third
2997 * party applications because a newly initialized user does not have any
2998 * third party applications installed for it.) This is sent early in
2999 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003000 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3001 * broadcast, since it is part of a visible user interaction; be as quick
3002 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003003 */
3004 public static final String ACTION_USER_INITIALIZE =
3005 "android.intent.action.USER_INITIALIZE";
3006
3007 /**
3008 * Sent when a user switch is happening, causing the process's user to be
3009 * brought to the foreground. This is only sent to receivers registered
3010 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3011 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003012 * foreground. This is sent as a foreground
3013 * broadcast, since it is part of a visible user interaction; be as quick
3014 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003015 */
3016 public static final String ACTION_USER_FOREGROUND =
3017 "android.intent.action.USER_FOREGROUND";
3018
3019 /**
3020 * Sent when a user switch is happening, causing the process's user to be
3021 * sent to the background. This is only sent to receivers registered
3022 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3023 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003024 * background. This is sent as a foreground
3025 * broadcast, since it is part of a visible user interaction; be as quick
3026 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003027 */
3028 public static final String ACTION_USER_BACKGROUND =
3029 "android.intent.action.USER_BACKGROUND";
3030
3031 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003032 * Broadcast sent to the system when a user is added. Carries an extra
3033 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3034 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003035 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003036 * @hide
3037 */
3038 public static final String ACTION_USER_ADDED =
3039 "android.intent.action.USER_ADDED";
3040
3041 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003042 * Broadcast sent by the system when a user is started. Carries an extra
3043 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003044 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003045 * that has been started. This is sent as a foreground
3046 * broadcast, since it is part of a visible user interaction; be as quick
3047 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003048 * @hide
3049 */
3050 public static final String ACTION_USER_STARTED =
3051 "android.intent.action.USER_STARTED";
3052
3053 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003054 * Broadcast sent when a user is in the process of starting. Carries an extra
3055 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3056 * sent to registered receivers, not manifest receivers. It is sent to all
3057 * users (including the one that is being started). You must hold
3058 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3059 * this broadcast. This is sent as a background broadcast, since
3060 * its result is not part of the primary UX flow; to safely keep track of
3061 * started/stopped state of a user you can use this in conjunction with
3062 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3063 * other user state broadcasts since those are foreground broadcasts so can
3064 * execute in a different order.
3065 * @hide
3066 */
3067 public static final String ACTION_USER_STARTING =
3068 "android.intent.action.USER_STARTING";
3069
3070 /**
3071 * Broadcast sent when a user is going to be stopped. Carries an extra
3072 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3073 * sent to registered receivers, not manifest receivers. It is sent to all
3074 * users (including the one that is being stopped). You must hold
3075 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3076 * this broadcast. The user will not stop until all receivers have
3077 * handled the broadcast. This is sent as a background broadcast, since
3078 * its result is not part of the primary UX flow; to safely keep track of
3079 * started/stopped state of a user you can use this in conjunction with
3080 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3081 * other user state broadcasts since those are foreground broadcasts so can
3082 * execute in a different order.
3083 * @hide
3084 */
3085 public static final String ACTION_USER_STOPPING =
3086 "android.intent.action.USER_STOPPING";
3087
3088 /**
3089 * Broadcast sent to the system when a user is stopped. Carries an extra
3090 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3091 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3092 * specific package. This is only sent to registered receivers, not manifest
3093 * receivers. It is sent to all running users <em>except</em> the one that
3094 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003095 * @hide
3096 */
3097 public static final String ACTION_USER_STOPPED =
3098 "android.intent.action.USER_STOPPED";
3099
3100 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003101 * 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 -07003102 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003103 * one that has been removed. The user will not be completely removed until all receivers have
3104 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003105 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003106 * @hide
3107 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003108 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003109 public static final String ACTION_USER_REMOVED =
3110 "android.intent.action.USER_REMOVED";
3111
3112 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003113 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003114 * the userHandle of the user to become the current one. This is only sent to
3115 * registered receivers, not manifest receivers. It is sent to all running users.
3116 * You must hold
3117 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003118 * @hide
3119 */
3120 public static final String ACTION_USER_SWITCHED =
3121 "android.intent.action.USER_SWITCHED";
3122
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003123 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003124 * Broadcast Action: Sent when the credential-encrypted private storage has
3125 * become unlocked for the target user. This is only sent to registered
3126 * receivers, not manifest receivers.
3127 */
3128 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3129 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3130
3131 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003132 * Broadcast sent to the system when a user's information changes. Carries an extra
3133 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003134 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003135 * @hide
3136 */
3137 public static final String ACTION_USER_INFO_CHANGED =
3138 "android.intent.action.USER_INFO_CHANGED";
3139
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003140 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003141 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3142 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003143 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3144 * that need to display merged content across both primary and managed profiles need to
3145 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003146 * not manifest receivers.
3147 */
3148 public static final String ACTION_MANAGED_PROFILE_ADDED =
3149 "android.intent.action.MANAGED_PROFILE_ADDED";
3150
3151 /**
3152 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003153 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3154 * Only applications (for example Launchers) that need to display merged content across both
3155 * primary and managed profiles need to worry about this broadcast. This is only sent to
3156 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003157 */
3158 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3159 "android.intent.action.MANAGED_PROFILE_REMOVED";
3160
3161 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003162 * Broadcast sent to the primary user when the credential-encrypted private storage for
3163 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3164 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3165 * Launchers) that need to display merged content across both primary and managed profiles
3166 * need to worry about this broadcast. This is only sent to registered receivers,
3167 * not manifest receivers.
3168 */
3169 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3170 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3171
3172 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003173 * Broadcast sent to the primary user when an associated managed profile has become available.
3174 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003175 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3176 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3177 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003178 */
Rubin Xue95057a2016-04-01 16:49:25 +01003179 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3180 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3181
3182 /**
3183 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3184 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3185 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3186 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3187 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3188 */
3189 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3190 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003191
3192 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003193 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3194 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3195 * the device was locked or unlocked.
3196 *
3197 * This is only sent to registered receivers.
3198 *
3199 * @hide
3200 */
3201 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3202 "android.intent.action.DEVICE_LOCKED_CHANGED";
3203
3204 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003205 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3206 */
3207 public static final String ACTION_QUICK_CLOCK =
3208 "android.intent.action.QUICK_CLOCK";
3209
Michael Wright0087a142013-02-05 16:29:39 -08003210 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003211 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003212 * @hide
3213 */
3214 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003215 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003216
Justin Kohd378ad72013-04-01 12:18:26 -07003217 /**
3218 * Broadcast Action: A global button was pressed. Includes a single
3219 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3220 * caused the broadcast.
3221 * @hide
3222 */
3223 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3224
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003225 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003226 * Broadcast Action: Sent when media resource is granted.
3227 * <p>
3228 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3229 * granted.
3230 * </p>
3231 * <p class="note">
3232 * This is a protected intent that can only be sent by the system.
3233 * </p>
3234 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003235 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003236 * </p>
3237 *
3238 * @hide
3239 */
3240 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3241 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3242
3243 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003244 * Broadcast Action: An overlay package has changed. The data contains the
3245 * name of the overlay package which has changed. This is broadcast on all
3246 * changes to the OverlayInfo returned by {@link
3247 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3248 * most common change is a state change that will change whether the
3249 * overlay is enabled or not.
3250 * @hide
3251 */
3252 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3253
3254 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003255 * Activity Action: Allow the user to select and return one or more existing
3256 * documents. When invoked, the system will display the various
3257 * {@link DocumentsProvider} instances installed on the device, letting the
3258 * user interactively navigate through them. These documents include local
3259 * media, such as photos and video, and documents provided by installed
3260 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003261 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003262 * Each document is represented as a {@code content://} URI backed by a
3263 * {@link DocumentsProvider}, which can be opened as a stream with
3264 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3265 * {@link android.provider.DocumentsContract.Document} metadata.
3266 * <p>
3267 * All selected documents are returned to the calling application with
3268 * persistable read and write permission grants. If you want to maintain
3269 * access to the documents across device reboots, you need to explicitly
3270 * take the persistable permissions using
3271 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3272 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003273 * Callers must indicate the acceptable document MIME types through
3274 * {@link #setType(String)}. For example, to select photos, use
3275 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3276 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3277 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003278 * <p>
3279 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003280 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3281 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003282 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003283 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3284 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003285 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003286 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003287 * Callers can set a document URI through
3288 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3289 * location of documents navigator. System will do its best to launch the
3290 * navigator in the specified document if it's a folder, or the folder that
3291 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003292 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003293 * Output: The URI of the item that was picked, returned in
3294 * {@link #getData()}. This must be a {@code content://} URI so that any
3295 * receiver can access it. If multiple documents were selected, they are
3296 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003297 *
3298 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003299 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003300 * @see #ACTION_CREATE_DOCUMENT
3301 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003302 */
3303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3304 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3305
3306 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003307 * Activity Action: Allow the user to create a new document. When invoked,
3308 * the system will display the various {@link DocumentsProvider} instances
3309 * installed on the device, letting the user navigate through them. The
3310 * returned document may be a newly created document with no content, or it
3311 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003312 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003313 * Each document is represented as a {@code content://} URI backed by a
3314 * {@link DocumentsProvider}, which can be opened as a stream with
3315 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3316 * {@link android.provider.DocumentsContract.Document} metadata.
3317 * <p>
3318 * Callers must indicate the concrete MIME type of the document being
3319 * created by setting {@link #setType(String)}. This MIME type cannot be
3320 * changed after the document is created.
3321 * <p>
3322 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3323 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003324 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003325 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3326 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003327 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003328 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003329 * Callers can set a document URI through
3330 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3331 * location of documents navigator. System will do its best to launch the
3332 * navigator in the specified document if it's a folder, or the folder that
3333 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003334 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003335 * Output: The URI of the item that was created. This must be a
3336 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003337 *
3338 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003339 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003340 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003341 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003342 */
3343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3344 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3345
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003346 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003347 * Activity Action: Allow the user to pick a directory subtree. When
3348 * invoked, the system will display the various {@link DocumentsProvider}
3349 * instances installed on the device, letting the user navigate through
3350 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003351 * <p>
3352 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003353 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3354 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3355 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003356 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003357 * Callers can set a document URI through
3358 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3359 * location of documents navigator. System will do its best to launch the
3360 * navigator in the specified document if it's a folder, or the folder that
3361 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003362 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003363 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003364 *
3365 * @see DocumentsContract
3366 */
3367 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003368 public static final String
3369 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003370
Felipe Lemec7b1f892016-01-15 15:02:31 -08003371 /**
Peng Xua35b5532016-01-20 00:05:45 -08003372 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3373 * exisiting sensor being disconnected.
3374 *
3375 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3376 *
3377 * {@hide}
3378 */
3379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3380 public static final String
3381 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3382
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003383 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003384 * Broadcast Action: The default subscription has changed. This has the following
3385 * extra values:</p>
3386 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3387 */
3388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3389 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3390 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3391
3392 /**
3393 * Broadcast Action: The default sms subscription has changed. This has the following
3394 * extra values:</p>
3395 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3396 * subscription index
3397 */
3398 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3399 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3400 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3401
3402 /**
3403 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3404 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3405 * which has changed.
3406 */
3407 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3408
3409 /**
Sam Line707f832017-04-13 17:00:55 -07003410 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003411 * @hide
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003412 */
3413 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003414 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003415 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3416
Christopher Tate6597e342015-02-17 12:15:25 -08003417 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003418 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3419 * is about to be performed.
3420 * @hide
3421 */
3422 @SystemApi
3423 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3424 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3425 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3426
3427 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003428 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3429 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3430 *
3431 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3432 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003433 * @hide
3434 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003435 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003436 public static final String EXTRA_FORCE_MASTER_CLEAR =
3437 "android.intent.extra.FORCE_MASTER_CLEAR";
3438
3439 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003440 * A broadcast action to trigger a factory reset.
3441 *
3442 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3443 *
3444 * <p>Not for use by third-party applications.
3445 *
3446 * @see #EXTRA_FORCE_MASTER_CLEAR
3447 *
3448 * {@hide}
3449 */
3450 @SystemApi
3451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3452 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3453
3454 /**
3455 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3456 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3457 *
3458 * <p>Not for use by third-party applications.
3459 *
3460 * @hide
3461 */
3462 @SystemApi
3463 public static final String EXTRA_FORCE_FACTORY_RESET =
3464 "android.intent.extra.FORCE_FACTORY_RESET";
3465
3466 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003467 * Broadcast action: report that a settings element is being restored from backup. The intent
3468 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3469 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3470 * is the value of that settings entry prior to the restore operation. All of these values are
3471 * represented as strings.
3472 *
3473 * <p>This broadcast is sent only for settings provider entries known to require special handling
3474 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3475 * the provider's backup agent implementation.
3476 *
3477 * @see #EXTRA_SETTING_NAME
3478 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3479 * @see #EXTRA_SETTING_NEW_VALUE
3480 * {@hide}
3481 */
3482 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3483
3484 /** {@hide} */
3485 public static final String EXTRA_SETTING_NAME = "setting_name";
3486 /** {@hide} */
3487 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3488 /** {@hide} */
3489 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3490
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003491 /**
3492 * Activity Action: Process a piece of text.
3493 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3494 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3495 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3496 */
3497 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3498 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003499
3500 /**
3501 * Broadcast Action: The sim card state has changed.
3502 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3503 * because TelephonyIntents is an internal class.
3504 * @hide
3505 */
3506 @SystemApi
3507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3508 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3509
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003510 /**
fionaxu90fee272017-03-31 12:45:12 -07003511 * Broadcast Action: indicate that the phone service state has changed.
3512 * The intent will have the following extra values:</p>
3513 * <p>
3514 * @see #EXTRA_VOICE_REG_STATE
3515 * @see #EXTRA_DATA_REG_STATE
3516 * @see #EXTRA_VOICE_ROAMING_TYPE
3517 * @see #EXTRA_DATA_ROAMING_TYPE
3518 * @see #EXTRA_OPERATOR_ALPHA_LONG
3519 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3520 * @see #EXTRA_OPERATOR_NUMERIC
3521 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3522 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3523 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3524 * @see #EXTRA_MANUAL
3525 * @see #EXTRA_VOICE_RADIO_TECH
3526 * @see #EXTRA_DATA_RADIO_TECH
3527 * @see #EXTRA_CSS_INDICATOR
3528 * @see #EXTRA_NETWORK_ID
3529 * @see #EXTRA_SYSTEM_ID
3530 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3531 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3532 * @see #EXTRA_EMERGENCY_ONLY
3533 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3534 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3535 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3536 *
3537 * <p class="note">
3538 * Requires the READ_PHONE_STATE permission.
3539 *
3540 * <p class="note">This is a protected intent that can only be sent by the system.
3541 * @hide
3542 */
3543 @Deprecated
3544 @SystemApi
3545 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3546 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3547
3548 /**
3549 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3550 * state.
3551 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3552 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3553 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3554 * @see android.telephony.ServiceState#STATE_POWER_OFF
3555 * @hide
3556 */
3557 @Deprecated
3558 @SystemApi
3559 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3560
3561 /**
3562 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3563 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3564 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3565 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3566 * @see android.telephony.ServiceState#STATE_POWER_OFF
3567 * @hide
3568 */
3569 @Deprecated
3570 @SystemApi
3571 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3572
3573 /**
3574 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3575 * type.
3576 * @hide
3577 */
3578 @Deprecated
3579 @SystemApi
3580 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3581
3582 /**
3583 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3584 * type.
3585 * @hide
3586 */
3587 @Deprecated
3588 @SystemApi
3589 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3590
3591 /**
3592 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3593 * registered voice operator name in long alphanumeric format.
3594 * {@code null} if the operator name is not known or unregistered.
3595 * @hide
3596 */
3597 @Deprecated
3598 @SystemApi
3599 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3600
3601 /**
3602 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3603 * registered voice operator name in short alphanumeric format.
3604 * {@code null} if the operator name is not known or unregistered.
3605 * @hide
3606 */
3607 @Deprecated
3608 @SystemApi
3609 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3610
3611 /**
3612 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3613 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3614 * network.
3615 * @hide
3616 */
3617 @Deprecated
3618 @SystemApi
3619 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3620
3621 /**
3622 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3623 * registered data operator name in long alphanumeric format.
3624 * {@code null} if the operator name is not known or unregistered.
3625 * @hide
3626 */
3627 @Deprecated
3628 @SystemApi
3629 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3630
3631 /**
3632 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3633 * registered data operator name in short alphanumeric format.
3634 * {@code null} if the operator name is not known or unregistered.
3635 * @hide
3636 */
3637 @Deprecated
3638 @SystemApi
3639 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3640
3641 /**
3642 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3643 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3644 * data operator.
3645 * @hide
3646 */
3647 @Deprecated
3648 @SystemApi
3649 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3650
3651 /**
3652 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3653 * network selection mode is manual.
3654 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3655 * @hide
3656 */
3657 @Deprecated
3658 @SystemApi
3659 public static final String EXTRA_MANUAL = "manual";
3660
3661 /**
3662 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3663 * radio technology.
3664 * @hide
3665 */
3666 @Deprecated
3667 @SystemApi
3668 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3669
3670 /**
3671 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3672 * radio technology.
3673 * @hide
3674 */
3675 @Deprecated
3676 @SystemApi
3677 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3678
3679 /**
3680 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3681 * support on CDMA network.
3682 * Will be {@code true} if support, {@code false} otherwise.
3683 * @hide
3684 */
3685 @Deprecated
3686 @SystemApi
3687 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3688
3689 /**
3690 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3691 * id. {@code Integer.MAX_VALUE} if unknown.
3692 * @hide
3693 */
3694 @Deprecated
3695 @SystemApi
3696 public static final String EXTRA_NETWORK_ID = "networkId";
3697
3698 /**
3699 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3700 * {@code Integer.MAX_VALUE} if unknown.
3701 * @hide
3702 */
3703 @Deprecated
3704 @SystemApi
3705 public static final String EXTRA_SYSTEM_ID = "systemId";
3706
3707 /**
3708 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3709 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3710 * @hide
3711 */
3712 @Deprecated
3713 @SystemApi
3714 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3715
3716 /**
3717 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3718 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3719 * @hide
3720 */
3721 @Deprecated
3722 @SystemApi
3723 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3724
3725 /**
3726 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3727 * only mode.
3728 * {@code true} if in emergency only mode, {@code false} otherwise.
3729 * @hide
3730 */
3731 @Deprecated
3732 @SystemApi
3733 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3734
3735 /**
3736 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3737 * registration state is roaming.
3738 * {@code true} if registration indicates roaming, {@code false} otherwise
3739 * @hide
3740 */
3741 @Deprecated
3742 @SystemApi
3743 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3744 "isDataRoamingFromRegistration";
3745
3746 /**
3747 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3748 * aggregation is in use.
3749 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3750 * @hide
3751 */
3752 @Deprecated
3753 @SystemApi
3754 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3755
3756 /**
3757 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3758 * is reduced from the rsrp threshold while calculating signal strength level.
3759 * @hide
3760 */
3761 @Deprecated
3762 @SystemApi
3763 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3764
3765 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003766 * The name of the extra used to define the text to be processed, as a
3767 * CharSequence. Note that this may be a styled CharSequence, so you must use
3768 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003769 */
3770 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3771 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003772 * 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 +00003773 */
3774 public static final String EXTRA_PROCESS_TEXT_READONLY =
3775 "android.intent.extra.PROCESS_TEXT_READONLY";
3776
Bryce Leebc58f592015-09-25 16:43:01 -07003777 /**
3778 * Broadcast action: reports when a new thermal event has been reached. When the device
3779 * is reaching its maximum temperatue, the thermal level reported
3780 * {@hide}
3781 */
3782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3783 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3784
3785 /** {@hide} */
3786 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3787
3788 /**
3789 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003790 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003791 * {@hide}
3792 */
3793 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3794
3795 /**
3796 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003797 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003798 * {@hide}
3799 */
3800 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3801
3802 /**
3803 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003804 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003805 * {@hide}
3806 */
3807 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3808
3809
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003810 // ---------------------------------------------------------------------
3811 // ---------------------------------------------------------------------
3812 // Standard intent categories (see addCategory()).
3813
3814 /**
3815 * Set if the activity should be an option for the default action
3816 * (center press) to perform on a piece of data. Setting this will
3817 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003818 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003819 * Intent when initiating an action -- it is for use in intent filters
3820 * specified in packages.
3821 */
3822 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3823 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3824 /**
3825 * Activities that can be safely invoked from a browser must support this
3826 * category. For example, if the user is viewing a web page or an e-mail
3827 * and clicks on a link in the text, the Intent generated execute that
3828 * link will require the BROWSABLE category, so that only activities
3829 * supporting this category will be considered as possible actions. By
3830 * supporting this category, you are promising that there is nothing
3831 * damaging (without user intervention) that can happen by invoking any
3832 * matching Intent.
3833 */
3834 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3835 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3836 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003837 * Categories for activities that can participate in voice interaction.
3838 * An activity that supports this category must be prepared to run with
3839 * no UI shown at all (though in some case it may have a UI shown), and
3840 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3841 */
3842 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3843 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3844 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003845 * Set if the activity should be considered as an alternative action to
3846 * the data the user is currently viewing. See also
3847 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3848 * applies to the selection in a list of items.
3849 *
3850 * <p>Supporting this category means that you would like your activity to be
3851 * displayed in the set of alternative things the user can do, usually as
3852 * part of the current activity's options menu. You will usually want to
3853 * include a specific label in the &lt;intent-filter&gt; of this action
3854 * describing to the user what it does.
3855 *
3856 * <p>The action of IntentFilter with this category is important in that it
3857 * describes the specific action the target will perform. This generally
3858 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3859 * a specific name such as "com.android.camera.action.CROP. Only one
3860 * alternative of any particular action will be shown to the user, so using
3861 * a specific action like this makes sure that your alternative will be
3862 * displayed while also allowing other applications to provide their own
3863 * overrides of that particular action.
3864 */
3865 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3866 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3867 /**
3868 * Set if the activity should be considered as an alternative selection
3869 * action to the data the user has currently selected. This is like
3870 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3871 * of items from which the user can select, giving them alternatives to the
3872 * default action that will be performed on it.
3873 */
3874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3875 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3876 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003877 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003878 */
3879 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3880 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3881 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003882 * Should be displayed in the top-level launcher.
3883 */
3884 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3885 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3886 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003887 * Indicates an activity optimized for Leanback mode, and that should
3888 * be displayed in the Leanback launcher.
3889 */
3890 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3891 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3892 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003893 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3894 * @hide
3895 */
3896 @SystemApi
3897 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3898 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003899 * Provides information about the package it is in; typically used if
3900 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3901 * a front-door to the user without having to be shown in the all apps list.
3902 */
3903 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3904 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3905 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003906 * This is the home activity, that is the first activity that is displayed
3907 * when the device boots.
3908 */
3909 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3910 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3911 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003912 * This is the home activity that is displayed when the device is finished setting up and ready
3913 * for use.
3914 * @hide
3915 */
3916 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3917 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3918 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003919 * This is the setup wizard activity, that is the first activity that is displayed
3920 * when the user sets up the device for the first time.
3921 * @hide
3922 */
3923 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3924 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3925 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003926 * This activity is a preference panel.
3927 */
3928 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3929 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3930 /**
3931 * This activity is a development preference panel.
3932 */
3933 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3934 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3935 /**
3936 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003937 */
3938 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3939 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3940 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003941 * This activity allows the user to browse and download new applications.
3942 */
3943 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3944 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3945 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003946 * This activity may be exercised by the monkey or other automated test tools.
3947 */
3948 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3949 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3950 /**
3951 * To be used as a test (not part of the normal user experience).
3952 */
3953 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3954 /**
3955 * To be used as a unit test (run through the Test Harness).
3956 */
3957 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3958 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003959 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003960 * experience).
3961 */
3962 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003963
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003964 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003965 * Used to indicate that an intent only wants URIs that can be opened with
3966 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3967 * must support at least the columns defined in {@link OpenableColumns} when
3968 * queried.
3969 *
3970 * @see #ACTION_GET_CONTENT
3971 * @see #ACTION_OPEN_DOCUMENT
3972 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003973 */
3974 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3975 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3976
3977 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003978 * Used to indicate that an intent filter can accept files which are not necessarily
3979 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3980 * at least streamable via
3981 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3982 * using one of the stream types exposed via
3983 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3984 *
3985 * @see #ACTION_SEND
3986 * @see #ACTION_SEND_MULTIPLE
3987 */
3988 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3989 public static final String CATEGORY_TYPED_OPENABLE =
3990 "android.intent.category.TYPED_OPENABLE";
3991
3992 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003993 * To be used as code under test for framework instrumentation tests.
3994 */
3995 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3996 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003997 /**
3998 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003999 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4000 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004001 */
4002 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4003 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4004 /**
4005 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004006 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4007 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004008 */
4009 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4010 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004011 /**
4012 * An activity to run when device is inserted into a analog (low 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_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4018
4019 /**
4020 * An activity to run when device is inserted into a digital (high end) dock.
4021 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4022 * information, see {@link android.app.UiModeManager}.
4023 */
4024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4025 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004026
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004027 /**
4028 * Used to indicate that the activity can be used in a car environment.
4029 */
4030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4031 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4032
Zak Cohendb6ca492017-01-26 14:09:00 -08004033 /**
4034 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4035 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4036 * information, see {@link android.app.UiModeManager}.
4037 */
4038 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4039 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004040 // ---------------------------------------------------------------------
4041 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004042 // Application launch intent categories (see addCategory()).
4043
4044 /**
4045 * Used with {@link #ACTION_MAIN} to launch the browser application.
4046 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004047 * <p>NOTE: This should not be used as the primary key of an Intent,
4048 * since it will not result in the app launching with the correct
4049 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004050 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004051 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004052 */
4053 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4054 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4055
4056 /**
4057 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4058 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004059 * <p>NOTE: This should not be used as the primary key of an Intent,
4060 * since it will not result in the app launching with the correct
4061 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004062 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004063 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004064 */
4065 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4066 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4067
4068 /**
4069 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4070 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004071 * <p>NOTE: This should not be used as the primary key of an Intent,
4072 * since it will not result in the app launching with the correct
4073 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004074 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004075 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004076 */
4077 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4078 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4079
4080 /**
4081 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4082 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004083 * <p>NOTE: This should not be used as the primary key of an Intent,
4084 * since it will not result in the app launching with the correct
4085 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004086 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004087 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004088 */
4089 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4090 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4091
4092 /**
4093 * Used with {@link #ACTION_MAIN} to launch the email application.
4094 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004095 * <p>NOTE: This should not be used as the primary key of an Intent,
4096 * since it will not result in the app launching with the correct
4097 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004098 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004099 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004100 */
4101 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4102 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4103
4104 /**
4105 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4106 * The activity should be able to view and manipulate image and video files
4107 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004108 * <p>NOTE: This should not be used as the primary key of an Intent,
4109 * since it will not result in the app launching with the correct
4110 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004111 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004112 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004113 */
4114 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4115 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4116
4117 /**
4118 * Used with {@link #ACTION_MAIN} to launch the maps application.
4119 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004120 * <p>NOTE: This should not be used as the primary key of an Intent,
4121 * since it will not result in the app launching with the correct
4122 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004123 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004124 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004125 */
4126 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4127 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4128
4129 /**
4130 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4131 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004132 * <p>NOTE: This should not be used as the primary key of an Intent,
4133 * since it will not result in the app launching with the correct
4134 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004135 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004136 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004137 */
4138 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4139 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4140
4141 /**
4142 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004143 * The activity should be able to play, browse, or manipulate music files
4144 * stored on the device.
4145 * <p>NOTE: This should not be used as the primary key of an Intent,
4146 * since it will not result in the app launching with the correct
4147 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004148 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004149 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004150 */
4151 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4152 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4153
4154 // ---------------------------------------------------------------------
4155 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004156 // Standard extra data keys.
4157
4158 /**
4159 * The initial data to place in a newly created record. Use with
4160 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4161 * fields as would be given to the underlying ContentProvider.insert()
4162 * call.
4163 */
4164 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4165
4166 /**
4167 * A constant CharSequence that is associated with the Intent, used with
4168 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4169 * this may be a styled CharSequence, so you must use
4170 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4171 * retrieve it.
4172 */
4173 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4174
4175 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004176 * A constant String that is associated with the Intent, used with
4177 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4178 * as HTML formatted text. Note that you <em>must</em> also supply
4179 * {@link #EXTRA_TEXT}.
4180 */
4181 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4182
4183 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004184 * A content: URI holding a stream of data associated with the Intent,
4185 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004186 */
4187 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4188
4189 /**
4190 * A String[] holding e-mail addresses that should be delivered to.
4191 */
4192 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4193
4194 /**
4195 * A String[] holding e-mail addresses that should be carbon copied.
4196 */
4197 public static final String EXTRA_CC = "android.intent.extra.CC";
4198
4199 /**
4200 * A String[] holding e-mail addresses that should be blind carbon copied.
4201 */
4202 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4203
4204 /**
4205 * A constant string holding the desired subject line of a message.
4206 */
4207 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4208
4209 /**
4210 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004211 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004212 */
4213 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4214
4215 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004216 * An int representing the user id to be used.
4217 *
4218 * @hide
4219 */
4220 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4221
4222 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004223 * An int representing the task id to be retrieved. This is used when a launch from recents is
4224 * intercepted by another action such as credentials confirmation to remember which task should
4225 * be resumed when complete.
4226 *
4227 * @hide
4228 */
4229 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4230
4231 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004232 * An Intent[] describing additional, alternate choices you would like shown with
4233 * {@link #ACTION_CHOOSER}.
4234 *
4235 * <p>An app may be capable of providing several different payload types to complete a
4236 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4237 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4238 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4239 * photo data or a hosted link where the photos can be viewed.</p>
4240 *
4241 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4242 * first/primary/preferred intent in the set. Additional intents specified in
4243 * this extra are ordered; by default intents that appear earlier in the array will be
4244 * preferred over intents that appear later in the array as matches for the same
4245 * target component. To alter this preference, a calling app may also supply
4246 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4247 */
4248 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4249
4250 /**
Adam Powell52c39212016-04-07 15:14:18 -07004251 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4252 * and omitted from a list of components presented to the user.
4253 *
4254 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4255 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4256 * from your own package or other apps from your organization if the idea of sending to those
4257 * targets would be redundant with other app functionality. Filtered components will not
4258 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4259 */
4260 public static final String EXTRA_EXCLUDE_COMPONENTS
4261 = "android.intent.extra.EXCLUDE_COMPONENTS";
4262
4263 /**
4264 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4265 * describing additional high-priority deep-link targets for the chooser to present to the user.
4266 *
4267 * <p>Targets provided in this way will be presented inline with all other targets provided
4268 * by services from other apps. They will be prioritized before other service targets, but
4269 * after those targets provided by sources that the user has manually pinned to the front.</p>
4270 *
4271 * @see #ACTION_CHOOSER
4272 */
4273 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4274
4275 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004276 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4277 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4278 *
4279 * <p>An app preparing an action for another app to complete may wish to allow the user to
4280 * disambiguate between several options for completing the action based on the chosen target
4281 * or otherwise refine the action before it is invoked.
4282 * </p>
4283 *
4284 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4285 * <ul>
4286 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4287 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4288 * chosen target beyond the first</li>
4289 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4290 * should fill in and send once the disambiguation is complete</li>
4291 * </ul>
4292 */
4293 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4294 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4295
4296 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004297 * An {@code ArrayList} of {@code String} annotations describing content for
4298 * {@link #ACTION_CHOOSER}.
4299 *
4300 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4301 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4302 *
4303 * <p>Annotations should describe the major components or topics of the content. It is up to
4304 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4305 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4306 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4307 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4308 * use the following annotations when applicable:</p>
4309 * <ul>
4310 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4311 * health & beauty, and office supplies.</li>
4312 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4313 * happy, and sad.</li>
4314 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4315 * face, finger, standing, and walking.</li>
4316 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4317 * child, and baby.</li>
4318 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4319 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4320 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4321 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4322 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4323 * flowers.</li>
4324 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4325 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4326 * sunglasses, jewelry, handbags and clothing.</li>
4327 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4328 * paper, and silk.</li>
4329 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4330 * cars, and boats.</li>
4331 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4332 * posters.</li>
4333 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4334 * and designs of houses.</li>
4335 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4336 * Christmas and Thanksgiving.</li>
4337 * </ul>
4338 */
4339 public static final String EXTRA_CONTENT_ANNOTATIONS
4340 = "android.intent.extra.CONTENT_ANNOTATIONS";
4341
4342 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004343 * A {@link ResultReceiver} used to return data back to the sender.
4344 *
4345 * <p>Used to complete an app-specific
4346 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4347 *
4348 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4349 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4350 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4351 * when the user selects a target component from the chooser. It is up to the recipient
4352 * to send a result to this ResultReceiver to signal that disambiguation is complete
4353 * and that the chooser should invoke the user's choice.</p>
4354 *
4355 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4356 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4357 * to match and fill in the final Intent or ChooserTarget before starting it.
4358 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4359 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4360 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4361 *
4362 * <p>The result code passed to the ResultReceiver should be
4363 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4364 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4365 * the chooser should finish without starting a target.</p>
4366 */
4367 public static final String EXTRA_RESULT_RECEIVER
4368 = "android.intent.extra.RESULT_RECEIVER";
4369
4370 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004371 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004372 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004373 */
4374 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4375
4376 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004377 * A Parcelable[] of {@link Intent} or
4378 * {@link android.content.pm.LabeledIntent} objects as set with
4379 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4380 * a the front of the list of choices, when shown to the user with a
4381 * {@link #ACTION_CHOOSER}.
4382 */
4383 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4384
4385 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004386 * A {@link IntentSender} to start after ephemeral installation success.
4387 * @hide
4388 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004389 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4390
4391 /**
4392 * A {@link IntentSender} to start after ephemeral installation failure.
4393 * @hide
4394 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004395 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4396
4397 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004398 * The host name that triggered an ephemeral resolution.
4399 * @hide
4400 */
4401 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4402
4403 /**
4404 * An opaque token to track ephemeral resolution.
4405 * @hide
4406 */
4407 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4408
4409 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004410 * The version code of the app to install components from.
4411 * @hide
4412 */
4413 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4414
4415 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004416 * A Bundle forming a mapping of potential target package names to different extras Bundles
4417 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4418 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4419 * be currently installed on the device.
4420 *
4421 * <p>An application may choose to provide alternate extras for the case where a user
4422 * selects an activity from a predetermined set of target packages. If the activity
4423 * the user selects from the chooser belongs to a package with its package name as
4424 * a key in this bundle, the corresponding extras for that package will be merged with
4425 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4426 * extra has the same key as an extra already present in the intent it will overwrite
4427 * the extra from the intent.</p>
4428 *
4429 * <p><em>Examples:</em>
4430 * <ul>
4431 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4432 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4433 * parameters for that target.</li>
4434 * <li>An application may offer additional metadata for known targets of a given intent
4435 * to pass along information only relevant to that target such as account or content
4436 * identifiers already known to that application.</li>
4437 * </ul></p>
4438 */
4439 public static final String EXTRA_REPLACEMENT_EXTRAS =
4440 "android.intent.extra.REPLACEMENT_EXTRAS";
4441
4442 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004443 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4444 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4445 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4446 * {@link ComponentName} of the chosen component.
4447 *
4448 * <p>In some situations this callback may never come, for example if the user abandons
4449 * the chooser, switches to another task or any number of other reasons. Apps should not
4450 * be written assuming that this callback will always occur.</p>
4451 */
4452 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4453 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4454
4455 /**
4456 * The {@link ComponentName} chosen by the user to complete an action.
4457 *
4458 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4459 */
4460 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4461
4462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004463 * A {@link android.view.KeyEvent} object containing the event that
4464 * triggered the creation of the Intent it is in.
4465 */
4466 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4467
4468 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004469 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4470 * before shutting down.
4471 *
4472 * {@hide}
4473 */
4474 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4475
4476 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004477 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4478 * requested by the user.
4479 *
4480 * {@hide}
4481 */
4482 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4483 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4484
4485 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004486 * 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 -07004487 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4488 * of restarting the application.
4489 */
4490 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4491
4492 /**
4493 * A String holding the phone number originally entered in
4494 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4495 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4496 */
4497 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004498
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004499 /**
4500 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4501 * intents to supply the uid the package had been assigned. Also an optional
4502 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4503 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4504 * purpose.
4505 */
4506 public static final String EXTRA_UID = "android.intent.extra.UID";
4507
4508 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004509 * @hide String array of package names.
4510 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004511 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004512 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4513
4514 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004515 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4516 * intents to indicate whether this represents a full uninstall (removing
4517 * both the code and its data) or a partial uninstall (leaving its data,
4518 * implying that this is an update).
4519 */
4520 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004521
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004522 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004523 * @hide
4524 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4525 * intents to indicate that at this point the package has been removed for
4526 * all users on the device.
4527 */
4528 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4529 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4530
4531 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004532 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4533 * intents to indicate that this is a replacement of the package, so this
4534 * broadcast will immediately be followed by an add broadcast for a
4535 * different version of the same package.
4536 */
4537 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004538
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004539 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004540 * Used as an int extra field in {@link android.app.AlarmManager} intents
4541 * to tell the application being invoked how many pending alarms are being
4542 * delievered with the intent. For one-shot alarms this will always be 1.
4543 * For recurring alarms, this might be greater than 1 if the device was
4544 * asleep or powered off at the time an earlier alarm would have been
4545 * delivered.
4546 */
4547 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004548
Jacek Surazski86b6c532009-05-13 14:38:28 +02004549 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004550 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4551 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004552 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4553 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004554 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4555 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4556 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004557 */
4558 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4559
4560 /**
4561 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4562 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004563 */
4564 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4565
4566 /**
4567 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4568 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004569 */
4570 public static final int EXTRA_DOCK_STATE_DESK = 1;
4571
4572 /**
4573 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4574 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004575 */
4576 public static final int EXTRA_DOCK_STATE_CAR = 2;
4577
4578 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004579 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4580 * to represent that the phone is in a analog (low end) dock.
4581 */
4582 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4583
4584 /**
4585 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4586 * to represent that the phone is in a digital (high end) dock.
4587 */
4588 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4589
4590 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004591 * Boolean that can be supplied as meta-data with a dock activity, to
4592 * indicate that the dock should take over the home key when it is active.
4593 */
4594 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004595
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004596 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004597 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4598 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004599 */
4600 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4601
4602 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004603 * Used in the extra field in the remote intent. It's astring token passed with the
4604 * remote intent.
4605 */
4606 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4607 "android.intent.extra.remote_intent_token";
4608
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004609 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004610 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004611 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004612 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004613 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004614 "android.intent.extra.changed_component_name";
4615
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004616 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004617 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004618 * and contains a string array of all of the components that have changed. If
4619 * the state of the overall package has changed, then it will contain an entry
4620 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004621 */
4622 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4623 "android.intent.extra.changed_component_name_list";
4624
4625 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004626 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004627 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004628 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4629 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4630 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004631 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004632 */
4633 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4634 "android.intent.extra.changed_package_list";
4635
4636 /**
4637 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004638 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4639 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004640 * and contains an integer array of uids of all of the components
4641 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004642 */
4643 public static final String EXTRA_CHANGED_UID_LIST =
4644 "android.intent.extra.changed_uid_list";
4645
4646 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004647 * @hide
4648 * Magic extra system code can use when binding, to give a label for
4649 * who it is that has bound to a service. This is an integer giving
4650 * a framework string resource that can be displayed to the user.
4651 */
4652 public static final String EXTRA_CLIENT_LABEL =
4653 "android.intent.extra.client_label";
4654
4655 /**
4656 * @hide
4657 * Magic extra system code can use when binding, to give a PendingIntent object
4658 * that can be launched for the user to disable the system's use of this
4659 * service.
4660 */
4661 public static final String EXTRA_CLIENT_INTENT =
4662 "android.intent.extra.client_intent";
4663
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004664 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004665 * Extra used to indicate that an intent should only return data that is on
4666 * the local device. This is a boolean extra; the default is false. If true,
4667 * an implementation should only allow the user to select data that is
4668 * already on the device, not requiring it be downloaded from a remote
4669 * service when opened.
4670 *
4671 * @see #ACTION_GET_CONTENT
4672 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004673 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004674 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004675 */
4676 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004677 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004678
Amith Yamasani13593602012-03-22 16:16:17 -07004679 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004680 * Extra used to indicate that an intent can allow the user to select and
4681 * return multiple items. This is a boolean extra; the default is false. If
4682 * true, an implementation is allowed to present the user with a UI where
4683 * they can pick multiple items that are all returned to the caller. When
4684 * this happens, they should be returned as the {@link #getClipData()} part
4685 * of the result Intent.
4686 *
4687 * @see #ACTION_GET_CONTENT
4688 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004689 */
4690 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004691 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004692
4693 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004694 * The integer userHandle carried with broadcast intents related to addition, removal and
4695 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4696 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4697 *
Amith Yamasani13593602012-03-22 16:16:17 -07004698 * @hide
4699 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004700 public static final String EXTRA_USER_HANDLE =
4701 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004702
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004703 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004704 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4705 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4706 */
4707 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004708 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004709
4710 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004711 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004712 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4713 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004714 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004715 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4716
4717 /**
4718 * Extra sent in the intent to the BroadcastReceiver that handles
4719 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4720 * the restrictions as key/value pairs.
4721 */
4722 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4723 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004724
Amith Yamasani86118ba2013-03-28 14:33:16 -07004725 /**
4726 * Extra used in the response from a BroadcastReceiver that handles
4727 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4728 */
4729 public static final String EXTRA_RESTRICTIONS_INTENT =
4730 "android.intent.extra.restrictions_intent";
4731
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004732 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004733 * Extra used to communicate a set of acceptable MIME types. The type of the
4734 * extra is {@code String[]}. Values may be a combination of concrete MIME
4735 * types (such as "image/png") and/or partial MIME types (such as
4736 * "audio/*").
4737 *
4738 * @see #ACTION_GET_CONTENT
4739 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004740 */
4741 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4742
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004743 /**
4744 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4745 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004746 * When this is true, hardware devices can use this information to determine that
4747 * they shouldn't do a complete shutdown of their device since this is not a
4748 * complete shutdown down to the kernel, but only user space restarting.
4749 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004750 */
4751 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4752 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4753
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004754 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004755 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4756 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4757 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4758 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004759 *
4760 * @hide for internal use only.
4761 */
4762 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4763 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004764 /** @hide */
4765 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4766 /** @hide */
4767 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4768 /** @hide */
4769 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004770
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004771 /** {@hide} */
4772 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4773
Rubin Xue8490f12015-06-25 12:17:48 +01004774 /** {@hide} */
4775 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4776
Santos Cordon15a13782015-03-31 18:32:31 -07004777 /**
4778 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4779 * activation request.
4780 * TODO: Add information about the structure and response data used with the pending intent.
4781 * @hide
4782 */
4783 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4784 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4785
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004786 /**
4787 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004788 *
4789 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004790 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004791 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004792 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4793
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004794 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004795 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4796 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4797 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004798 *
4799 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004800 * @see #ACTION_QUICK_VIEW
4801 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004802 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004803 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004804 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4805 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004806
4807 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004808 * An optional extra of {@code String[]} indicating which quick view features should be made
4809 * available to the user in the quick view UI while handing a
4810 * {@link Intent#ACTION_QUICK_VIEW} intent.
4811 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4812 * Quick viewer can implement features not listed below.
4813 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4814 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4815 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4816 * <p>
4817 * Requirements:
4818 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4819 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4820 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4821 * internal policies.
4822 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4823 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4824 * disable or hide features.
4825 *
4826 * @see #ACTION_QUICK_VIEW
4827 */
4828 public static final String EXTRA_QUICK_VIEW_FEATURES =
4829 "android.intent.extra.QUICK_VIEW_FEATURES";
4830
4831 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004832 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004833 * When a profile goes into quiet mode, all apps in the profile are killed and the
4834 * profile user is stopped. Widgets originating from the profile are masked, and app
4835 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004836 */
4837 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004838
4839 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004840 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004841 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004842 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4843 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004844 *
4845 * @hide
4846 */
4847 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4848 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4849
4850 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004851 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4852 * whether to show the chooser or not when there is only one application available
4853 * to choose from.
4854 *
4855 * @hide
4856 */
4857 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4858 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
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 video codec is allowed to use.
4863 *
4864 * @hide
4865 */
4866 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4867
4868 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004869 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004870 * to represent that a audio codec is allowed to use.
4871 *
4872 * @hide
4873 */
4874 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4875
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004876 // ---------------------------------------------------------------------
4877 // ---------------------------------------------------------------------
4878 // Intent flags (see mFlags variable).
4879
Tor Norbyed9273d62013-05-30 15:59:53 -07004880 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004881 @IntDef(flag = true, value = {
4882 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4883 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004884 @Retention(RetentionPolicy.SOURCE)
4885 public @interface GrantUriMode {}
4886
Jeff Sharkey846318a2014-04-04 12:12:41 -07004887 /** @hide */
4888 @IntDef(flag = true, value = {
4889 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4890 @Retention(RetentionPolicy.SOURCE)
4891 public @interface AccessUriMode {}
4892
4893 /**
4894 * Test if given mode flags specify an access mode, which must be at least
4895 * read and/or write.
4896 *
4897 * @hide
4898 */
4899 public static boolean isAccessUriMode(int modeFlags) {
4900 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4901 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4902 }
4903
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004904 /**
4905 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004906 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004907 * specified in its ClipData. When applying to an Intent's ClipData,
4908 * all URIs as well as recursive traversals through data or other ClipData
4909 * in Intent items will be granted; only the grant flags of the top-level
4910 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004911 */
4912 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4913 /**
4914 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004915 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004916 * specified in its ClipData. When applying to an Intent's ClipData,
4917 * all URIs as well as recursive traversals through data or other ClipData
4918 * in Intent items will be granted; only the grant flags of the top-level
4919 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004920 */
4921 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4922 /**
4923 * Can be set by the caller to indicate that this Intent is coming from
4924 * a background operation, not from direct user interaction.
4925 */
4926 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4927 /**
4928 * A flag you can enable for debugging: when set, log messages will be
4929 * printed during the resolution of this intent to show you what has
4930 * been found to create the final resolved list.
4931 */
4932 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004933 /**
4934 * If set, this intent will not match any components in packages that
4935 * are currently stopped. If this is not set, then the default behavior
4936 * is to include such applications in the result.
4937 */
4938 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4939 /**
4940 * If set, this intent will always match any components in packages that
4941 * are currently stopped. This is the default behavior when
4942 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4943 * flags are set, this one wins (it allows overriding of exclude for
4944 * places where the framework may automatically set the exclude flag).
4945 */
4946 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004947
4948 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004949 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004950 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004951 * persisted across device reboots until explicitly revoked with
4952 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4953 * grant for possible persisting; the receiving application must call
4954 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4955 * actually persist.
4956 *
4957 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4958 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4959 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004960 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004961 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004962 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004963
4964 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004965 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4966 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4967 * applies to any URI that is a prefix match against the original granted
4968 * URI. (Without this flag, the URI must match exactly for access to be
4969 * granted.) Another URI is considered a prefix match only when scheme,
4970 * authority, and all path segments defined by the prefix are an exact
4971 * match.
4972 */
4973 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4974
4975 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004976 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004977 * homework and verified that they correctly handle packages and components
4978 * that come and go over time. In particular:
4979 * <ul>
4980 * <li>Apps installed on external storage, which will appear to be
4981 * uninstalled while the the device is ejected.
4982 * <li>Apps with encryption unaware components, which will appear to not
4983 * exist while the device is locked.
4984 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004985 *
4986 * @hide
4987 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004988 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004989
4990 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004991 * Internal flag used to indicate ephemeral applications should not be
4992 * considered when resolving the intent.
4993 *
4994 * @hide
4995 */
4996 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4997
4998 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004999 * If set, the new activity is not kept in the history stack. As soon as
5000 * the user navigates away from it, the activity is finished. This may also
5001 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5002 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005003 *
5004 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5005 * is never invoked when the current activity starts a new activity which
5006 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005007 */
5008 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5009 /**
5010 * If set, the activity will not be launched if it is already running
5011 * at the top of the history stack.
5012 */
5013 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5014 /**
5015 * If set, this activity will become the start of a new task on this
5016 * history stack. A task (from the activity that started it to the
5017 * next task activity) defines an atomic group of activities that the
5018 * user can move to. Tasks can be moved to the foreground and background;
5019 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005020 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005021 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5022 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005023 *
5024 * <p>This flag is generally used by activities that want
5025 * to present a "launcher" style behavior: they give the user a list of
5026 * separate things that can be done, which otherwise run completely
5027 * independently of the activity launching them.
5028 *
5029 * <p>When using this flag, if a task is already running for the activity
5030 * you are now starting, then a new activity will not be started; instead,
5031 * the current task will simply be brought to the front of the screen with
5032 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5033 * to disable this behavior.
5034 *
5035 * <p>This flag can not be used when the caller is requesting a result from
5036 * the activity being launched.
5037 */
5038 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5039 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005040 * This flag is used to create a new task and launch an activity into it.
5041 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5042 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5043 * search through existing tasks for ones matching this Intent. Only if no such
5044 * task is found would a new task be created. When paired with
5045 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5046 * the search for a matching task and unconditionally start a new task.
5047 *
5048 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5049 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005050 * top-level application launcher.</strong> Used in conjunction with
5051 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5052 * behavior of bringing an existing task to the foreground. When set,
5053 * a new task is <em>always</em> started to host the Activity for the
5054 * Intent, regardless of whether there is already an existing task running
5055 * the same thing.
5056 *
5057 * <p><strong>Because the default system does not include graphical task management,
5058 * you should not use this flag unless you provide some way for a user to
5059 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005060 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005061 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5062 * creating new document tasks.
5063 *
5064 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005065 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005066 *
Scott Main7aee61f2011-02-08 11:25:01 -08005067 * <p>See
5068 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5069 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005070 *
5071 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5072 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005073 */
5074 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5075 /**
5076 * If set, and the activity being launched is already running in the
5077 * current task, then instead of launching a new instance of that activity,
5078 * all of the other activities on top of it will be closed and this Intent
5079 * will be delivered to the (now on top) old activity as a new Intent.
5080 *
5081 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5082 * If D calls startActivity() with an Intent that resolves to the component
5083 * of activity B, then C and D will be finished and B receive the given
5084 * Intent, resulting in the stack now being: A, B.
5085 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005086 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005087 * either receive the new intent you are starting here in its
5088 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005089 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005090 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5091 * the same intent, then it will be finished and re-created; for all other
5092 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5093 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005094 *
5095 * <p>This launch mode can also be used to good effect in conjunction with
5096 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5097 * of a task, it will bring any currently running instance of that task
5098 * to the foreground, and then clear it to its root state. This is
5099 * especially useful, for example, when launching an activity from the
5100 * notification manager.
5101 *
Scott Main7aee61f2011-02-08 11:25:01 -08005102 * <p>See
5103 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5104 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005105 */
5106 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5107 /**
5108 * If set and this intent is being used to launch a new activity from an
5109 * existing one, then the reply target of the existing activity will be
5110 * transfered to the new activity. This way the new activity can call
5111 * {@link android.app.Activity#setResult} and have that result sent back to
5112 * the reply target of the original activity.
5113 */
5114 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5115 /**
5116 * If set and this intent is being used to launch a new activity from an
5117 * existing one, the current activity will not be counted as the top
5118 * activity for deciding whether the new intent should be delivered to
5119 * the top instead of starting a new one. The previous activity will
5120 * be used as the top, with the assumption being that the current activity
5121 * will finish itself immediately.
5122 */
5123 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5124 /**
5125 * If set, the new activity is not kept in the list of recently launched
5126 * activities.
5127 */
5128 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5129 /**
5130 * This flag is not normally set by application code, but set for you by
5131 * the system as described in the
5132 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5133 * launchMode} documentation for the singleTask mode.
5134 */
5135 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5136 /**
5137 * If set, and this activity is either being started in a new task or
5138 * bringing to the top an existing task, then it will be launched as
5139 * the front door of the task. This will result in the application of
5140 * any affinities needed to have that task in the proper state (either
5141 * moving activities to or from it), or simply resetting that task to
5142 * its initial state if needed.
5143 */
5144 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5145 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005146 * This flag is not normally set by application code, but set for you by
5147 * the system if this activity is being launched from history
5148 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 */
5150 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005151 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005152 * @deprecated As of API 21 this performs identically to
5153 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005154 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005155 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005156 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005157 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005158 * This flag is used to open a document into a new task rooted at the activity launched
5159 * by this Intent. Through the use of this flag, or its equivalent attribute,
5160 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005161 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005162 *
Craig Mautner026596b2014-05-21 15:35:44 -07005163 * <p>The use of the activity attribute form of this,
5164 * {@link android.R.attr#documentLaunchMode}, is
5165 * preferred over the Intent flag described here. The attribute form allows the
5166 * Activity to specify multiple document behavior for all launchers of the Activity
5167 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005168 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005169 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5170 * it is kept after the activity is finished is different than the use of
5171 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5172 * this flag is being used to create a new recents entry, then by default that entry
5173 * will be removed once the activity is finished. You can modify this behavior with
5174 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5175 *
Craig Mautner026596b2014-05-21 15:35:44 -07005176 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5177 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5178 * equivalent of the Activity manifest specifying {@link
5179 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5180 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5181 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005182 *
Craig Mautner026596b2014-05-21 15:35:44 -07005183 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005184 *
Craig Mautner026596b2014-05-21 15:35:44 -07005185 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005186 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5187 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005188 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005189 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005190 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005191 * callback from occurring on the current frontmost activity before it is
5192 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005193 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005194 * <p>Typically, an activity can rely on that callback to indicate that an
5195 * explicit user action has caused their activity to be moved out of the
5196 * foreground. The callback marks an appropriate point in the activity's
5197 * lifecycle for it to dismiss any notifications that it intends to display
5198 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005199 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005200 * <p>If an activity is ever started via any non-user-driven events such as
5201 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5202 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005203 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005204 */
5205 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005206 /**
5207 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5208 * this flag will cause the launched activity to be brought to the front of its
5209 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005210 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005211 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5212 * If D calls startActivity() with an Intent that resolves to the component
5213 * of activity B, then B will be brought to the front of the history stack,
5214 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005215 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005216 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005217 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005218 */
5219 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005220 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005221 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5222 * this flag will prevent the system from applying an activity transition
5223 * animation to go to the next activity state. This doesn't mean an
5224 * animation will never run -- if another activity change happens that doesn't
5225 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005226 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005227 * when you are going to do a series of activity operations but the
5228 * animation seen by the user shouldn't be driven by the first activity
5229 * change but rather a later one.
5230 */
5231 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5232 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005233 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5234 * this flag will cause any existing task that would be associated with the
5235 * activity to be cleared before the activity is started. That is, the activity
5236 * becomes the new root of an otherwise empty task, and any old activities
5237 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5238 */
5239 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5240 /**
5241 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5242 * this flag will cause a newly launching task to be placed on top of the current
5243 * home activity task (if there is one). That is, pressing back from the task
5244 * will always return the user to home even if that was not the last activity they
5245 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5246 */
5247 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5248 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005249 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5250 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005251 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005252 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005253 * this flag. When set and the task's activity is finished, the recents
5254 * entry will remain in the interface for the user to re-launch it, like a
5255 * recents entry for a top-level application.
5256 * <p>
5257 * The receiving activity can override this request with
5258 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5259 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005260 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005261 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005262 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005263
5264 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005265 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5266 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005267 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5268 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005269 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005270 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005271
5272 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005273 * If set, when sending a broadcast only registered receivers will be
5274 * called -- no BroadcastReceiver components will be launched.
5275 */
5276 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005277 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005278 * If set, when sending a broadcast the new broadcast will replace
5279 * any existing pending broadcast that matches it. Matching is defined
5280 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5281 * true for the intents of the two broadcasts. When a match is found,
5282 * the new broadcast (and receivers associated with it) will replace the
5283 * existing one in the pending broadcast list, remaining at the same
5284 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005285 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005286 * <p>This flag is most typically used with sticky broadcasts, which
5287 * only care about delivering the most recent values of the broadcast
5288 * to their receivers.
5289 */
5290 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5291 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005292 * If set, when sending a broadcast the recipient is allowed to run at
5293 * foreground priority, with a shorter timeout interval. During normal
5294 * broadcasts the receivers are not automatically hoisted out of the
5295 * background priority class.
5296 */
5297 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5298 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005299 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5300 * They can still propagate results through to later receivers, but they can not prevent
5301 * later receivers from seeing the broadcast.
5302 */
5303 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5304 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005305 * If set, when sending a broadcast <i>before boot has completed</i> only
5306 * registered receivers will be called -- no BroadcastReceiver components
5307 * will be launched. Sticky intent state will be recorded properly even
5308 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5309 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005310 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005311 * <p>This flag is only for use by system sevices as a convenience to
5312 * avoid having to implement a more complex mechanism around detection
5313 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005314 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005315 * @hide
5316 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005317 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005318 /**
5319 * Set when this broadcast is for a boot upgrade, a special mode that
5320 * allows the broadcast to be sent before the system is ready and launches
5321 * the app process with no providers running in it.
5322 * @hide
5323 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005324 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005325 /**
5326 * If set, the broadcast will always go to manifest receivers in background (cached
5327 * or not running) apps, regardless of whether that would be done by default. By
5328 * default they will only receive broadcasts if the broadcast has specified an
5329 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005330 *
5331 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5332 * the broadcast code there must also be changed to match.
5333 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005334 * @hide
5335 */
5336 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5337 /**
5338 * If set, the broadcast will never go to manifest receivers in background (cached
5339 * or not running) apps, regardless of whether that would be done by default. By
5340 * default they will receive broadcasts if the broadcast has specified an
5341 * explicit component or package name.
5342 * @hide
5343 */
5344 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005345 /**
5346 * If set, this broadcast is being sent from the shell.
5347 * @hide
5348 */
5349 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005350
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005351 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005352 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5353 * will not receive broadcasts.
5354 *
5355 * <em>This flag has no effect when used by an Instant App.</em>
5356 */
5357 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5358
5359 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005360 * @hide Flags that can't be changed with PendingIntent.
5361 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005362 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5363 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5364 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005365
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005366 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005367 // ---------------------------------------------------------------------
5368 // toUri() and parseUri() options.
5369
5370 /**
5371 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5372 * always has the "intent:" scheme. This syntax can be used when you want
5373 * to later disambiguate between URIs that are intended to describe an
5374 * Intent vs. all others that should be treated as raw URIs. When used
5375 * with {@link #parseUri}, any other scheme will result in a generic
5376 * VIEW action for that raw URI.
5377 */
5378 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005379
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005380 /**
5381 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5382 * always has the "android-app:" scheme. This is a variation of
5383 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5384 * http/https URI being delivered to a specific package name. The format
5385 * is:
5386 *
5387 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005388 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005389 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005390 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5391 * you must also include a scheme; including a path also requires both a host and a scheme.
5392 * The final #Intent; fragment can be used without a scheme, host, or path.
5393 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005394 * used with intents that have a {@link #setSelector}, since the base intent
5395 * will always have an explicit package name.</p>
5396 *
5397 * <p>Some examples of how this scheme maps to Intent objects:</p>
5398 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5399 * <colgroup align="left" />
5400 * <colgroup align="left" />
5401 * <thead>
5402 * <tr><th>URI</th> <th>Intent</th></tr>
5403 * </thead>
5404 *
5405 * <tbody>
5406 * <tr><td><code>android-app://com.example.app</code></td>
5407 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5408 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5409 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5410 * </table></td>
5411 * </tr>
5412 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5413 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5414 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5415 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5416 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5417 * </table></td>
5418 * </tr>
5419 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5420 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5421 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5422 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5423 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5424 * </table></td>
5425 * </tr>
5426 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5427 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5428 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5429 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5430 * </table></td>
5431 * </tr>
5432 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5433 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5434 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5435 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5436 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5437 * </table></td>
5438 * </tr>
5439 * <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>
5440 * <td><table border="" style="margin:0" >
5441 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5442 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5443 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5444 * </table></td>
5445 * </tr>
5446 * </tbody>
5447 * </table>
5448 */
5449 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5450
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005451 /**
5452 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5453 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5454 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5455 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5456 * generated Intent can not cause unexpected data access to happen.
5457 *
5458 * <p>If you do not trust the source of the URI being parsed, you should still do further
5459 * processing to protect yourself from it. In particular, when using it to start an
5460 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5461 * that can handle it.</p>
5462 */
5463 public static final int URI_ALLOW_UNSAFE = 1<<2;
5464
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005465 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466
5467 private String mAction;
5468 private Uri mData;
5469 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005470 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005471 private ComponentName mComponent;
5472 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005473 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005474 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005475 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005476 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005477 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005478 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005479 /** Token to track instant app launches. Local only; do not copy cross-process. */
5480 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005481
5482 // ---------------------------------------------------------------------
5483
5484 /**
5485 * Create an empty intent.
5486 */
5487 public Intent() {
5488 }
5489
5490 /**
5491 * Copy constructor.
5492 */
5493 public Intent(Intent o) {
5494 this.mAction = o.mAction;
5495 this.mData = o.mData;
5496 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005497 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005498 this.mComponent = o.mComponent;
5499 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005500 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005501 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005502 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005503 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005504 }
5505 if (o.mExtras != null) {
5506 this.mExtras = new Bundle(o.mExtras);
5507 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005508 if (o.mSourceBounds != null) {
5509 this.mSourceBounds = new Rect(o.mSourceBounds);
5510 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005511 if (o.mSelector != null) {
5512 this.mSelector = new Intent(o.mSelector);
5513 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005514 if (o.mClipData != null) {
5515 this.mClipData = new ClipData(o.mClipData);
5516 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005517 }
5518
5519 @Override
5520 public Object clone() {
5521 return new Intent(this);
5522 }
5523
5524 private Intent(Intent o, boolean all) {
5525 this.mAction = o.mAction;
5526 this.mData = o.mData;
5527 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005528 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005529 this.mComponent = o.mComponent;
5530 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005531 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005532 }
5533 }
5534
5535 /**
5536 * Make a clone of only the parts of the Intent that are relevant for
5537 * filter matching: the action, data, type, component, and categories.
5538 */
5539 public Intent cloneFilter() {
5540 return new Intent(this, false);
5541 }
5542
5543 /**
5544 * Create an intent with a given action. All other fields (data, type,
5545 * class) are null. Note that the action <em>must</em> be in a
5546 * namespace because Intents are used globally in the system -- for
5547 * example the system VIEW action is android.intent.action.VIEW; an
5548 * application's custom action would be something like
5549 * com.google.app.myapp.CUSTOM_ACTION.
5550 *
5551 * @param action The Intent action, such as ACTION_VIEW.
5552 */
5553 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005554 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005555 }
5556
5557 /**
5558 * Create an intent with a given action and for a given data url. Note
5559 * that the action <em>must</em> be in a namespace because Intents are
5560 * used globally in the system -- for example the system VIEW action is
5561 * android.intent.action.VIEW; an application's custom action would be
5562 * something like com.google.app.myapp.CUSTOM_ACTION.
5563 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005564 * <p><em>Note: scheme and host name matching in the Android framework is
5565 * case-sensitive, unlike the formal RFC. As a result,
5566 * you should always ensure that you write your Uri with these elements
5567 * using lower case letters, and normalize any Uris you receive from
5568 * outside of Android to ensure the scheme and host is lower case.</em></p>
5569 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005570 * @param action The Intent action, such as ACTION_VIEW.
5571 * @param uri The Intent data URI.
5572 */
5573 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005574 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005575 mData = uri;
5576 }
5577
5578 /**
5579 * Create an intent for a specific component. All other fields (action, data,
5580 * type, class) are null, though they can be modified later with explicit
5581 * calls. This provides a convenient way to create an intent that is
5582 * intended to execute a hard-coded class name, rather than relying on the
5583 * system to find an appropriate class for you; see {@link #setComponent}
5584 * for more information on the repercussions of this.
5585 *
5586 * @param packageContext A Context of the application package implementing
5587 * this class.
5588 * @param cls The component class that is to be used for the intent.
5589 *
5590 * @see #setClass
5591 * @see #setComponent
5592 * @see #Intent(String, android.net.Uri , Context, Class)
5593 */
5594 public Intent(Context packageContext, Class<?> cls) {
5595 mComponent = new ComponentName(packageContext, cls);
5596 }
5597
5598 /**
5599 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005600 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005601 * construct the Intent and then calling {@link #setClass} to set its
5602 * class.
5603 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005604 * <p><em>Note: scheme and host name matching in the Android framework is
5605 * case-sensitive, unlike the formal RFC. As a result,
5606 * you should always ensure that you write your Uri with these elements
5607 * using lower case letters, and normalize any Uris you receive from
5608 * outside of Android to ensure the scheme and host is lower case.</em></p>
5609 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005610 * @param action The Intent action, such as ACTION_VIEW.
5611 * @param uri The Intent data URI.
5612 * @param packageContext A Context of the application package implementing
5613 * this class.
5614 * @param cls The component class that is to be used for the intent.
5615 *
5616 * @see #Intent(String, android.net.Uri)
5617 * @see #Intent(Context, Class)
5618 * @see #setClass
5619 * @see #setComponent
5620 */
5621 public Intent(String action, Uri uri,
5622 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005623 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005624 mData = uri;
5625 mComponent = new ComponentName(packageContext, cls);
5626 }
5627
5628 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005629 * Create an intent to launch the main (root) activity of a task. This
5630 * is the Intent that is started when the application's is launched from
5631 * Home. For anything else that wants to launch an application in the
5632 * same way, it is important that they use an Intent structured the same
5633 * way, and can use this function to ensure this is the case.
5634 *
5635 * <p>The returned Intent has the given Activity component as its explicit
5636 * component, {@link #ACTION_MAIN} as its action, and includes the
5637 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5638 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5639 * to do that through {@link #addFlags(int)} on the returned Intent.
5640 *
5641 * @param mainActivity The main activity component that this Intent will
5642 * launch.
5643 * @return Returns a newly created Intent that can be used to launch the
5644 * activity as a main application entry.
5645 *
5646 * @see #setClass
5647 * @see #setComponent
5648 */
5649 public static Intent makeMainActivity(ComponentName mainActivity) {
5650 Intent intent = new Intent(ACTION_MAIN);
5651 intent.setComponent(mainActivity);
5652 intent.addCategory(CATEGORY_LAUNCHER);
5653 return intent;
5654 }
5655
5656 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005657 * Make an Intent for the main activity of an application, without
5658 * specifying a specific activity to run but giving a selector to find
5659 * the activity. This results in a final Intent that is structured
5660 * the same as when the application is launched from
5661 * Home. For anything else that wants to launch an application in the
5662 * same way, it is important that they use an Intent structured the same
5663 * way, and can use this function to ensure this is the case.
5664 *
5665 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5666 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5667 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5668 * to do that through {@link #addFlags(int)} on the returned Intent.
5669 *
5670 * @param selectorAction The action name of the Intent's selector.
5671 * @param selectorCategory The name of a category to add to the Intent's
5672 * selector.
5673 * @return Returns a newly created Intent that can be used to launch the
5674 * activity as a main application entry.
5675 *
5676 * @see #setSelector(Intent)
5677 */
5678 public static Intent makeMainSelectorActivity(String selectorAction,
5679 String selectorCategory) {
5680 Intent intent = new Intent(ACTION_MAIN);
5681 intent.addCategory(CATEGORY_LAUNCHER);
5682 Intent selector = new Intent();
5683 selector.setAction(selectorAction);
5684 selector.addCategory(selectorCategory);
5685 intent.setSelector(selector);
5686 return intent;
5687 }
5688
5689 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005690 * Make an Intent that can be used to re-launch an application's task
5691 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5692 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5693 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5694 *
5695 * @param mainActivity The activity component that is the root of the
5696 * task; this is the activity that has been published in the application's
5697 * manifest as the main launcher icon.
5698 *
5699 * @return Returns a newly created Intent that can be used to relaunch the
5700 * activity's task in its root state.
5701 */
5702 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5703 Intent intent = makeMainActivity(mainActivity);
5704 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5705 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5706 return intent;
5707 }
5708
5709 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005710 * Call {@link #parseUri} with 0 flags.
5711 * @deprecated Use {@link #parseUri} instead.
5712 */
5713 @Deprecated
5714 public static Intent getIntent(String uri) throws URISyntaxException {
5715 return parseUri(uri, 0);
5716 }
Tom Taylord4a47292009-12-21 13:59:18 -08005717
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005718 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005719 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005720 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005721 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005722 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005723 *
5724 * <p>The URI given here must not be relative -- that is, it must include
5725 * the scheme and full path.
5726 *
5727 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005728 * @param flags Additional processing flags. Either 0,
5729 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005730 *
5731 * @return Intent The newly created Intent object.
5732 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005733 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5734 * it bad (as parsed by the Uri class) or the Intent data within the
5735 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005736 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005737 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005738 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005739 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005740 int i = 0;
5741 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005742 final boolean androidApp = uri.startsWith("android-app:");
5743
5744 // Validate intent scheme if requested.
5745 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5746 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005747 Intent intent = new Intent(ACTION_VIEW);
5748 try {
5749 intent.setData(Uri.parse(uri));
5750 } catch (IllegalArgumentException e) {
5751 throw new URISyntaxException(uri, e.getMessage());
5752 }
5753 return intent;
5754 }
5755 }
Tom Taylord4a47292009-12-21 13:59:18 -08005756
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005757 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005758 // simple case
5759 if (i == -1) {
5760 if (!androidApp) {
5761 return new Intent(ACTION_VIEW, Uri.parse(uri));
5762 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763
5764 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005765 } else if (!uri.startsWith("#Intent;", i)) {
5766 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005767 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005768 } else {
5769 i = -1;
5770 }
5771 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005772
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005773 // new format
5774 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005775 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005776 boolean explicitAction = false;
5777 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005778
5779 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005780 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005781 String data;
5782 if (i >= 0) {
5783 data = uri.substring(0, i);
5784 i += 8; // length of "#Intent;"
5785 } else {
5786 data = uri;
5787 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005788
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005789 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005790 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005791 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005792 if (eq < 0) eq = i-1;
5793 int semi = uri.indexOf(';', i);
5794 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005795
5796 // action
5797 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005798 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005799 if (!inSelector) {
5800 explicitAction = true;
5801 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005802 }
5803
5804 // categories
5805 else if (uri.startsWith("category=", i)) {
5806 intent.addCategory(value);
5807 }
5808
5809 // type
5810 else if (uri.startsWith("type=", i)) {
5811 intent.mType = value;
5812 }
5813
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005814 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005815 else if (uri.startsWith("launchFlags=", i)) {
5816 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005817 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5818 intent.mFlags &= ~IMMUTABLE_FLAGS;
5819 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005820 }
5821
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005822 // package
5823 else if (uri.startsWith("package=", i)) {
5824 intent.mPackage = value;
5825 }
5826
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005827 // component
5828 else if (uri.startsWith("component=", i)) {
5829 intent.mComponent = ComponentName.unflattenFromString(value);
5830 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005831
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005832 // scheme
5833 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005834 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005835 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005836 } else {
5837 scheme = value;
5838 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005839 }
5840
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005841 // source bounds
5842 else if (uri.startsWith("sourceBounds=", i)) {
5843 intent.mSourceBounds = Rect.unflattenFromString(value);
5844 }
5845
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005846 // selector
5847 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5848 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005849 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005850 }
5851
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005852 // extra
5853 else {
5854 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005855 // create Bundle if it doesn't already exist
5856 if (intent.mExtras == null) intent.mExtras = new Bundle();
5857 Bundle b = intent.mExtras;
5858 // add EXTRA
5859 if (uri.startsWith("S.", i)) b.putString(key, value);
5860 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5861 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5862 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5863 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5864 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5865 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5866 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5867 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5868 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5869 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005870
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005871 // move to the next item
5872 i = semi + 1;
5873 }
5874
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005875 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005876 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005877 if (baseIntent.mPackage == null) {
5878 baseIntent.setSelector(intent);
5879 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005880 intent = baseIntent;
5881 }
5882
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005883 if (data != null) {
5884 if (data.startsWith("intent:")) {
5885 data = data.substring(7);
5886 if (scheme != null) {
5887 data = scheme + ':' + data;
5888 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005889 } else if (data.startsWith("android-app:")) {
5890 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5891 // Correctly formed android-app, first part is package name.
5892 int end = data.indexOf('/', 14);
5893 if (end < 0) {
5894 // All we have is a package name.
5895 intent.mPackage = data.substring(14);
5896 if (!explicitAction) {
5897 intent.setAction(ACTION_MAIN);
5898 }
5899 data = "";
5900 } else {
5901 // Target the Intent at the given package name always.
5902 String authority = null;
5903 intent.mPackage = data.substring(14, end);
5904 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005905 if ((end+1) < data.length()) {
5906 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5907 // Found a scheme, remember it.
5908 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005909 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005910 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5911 // Found a authority, remember it.
5912 authority = data.substring(end+1, newEnd);
5913 end = newEnd;
5914 }
5915 } else {
5916 // All we have is a scheme.
5917 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005918 }
5919 }
5920 if (scheme == null) {
5921 // If there was no scheme, then this just targets the package.
5922 if (!explicitAction) {
5923 intent.setAction(ACTION_MAIN);
5924 }
5925 data = "";
5926 } else if (authority == null) {
5927 data = scheme + ":";
5928 } else {
5929 data = scheme + "://" + authority + data.substring(end);
5930 }
5931 }
5932 } else {
5933 data = "";
5934 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005935 }
Tom Taylord4a47292009-12-21 13:59:18 -08005936
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005937 if (data.length() > 0) {
5938 try {
5939 intent.mData = Uri.parse(data);
5940 } catch (IllegalArgumentException e) {
5941 throw new URISyntaxException(uri, e.getMessage());
5942 }
5943 }
5944 }
Tom Taylord4a47292009-12-21 13:59:18 -08005945
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005946 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005947
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948 } catch (IndexOutOfBoundsException e) {
5949 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5950 }
5951 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005952
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005953 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005954 return getIntentOld(uri, 0);
5955 }
5956
5957 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 Intent intent;
5959
5960 int i = uri.lastIndexOf('#');
5961 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005962 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005963 final int intentFragmentStart = i;
5964 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005965
5966 i++;
5967
5968 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005969 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005970 i += 7;
5971 int j = uri.indexOf(')', i);
5972 action = uri.substring(i, j);
5973 i = j + 1;
5974 }
5975
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005976 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977
5978 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005979 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005980 i += 11;
5981 int j = uri.indexOf(')', i);
5982 while (i < j) {
5983 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005984 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005985 if (i < sep) {
5986 intent.addCategory(uri.substring(i, sep));
5987 }
5988 i = sep + 1;
5989 }
5990 i = j + 1;
5991 }
5992
5993 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005994 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005995 i += 5;
5996 int j = uri.indexOf(')', i);
5997 intent.mType = uri.substring(i, j);
5998 i = j + 1;
5999 }
6000
6001 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006002 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006003 i += 12;
6004 int j = uri.indexOf(')', i);
6005 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006006 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6007 intent.mFlags &= ~IMMUTABLE_FLAGS;
6008 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006009 i = j + 1;
6010 }
6011
6012 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006013 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006014 i += 10;
6015 int j = uri.indexOf(')', i);
6016 int sep = uri.indexOf('!', i);
6017 if (sep >= 0 && sep < j) {
6018 String pkg = uri.substring(i, sep);
6019 String cls = uri.substring(sep + 1, j);
6020 intent.mComponent = new ComponentName(pkg, cls);
6021 }
6022 i = j + 1;
6023 }
6024
6025 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006026 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006027 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006028
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006029 final int closeParen = uri.indexOf(')', i);
6030 if (closeParen == -1) throw new URISyntaxException(uri,
6031 "EXTRA missing trailing ')'", i);
6032
6033 while (i < closeParen) {
6034 // fetch the key value
6035 int j = uri.indexOf('=', i);
6036 if (j <= i + 1 || i >= closeParen) {
6037 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6038 }
6039 char type = uri.charAt(i);
6040 i++;
6041 String key = uri.substring(i, j);
6042 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006043
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006044 // get type-value
6045 j = uri.indexOf('!', i);
6046 if (j == -1 || j >= closeParen) j = closeParen;
6047 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6048 String value = uri.substring(i, j);
6049 i = j;
6050
6051 // create Bundle if it doesn't already exist
6052 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006053
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006054 // add item to bundle
6055 try {
6056 switch (type) {
6057 case 'S':
6058 intent.mExtras.putString(key, Uri.decode(value));
6059 break;
6060 case 'B':
6061 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6062 break;
6063 case 'b':
6064 intent.mExtras.putByte(key, Byte.parseByte(value));
6065 break;
6066 case 'c':
6067 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6068 break;
6069 case 'd':
6070 intent.mExtras.putDouble(key, Double.parseDouble(value));
6071 break;
6072 case 'f':
6073 intent.mExtras.putFloat(key, Float.parseFloat(value));
6074 break;
6075 case 'i':
6076 intent.mExtras.putInt(key, Integer.parseInt(value));
6077 break;
6078 case 'l':
6079 intent.mExtras.putLong(key, Long.parseLong(value));
6080 break;
6081 case 's':
6082 intent.mExtras.putShort(key, Short.parseShort(value));
6083 break;
6084 default:
6085 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6086 }
6087 } catch (NumberFormatException e) {
6088 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6089 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006090
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006091 char ch = uri.charAt(i);
6092 if (ch == ')') break;
6093 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6094 i++;
6095 }
6096 }
6097
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006098 if (isIntentFragment) {
6099 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6100 } else {
6101 intent.mData = Uri.parse(uri);
6102 }
Tom Taylord4a47292009-12-21 13:59:18 -08006103
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006104 if (intent.mAction == null) {
6105 // By default, if no action is specified, then use VIEW.
6106 intent.mAction = ACTION_VIEW;
6107 }
6108
6109 } else {
6110 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6111 }
6112
6113 return intent;
6114 }
6115
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006116 /** @hide */
6117 public interface CommandOptionHandler {
6118 boolean handleOption(String opt, ShellCommand cmd);
6119 }
6120
6121 /** @hide */
6122 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6123 throws URISyntaxException {
6124 Intent intent = new Intent();
6125 Intent baseIntent = intent;
6126 boolean hasIntentInfo = false;
6127
6128 Uri data = null;
6129 String type = null;
6130
6131 String opt;
6132 while ((opt=cmd.getNextOption()) != null) {
6133 switch (opt) {
6134 case "-a":
6135 intent.setAction(cmd.getNextArgRequired());
6136 if (intent == baseIntent) {
6137 hasIntentInfo = true;
6138 }
6139 break;
6140 case "-d":
6141 data = Uri.parse(cmd.getNextArgRequired());
6142 if (intent == baseIntent) {
6143 hasIntentInfo = true;
6144 }
6145 break;
6146 case "-t":
6147 type = cmd.getNextArgRequired();
6148 if (intent == baseIntent) {
6149 hasIntentInfo = true;
6150 }
6151 break;
6152 case "-c":
6153 intent.addCategory(cmd.getNextArgRequired());
6154 if (intent == baseIntent) {
6155 hasIntentInfo = true;
6156 }
6157 break;
6158 case "-e":
6159 case "--es": {
6160 String key = cmd.getNextArgRequired();
6161 String value = cmd.getNextArgRequired();
6162 intent.putExtra(key, value);
6163 }
6164 break;
6165 case "--esn": {
6166 String key = cmd.getNextArgRequired();
6167 intent.putExtra(key, (String) null);
6168 }
6169 break;
6170 case "--ei": {
6171 String key = cmd.getNextArgRequired();
6172 String value = cmd.getNextArgRequired();
6173 intent.putExtra(key, Integer.decode(value));
6174 }
6175 break;
6176 case "--eu": {
6177 String key = cmd.getNextArgRequired();
6178 String value = cmd.getNextArgRequired();
6179 intent.putExtra(key, Uri.parse(value));
6180 }
6181 break;
6182 case "--ecn": {
6183 String key = cmd.getNextArgRequired();
6184 String value = cmd.getNextArgRequired();
6185 ComponentName cn = ComponentName.unflattenFromString(value);
6186 if (cn == null)
6187 throw new IllegalArgumentException("Bad component name: " + value);
6188 intent.putExtra(key, cn);
6189 }
6190 break;
6191 case "--eia": {
6192 String key = cmd.getNextArgRequired();
6193 String value = cmd.getNextArgRequired();
6194 String[] strings = value.split(",");
6195 int[] list = new int[strings.length];
6196 for (int i = 0; i < strings.length; i++) {
6197 list[i] = Integer.decode(strings[i]);
6198 }
6199 intent.putExtra(key, list);
6200 }
6201 break;
6202 case "--eial": {
6203 String key = cmd.getNextArgRequired();
6204 String value = cmd.getNextArgRequired();
6205 String[] strings = value.split(",");
6206 ArrayList<Integer> list = new ArrayList<>(strings.length);
6207 for (int i = 0; i < strings.length; i++) {
6208 list.add(Integer.decode(strings[i]));
6209 }
6210 intent.putExtra(key, list);
6211 }
6212 break;
6213 case "--el": {
6214 String key = cmd.getNextArgRequired();
6215 String value = cmd.getNextArgRequired();
6216 intent.putExtra(key, Long.valueOf(value));
6217 }
6218 break;
6219 case "--ela": {
6220 String key = cmd.getNextArgRequired();
6221 String value = cmd.getNextArgRequired();
6222 String[] strings = value.split(",");
6223 long[] list = new long[strings.length];
6224 for (int i = 0; i < strings.length; i++) {
6225 list[i] = Long.valueOf(strings[i]);
6226 }
6227 intent.putExtra(key, list);
6228 hasIntentInfo = true;
6229 }
6230 break;
6231 case "--elal": {
6232 String key = cmd.getNextArgRequired();
6233 String value = cmd.getNextArgRequired();
6234 String[] strings = value.split(",");
6235 ArrayList<Long> list = new ArrayList<>(strings.length);
6236 for (int i = 0; i < strings.length; i++) {
6237 list.add(Long.valueOf(strings[i]));
6238 }
6239 intent.putExtra(key, list);
6240 hasIntentInfo = true;
6241 }
6242 break;
6243 case "--ef": {
6244 String key = cmd.getNextArgRequired();
6245 String value = cmd.getNextArgRequired();
6246 intent.putExtra(key, Float.valueOf(value));
6247 hasIntentInfo = true;
6248 }
6249 break;
6250 case "--efa": {
6251 String key = cmd.getNextArgRequired();
6252 String value = cmd.getNextArgRequired();
6253 String[] strings = value.split(",");
6254 float[] list = new float[strings.length];
6255 for (int i = 0; i < strings.length; i++) {
6256 list[i] = Float.valueOf(strings[i]);
6257 }
6258 intent.putExtra(key, list);
6259 hasIntentInfo = true;
6260 }
6261 break;
6262 case "--efal": {
6263 String key = cmd.getNextArgRequired();
6264 String value = cmd.getNextArgRequired();
6265 String[] strings = value.split(",");
6266 ArrayList<Float> list = new ArrayList<>(strings.length);
6267 for (int i = 0; i < strings.length; i++) {
6268 list.add(Float.valueOf(strings[i]));
6269 }
6270 intent.putExtra(key, list);
6271 hasIntentInfo = true;
6272 }
6273 break;
6274 case "--esa": {
6275 String key = cmd.getNextArgRequired();
6276 String value = cmd.getNextArgRequired();
6277 // Split on commas unless they are preceeded by an escape.
6278 // The escape character must be escaped for the string and
6279 // again for the regex, thus four escape characters become one.
6280 String[] strings = value.split("(?<!\\\\),");
6281 intent.putExtra(key, strings);
6282 hasIntentInfo = true;
6283 }
6284 break;
6285 case "--esal": {
6286 String key = cmd.getNextArgRequired();
6287 String value = cmd.getNextArgRequired();
6288 // Split on commas unless they are preceeded by an escape.
6289 // The escape character must be escaped for the string and
6290 // again for the regex, thus four escape characters become one.
6291 String[] strings = value.split("(?<!\\\\),");
6292 ArrayList<String> list = new ArrayList<>(strings.length);
6293 for (int i = 0; i < strings.length; i++) {
6294 list.add(strings[i]);
6295 }
6296 intent.putExtra(key, list);
6297 hasIntentInfo = true;
6298 }
6299 break;
6300 case "--ez": {
6301 String key = cmd.getNextArgRequired();
6302 String value = cmd.getNextArgRequired().toLowerCase();
6303 // Boolean.valueOf() results in false for anything that is not "true", which is
6304 // error-prone in shell commands
6305 boolean arg;
6306 if ("true".equals(value) || "t".equals(value)) {
6307 arg = true;
6308 } else if ("false".equals(value) || "f".equals(value)) {
6309 arg = false;
6310 } else {
6311 try {
6312 arg = Integer.decode(value) != 0;
6313 } catch (NumberFormatException ex) {
6314 throw new IllegalArgumentException("Invalid boolean value: " + value);
6315 }
6316 }
6317
6318 intent.putExtra(key, arg);
6319 }
6320 break;
6321 case "-n": {
6322 String str = cmd.getNextArgRequired();
6323 ComponentName cn = ComponentName.unflattenFromString(str);
6324 if (cn == null)
6325 throw new IllegalArgumentException("Bad component name: " + str);
6326 intent.setComponent(cn);
6327 if (intent == baseIntent) {
6328 hasIntentInfo = true;
6329 }
6330 }
6331 break;
6332 case "-p": {
6333 String str = cmd.getNextArgRequired();
6334 intent.setPackage(str);
6335 if (intent == baseIntent) {
6336 hasIntentInfo = true;
6337 }
6338 }
6339 break;
6340 case "-f":
6341 String str = cmd.getNextArgRequired();
6342 intent.setFlags(Integer.decode(str).intValue());
6343 break;
6344 case "--grant-read-uri-permission":
6345 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6346 break;
6347 case "--grant-write-uri-permission":
6348 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6349 break;
6350 case "--grant-persistable-uri-permission":
6351 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6352 break;
6353 case "--grant-prefix-uri-permission":
6354 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6355 break;
6356 case "--exclude-stopped-packages":
6357 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6358 break;
6359 case "--include-stopped-packages":
6360 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6361 break;
6362 case "--debug-log-resolution":
6363 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6364 break;
6365 case "--activity-brought-to-front":
6366 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6367 break;
6368 case "--activity-clear-top":
6369 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6370 break;
6371 case "--activity-clear-when-task-reset":
6372 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6373 break;
6374 case "--activity-exclude-from-recents":
6375 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6376 break;
6377 case "--activity-launched-from-history":
6378 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6379 break;
6380 case "--activity-multiple-task":
6381 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6382 break;
6383 case "--activity-no-animation":
6384 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6385 break;
6386 case "--activity-no-history":
6387 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6388 break;
6389 case "--activity-no-user-action":
6390 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6391 break;
6392 case "--activity-previous-is-top":
6393 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6394 break;
6395 case "--activity-reorder-to-front":
6396 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6397 break;
6398 case "--activity-reset-task-if-needed":
6399 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6400 break;
6401 case "--activity-single-top":
6402 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6403 break;
6404 case "--activity-clear-task":
6405 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6406 break;
6407 case "--activity-task-on-home":
6408 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6409 break;
6410 case "--receiver-registered-only":
6411 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6412 break;
6413 case "--receiver-replace-pending":
6414 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6415 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006416 case "--receiver-foreground":
6417 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6418 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006419 case "--receiver-no-abort":
6420 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6421 break;
6422 case "--receiver-include-background":
6423 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6424 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006425 case "--selector":
6426 intent.setDataAndType(data, type);
6427 intent = new Intent();
6428 break;
6429 default:
6430 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6431 // Okay, caller handled this option.
6432 } else {
6433 throw new IllegalArgumentException("Unknown option: " + opt);
6434 }
6435 break;
6436 }
6437 }
6438 intent.setDataAndType(data, type);
6439
6440 final boolean hasSelector = intent != baseIntent;
6441 if (hasSelector) {
6442 // A selector was specified; fix up.
6443 baseIntent.setSelector(intent);
6444 intent = baseIntent;
6445 }
6446
6447 String arg = cmd.getNextArg();
6448 baseIntent = null;
6449 if (arg == null) {
6450 if (hasSelector) {
6451 // If a selector has been specified, and no arguments
6452 // have been supplied for the main Intent, then we can
6453 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6454 // need to have a component name specified yet, the
6455 // selector will take care of that.
6456 baseIntent = new Intent(Intent.ACTION_MAIN);
6457 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6458 }
6459 } else if (arg.indexOf(':') >= 0) {
6460 // The argument is a URI. Fully parse it, and use that result
6461 // to fill in any data not specified so far.
6462 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6463 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6464 } else if (arg.indexOf('/') >= 0) {
6465 // The argument is a component name. Build an Intent to launch
6466 // it.
6467 baseIntent = new Intent(Intent.ACTION_MAIN);
6468 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6469 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6470 } else {
6471 // Assume the argument is a package name.
6472 baseIntent = new Intent(Intent.ACTION_MAIN);
6473 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6474 baseIntent.setPackage(arg);
6475 }
6476 if (baseIntent != null) {
6477 Bundle extras = intent.getExtras();
6478 intent.replaceExtras((Bundle)null);
6479 Bundle uriExtras = baseIntent.getExtras();
6480 baseIntent.replaceExtras((Bundle)null);
6481 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6482 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6483 for (String c : cats) {
6484 baseIntent.removeCategory(c);
6485 }
6486 }
6487 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6488 if (extras == null) {
6489 extras = uriExtras;
6490 } else if (uriExtras != null) {
6491 uriExtras.putAll(extras);
6492 extras = uriExtras;
6493 }
6494 intent.replaceExtras(extras);
6495 hasIntentInfo = true;
6496 }
6497
6498 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6499 return intent;
6500 }
6501
6502 /** @hide */
6503 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6504 final String[] lines = new String[] {
6505 "<INTENT> specifications include these flags and arguments:",
6506 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6507 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6508 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6509 " [--esn <EXTRA_KEY> ...]",
6510 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6511 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6512 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6513 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6514 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6515 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6516 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6517 " (mutiple extras passed as Integer[])",
6518 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6519 " (mutiple extras passed as List<Integer>)",
6520 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6521 " (mutiple extras passed as Long[])",
6522 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6523 " (mutiple extras passed as List<Long>)",
6524 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6525 " (mutiple extras passed as Float[])",
6526 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6527 " (mutiple extras passed as List<Float>)",
6528 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6529 " (mutiple extras passed as String[]; to embed a comma into a string,",
6530 " escape it using \"\\,\")",
6531 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6532 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6533 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006534 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006535 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6536 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6537 " [--debug-log-resolution] [--exclude-stopped-packages]",
6538 " [--include-stopped-packages]",
6539 " [--activity-brought-to-front] [--activity-clear-top]",
6540 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6541 " [--activity-launched-from-history] [--activity-multiple-task]",
6542 " [--activity-no-animation] [--activity-no-history]",
6543 " [--activity-no-user-action] [--activity-previous-is-top]",
6544 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6545 " [--activity-single-top] [--activity-clear-task]",
6546 " [--activity-task-on-home]",
6547 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006548 " [--receiver-foreground] [--receiver-no-abort]",
6549 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006550 " [--selector]",
6551 " [<URI> | <PACKAGE> | <COMPONENT>]"
6552 };
6553 for (String line : lines) {
6554 pw.print(prefix);
6555 pw.println(line);
6556 }
6557 }
6558
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006559 /**
6560 * Retrieve the general action to be performed, such as
6561 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6562 * the information in the intent should be interpreted -- most importantly,
6563 * what to do with the data returned by {@link #getData}.
6564 *
6565 * @return The action of this intent or null if none is specified.
6566 *
6567 * @see #setAction
6568 */
6569 public String getAction() {
6570 return mAction;
6571 }
6572
6573 /**
6574 * Retrieve data this intent is operating on. This URI specifies the name
6575 * of the data; often it uses the content: scheme, specifying data in a
6576 * content provider. Other schemes may be handled by specific activities,
6577 * such as http: by the web browser.
6578 *
6579 * @return The URI of the data this intent is targeting or null.
6580 *
6581 * @see #getScheme
6582 * @see #setData
6583 */
6584 public Uri getData() {
6585 return mData;
6586 }
6587
6588 /**
6589 * The same as {@link #getData()}, but returns the URI as an encoded
6590 * String.
6591 */
6592 public String getDataString() {
6593 return mData != null ? mData.toString() : null;
6594 }
6595
6596 /**
6597 * Return the scheme portion of the intent's data. If the data is null or
6598 * does not include a scheme, null is returned. Otherwise, the scheme
6599 * prefix without the final ':' is returned, i.e. "http".
6600 *
6601 * <p>This is the same as calling getData().getScheme() (and checking for
6602 * null data).
6603 *
6604 * @return The scheme of this intent.
6605 *
6606 * @see #getData
6607 */
6608 public String getScheme() {
6609 return mData != null ? mData.getScheme() : null;
6610 }
6611
6612 /**
6613 * Retrieve any explicit MIME type included in the intent. This is usually
6614 * null, as the type is determined by the intent data.
6615 *
6616 * @return If a type was manually set, it is returned; else null is
6617 * returned.
6618 *
6619 * @see #resolveType(ContentResolver)
6620 * @see #setType
6621 */
6622 public String getType() {
6623 return mType;
6624 }
6625
6626 /**
6627 * Return the MIME data type of this intent. If the type field is
6628 * explicitly set, that is simply returned. Otherwise, if the data is set,
6629 * the type of that data is returned. If neither fields are set, a null is
6630 * returned.
6631 *
6632 * @return The MIME type of this intent.
6633 *
6634 * @see #getType
6635 * @see #resolveType(ContentResolver)
6636 */
6637 public String resolveType(Context context) {
6638 return resolveType(context.getContentResolver());
6639 }
6640
6641 /**
6642 * Return the MIME data type of this intent. If the type field is
6643 * explicitly set, that is simply returned. Otherwise, if the data is set,
6644 * the type of that data is returned. If neither fields are set, a null is
6645 * returned.
6646 *
6647 * @param resolver A ContentResolver that can be used to determine the MIME
6648 * type of the intent's data.
6649 *
6650 * @return The MIME type of this intent.
6651 *
6652 * @see #getType
6653 * @see #resolveType(Context)
6654 */
6655 public String resolveType(ContentResolver resolver) {
6656 if (mType != null) {
6657 return mType;
6658 }
6659 if (mData != null) {
6660 if ("content".equals(mData.getScheme())) {
6661 return resolver.getType(mData);
6662 }
6663 }
6664 return null;
6665 }
6666
6667 /**
6668 * Return the MIME data type of this intent, only if it will be needed for
6669 * intent resolution. This is not generally useful for application code;
6670 * it is used by the frameworks for communicating with back-end system
6671 * services.
6672 *
6673 * @param resolver A ContentResolver that can be used to determine the MIME
6674 * type of the intent's data.
6675 *
6676 * @return The MIME type of this intent, or null if it is unknown or not
6677 * needed.
6678 */
6679 public String resolveTypeIfNeeded(ContentResolver resolver) {
6680 if (mComponent != null) {
6681 return mType;
6682 }
6683 return resolveType(resolver);
6684 }
6685
6686 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006687 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006688 *
6689 * @param category The category to check.
6690 *
6691 * @return boolean True if the intent contains the category, else false.
6692 *
6693 * @see #getCategories
6694 * @see #addCategory
6695 */
6696 public boolean hasCategory(String category) {
6697 return mCategories != null && mCategories.contains(category);
6698 }
6699
6700 /**
6701 * Return the set of all categories in the intent. If there are no categories,
6702 * returns NULL.
6703 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006704 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006705 *
6706 * @see #hasCategory
6707 * @see #addCategory
6708 */
6709 public Set<String> getCategories() {
6710 return mCategories;
6711 }
6712
6713 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006714 * Return the specific selector associated with this Intent. If there is
6715 * none, returns null. See {@link #setSelector} for more information.
6716 *
6717 * @see #setSelector
6718 */
6719 public Intent getSelector() {
6720 return mSelector;
6721 }
6722
6723 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006724 * Return the {@link ClipData} associated with this Intent. If there is
6725 * none, returns null. See {@link #setClipData} for more information.
6726 *
John Spurlock125d1332013-11-25 11:58:37 -05006727 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006728 */
6729 public ClipData getClipData() {
6730 return mClipData;
6731 }
6732
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006733 /** @hide */
6734 public int getContentUserHint() {
6735 return mContentUserHint;
6736 }
6737
Todd Kennedyb3b431302017-03-20 16:05:48 -07006738 /** @hide */
6739 public String getLaunchToken() {
6740 return mLaunchToken;
6741 }
6742
6743 /** @hide */
6744 public void setLaunchToken(String launchToken) {
6745 mLaunchToken = launchToken;
6746 }
6747
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006748 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006749 * Sets the ClassLoader that will be used when unmarshalling
6750 * any Parcelable values from the extras of this Intent.
6751 *
6752 * @param loader a ClassLoader, or null to use the default loader
6753 * at the time of unmarshalling.
6754 */
6755 public void setExtrasClassLoader(ClassLoader loader) {
6756 if (mExtras != null) {
6757 mExtras.setClassLoader(loader);
6758 }
6759 }
6760
6761 /**
6762 * Returns true if an extra value is associated with the given name.
6763 * @param name the extra's name
6764 * @return true if the given extra is present.
6765 */
6766 public boolean hasExtra(String name) {
6767 return mExtras != null && mExtras.containsKey(name);
6768 }
6769
6770 /**
6771 * Returns true if the Intent's extras contain a parcelled file descriptor.
6772 * @return true if the Intent contains a parcelled file descriptor.
6773 */
6774 public boolean hasFileDescriptors() {
6775 return mExtras != null && mExtras.hasFileDescriptors();
6776 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006777
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006778 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006779 public void setAllowFds(boolean allowFds) {
6780 if (mExtras != null) {
6781 mExtras.setAllowFds(allowFds);
6782 }
6783 }
6784
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006785 /** {@hide} */
6786 public void setDefusable(boolean defusable) {
6787 if (mExtras != null) {
6788 mExtras.setDefusable(defusable);
6789 }
6790 }
6791
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006792 /**
6793 * Retrieve extended data from the intent.
6794 *
6795 * @param name The name of the desired item.
6796 *
6797 * @return the value of an item that previously added with putExtra()
6798 * or null if none was found.
6799 *
6800 * @deprecated
6801 * @hide
6802 */
6803 @Deprecated
6804 public Object getExtra(String name) {
6805 return getExtra(name, null);
6806 }
6807
6808 /**
6809 * Retrieve extended data from the intent.
6810 *
6811 * @param name The name of the desired item.
6812 * @param defaultValue the value to be returned if no value of the desired
6813 * type is stored with the given name.
6814 *
6815 * @return the value of an item that previously added with putExtra()
6816 * or the default value if none was found.
6817 *
6818 * @see #putExtra(String, boolean)
6819 */
6820 public boolean getBooleanExtra(String name, boolean defaultValue) {
6821 return mExtras == null ? defaultValue :
6822 mExtras.getBoolean(name, defaultValue);
6823 }
6824
6825 /**
6826 * Retrieve extended data from the intent.
6827 *
6828 * @param name The name of the desired item.
6829 * @param defaultValue the value to be returned if no value of the desired
6830 * type is stored with the given name.
6831 *
6832 * @return the value of an item that previously added with putExtra()
6833 * or the default value if none was found.
6834 *
6835 * @see #putExtra(String, byte)
6836 */
6837 public byte getByteExtra(String name, byte defaultValue) {
6838 return mExtras == null ? defaultValue :
6839 mExtras.getByte(name, defaultValue);
6840 }
6841
6842 /**
6843 * Retrieve extended data from the intent.
6844 *
6845 * @param name The name of the desired item.
6846 * @param defaultValue the value to be returned if no value of the desired
6847 * type is stored with the given name.
6848 *
6849 * @return the value of an item that previously added with putExtra()
6850 * or the default value if none was found.
6851 *
6852 * @see #putExtra(String, short)
6853 */
6854 public short getShortExtra(String name, short defaultValue) {
6855 return mExtras == null ? defaultValue :
6856 mExtras.getShort(name, defaultValue);
6857 }
6858
6859 /**
6860 * Retrieve extended data from the intent.
6861 *
6862 * @param name The name of the desired item.
6863 * @param defaultValue the value to be returned if no value of the desired
6864 * type is stored with the given name.
6865 *
6866 * @return the value of an item that previously added with putExtra()
6867 * or the default value if none was found.
6868 *
6869 * @see #putExtra(String, char)
6870 */
6871 public char getCharExtra(String name, char defaultValue) {
6872 return mExtras == null ? defaultValue :
6873 mExtras.getChar(name, defaultValue);
6874 }
6875
6876 /**
6877 * Retrieve extended data from the intent.
6878 *
6879 * @param name The name of the desired item.
6880 * @param defaultValue the value to be returned if no value of the desired
6881 * type is stored with the given name.
6882 *
6883 * @return the value of an item that previously added with putExtra()
6884 * or the default value if none was found.
6885 *
6886 * @see #putExtra(String, int)
6887 */
6888 public int getIntExtra(String name, int defaultValue) {
6889 return mExtras == null ? defaultValue :
6890 mExtras.getInt(name, defaultValue);
6891 }
6892
6893 /**
6894 * Retrieve extended data from the intent.
6895 *
6896 * @param name The name of the desired item.
6897 * @param defaultValue the value to be returned if no value of the desired
6898 * type is stored with the given name.
6899 *
6900 * @return the value of an item that previously added with putExtra()
6901 * or the default value if none was found.
6902 *
6903 * @see #putExtra(String, long)
6904 */
6905 public long getLongExtra(String name, long defaultValue) {
6906 return mExtras == null ? defaultValue :
6907 mExtras.getLong(name, defaultValue);
6908 }
6909
6910 /**
6911 * Retrieve extended data from the intent.
6912 *
6913 * @param name The name of the desired item.
6914 * @param defaultValue the value to be returned if no value of the desired
6915 * type is stored with the given name.
6916 *
6917 * @return the value of an item that previously added with putExtra(),
6918 * or the default value if no such item is present
6919 *
6920 * @see #putExtra(String, float)
6921 */
6922 public float getFloatExtra(String name, float defaultValue) {
6923 return mExtras == null ? defaultValue :
6924 mExtras.getFloat(name, defaultValue);
6925 }
6926
6927 /**
6928 * Retrieve extended data from the intent.
6929 *
6930 * @param name The name of the desired item.
6931 * @param defaultValue the value to be returned if no value of the desired
6932 * type is stored with the given name.
6933 *
6934 * @return the value of an item that previously added with putExtra()
6935 * or the default value if none was found.
6936 *
6937 * @see #putExtra(String, double)
6938 */
6939 public double getDoubleExtra(String name, double defaultValue) {
6940 return mExtras == null ? defaultValue :
6941 mExtras.getDouble(name, defaultValue);
6942 }
6943
6944 /**
6945 * Retrieve extended data from the intent.
6946 *
6947 * @param name The name of the desired item.
6948 *
6949 * @return the value of an item that previously added with putExtra()
6950 * or null if no String value was found.
6951 *
6952 * @see #putExtra(String, String)
6953 */
6954 public String getStringExtra(String name) {
6955 return mExtras == null ? null : mExtras.getString(name);
6956 }
6957
6958 /**
6959 * Retrieve extended data from the intent.
6960 *
6961 * @param name The name of the desired item.
6962 *
6963 * @return the value of an item that previously added with putExtra()
6964 * or null if no CharSequence value was found.
6965 *
6966 * @see #putExtra(String, CharSequence)
6967 */
6968 public CharSequence getCharSequenceExtra(String name) {
6969 return mExtras == null ? null : mExtras.getCharSequence(name);
6970 }
6971
6972 /**
6973 * Retrieve extended data from the intent.
6974 *
6975 * @param name The name of the desired item.
6976 *
6977 * @return the value of an item that previously added with putExtra()
6978 * or null if no Parcelable value was found.
6979 *
6980 * @see #putExtra(String, Parcelable)
6981 */
6982 public <T extends Parcelable> T getParcelableExtra(String name) {
6983 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6984 }
6985
6986 /**
6987 * Retrieve extended data from the intent.
6988 *
6989 * @param name The name of the desired item.
6990 *
6991 * @return the value of an item that previously added with putExtra()
6992 * or null if no Parcelable[] value was found.
6993 *
6994 * @see #putExtra(String, Parcelable[])
6995 */
6996 public Parcelable[] getParcelableArrayExtra(String name) {
6997 return mExtras == null ? null : mExtras.getParcelableArray(name);
6998 }
6999
7000 /**
7001 * Retrieve extended data from the intent.
7002 *
7003 * @param name The name of the desired item.
7004 *
7005 * @return the value of an item that previously added with putExtra()
7006 * or null if no ArrayList<Parcelable> value was found.
7007 *
7008 * @see #putParcelableArrayListExtra(String, ArrayList)
7009 */
7010 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7011 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7012 }
7013
7014 /**
7015 * Retrieve extended data from the intent.
7016 *
7017 * @param name The name of the desired item.
7018 *
7019 * @return the value of an item that previously added with putExtra()
7020 * or null if no Serializable value was found.
7021 *
7022 * @see #putExtra(String, Serializable)
7023 */
7024 public Serializable getSerializableExtra(String name) {
7025 return mExtras == null ? null : mExtras.getSerializable(name);
7026 }
7027
7028 /**
7029 * Retrieve extended data from the intent.
7030 *
7031 * @param name The name of the desired item.
7032 *
7033 * @return the value of an item that previously added with putExtra()
7034 * or null if no ArrayList<Integer> value was found.
7035 *
7036 * @see #putIntegerArrayListExtra(String, ArrayList)
7037 */
7038 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7039 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7040 }
7041
7042 /**
7043 * Retrieve extended data from the intent.
7044 *
7045 * @param name The name of the desired item.
7046 *
7047 * @return the value of an item that previously added with putExtra()
7048 * or null if no ArrayList<String> value was found.
7049 *
7050 * @see #putStringArrayListExtra(String, ArrayList)
7051 */
7052 public ArrayList<String> getStringArrayListExtra(String name) {
7053 return mExtras == null ? null : mExtras.getStringArrayList(name);
7054 }
7055
7056 /**
7057 * Retrieve extended data from the intent.
7058 *
7059 * @param name The name of the desired item.
7060 *
7061 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007062 * or null if no ArrayList<CharSequence> value was found.
7063 *
7064 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7065 */
7066 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7067 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7068 }
7069
7070 /**
7071 * Retrieve extended data from the intent.
7072 *
7073 * @param name The name of the desired item.
7074 *
7075 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007076 * or null if no boolean array value was found.
7077 *
7078 * @see #putExtra(String, boolean[])
7079 */
7080 public boolean[] getBooleanArrayExtra(String name) {
7081 return mExtras == null ? null : mExtras.getBooleanArray(name);
7082 }
7083
7084 /**
7085 * Retrieve extended data from the intent.
7086 *
7087 * @param name The name of the desired item.
7088 *
7089 * @return the value of an item that previously added with putExtra()
7090 * or null if no byte array value was found.
7091 *
7092 * @see #putExtra(String, byte[])
7093 */
7094 public byte[] getByteArrayExtra(String name) {
7095 return mExtras == null ? null : mExtras.getByteArray(name);
7096 }
7097
7098 /**
7099 * Retrieve extended data from the intent.
7100 *
7101 * @param name The name of the desired item.
7102 *
7103 * @return the value of an item that previously added with putExtra()
7104 * or null if no short array value was found.
7105 *
7106 * @see #putExtra(String, short[])
7107 */
7108 public short[] getShortArrayExtra(String name) {
7109 return mExtras == null ? null : mExtras.getShortArray(name);
7110 }
7111
7112 /**
7113 * Retrieve extended data from the intent.
7114 *
7115 * @param name The name of the desired item.
7116 *
7117 * @return the value of an item that previously added with putExtra()
7118 * or null if no char array value was found.
7119 *
7120 * @see #putExtra(String, char[])
7121 */
7122 public char[] getCharArrayExtra(String name) {
7123 return mExtras == null ? null : mExtras.getCharArray(name);
7124 }
7125
7126 /**
7127 * Retrieve extended data from the intent.
7128 *
7129 * @param name The name of the desired item.
7130 *
7131 * @return the value of an item that previously added with putExtra()
7132 * or null if no int array value was found.
7133 *
7134 * @see #putExtra(String, int[])
7135 */
7136 public int[] getIntArrayExtra(String name) {
7137 return mExtras == null ? null : mExtras.getIntArray(name);
7138 }
7139
7140 /**
7141 * Retrieve extended data from the intent.
7142 *
7143 * @param name The name of the desired item.
7144 *
7145 * @return the value of an item that previously added with putExtra()
7146 * or null if no long array value was found.
7147 *
7148 * @see #putExtra(String, long[])
7149 */
7150 public long[] getLongArrayExtra(String name) {
7151 return mExtras == null ? null : mExtras.getLongArray(name);
7152 }
7153
7154 /**
7155 * Retrieve extended data from the intent.
7156 *
7157 * @param name The name of the desired item.
7158 *
7159 * @return the value of an item that previously added with putExtra()
7160 * or null if no float array value was found.
7161 *
7162 * @see #putExtra(String, float[])
7163 */
7164 public float[] getFloatArrayExtra(String name) {
7165 return mExtras == null ? null : mExtras.getFloatArray(name);
7166 }
7167
7168 /**
7169 * Retrieve extended data from the intent.
7170 *
7171 * @param name The name of the desired item.
7172 *
7173 * @return the value of an item that previously added with putExtra()
7174 * or null if no double array value was found.
7175 *
7176 * @see #putExtra(String, double[])
7177 */
7178 public double[] getDoubleArrayExtra(String name) {
7179 return mExtras == null ? null : mExtras.getDoubleArray(name);
7180 }
7181
7182 /**
7183 * Retrieve extended data from the intent.
7184 *
7185 * @param name The name of the desired item.
7186 *
7187 * @return the value of an item that previously added with putExtra()
7188 * or null if no String array value was found.
7189 *
7190 * @see #putExtra(String, String[])
7191 */
7192 public String[] getStringArrayExtra(String name) {
7193 return mExtras == null ? null : mExtras.getStringArray(name);
7194 }
7195
7196 /**
7197 * Retrieve extended data from the intent.
7198 *
7199 * @param name The name of the desired item.
7200 *
7201 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007202 * or null if no CharSequence array value was found.
7203 *
7204 * @see #putExtra(String, CharSequence[])
7205 */
7206 public CharSequence[] getCharSequenceArrayExtra(String name) {
7207 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7208 }
7209
7210 /**
7211 * Retrieve extended data from the intent.
7212 *
7213 * @param name The name of the desired item.
7214 *
7215 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007216 * or null if no Bundle value was found.
7217 *
7218 * @see #putExtra(String, Bundle)
7219 */
7220 public Bundle getBundleExtra(String name) {
7221 return mExtras == null ? null : mExtras.getBundle(name);
7222 }
7223
7224 /**
7225 * Retrieve extended data from the intent.
7226 *
7227 * @param name The name of the desired item.
7228 *
7229 * @return the value of an item that previously added with putExtra()
7230 * or null if no IBinder value was found.
7231 *
7232 * @see #putExtra(String, IBinder)
7233 *
7234 * @deprecated
7235 * @hide
7236 */
7237 @Deprecated
7238 public IBinder getIBinderExtra(String name) {
7239 return mExtras == null ? null : mExtras.getIBinder(name);
7240 }
7241
7242 /**
7243 * Retrieve extended data from the intent.
7244 *
7245 * @param name The name of the desired item.
7246 * @param defaultValue The default value to return in case no item is
7247 * associated with the key 'name'
7248 *
7249 * @return the value of an item that previously added with putExtra()
7250 * or defaultValue if none was found.
7251 *
7252 * @see #putExtra
7253 *
7254 * @deprecated
7255 * @hide
7256 */
7257 @Deprecated
7258 public Object getExtra(String name, Object defaultValue) {
7259 Object result = defaultValue;
7260 if (mExtras != null) {
7261 Object result2 = mExtras.get(name);
7262 if (result2 != null) {
7263 result = result2;
7264 }
7265 }
7266
7267 return result;
7268 }
7269
7270 /**
7271 * Retrieves a map of extended data from the intent.
7272 *
7273 * @return the map of all extras previously added with putExtra(),
7274 * or null if none have been added.
7275 */
7276 public Bundle getExtras() {
7277 return (mExtras != null)
7278 ? new Bundle(mExtras)
7279 : null;
7280 }
7281
7282 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007283 * Filter extras to only basic types.
7284 * @hide
7285 */
7286 public void removeUnsafeExtras() {
7287 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007288 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007289 }
7290 }
7291
7292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007293 * Retrieve any special flags associated with this intent. You will
7294 * normally just set them with {@link #setFlags} and let the system
7295 * take the appropriate action with them.
7296 *
7297 * @return int The currently set flags.
7298 *
7299 * @see #setFlags
7300 */
7301 public int getFlags() {
7302 return mFlags;
7303 }
7304
Dianne Hackborne7f97212011-02-24 14:40:20 -08007305 /** @hide */
7306 public boolean isExcludingStopped() {
7307 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7308 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7309 }
7310
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007311 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007312 * Retrieve the application package name this Intent is limited to. When
7313 * resolving an Intent, if non-null this limits the resolution to only
7314 * components in the given application package.
7315 *
7316 * @return The name of the application package for the Intent.
7317 *
7318 * @see #resolveActivity
7319 * @see #setPackage
7320 */
7321 public String getPackage() {
7322 return mPackage;
7323 }
7324
7325 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007326 * Retrieve the concrete component associated with the intent. When receiving
7327 * an intent, this is the component that was found to best handle it (that is,
7328 * yourself) and will always be non-null; in all other cases it will be
7329 * null unless explicitly set.
7330 *
7331 * @return The name of the application component to handle the intent.
7332 *
7333 * @see #resolveActivity
7334 * @see #setComponent
7335 */
7336 public ComponentName getComponent() {
7337 return mComponent;
7338 }
7339
7340 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007341 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7342 * used as a hint to the receiver for animations and the like. Null means that there
7343 * is no source bounds.
7344 */
7345 public Rect getSourceBounds() {
7346 return mSourceBounds;
7347 }
7348
7349 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007350 * Return the Activity component that should be used to handle this intent.
7351 * The appropriate component is determined based on the information in the
7352 * intent, evaluated as follows:
7353 *
7354 * <p>If {@link #getComponent} returns an explicit class, that is returned
7355 * without any further consideration.
7356 *
7357 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7358 * category to be considered.
7359 *
7360 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7361 * action.
7362 *
7363 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7364 * this type.
7365 *
7366 * <p>If {@link #addCategory} has added any categories, the activity must
7367 * handle ALL of the categories specified.
7368 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007369 * <p>If {@link #getPackage} is non-NULL, only activity components in
7370 * that application package will be considered.
7371 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007372 * <p>If there are no activities that satisfy all of these conditions, a
7373 * null string is returned.
7374 *
7375 * <p>If multiple activities are found to satisfy the intent, the one with
7376 * the highest priority will be used. If there are multiple activities
7377 * with the same priority, the system will either pick the best activity
7378 * based on user preference, or resolve to a system class that will allow
7379 * the user to pick an activity and forward from there.
7380 *
7381 * <p>This method is implemented simply by calling
7382 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7383 * true.</p>
7384 * <p> This API is called for you as part of starting an activity from an
7385 * intent. You do not normally need to call it yourself.</p>
7386 *
7387 * @param pm The package manager with which to resolve the Intent.
7388 *
7389 * @return Name of the component implementing an activity that can
7390 * display the intent.
7391 *
7392 * @see #setComponent
7393 * @see #getComponent
7394 * @see #resolveActivityInfo
7395 */
7396 public ComponentName resolveActivity(PackageManager pm) {
7397 if (mComponent != null) {
7398 return mComponent;
7399 }
7400
7401 ResolveInfo info = pm.resolveActivity(
7402 this, PackageManager.MATCH_DEFAULT_ONLY);
7403 if (info != null) {
7404 return new ComponentName(
7405 info.activityInfo.applicationInfo.packageName,
7406 info.activityInfo.name);
7407 }
7408
7409 return null;
7410 }
7411
7412 /**
7413 * Resolve the Intent into an {@link ActivityInfo}
7414 * describing the activity that should execute the intent. Resolution
7415 * follows the same rules as described for {@link #resolveActivity}, but
7416 * you get back the completely information about the resolved activity
7417 * instead of just its class name.
7418 *
7419 * @param pm The package manager with which to resolve the Intent.
7420 * @param flags Addition information to retrieve as per
7421 * {@link PackageManager#getActivityInfo(ComponentName, int)
7422 * PackageManager.getActivityInfo()}.
7423 *
7424 * @return PackageManager.ActivityInfo
7425 *
7426 * @see #resolveActivity
7427 */
7428 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7429 ActivityInfo ai = null;
7430 if (mComponent != null) {
7431 try {
7432 ai = pm.getActivityInfo(mComponent, flags);
7433 } catch (PackageManager.NameNotFoundException e) {
7434 // ignore
7435 }
7436 } else {
7437 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007438 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007439 if (info != null) {
7440 ai = info.activityInfo;
7441 }
7442 }
7443
7444 return ai;
7445 }
7446
7447 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007448 * Special function for use by the system to resolve service
7449 * intents to system apps. Throws an exception if there are
7450 * multiple potential matches to the Intent. Returns null if
7451 * there are no matches.
7452 * @hide
7453 */
7454 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7455 if (mComponent != null) {
7456 return mComponent;
7457 }
7458
7459 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7460 if (results == null) {
7461 return null;
7462 }
7463 ComponentName comp = null;
7464 for (int i=0; i<results.size(); i++) {
7465 ResolveInfo ri = results.get(i);
7466 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7467 continue;
7468 }
7469 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7470 ri.serviceInfo.name);
7471 if (comp != null) {
7472 throw new IllegalStateException("Multiple system services handle " + this
7473 + ": " + comp + ", " + foundComp);
7474 }
7475 comp = foundComp;
7476 }
7477 return comp;
7478 }
7479
7480 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007481 * Set the general action to be performed.
7482 *
7483 * @param action An action name, such as ACTION_VIEW. Application-specific
7484 * actions should be prefixed with the vendor's package name.
7485 *
7486 * @return Returns the same Intent object, for chaining multiple calls
7487 * into a single statement.
7488 *
7489 * @see #getAction
7490 */
7491 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007492 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007493 return this;
7494 }
7495
7496 /**
7497 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007498 * clears any type that was previously set by {@link #setType} or
7499 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007500 *
Nick Pellyccae4122012-01-09 14:12:58 -08007501 * <p><em>Note: scheme matching in the Android framework is
7502 * case-sensitive, unlike the formal RFC. As a result,
7503 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007504 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007505 * {@link #setDataAndNormalize}
7506 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007507 *
Nick Pellyccae4122012-01-09 14:12:58 -08007508 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007509 *
7510 * @return Returns the same Intent object, for chaining multiple calls
7511 * into a single statement.
7512 *
7513 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007514 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007515 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007516 */
7517 public Intent setData(Uri data) {
7518 mData = data;
7519 mType = null;
7520 return this;
7521 }
7522
7523 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007524 * Normalize and set the data this intent is operating on.
7525 *
7526 * <p>This method automatically clears any type that was
7527 * previously set (for example, by {@link #setType}).
7528 *
7529 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007530 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007531 * so really this is just a convenience method for
7532 * <pre>
7533 * setData(data.normalize())
7534 * </pre>
7535 *
7536 * @param data The Uri of the data this intent is now targeting.
7537 *
7538 * @return Returns the same Intent object, for chaining multiple calls
7539 * into a single statement.
7540 *
7541 * @see #getData
7542 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007543 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007544 */
7545 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007546 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007547 }
7548
7549 /**
7550 * Set an explicit MIME data type.
7551 *
7552 * <p>This is used to create intents that only specify a type and not data,
7553 * for example to indicate the type of data to return.
7554 *
7555 * <p>This method automatically clears any data that was
7556 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007557 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007558 * <p><em>Note: MIME type matching in the Android framework is
7559 * case-sensitive, unlike formal RFC MIME types. As a result,
7560 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007561 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7562 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007563 *
7564 * @param type The MIME type of the data being handled by this intent.
7565 *
7566 * @return Returns the same Intent object, for chaining multiple calls
7567 * into a single statement.
7568 *
7569 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007570 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007571 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007572 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007573 */
7574 public Intent setType(String type) {
7575 mData = null;
7576 mType = type;
7577 return this;
7578 }
7579
7580 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007581 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007582 *
Nick Pellyccae4122012-01-09 14:12:58 -08007583 * <p>This is used to create intents that only specify a type and not data,
7584 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007585 *
Nick Pellyccae4122012-01-09 14:12:58 -08007586 * <p>This method automatically clears any data that was
7587 * previously set (for example by {@link #setData}).
7588 *
7589 * <p>The MIME type is normalized using
7590 * {@link #normalizeMimeType} before it is set,
7591 * so really this is just a convenience method for
7592 * <pre>
7593 * setType(Intent.normalizeMimeType(type))
7594 * </pre>
7595 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007596 * @param type The MIME type of the data being handled by this intent.
7597 *
7598 * @return Returns the same Intent object, for chaining multiple calls
7599 * into a single statement.
7600 *
Nick Pellyccae4122012-01-09 14:12:58 -08007601 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007602 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007603 * @see #normalizeMimeType
7604 */
7605 public Intent setTypeAndNormalize(String type) {
7606 return setType(normalizeMimeType(type));
7607 }
7608
7609 /**
7610 * (Usually optional) Set the data for the intent along with an explicit
7611 * MIME data type. This method should very rarely be used -- it allows you
7612 * to override the MIME type that would ordinarily be inferred from the
7613 * data with your own type given here.
7614 *
7615 * <p><em>Note: MIME type and Uri scheme matching in the
7616 * Android framework is case-sensitive, unlike the formal RFC definitions.
7617 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007618 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007619 * {@link #setDataAndTypeAndNormalize}
7620 * to ensure that they are converted to lower case.</em>
7621 *
7622 * @param data The Uri of the data this intent is now targeting.
7623 * @param type The MIME type of the data being handled by this intent.
7624 *
7625 * @return Returns the same Intent object, for chaining multiple calls
7626 * into a single statement.
7627 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007628 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007629 * @see #setData
7630 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007631 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007632 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007633 */
7634 public Intent setDataAndType(Uri data, String type) {
7635 mData = data;
7636 mType = type;
7637 return this;
7638 }
7639
7640 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007641 * (Usually optional) Normalize and set both the data Uri and an explicit
7642 * MIME data type. This method should very rarely be used -- it allows you
7643 * to override the MIME type that would ordinarily be inferred from the
7644 * data with your own type given here.
7645 *
7646 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007647 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007648 * before they are set, so really this is just a convenience method for
7649 * <pre>
7650 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7651 * </pre>
7652 *
7653 * @param data The Uri of the data this intent is now targeting.
7654 * @param type The MIME type of the data being handled by this intent.
7655 *
7656 * @return Returns the same Intent object, for chaining multiple calls
7657 * into a single statement.
7658 *
7659 * @see #setType
7660 * @see #setData
7661 * @see #setDataAndType
7662 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007663 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007664 */
7665 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007666 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007667 }
7668
7669 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007670 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007671 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007672 * activities that provide <em>all</em> of the requested categories will be
7673 * used.
7674 *
7675 * @param category The desired category. This can be either one of the
7676 * predefined Intent categories, or a custom category in your own
7677 * namespace.
7678 *
7679 * @return Returns the same Intent object, for chaining multiple calls
7680 * into a single statement.
7681 *
7682 * @see #hasCategory
7683 * @see #removeCategory
7684 */
7685 public Intent addCategory(String category) {
7686 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007687 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007688 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007689 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007690 return this;
7691 }
7692
7693 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007694 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 *
7696 * @param category The category to remove.
7697 *
7698 * @see #addCategory
7699 */
7700 public void removeCategory(String category) {
7701 if (mCategories != null) {
7702 mCategories.remove(category);
7703 if (mCategories.size() == 0) {
7704 mCategories = null;
7705 }
7706 }
7707 }
7708
7709 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007710 * Set a selector for this Intent. This is a modification to the kinds of
7711 * things the Intent will match. If the selector is set, it will be used
7712 * when trying to find entities that can handle the Intent, instead of the
7713 * main contents of the Intent. This allows you build an Intent containing
7714 * a generic protocol while targeting it more specifically.
7715 *
7716 * <p>An example of where this may be used is with things like
7717 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7718 * Intent that will launch the Browser application. However, the correct
7719 * main entry point of an application is actually {@link #ACTION_MAIN}
7720 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7721 * used to specify the actual Activity to launch. If you launch the browser
7722 * with something different, undesired behavior may happen if the user has
7723 * previously or later launches it the normal way, since they do not match.
7724 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7725 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7726 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7727 *
7728 * <p>Setting a selector does not impact the behavior of
7729 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7730 * desired behavior of a selector -- it does not impact the base meaning
7731 * of the Intent, just what kinds of things will be matched against it
7732 * when determining who can handle it.</p>
7733 *
7734 * <p>You can not use both a selector and {@link #setPackage(String)} on
7735 * the same base Intent.</p>
7736 *
7737 * @param selector The desired selector Intent; set to null to not use
7738 * a special selector.
7739 */
7740 public void setSelector(Intent selector) {
7741 if (selector == this) {
7742 throw new IllegalArgumentException(
7743 "Intent being set as a selector of itself");
7744 }
7745 if (selector != null && mPackage != null) {
7746 throw new IllegalArgumentException(
7747 "Can't set selector when package name is already set");
7748 }
7749 mSelector = selector;
7750 }
7751
7752 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007753 * Set a {@link ClipData} associated with this Intent. This replaces any
7754 * previously set ClipData.
7755 *
7756 * <p>The ClipData in an intent is not used for Intent matching or other
7757 * such operations. Semantically it is like extras, used to transmit
7758 * additional data with the Intent. The main feature of using this over
7759 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7760 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7761 * items included in the clip data. This is useful, in particular, if
7762 * you want to transmit an Intent containing multiple <code>content:</code>
7763 * URIs for which the recipient may not have global permission to access the
7764 * content provider.
7765 *
7766 * <p>If the ClipData contains items that are themselves Intents, any
7767 * grant flags in those Intents will be ignored. Only the top-level flags
7768 * of the main Intent are respected, and will be applied to all Uri or
7769 * Intent items in the clip (or sub-items of the clip).
7770 *
7771 * <p>The MIME type, label, and icon in the ClipData object are not
7772 * directly used by Intent. Applications should generally rely on the
7773 * MIME type of the Intent itself, not what it may find in the ClipData.
7774 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007775 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007776 *
7777 * @param clip The new clip to set. May be null to clear the current clip.
7778 */
7779 public void setClipData(ClipData clip) {
7780 mClipData = clip;
7781 }
7782
7783 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007784 * This is NOT a secure mechanism to identify the user who sent the intent.
7785 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7786 * who sent the intent.
7787 * @hide
7788 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007789 public void prepareToLeaveUser(int userId) {
7790 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7791 // We want mContentUserHint to refer to the original user, so don't do anything.
7792 if (mContentUserHint == UserHandle.USER_CURRENT) {
7793 mContentUserHint = userId;
7794 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007795 }
7796
7797 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007798 * Add extended data to the intent. The name must include a package
7799 * prefix, for example the app com.android.contacts would use names
7800 * like "com.android.contacts.ShowAll".
7801 *
7802 * @param name The name of the extra data, with package prefix.
7803 * @param value The boolean data value.
7804 *
7805 * @return Returns the same Intent object, for chaining multiple calls
7806 * into a single statement.
7807 *
7808 * @see #putExtras
7809 * @see #removeExtra
7810 * @see #getBooleanExtra(String, boolean)
7811 */
7812 public Intent putExtra(String name, boolean value) {
7813 if (mExtras == null) {
7814 mExtras = new Bundle();
7815 }
7816 mExtras.putBoolean(name, value);
7817 return this;
7818 }
7819
7820 /**
7821 * Add extended data to the intent. The name must include a package
7822 * prefix, for example the app com.android.contacts would use names
7823 * like "com.android.contacts.ShowAll".
7824 *
7825 * @param name The name of the extra data, with package prefix.
7826 * @param value The byte data value.
7827 *
7828 * @return Returns the same Intent object, for chaining multiple calls
7829 * into a single statement.
7830 *
7831 * @see #putExtras
7832 * @see #removeExtra
7833 * @see #getByteExtra(String, byte)
7834 */
7835 public Intent putExtra(String name, byte value) {
7836 if (mExtras == null) {
7837 mExtras = new Bundle();
7838 }
7839 mExtras.putByte(name, value);
7840 return this;
7841 }
7842
7843 /**
7844 * Add extended data to the intent. The name must include a package
7845 * prefix, for example the app com.android.contacts would use names
7846 * like "com.android.contacts.ShowAll".
7847 *
7848 * @param name The name of the extra data, with package prefix.
7849 * @param value The char data value.
7850 *
7851 * @return Returns the same Intent object, for chaining multiple calls
7852 * into a single statement.
7853 *
7854 * @see #putExtras
7855 * @see #removeExtra
7856 * @see #getCharExtra(String, char)
7857 */
7858 public Intent putExtra(String name, char value) {
7859 if (mExtras == null) {
7860 mExtras = new Bundle();
7861 }
7862 mExtras.putChar(name, value);
7863 return this;
7864 }
7865
7866 /**
7867 * Add extended data to the intent. The name must include a package
7868 * prefix, for example the app com.android.contacts would use names
7869 * like "com.android.contacts.ShowAll".
7870 *
7871 * @param name The name of the extra data, with package prefix.
7872 * @param value The short data value.
7873 *
7874 * @return Returns the same Intent object, for chaining multiple calls
7875 * into a single statement.
7876 *
7877 * @see #putExtras
7878 * @see #removeExtra
7879 * @see #getShortExtra(String, short)
7880 */
7881 public Intent putExtra(String name, short value) {
7882 if (mExtras == null) {
7883 mExtras = new Bundle();
7884 }
7885 mExtras.putShort(name, value);
7886 return this;
7887 }
7888
7889 /**
7890 * Add extended data to the intent. The name must include a package
7891 * prefix, for example the app com.android.contacts would use names
7892 * like "com.android.contacts.ShowAll".
7893 *
7894 * @param name The name of the extra data, with package prefix.
7895 * @param value The integer data value.
7896 *
7897 * @return Returns the same Intent object, for chaining multiple calls
7898 * into a single statement.
7899 *
7900 * @see #putExtras
7901 * @see #removeExtra
7902 * @see #getIntExtra(String, int)
7903 */
7904 public Intent putExtra(String name, int value) {
7905 if (mExtras == null) {
7906 mExtras = new Bundle();
7907 }
7908 mExtras.putInt(name, value);
7909 return this;
7910 }
7911
7912 /**
7913 * Add extended data to the intent. The name must include a package
7914 * prefix, for example the app com.android.contacts would use names
7915 * like "com.android.contacts.ShowAll".
7916 *
7917 * @param name The name of the extra data, with package prefix.
7918 * @param value The long data value.
7919 *
7920 * @return Returns the same Intent object, for chaining multiple calls
7921 * into a single statement.
7922 *
7923 * @see #putExtras
7924 * @see #removeExtra
7925 * @see #getLongExtra(String, long)
7926 */
7927 public Intent putExtra(String name, long value) {
7928 if (mExtras == null) {
7929 mExtras = new Bundle();
7930 }
7931 mExtras.putLong(name, value);
7932 return this;
7933 }
7934
7935 /**
7936 * Add extended data to the intent. The name must include a package
7937 * prefix, for example the app com.android.contacts would use names
7938 * like "com.android.contacts.ShowAll".
7939 *
7940 * @param name The name of the extra data, with package prefix.
7941 * @param value The float data value.
7942 *
7943 * @return Returns the same Intent object, for chaining multiple calls
7944 * into a single statement.
7945 *
7946 * @see #putExtras
7947 * @see #removeExtra
7948 * @see #getFloatExtra(String, float)
7949 */
7950 public Intent putExtra(String name, float value) {
7951 if (mExtras == null) {
7952 mExtras = new Bundle();
7953 }
7954 mExtras.putFloat(name, value);
7955 return this;
7956 }
7957
7958 /**
7959 * Add extended data to the intent. The name must include a package
7960 * prefix, for example the app com.android.contacts would use names
7961 * like "com.android.contacts.ShowAll".
7962 *
7963 * @param name The name of the extra data, with package prefix.
7964 * @param value The double data value.
7965 *
7966 * @return Returns the same Intent object, for chaining multiple calls
7967 * into a single statement.
7968 *
7969 * @see #putExtras
7970 * @see #removeExtra
7971 * @see #getDoubleExtra(String, double)
7972 */
7973 public Intent putExtra(String name, double value) {
7974 if (mExtras == null) {
7975 mExtras = new Bundle();
7976 }
7977 mExtras.putDouble(name, value);
7978 return this;
7979 }
7980
7981 /**
7982 * Add extended data to the intent. The name must include a package
7983 * prefix, for example the app com.android.contacts would use names
7984 * like "com.android.contacts.ShowAll".
7985 *
7986 * @param name The name of the extra data, with package prefix.
7987 * @param value The String data value.
7988 *
7989 * @return Returns the same Intent object, for chaining multiple calls
7990 * into a single statement.
7991 *
7992 * @see #putExtras
7993 * @see #removeExtra
7994 * @see #getStringExtra(String)
7995 */
7996 public Intent putExtra(String name, String value) {
7997 if (mExtras == null) {
7998 mExtras = new Bundle();
7999 }
8000 mExtras.putString(name, value);
8001 return this;
8002 }
8003
8004 /**
8005 * Add extended data to the intent. The name must include a package
8006 * prefix, for example the app com.android.contacts would use names
8007 * like "com.android.contacts.ShowAll".
8008 *
8009 * @param name The name of the extra data, with package prefix.
8010 * @param value The CharSequence data value.
8011 *
8012 * @return Returns the same Intent object, for chaining multiple calls
8013 * into a single statement.
8014 *
8015 * @see #putExtras
8016 * @see #removeExtra
8017 * @see #getCharSequenceExtra(String)
8018 */
8019 public Intent putExtra(String name, CharSequence value) {
8020 if (mExtras == null) {
8021 mExtras = new Bundle();
8022 }
8023 mExtras.putCharSequence(name, value);
8024 return this;
8025 }
8026
8027 /**
8028 * Add extended data to the intent. The name must include a package
8029 * prefix, for example the app com.android.contacts would use names
8030 * like "com.android.contacts.ShowAll".
8031 *
8032 * @param name The name of the extra data, with package prefix.
8033 * @param value The Parcelable data value.
8034 *
8035 * @return Returns the same Intent object, for chaining multiple calls
8036 * into a single statement.
8037 *
8038 * @see #putExtras
8039 * @see #removeExtra
8040 * @see #getParcelableExtra(String)
8041 */
8042 public Intent putExtra(String name, Parcelable value) {
8043 if (mExtras == null) {
8044 mExtras = new Bundle();
8045 }
8046 mExtras.putParcelable(name, value);
8047 return this;
8048 }
8049
8050 /**
8051 * Add extended data to the intent. The name must include a package
8052 * prefix, for example the app com.android.contacts would use names
8053 * like "com.android.contacts.ShowAll".
8054 *
8055 * @param name The name of the extra data, with package prefix.
8056 * @param value The Parcelable[] data value.
8057 *
8058 * @return Returns the same Intent object, for chaining multiple calls
8059 * into a single statement.
8060 *
8061 * @see #putExtras
8062 * @see #removeExtra
8063 * @see #getParcelableArrayExtra(String)
8064 */
8065 public Intent putExtra(String name, Parcelable[] value) {
8066 if (mExtras == null) {
8067 mExtras = new Bundle();
8068 }
8069 mExtras.putParcelableArray(name, value);
8070 return this;
8071 }
8072
8073 /**
8074 * Add extended data to the intent. The name must include a package
8075 * prefix, for example the app com.android.contacts would use names
8076 * like "com.android.contacts.ShowAll".
8077 *
8078 * @param name The name of the extra data, with package prefix.
8079 * @param value The ArrayList<Parcelable> data value.
8080 *
8081 * @return Returns the same Intent object, for chaining multiple calls
8082 * into a single statement.
8083 *
8084 * @see #putExtras
8085 * @see #removeExtra
8086 * @see #getParcelableArrayListExtra(String)
8087 */
8088 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
8089 if (mExtras == null) {
8090 mExtras = new Bundle();
8091 }
8092 mExtras.putParcelableArrayList(name, value);
8093 return this;
8094 }
8095
8096 /**
8097 * Add extended data to the intent. The name must include a package
8098 * prefix, for example the app com.android.contacts would use names
8099 * like "com.android.contacts.ShowAll".
8100 *
8101 * @param name The name of the extra data, with package prefix.
8102 * @param value The ArrayList<Integer> data value.
8103 *
8104 * @return Returns the same Intent object, for chaining multiple calls
8105 * into a single statement.
8106 *
8107 * @see #putExtras
8108 * @see #removeExtra
8109 * @see #getIntegerArrayListExtra(String)
8110 */
8111 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
8112 if (mExtras == null) {
8113 mExtras = new Bundle();
8114 }
8115 mExtras.putIntegerArrayList(name, value);
8116 return this;
8117 }
8118
8119 /**
8120 * Add extended data to the intent. The name must include a package
8121 * prefix, for example the app com.android.contacts would use names
8122 * like "com.android.contacts.ShowAll".
8123 *
8124 * @param name The name of the extra data, with package prefix.
8125 * @param value The ArrayList<String> data value.
8126 *
8127 * @return Returns the same Intent object, for chaining multiple calls
8128 * into a single statement.
8129 *
8130 * @see #putExtras
8131 * @see #removeExtra
8132 * @see #getStringArrayListExtra(String)
8133 */
8134 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
8135 if (mExtras == null) {
8136 mExtras = new Bundle();
8137 }
8138 mExtras.putStringArrayList(name, value);
8139 return this;
8140 }
8141
8142 /**
8143 * Add extended data to the intent. The name must include a package
8144 * prefix, for example the app com.android.contacts would use names
8145 * like "com.android.contacts.ShowAll".
8146 *
8147 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008148 * @param value The ArrayList<CharSequence> data value.
8149 *
8150 * @return Returns the same Intent object, for chaining multiple calls
8151 * into a single statement.
8152 *
8153 * @see #putExtras
8154 * @see #removeExtra
8155 * @see #getCharSequenceArrayListExtra(String)
8156 */
8157 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
8158 if (mExtras == null) {
8159 mExtras = new Bundle();
8160 }
8161 mExtras.putCharSequenceArrayList(name, value);
8162 return this;
8163 }
8164
8165 /**
8166 * Add extended data to the intent. The name must include a package
8167 * prefix, for example the app com.android.contacts would use names
8168 * like "com.android.contacts.ShowAll".
8169 *
8170 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008171 * @param value The Serializable data value.
8172 *
8173 * @return Returns the same Intent object, for chaining multiple calls
8174 * into a single statement.
8175 *
8176 * @see #putExtras
8177 * @see #removeExtra
8178 * @see #getSerializableExtra(String)
8179 */
8180 public Intent putExtra(String name, Serializable value) {
8181 if (mExtras == null) {
8182 mExtras = new Bundle();
8183 }
8184 mExtras.putSerializable(name, value);
8185 return this;
8186 }
8187
8188 /**
8189 * Add extended data to the intent. The name must include a package
8190 * prefix, for example the app com.android.contacts would use names
8191 * like "com.android.contacts.ShowAll".
8192 *
8193 * @param name The name of the extra data, with package prefix.
8194 * @param value The boolean array data value.
8195 *
8196 * @return Returns the same Intent object, for chaining multiple calls
8197 * into a single statement.
8198 *
8199 * @see #putExtras
8200 * @see #removeExtra
8201 * @see #getBooleanArrayExtra(String)
8202 */
8203 public Intent putExtra(String name, boolean[] value) {
8204 if (mExtras == null) {
8205 mExtras = new Bundle();
8206 }
8207 mExtras.putBooleanArray(name, value);
8208 return this;
8209 }
8210
8211 /**
8212 * Add extended data to the intent. The name must include a package
8213 * prefix, for example the app com.android.contacts would use names
8214 * like "com.android.contacts.ShowAll".
8215 *
8216 * @param name The name of the extra data, with package prefix.
8217 * @param value The byte array data value.
8218 *
8219 * @return Returns the same Intent object, for chaining multiple calls
8220 * into a single statement.
8221 *
8222 * @see #putExtras
8223 * @see #removeExtra
8224 * @see #getByteArrayExtra(String)
8225 */
8226 public Intent putExtra(String name, byte[] value) {
8227 if (mExtras == null) {
8228 mExtras = new Bundle();
8229 }
8230 mExtras.putByteArray(name, value);
8231 return this;
8232 }
8233
8234 /**
8235 * Add extended data to the intent. The name must include a package
8236 * prefix, for example the app com.android.contacts would use names
8237 * like "com.android.contacts.ShowAll".
8238 *
8239 * @param name The name of the extra data, with package prefix.
8240 * @param value The short array data value.
8241 *
8242 * @return Returns the same Intent object, for chaining multiple calls
8243 * into a single statement.
8244 *
8245 * @see #putExtras
8246 * @see #removeExtra
8247 * @see #getShortArrayExtra(String)
8248 */
8249 public Intent putExtra(String name, short[] value) {
8250 if (mExtras == null) {
8251 mExtras = new Bundle();
8252 }
8253 mExtras.putShortArray(name, value);
8254 return this;
8255 }
8256
8257 /**
8258 * Add extended data to the intent. The name must include a package
8259 * prefix, for example the app com.android.contacts would use names
8260 * like "com.android.contacts.ShowAll".
8261 *
8262 * @param name The name of the extra data, with package prefix.
8263 * @param value The char array data value.
8264 *
8265 * @return Returns the same Intent object, for chaining multiple calls
8266 * into a single statement.
8267 *
8268 * @see #putExtras
8269 * @see #removeExtra
8270 * @see #getCharArrayExtra(String)
8271 */
8272 public Intent putExtra(String name, char[] value) {
8273 if (mExtras == null) {
8274 mExtras = new Bundle();
8275 }
8276 mExtras.putCharArray(name, value);
8277 return this;
8278 }
8279
8280 /**
8281 * Add extended data to the intent. The name must include a package
8282 * prefix, for example the app com.android.contacts would use names
8283 * like "com.android.contacts.ShowAll".
8284 *
8285 * @param name The name of the extra data, with package prefix.
8286 * @param value The int array data value.
8287 *
8288 * @return Returns the same Intent object, for chaining multiple calls
8289 * into a single statement.
8290 *
8291 * @see #putExtras
8292 * @see #removeExtra
8293 * @see #getIntArrayExtra(String)
8294 */
8295 public Intent putExtra(String name, int[] value) {
8296 if (mExtras == null) {
8297 mExtras = new Bundle();
8298 }
8299 mExtras.putIntArray(name, value);
8300 return this;
8301 }
8302
8303 /**
8304 * Add extended data to the intent. The name must include a package
8305 * prefix, for example the app com.android.contacts would use names
8306 * like "com.android.contacts.ShowAll".
8307 *
8308 * @param name The name of the extra data, with package prefix.
8309 * @param value The byte array data value.
8310 *
8311 * @return Returns the same Intent object, for chaining multiple calls
8312 * into a single statement.
8313 *
8314 * @see #putExtras
8315 * @see #removeExtra
8316 * @see #getLongArrayExtra(String)
8317 */
8318 public Intent putExtra(String name, long[] value) {
8319 if (mExtras == null) {
8320 mExtras = new Bundle();
8321 }
8322 mExtras.putLongArray(name, value);
8323 return this;
8324 }
8325
8326 /**
8327 * Add extended data to the intent. The name must include a package
8328 * prefix, for example the app com.android.contacts would use names
8329 * like "com.android.contacts.ShowAll".
8330 *
8331 * @param name The name of the extra data, with package prefix.
8332 * @param value The float array data value.
8333 *
8334 * @return Returns the same Intent object, for chaining multiple calls
8335 * into a single statement.
8336 *
8337 * @see #putExtras
8338 * @see #removeExtra
8339 * @see #getFloatArrayExtra(String)
8340 */
8341 public Intent putExtra(String name, float[] value) {
8342 if (mExtras == null) {
8343 mExtras = new Bundle();
8344 }
8345 mExtras.putFloatArray(name, value);
8346 return this;
8347 }
8348
8349 /**
8350 * Add extended data to the intent. The name must include a package
8351 * prefix, for example the app com.android.contacts would use names
8352 * like "com.android.contacts.ShowAll".
8353 *
8354 * @param name The name of the extra data, with package prefix.
8355 * @param value The double array data value.
8356 *
8357 * @return Returns the same Intent object, for chaining multiple calls
8358 * into a single statement.
8359 *
8360 * @see #putExtras
8361 * @see #removeExtra
8362 * @see #getDoubleArrayExtra(String)
8363 */
8364 public Intent putExtra(String name, double[] value) {
8365 if (mExtras == null) {
8366 mExtras = new Bundle();
8367 }
8368 mExtras.putDoubleArray(name, value);
8369 return this;
8370 }
8371
8372 /**
8373 * Add extended data to the intent. The name must include a package
8374 * prefix, for example the app com.android.contacts would use names
8375 * like "com.android.contacts.ShowAll".
8376 *
8377 * @param name The name of the extra data, with package prefix.
8378 * @param value The String array data value.
8379 *
8380 * @return Returns the same Intent object, for chaining multiple calls
8381 * into a single statement.
8382 *
8383 * @see #putExtras
8384 * @see #removeExtra
8385 * @see #getStringArrayExtra(String)
8386 */
8387 public Intent putExtra(String name, String[] value) {
8388 if (mExtras == null) {
8389 mExtras = new Bundle();
8390 }
8391 mExtras.putStringArray(name, value);
8392 return this;
8393 }
8394
8395 /**
8396 * Add extended data to the intent. The name must include a package
8397 * prefix, for example the app com.android.contacts would use names
8398 * like "com.android.contacts.ShowAll".
8399 *
8400 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008401 * @param value The CharSequence array data value.
8402 *
8403 * @return Returns the same Intent object, for chaining multiple calls
8404 * into a single statement.
8405 *
8406 * @see #putExtras
8407 * @see #removeExtra
8408 * @see #getCharSequenceArrayExtra(String)
8409 */
8410 public Intent putExtra(String name, CharSequence[] value) {
8411 if (mExtras == null) {
8412 mExtras = new Bundle();
8413 }
8414 mExtras.putCharSequenceArray(name, value);
8415 return this;
8416 }
8417
8418 /**
8419 * Add extended data to the intent. The name must include a package
8420 * prefix, for example the app com.android.contacts would use names
8421 * like "com.android.contacts.ShowAll".
8422 *
8423 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008424 * @param value The Bundle data value.
8425 *
8426 * @return Returns the same Intent object, for chaining multiple calls
8427 * into a single statement.
8428 *
8429 * @see #putExtras
8430 * @see #removeExtra
8431 * @see #getBundleExtra(String)
8432 */
8433 public Intent putExtra(String name, Bundle value) {
8434 if (mExtras == null) {
8435 mExtras = new Bundle();
8436 }
8437 mExtras.putBundle(name, value);
8438 return this;
8439 }
8440
8441 /**
8442 * Add extended data to the intent. The name must include a package
8443 * prefix, for example the app com.android.contacts would use names
8444 * like "com.android.contacts.ShowAll".
8445 *
8446 * @param name The name of the extra data, with package prefix.
8447 * @param value The IBinder data value.
8448 *
8449 * @return Returns the same Intent object, for chaining multiple calls
8450 * into a single statement.
8451 *
8452 * @see #putExtras
8453 * @see #removeExtra
8454 * @see #getIBinderExtra(String)
8455 *
8456 * @deprecated
8457 * @hide
8458 */
8459 @Deprecated
8460 public Intent putExtra(String name, IBinder value) {
8461 if (mExtras == null) {
8462 mExtras = new Bundle();
8463 }
8464 mExtras.putIBinder(name, value);
8465 return this;
8466 }
8467
8468 /**
8469 * Copy all extras in 'src' in to this intent.
8470 *
8471 * @param src Contains the extras to copy.
8472 *
8473 * @see #putExtra
8474 */
8475 public Intent putExtras(Intent src) {
8476 if (src.mExtras != null) {
8477 if (mExtras == null) {
8478 mExtras = new Bundle(src.mExtras);
8479 } else {
8480 mExtras.putAll(src.mExtras);
8481 }
8482 }
8483 return this;
8484 }
8485
8486 /**
8487 * Add a set of extended data to the intent. The keys must include a package
8488 * prefix, for example the app com.android.contacts would use names
8489 * like "com.android.contacts.ShowAll".
8490 *
8491 * @param extras The Bundle of extras to add to this intent.
8492 *
8493 * @see #putExtra
8494 * @see #removeExtra
8495 */
8496 public Intent putExtras(Bundle extras) {
8497 if (mExtras == null) {
8498 mExtras = new Bundle();
8499 }
8500 mExtras.putAll(extras);
8501 return this;
8502 }
8503
8504 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008505 * Completely replace the extras in the Intent with the extras in the
8506 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008507 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008508 * @param src The exact extras contained in this Intent are copied
8509 * into the target intent, replacing any that were previously there.
8510 */
8511 public Intent replaceExtras(Intent src) {
8512 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8513 return this;
8514 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008515
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008516 /**
8517 * Completely replace the extras in the Intent with the given Bundle of
8518 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008519 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008520 * @param extras The new set of extras in the Intent, or null to erase
8521 * all extras.
8522 */
8523 public Intent replaceExtras(Bundle extras) {
8524 mExtras = extras != null ? new Bundle(extras) : null;
8525 return this;
8526 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008527
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008528 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008529 * Remove extended data from the intent.
8530 *
8531 * @see #putExtra
8532 */
8533 public void removeExtra(String name) {
8534 if (mExtras != null) {
8535 mExtras.remove(name);
8536 if (mExtras.size() == 0) {
8537 mExtras = null;
8538 }
8539 }
8540 }
8541
8542 /**
8543 * Set special flags controlling how this intent is handled. Most values
8544 * here depend on the type of component being executed by the Intent,
8545 * specifically the FLAG_ACTIVITY_* flags are all for use with
8546 * {@link Context#startActivity Context.startActivity()} and the
8547 * FLAG_RECEIVER_* flags are all for use with
8548 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8549 *
Scott Main7aee61f2011-02-08 11:25:01 -08008550 * <p>See the
8551 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8552 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008553 * the behavior of your application.
8554 *
8555 * @param flags The desired flags.
8556 *
8557 * @return Returns the same Intent object, for chaining multiple calls
8558 * into a single statement.
8559 *
8560 * @see #getFlags
8561 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008562 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008563 *
8564 * @see #FLAG_GRANT_READ_URI_PERMISSION
8565 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008566 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8567 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 * @see #FLAG_DEBUG_LOG_RESOLUTION
8569 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008570 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008571 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008572 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008573 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008574 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8575 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008576 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008577 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008578 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008579 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008580 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008582 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008583 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8584 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008585 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008586 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008587 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008588 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8589 */
8590 public Intent setFlags(int flags) {
8591 mFlags = flags;
8592 return this;
8593 }
8594
8595 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008596 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008597 *
8598 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008599 * @return Returns the same Intent object, for chaining multiple calls into
8600 * a single statement.
8601 * @see #setFlags(int)
8602 * @see #removeFlags(int)
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06008603 *
8604 * @see #FLAG_GRANT_READ_URI_PERMISSION
8605 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
8606 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8607 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
8608 * @see #FLAG_DEBUG_LOG_RESOLUTION
8609 * @see #FLAG_FROM_BACKGROUND
8610 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
8611 * @see #FLAG_ACTIVITY_CLEAR_TASK
8612 * @see #FLAG_ACTIVITY_CLEAR_TOP
8613 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
8614 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8615 * @see #FLAG_ACTIVITY_FORWARD_RESULT
8616 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
8617 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
8618 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
8619 * @see #FLAG_ACTIVITY_NEW_TASK
8620 * @see #FLAG_ACTIVITY_NO_ANIMATION
8621 * @see #FLAG_ACTIVITY_NO_HISTORY
8622 * @see #FLAG_ACTIVITY_NO_USER_ACTION
8623 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8624 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8625 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
8626 * @see #FLAG_ACTIVITY_SINGLE_TOP
8627 * @see #FLAG_ACTIVITY_TASK_ON_HOME
8628 * @see #FLAG_RECEIVER_REGISTERED_ONLY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008629 */
8630 public Intent addFlags(int flags) {
8631 mFlags |= flags;
8632 return this;
8633 }
8634
8635 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008636 * Remove these flags from the intent.
8637 *
8638 * @param flags The flags to remove.
8639 * @see #setFlags(int)
8640 * @see #addFlags(int)
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06008641 *
8642 * @see #FLAG_GRANT_READ_URI_PERMISSION
8643 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
8644 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8645 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
8646 * @see #FLAG_DEBUG_LOG_RESOLUTION
8647 * @see #FLAG_FROM_BACKGROUND
8648 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
8649 * @see #FLAG_ACTIVITY_CLEAR_TASK
8650 * @see #FLAG_ACTIVITY_CLEAR_TOP
8651 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
8652 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8653 * @see #FLAG_ACTIVITY_FORWARD_RESULT
8654 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
8655 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
8656 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
8657 * @see #FLAG_ACTIVITY_NEW_TASK
8658 * @see #FLAG_ACTIVITY_NO_ANIMATION
8659 * @see #FLAG_ACTIVITY_NO_HISTORY
8660 * @see #FLAG_ACTIVITY_NO_USER_ACTION
8661 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8662 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8663 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
8664 * @see #FLAG_ACTIVITY_SINGLE_TOP
8665 * @see #FLAG_ACTIVITY_TASK_ON_HOME
8666 * @see #FLAG_RECEIVER_REGISTERED_ONLY
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008667 */
8668 public void removeFlags(int flags) {
8669 mFlags &= ~flags;
8670 }
8671
8672 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008673 * (Usually optional) Set an explicit application package name that limits
8674 * the components this Intent will resolve to. If left to the default
8675 * value of null, all components in all applications will considered.
8676 * If non-null, the Intent can only match the components in the given
8677 * application package.
8678 *
8679 * @param packageName The name of the application package to handle the
8680 * intent, or null to allow any application package.
8681 *
8682 * @return Returns the same Intent object, for chaining multiple calls
8683 * into a single statement.
8684 *
8685 * @see #getPackage
8686 * @see #resolveActivity
8687 */
8688 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008689 if (packageName != null && mSelector != null) {
8690 throw new IllegalArgumentException(
8691 "Can't set package name when selector is already set");
8692 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008693 mPackage = packageName;
8694 return this;
8695 }
8696
8697 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008698 * (Usually optional) Explicitly set the component to handle the intent.
8699 * If left with the default value of null, the system will determine the
8700 * appropriate class to use based on the other fields (action, data,
8701 * type, categories) in the Intent. If this class is defined, the
8702 * specified class will always be used regardless of the other fields. You
8703 * should only set this value when you know you absolutely want a specific
8704 * class to be used; otherwise it is better to let the system find the
8705 * appropriate class so that you will respect the installed applications
8706 * and user preferences.
8707 *
8708 * @param component The name of the application component to handle the
8709 * intent, or null to let the system find one for you.
8710 *
8711 * @return Returns the same Intent object, for chaining multiple calls
8712 * into a single statement.
8713 *
8714 * @see #setClass
8715 * @see #setClassName(Context, String)
8716 * @see #setClassName(String, String)
8717 * @see #getComponent
8718 * @see #resolveActivity
8719 */
8720 public Intent setComponent(ComponentName component) {
8721 mComponent = component;
8722 return this;
8723 }
8724
8725 /**
8726 * Convenience for calling {@link #setComponent} with an
8727 * explicit class name.
8728 *
8729 * @param packageContext A Context of the application package implementing
8730 * this class.
8731 * @param className The name of a class inside of the application package
8732 * that will be used as the component for this Intent.
8733 *
8734 * @return Returns the same Intent object, for chaining multiple calls
8735 * into a single statement.
8736 *
8737 * @see #setComponent
8738 * @see #setClass
8739 */
8740 public Intent setClassName(Context packageContext, String className) {
8741 mComponent = new ComponentName(packageContext, className);
8742 return this;
8743 }
8744
8745 /**
8746 * Convenience for calling {@link #setComponent} with an
8747 * explicit application package name and class name.
8748 *
8749 * @param packageName The name of the package implementing the desired
8750 * component.
8751 * @param className The name of a class inside of the application package
8752 * that will be used as the component for this Intent.
8753 *
8754 * @return Returns the same Intent object, for chaining multiple calls
8755 * into a single statement.
8756 *
8757 * @see #setComponent
8758 * @see #setClass
8759 */
8760 public Intent setClassName(String packageName, String className) {
8761 mComponent = new ComponentName(packageName, className);
8762 return this;
8763 }
8764
8765 /**
8766 * Convenience for calling {@link #setComponent(ComponentName)} with the
8767 * name returned by a {@link Class} object.
8768 *
8769 * @param packageContext A Context of the application package implementing
8770 * this class.
8771 * @param cls The class name to set, equivalent to
8772 * <code>setClassName(context, cls.getName())</code>.
8773 *
8774 * @return Returns the same Intent object, for chaining multiple calls
8775 * into a single statement.
8776 *
8777 * @see #setComponent
8778 */
8779 public Intent setClass(Context packageContext, Class<?> cls) {
8780 mComponent = new ComponentName(packageContext, cls);
8781 return this;
8782 }
8783
8784 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008785 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8786 * used as a hint to the receiver for animations and the like. Null means that there
8787 * is no source bounds.
8788 */
8789 public void setSourceBounds(Rect r) {
8790 if (r != null) {
8791 mSourceBounds = new Rect(r);
8792 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008793 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008794 }
8795 }
8796
Tor Norbyed9273d62013-05-30 15:59:53 -07008797 /** @hide */
8798 @IntDef(flag = true,
8799 value = {
8800 FILL_IN_ACTION,
8801 FILL_IN_DATA,
8802 FILL_IN_CATEGORIES,
8803 FILL_IN_COMPONENT,
8804 FILL_IN_PACKAGE,
8805 FILL_IN_SOURCE_BOUNDS,
8806 FILL_IN_SELECTOR,
8807 FILL_IN_CLIP_DATA
8808 })
8809 @Retention(RetentionPolicy.SOURCE)
8810 public @interface FillInFlags {}
8811
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008812 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008813 * Use with {@link #fillIn} to allow the current action value to be
8814 * overwritten, even if it is already set.
8815 */
8816 public static final int FILL_IN_ACTION = 1<<0;
8817
8818 /**
8819 * Use with {@link #fillIn} to allow the current data or type value
8820 * overwritten, even if it is already set.
8821 */
8822 public static final int FILL_IN_DATA = 1<<1;
8823
8824 /**
8825 * Use with {@link #fillIn} to allow the current categories to be
8826 * overwritten, even if they are already set.
8827 */
8828 public static final int FILL_IN_CATEGORIES = 1<<2;
8829
8830 /**
8831 * Use with {@link #fillIn} to allow the current component value to be
8832 * overwritten, even if it is already set.
8833 */
8834 public static final int FILL_IN_COMPONENT = 1<<3;
8835
8836 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008837 * Use with {@link #fillIn} to allow the current package value to be
8838 * overwritten, even if it is already set.
8839 */
8840 public static final int FILL_IN_PACKAGE = 1<<4;
8841
8842 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008843 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008844 * overwritten, even if it is already set.
8845 */
8846 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8847
8848 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008849 * Use with {@link #fillIn} to allow the current selector to be
8850 * overwritten, even if it is already set.
8851 */
8852 public static final int FILL_IN_SELECTOR = 1<<6;
8853
8854 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008855 * Use with {@link #fillIn} to allow the current ClipData to be
8856 * overwritten, even if it is already set.
8857 */
8858 public static final int FILL_IN_CLIP_DATA = 1<<7;
8859
8860 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008861 * Copy the contents of <var>other</var> in to this object, but only
8862 * where fields are not defined by this object. For purposes of a field
8863 * being defined, the following pieces of data in the Intent are
8864 * considered to be separate fields:
8865 *
8866 * <ul>
8867 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008868 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008869 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8870 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008871 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008872 * <li> component, as set by {@link #setComponent(ComponentName)} or
8873 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008874 * <li> source bounds, as set by {@link #setSourceBounds}.
8875 * <li> selector, as set by {@link #setSelector(Intent)}.
8876 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008877 * <li> each top-level name in the associated extras.
8878 * </ul>
8879 *
8880 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008881 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008882 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8883 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8884 * the restriction where the corresponding field will not be replaced if
8885 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008886 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008887 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8888 * is explicitly specified. The selector will only be copied if
8889 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008890 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008891 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8892 * and Intent B with {action="gotit", data-type="some/thing",
8893 * categories="one","two"}.
8894 *
8895 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8896 * containing: {action="gotit", data-type="some/thing",
8897 * categories="bar"}.
8898 *
8899 * @param other Another Intent whose values are to be used to fill in
8900 * the current one.
8901 * @param flags Options to control which fields can be filled in.
8902 *
8903 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008904 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008905 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008906 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008907 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008908 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008909 @FillInFlags
8910 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008911 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008912 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008913 if (other.mAction != null
8914 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008915 mAction = other.mAction;
8916 changes |= FILL_IN_ACTION;
8917 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008918 if ((other.mData != null || other.mType != null)
8919 && ((mData == null && mType == null)
8920 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008921 mData = other.mData;
8922 mType = other.mType;
8923 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008924 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008925 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008926 if (other.mCategories != null
8927 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008928 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008929 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008930 }
8931 changes |= FILL_IN_CATEGORIES;
8932 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008933 if (other.mPackage != null
8934 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008935 // Only do this if mSelector is not set.
8936 if (mSelector == null) {
8937 mPackage = other.mPackage;
8938 changes |= FILL_IN_PACKAGE;
8939 }
8940 }
8941 // Selector is special: it can only be set if explicitly allowed,
8942 // for the same reason as the component name.
8943 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8944 if (mPackage == null) {
8945 mSelector = new Intent(other.mSelector);
8946 mPackage = null;
8947 changes |= FILL_IN_SELECTOR;
8948 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008949 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008950 if (other.mClipData != null
8951 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8952 mClipData = other.mClipData;
8953 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008954 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008955 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008956 // Component is special: it can -only- be set if explicitly allowed,
8957 // since otherwise the sender could force the intent somewhere the
8958 // originator didn't intend.
8959 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008960 mComponent = other.mComponent;
8961 changes |= FILL_IN_COMPONENT;
8962 }
8963 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008964 if (other.mSourceBounds != null
8965 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8966 mSourceBounds = new Rect(other.mSourceBounds);
8967 changes |= FILL_IN_SOURCE_BOUNDS;
8968 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008969 if (mExtras == null) {
8970 if (other.mExtras != null) {
8971 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008972 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008973 }
8974 } else if (other.mExtras != null) {
8975 try {
8976 Bundle newb = new Bundle(other.mExtras);
8977 newb.putAll(mExtras);
8978 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008979 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008980 } catch (RuntimeException e) {
8981 // Modifying the extras can cause us to unparcel the contents
8982 // of the bundle, and if we do this in the system process that
8983 // may fail. We really should handle this (i.e., the Bundle
8984 // impl shouldn't be on top of a plain map), but for now just
8985 // ignore it and keep the original contents. :(
8986 Log.w("Intent", "Failure filling in extras", e);
8987 }
8988 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008989 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8990 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8991 mContentUserHint = other.mContentUserHint;
8992 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008993 return changes;
8994 }
8995
8996 /**
8997 * Wrapper class holding an Intent and implementing comparisons on it for
8998 * the purpose of filtering. The class implements its
8999 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9000 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9001 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9002 * on the wrapped Intent.
9003 */
9004 public static final class FilterComparison {
9005 private final Intent mIntent;
9006 private final int mHashCode;
9007
9008 public FilterComparison(Intent intent) {
9009 mIntent = intent;
9010 mHashCode = intent.filterHashCode();
9011 }
9012
9013 /**
9014 * Return the Intent that this FilterComparison represents.
9015 * @return Returns the Intent held by the FilterComparison. Do
9016 * not modify!
9017 */
9018 public Intent getIntent() {
9019 return mIntent;
9020 }
9021
9022 @Override
9023 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009024 if (obj instanceof FilterComparison) {
9025 Intent other = ((FilterComparison)obj).mIntent;
9026 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009027 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009028 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009029 }
9030
9031 @Override
9032 public int hashCode() {
9033 return mHashCode;
9034 }
9035 }
9036
9037 /**
9038 * Determine if two intents are the same for the purposes of intent
9039 * resolution (filtering). That is, if their action, data, type,
9040 * class, and categories are the same. This does <em>not</em> compare
9041 * any extra data included in the intents.
9042 *
9043 * @param other The other Intent to compare against.
9044 *
9045 * @return Returns true if action, data, type, class, and categories
9046 * are the same.
9047 */
9048 public boolean filterEquals(Intent other) {
9049 if (other == null) {
9050 return false;
9051 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009052 if (!Objects.equals(this.mAction, other.mAction)) return false;
9053 if (!Objects.equals(this.mData, other.mData)) return false;
9054 if (!Objects.equals(this.mType, other.mType)) return false;
9055 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9056 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9057 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009058
9059 return true;
9060 }
9061
9062 /**
9063 * Generate hash code that matches semantics of filterEquals().
9064 *
9065 * @return Returns the hash value of the action, data, type, class, and
9066 * categories.
9067 *
9068 * @see #filterEquals
9069 */
9070 public int filterHashCode() {
9071 int code = 0;
9072 if (mAction != null) {
9073 code += mAction.hashCode();
9074 }
9075 if (mData != null) {
9076 code += mData.hashCode();
9077 }
9078 if (mType != null) {
9079 code += mType.hashCode();
9080 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009081 if (mPackage != null) {
9082 code += mPackage.hashCode();
9083 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009084 if (mComponent != null) {
9085 code += mComponent.hashCode();
9086 }
9087 if (mCategories != null) {
9088 code += mCategories.hashCode();
9089 }
9090 return code;
9091 }
9092
9093 @Override
9094 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009095 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009096
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009097 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009098 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009099 b.append(" }");
9100
9101 return b.toString();
9102 }
9103
9104 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009105 public String toInsecureString() {
9106 StringBuilder b = new StringBuilder(128);
9107
9108 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009109 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009110 b.append(" }");
9111
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009112 return b.toString();
9113 }
Romain Guy4969af72009-06-17 10:53:19 -07009114
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009115 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009116 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009117 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009118
9119 b.append("Intent { ");
9120 toShortString(b, false, true, true, true);
9121 b.append(" }");
9122
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009123 return b.toString();
9124 }
9125
9126 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009127 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9128 StringBuilder b = new StringBuilder(128);
9129 toShortString(b, secure, comp, extras, clip);
9130 return b.toString();
9131 }
9132
9133 /** @hide */
9134 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9135 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009136 boolean first = true;
9137 if (mAction != null) {
9138 b.append("act=").append(mAction);
9139 first = false;
9140 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009141 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009142 if (!first) {
9143 b.append(' ');
9144 }
9145 first = false;
9146 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009147 for (int i=0; i<mCategories.size(); i++) {
9148 if (i > 0) b.append(',');
9149 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009150 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009151 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009152 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009153 if (mData != null) {
9154 if (!first) {
9155 b.append(' ');
9156 }
9157 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009158 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009159 if (secure) {
9160 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009161 } else {
9162 b.append(mData);
9163 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009164 }
9165 if (mType != null) {
9166 if (!first) {
9167 b.append(' ');
9168 }
9169 first = false;
9170 b.append("typ=").append(mType);
9171 }
9172 if (mFlags != 0) {
9173 if (!first) {
9174 b.append(' ');
9175 }
9176 first = false;
9177 b.append("flg=0x").append(Integer.toHexString(mFlags));
9178 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009179 if (mPackage != null) {
9180 if (!first) {
9181 b.append(' ');
9182 }
9183 first = false;
9184 b.append("pkg=").append(mPackage);
9185 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009186 if (comp && mComponent != null) {
9187 if (!first) {
9188 b.append(' ');
9189 }
9190 first = false;
9191 b.append("cmp=").append(mComponent.flattenToShortString());
9192 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009193 if (mSourceBounds != null) {
9194 if (!first) {
9195 b.append(' ');
9196 }
9197 first = false;
9198 b.append("bnds=").append(mSourceBounds.toShortString());
9199 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009200 if (mClipData != null) {
9201 if (!first) {
9202 b.append(' ');
9203 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009204 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009205 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009206 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009207 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009208 if (mClipData.getDescription() != null) {
9209 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9210 } else {
9211 first = true;
9212 }
9213 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009214 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009215 first = false;
9216 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009217 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009218 if (extras && mExtras != null) {
9219 if (!first) {
9220 b.append(' ');
9221 }
9222 first = false;
9223 b.append("(has extras)");
9224 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009225 if (mContentUserHint != UserHandle.USER_CURRENT) {
9226 if (!first) {
9227 b.append(' ');
9228 }
9229 first = false;
9230 b.append("u=").append(mContentUserHint);
9231 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009232 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009233 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009234 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009235 b.append("}");
9236 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009237 }
9238
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009239 /**
9240 * Call {@link #toUri} with 0 flags.
9241 * @deprecated Use {@link #toUri} instead.
9242 */
9243 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009244 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009245 return toUri(0);
9246 }
9247
9248 /**
9249 * Convert this Intent into a String holding a URI representation of it.
9250 * The returned URI string has been properly URI encoded, so it can be
9251 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9252 * Intent's data as the base URI, with an additional fragment describing
9253 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009254 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009255 * <p>You can convert the returned string back to an Intent with
9256 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009257 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009258 * @param flags Additional operating flags. Either 0,
9259 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08009260 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009261 * @return Returns a URI encoding URI string describing the entire contents
9262 * of the Intent.
9263 */
9264 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009265 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009266 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9267 if (mPackage == null) {
9268 throw new IllegalArgumentException(
9269 "Intent must include an explicit package name to build an android-app: "
9270 + this);
9271 }
9272 uri.append("android-app://");
9273 uri.append(mPackage);
9274 String scheme = null;
9275 if (mData != null) {
9276 scheme = mData.getScheme();
9277 if (scheme != null) {
9278 uri.append('/');
9279 uri.append(scheme);
9280 String authority = mData.getEncodedAuthority();
9281 if (authority != null) {
9282 uri.append('/');
9283 uri.append(authority);
9284 String path = mData.getEncodedPath();
9285 if (path != null) {
9286 uri.append(path);
9287 }
9288 String queryParams = mData.getEncodedQuery();
9289 if (queryParams != null) {
9290 uri.append('?');
9291 uri.append(queryParams);
9292 }
9293 String fragment = mData.getEncodedFragment();
9294 if (fragment != null) {
9295 uri.append('#');
9296 uri.append(fragment);
9297 }
9298 }
9299 }
9300 }
9301 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9302 mPackage, flags);
9303 return uri.toString();
9304 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009305 String scheme = null;
9306 if (mData != null) {
9307 String data = mData.toString();
9308 if ((flags&URI_INTENT_SCHEME) != 0) {
9309 final int N = data.length();
9310 for (int i=0; i<N; i++) {
9311 char c = data.charAt(i);
9312 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9313 || c == '.' || c == '-') {
9314 continue;
9315 }
9316 if (c == ':' && i > 0) {
9317 // Valid scheme.
9318 scheme = data.substring(0, i);
9319 uri.append("intent:");
9320 data = data.substring(i+1);
9321 break;
9322 }
Tom Taylord4a47292009-12-21 13:59:18 -08009323
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009324 // No scheme.
9325 break;
9326 }
9327 }
9328 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009329
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009330 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9331 uri.append("intent:");
9332 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009333
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009334 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009335
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009336 return uri.toString();
9337 }
9338
9339 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9340 String defPackage, int flags) {
9341 StringBuilder frag = new StringBuilder(128);
9342
9343 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009344 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009345 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009346 // Note that for now we are not going to try to handle the
9347 // data part; not clear how to represent this as a URI, and
9348 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009349 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9350 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009351 }
9352
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009353 if (frag.length() > 0) {
9354 uri.append("#Intent;");
9355 uri.append(frag);
9356 uri.append("end");
9357 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009358 }
9359
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009360 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9361 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009362 if (scheme != null) {
9363 uri.append("scheme=").append(scheme).append(';');
9364 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009365 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009366 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009367 }
9368 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009369 for (int i=0; i<mCategories.size(); i++) {
9370 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009371 }
9372 }
9373 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009374 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009375 }
9376 if (mFlags != 0) {
9377 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9378 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009379 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009380 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9381 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009382 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009383 uri.append("component=").append(Uri.encode(
9384 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009385 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009386 if (mSourceBounds != null) {
9387 uri.append("sourceBounds=")
9388 .append(Uri.encode(mSourceBounds.flattenToString()))
9389 .append(';');
9390 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009391 if (mExtras != null) {
9392 for (String key : mExtras.keySet()) {
9393 final Object value = mExtras.get(key);
9394 char entryType =
9395 value instanceof String ? 'S' :
9396 value instanceof Boolean ? 'B' :
9397 value instanceof Byte ? 'b' :
9398 value instanceof Character ? 'c' :
9399 value instanceof Double ? 'd' :
9400 value instanceof Float ? 'f' :
9401 value instanceof Integer ? 'i' :
9402 value instanceof Long ? 'l' :
9403 value instanceof Short ? 's' :
9404 '\0';
9405
9406 if (entryType != '\0') {
9407 uri.append(entryType);
9408 uri.append('.');
9409 uri.append(Uri.encode(key));
9410 uri.append('=');
9411 uri.append(Uri.encode(value.toString()));
9412 uri.append(';');
9413 }
9414 }
9415 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009416 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009417
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009418 public int describeContents() {
9419 return (mExtras != null) ? mExtras.describeContents() : 0;
9420 }
9421
9422 public void writeToParcel(Parcel out, int flags) {
9423 out.writeString(mAction);
9424 Uri.writeToParcel(out, mData);
9425 out.writeString(mType);
9426 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009427 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009428 ComponentName.writeToParcel(mComponent, out);
9429
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009430 if (mSourceBounds != null) {
9431 out.writeInt(1);
9432 mSourceBounds.writeToParcel(out, flags);
9433 } else {
9434 out.writeInt(0);
9435 }
9436
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009437 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009438 final int N = mCategories.size();
9439 out.writeInt(N);
9440 for (int i=0; i<N; i++) {
9441 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009442 }
9443 } else {
9444 out.writeInt(0);
9445 }
9446
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009447 if (mSelector != null) {
9448 out.writeInt(1);
9449 mSelector.writeToParcel(out, flags);
9450 } else {
9451 out.writeInt(0);
9452 }
9453
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009454 if (mClipData != null) {
9455 out.writeInt(1);
9456 mClipData.writeToParcel(out, flags);
9457 } else {
9458 out.writeInt(0);
9459 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009460 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009461 out.writeBundle(mExtras);
9462 }
9463
9464 public static final Parcelable.Creator<Intent> CREATOR
9465 = new Parcelable.Creator<Intent>() {
9466 public Intent createFromParcel(Parcel in) {
9467 return new Intent(in);
9468 }
9469 public Intent[] newArray(int size) {
9470 return new Intent[size];
9471 }
9472 };
9473
Dianne Hackborneb034652009-09-07 00:49:58 -07009474 /** @hide */
9475 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009476 readFromParcel(in);
9477 }
9478
9479 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009480 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009481 mData = Uri.CREATOR.createFromParcel(in);
9482 mType = in.readString();
9483 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009484 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009485 mComponent = ComponentName.readFromParcel(in);
9486
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009487 if (in.readInt() != 0) {
9488 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9489 }
9490
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009491 int N = in.readInt();
9492 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009493 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009494 int i;
9495 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009496 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009497 }
9498 } else {
9499 mCategories = null;
9500 }
9501
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009502 if (in.readInt() != 0) {
9503 mSelector = new Intent(in);
9504 }
9505
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009506 if (in.readInt() != 0) {
9507 mClipData = new ClipData(in);
9508 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009509 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009510 mExtras = in.readBundle();
9511 }
9512
9513 /**
9514 * Parses the "intent" element (and its children) from XML and instantiates
9515 * an Intent object. The given XML parser should be located at the tag
9516 * where parsing should start (often named "intent"), from which the
9517 * basic action, data, type, and package and class name will be
9518 * retrieved. The function will then parse in to any child elements,
9519 * looking for <category android:name="xxx"> tags to add categories and
9520 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9521 * to the intent.
9522 *
9523 * @param resources The Resources to use when inflating resources.
9524 * @param parser The XML parser pointing at an "intent" tag.
9525 * @param attrs The AttributeSet interface for retrieving extended
9526 * attribute data at the current <var>parser</var> location.
9527 * @return An Intent object matching the XML data.
9528 * @throws XmlPullParserException If there was an XML parsing error.
9529 * @throws IOException If there was an I/O error.
9530 */
9531 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9532 throws XmlPullParserException, IOException {
9533 Intent intent = new Intent();
9534
9535 TypedArray sa = resources.obtainAttributes(attrs,
9536 com.android.internal.R.styleable.Intent);
9537
9538 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9539
9540 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9541 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9542 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9543
9544 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9545 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9546 if (packageName != null && className != null) {
9547 intent.setComponent(new ComponentName(packageName, className));
9548 }
9549
9550 sa.recycle();
9551
9552 int outerDepth = parser.getDepth();
9553 int type;
9554 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9555 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9556 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9557 continue;
9558 }
9559
9560 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009561 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009562 sa = resources.obtainAttributes(attrs,
9563 com.android.internal.R.styleable.IntentCategory);
9564 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9565 sa.recycle();
9566
9567 if (cat != null) {
9568 intent.addCategory(cat);
9569 }
9570 XmlUtils.skipCurrentTag(parser);
9571
Craig Mautner21d24a22014-04-23 11:45:37 -07009572 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009573 if (intent.mExtras == null) {
9574 intent.mExtras = new Bundle();
9575 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009576 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009577 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009578
9579 } else {
9580 XmlUtils.skipCurrentTag(parser);
9581 }
9582 }
9583
9584 return intent;
9585 }
Nick Pellyccae4122012-01-09 14:12:58 -08009586
Craig Mautner21d24a22014-04-23 11:45:37 -07009587 /** @hide */
9588 public void saveToXml(XmlSerializer out) throws IOException {
9589 if (mAction != null) {
9590 out.attribute(null, ATTR_ACTION, mAction);
9591 }
9592 if (mData != null) {
9593 out.attribute(null, ATTR_DATA, mData.toString());
9594 }
9595 if (mType != null) {
9596 out.attribute(null, ATTR_TYPE, mType);
9597 }
9598 if (mComponent != null) {
9599 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9600 }
9601 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9602
9603 if (mCategories != null) {
9604 out.startTag(null, TAG_CATEGORIES);
9605 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9606 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9607 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009608 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009609 }
9610 }
9611
9612 /** @hide */
9613 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9614 XmlPullParserException {
9615 Intent intent = new Intent();
9616 final int outerDepth = in.getDepth();
9617
9618 int attrCount = in.getAttributeCount();
9619 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9620 final String attrName = in.getAttributeName(attrNdx);
9621 final String attrValue = in.getAttributeValue(attrNdx);
9622 if (ATTR_ACTION.equals(attrName)) {
9623 intent.setAction(attrValue);
9624 } else if (ATTR_DATA.equals(attrName)) {
9625 intent.setData(Uri.parse(attrValue));
9626 } else if (ATTR_TYPE.equals(attrName)) {
9627 intent.setType(attrValue);
9628 } else if (ATTR_COMPONENT.equals(attrName)) {
9629 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9630 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009631 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009632 } else {
9633 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9634 }
9635 }
9636
9637 int event;
9638 String name;
9639 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9640 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9641 if (event == XmlPullParser.START_TAG) {
9642 name = in.getName();
9643 if (TAG_CATEGORIES.equals(name)) {
9644 attrCount = in.getAttributeCount();
9645 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9646 intent.addCategory(in.getAttributeValue(attrNdx));
9647 }
9648 } else {
9649 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9650 XmlUtils.skipCurrentTag(in);
9651 }
9652 }
9653 }
9654
9655 return intent;
9656 }
9657
Nick Pellyccae4122012-01-09 14:12:58 -08009658 /**
9659 * Normalize a MIME data type.
9660 *
9661 * <p>A normalized MIME type has white-space trimmed,
9662 * content-type parameters removed, and is lower-case.
9663 * This aligns the type with Android best practices for
9664 * intent filtering.
9665 *
9666 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9667 * "text/x-vCard" becomes "text/x-vcard".
9668 *
9669 * <p>All MIME types received from outside Android (such as user input,
9670 * or external sources like Bluetooth, NFC, or the Internet) should
9671 * be normalized before they are used to create an Intent.
9672 *
9673 * @param type MIME data type to normalize
9674 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009675 * @see #setType
9676 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009677 */
9678 public static String normalizeMimeType(String type) {
9679 if (type == null) {
9680 return null;
9681 }
9682
Elliott Hughescb64d432013-08-02 10:00:44 -07009683 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009684
9685 final int semicolonIndex = type.indexOf(';');
9686 if (semicolonIndex != -1) {
9687 type = type.substring(0, semicolonIndex);
9688 }
9689 return type;
9690 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009691
9692 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009693 * Prepare this {@link Intent} to leave an app process.
9694 *
9695 * @hide
9696 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009697 public void prepareToLeaveProcess(Context context) {
9698 final boolean leavingPackage = (mComponent == null)
9699 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9700 prepareToLeaveProcess(leavingPackage);
9701 }
9702
9703 /**
9704 * Prepare this {@link Intent} to leave an app process.
9705 *
9706 * @hide
9707 */
9708 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009709 setAllowFds(false);
9710
9711 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009712 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009713 }
9714 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009715 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009716 }
9717
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009718 if (mExtras != null && !mExtras.isParcelled()) {
9719 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9720 if (intent instanceof Intent) {
9721 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9722 }
9723 }
9724
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009725 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9726 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009727 switch (mAction) {
9728 case ACTION_MEDIA_REMOVED:
9729 case ACTION_MEDIA_UNMOUNTED:
9730 case ACTION_MEDIA_CHECKING:
9731 case ACTION_MEDIA_NOFS:
9732 case ACTION_MEDIA_MOUNTED:
9733 case ACTION_MEDIA_SHARED:
9734 case ACTION_MEDIA_UNSHARED:
9735 case ACTION_MEDIA_BAD_REMOVAL:
9736 case ACTION_MEDIA_UNMOUNTABLE:
9737 case ACTION_MEDIA_EJECT:
9738 case ACTION_MEDIA_SCANNER_STARTED:
9739 case ACTION_MEDIA_SCANNER_FINISHED:
9740 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009741 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9742 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009743 // Ignore legacy actions
9744 break;
9745 default:
9746 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009747 }
9748 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009749
9750 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9751 && leavingPackage) {
9752 switch (mAction) {
9753 case ACTION_PROVIDER_CHANGED:
9754 // Ignore actions that don't need to grant
9755 break;
9756 default:
9757 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9758 }
9759 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009760 }
9761
9762 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009763 * @hide
9764 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009765 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009766 // We just entered destination process, so we should be able to read all
9767 // parcelables inside.
9768 setDefusable(true);
9769
9770 if (mSelector != null) {
9771 mSelector.prepareToEnterProcess();
9772 }
9773 if (mClipData != null) {
9774 mClipData.prepareToEnterProcess();
9775 }
9776
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009777 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009778 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9779 fixUris(mContentUserHint);
9780 mContentUserHint = UserHandle.USER_CURRENT;
9781 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009782 }
9783 }
9784
9785 /**
9786 * @hide
9787 */
9788 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009789 Uri data = getData();
9790 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009791 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009792 }
9793 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009794 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009795 }
9796 String action = getAction();
9797 if (ACTION_SEND.equals(action)) {
9798 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9799 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009800 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009801 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009802 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009803 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9804 if (streams != null) {
9805 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9806 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009807 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009808 }
9809 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9810 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009811 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9812 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9813 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9814 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9815 if (output != null) {
9816 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9817 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009818 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009819 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009820
9821 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009822 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009823 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9824 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009825 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009826 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009827 * @hide
9828 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009829 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009830 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009831 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009832
9833 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009834 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009835
9836 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009837 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009838 // Inspect contained intents to see if we need to migrate extras. We
9839 // don't promote ClipData to the parent, since ChooserActivity will
9840 // already start the picked item as the caller, and we can't combine
9841 // the flags in a safe way.
9842
9843 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009844 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009845 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9846 if (intent != null) {
9847 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009848 }
9849 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009850 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009851 try {
9852 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9853 if (intents != null) {
9854 for (int i = 0; i < intents.length; i++) {
9855 final Intent intent = (Intent) intents[i];
9856 if (intent != null) {
9857 migrated |= intent.migrateExtraStreamToClipData();
9858 }
9859 }
9860 }
9861 } catch (ClassCastException e) {
9862 }
9863 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009864
9865 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009866 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009867 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9868 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9869 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9870 if (stream != null || text != null || htmlText != null) {
9871 final ClipData clipData = new ClipData(
9872 null, new String[] { getType() },
9873 new ClipData.Item(text, htmlText, null, stream));
9874 setClipData(clipData);
9875 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009876 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009877 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009878 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009879 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009880
9881 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009882 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009883 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9884 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9885 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9886 int num = -1;
9887 if (streams != null) {
9888 num = streams.size();
9889 }
9890 if (texts != null) {
9891 if (num >= 0 && num != texts.size()) {
9892 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009893 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009894 }
9895 num = texts.size();
9896 }
9897 if (htmlTexts != null) {
9898 if (num >= 0 && num != htmlTexts.size()) {
9899 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009900 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009901 }
9902 num = htmlTexts.size();
9903 }
9904 if (num > 0) {
9905 final ClipData clipData = new ClipData(
9906 null, new String[] { getType() },
9907 makeClipItem(streams, texts, htmlTexts, 0));
9908
9909 for (int i = 1; i < num; i++) {
9910 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9911 }
9912
9913 setClipData(clipData);
9914 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009915 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009916 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009917 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009918 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009919 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9920 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9921 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9922 final Uri output;
9923 try {
9924 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9925 } catch (ClassCastException e) {
9926 return false;
9927 }
9928 if (output != null) {
9929 setClipData(ClipData.newRawUri("", output));
9930 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9931 return true;
9932 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009933 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009934
9935 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009936 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009937
9938 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9939 ArrayList<String> htmlTexts, int which) {
9940 Uri uri = streams != null ? streams.get(which) : null;
9941 CharSequence text = texts != null ? texts.get(which) : null;
9942 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9943 return new ClipData.Item(text, htmlText, null, uri);
9944 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009945
9946 /** @hide */
9947 public boolean isDocument() {
9948 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9949 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009950}