blob: b03ba1b5c345a066199e185dc386f227775d5da9 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070022import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050024import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060027import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30import android.content.res.Resources;
31import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080032import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060034import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.os.Bundle;
36import android.os.IBinder;
37import android.os.Parcel;
38import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000039import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050040import android.os.ResultReceiver;
41import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070042import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010043import android.os.UserHandle;
Jeff Sharkey81aebe72017-04-03 20:14:10 +000044import android.os.storage.StorageManager;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070045import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070048import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070050import android.util.AttributeSet;
51import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080052import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import org.xmlpull.v1.XmlPullParser;
54import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070055import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070056
57import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080058import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070060import java.lang.annotation.Retention;
61import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.net.URISyntaxException;
63import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080064import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070065import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080066import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070067import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.util.Set;
69
Jeff Sharkey81aebe72017-04-03 20:14:10 +000070import static android.content.ContentProvider.maybeAddUserId;
71
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072/**
73 * An intent is an abstract description of an operation to be performed. It
74 * can be used with {@link Context#startActivity(Intent) startActivity} to
75 * launch an {@link android.app.Activity},
76 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
77 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
78 * and {@link android.content.Context#startService} or
79 * {@link android.content.Context#bindService} to communicate with a
80 * background {@link android.app.Service}.
81 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 * <p>An Intent provides a facility for performing late runtime binding between the code in
83 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070084 * can be thought of as the glue between activities. It is basically a passive data structure
85 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 *
87 * <div class="special reference">
88 * <h3>Developer Guides</h3>
89 * <p>For information about how to create and resolve intents, read the
90 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
91 * developer guide.</p>
92 * </div>
93 *
94 * <a name="IntentStructure"></a>
95 * <h3>Intent Structure</h3>
96 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 *
98 * <ul>
99 * <li> <p><b>action</b> -- The general action to be performed, such as
100 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
101 * etc.</p>
102 * </li>
103 * <li> <p><b>data</b> -- The data to operate on, such as a person record
104 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
105 * </li>
106 * </ul>
107 *
108 *
109 * <p>Some examples of action/data pairs are:</p>
110 *
111 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700112 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700113 * information about the person whose identifier is "1".</p>
114 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700115 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700116 * the phone dialer with the person filled in.</p>
117 * </li>
118 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
119 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700120 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * a particular URI.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in.</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * information about the person whose identifier is "1".</p>
128 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a list of people, which the user can browse through. This example is a
131 * typical top-level entry into the Contacts application, showing you the
132 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700133 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * being used to start an activity to display that person.</p>
135 * </li>
136 * </ul>
137 *
138 * <p>In addition to these primary attributes, there are a number of secondary
139 * attributes that you can also include with an intent:</p>
140 *
141 * <ul>
142 * <li> <p><b>category</b> -- Gives additional information about the action
143 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
144 * appear in the Launcher as a top-level application, while
145 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
146 * of alternative actions the user can perform on a piece of data.</p>
147 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
148 * intent data. Normally the type is inferred from the data itself.
149 * By setting this attribute, you disable that evaluation and force
150 * an explicit type.</p>
151 * <li> <p><b>component</b> -- Specifies an explicit name of a component
152 * class to use for the intent. Normally this is determined by looking
153 * at the other information in the intent (the action, data/type, and
154 * categories) and matching that with a component that can handle it.
155 * If this attribute is set then none of the evaluation is performed,
156 * and this component is used exactly as is. By specifying this attribute,
157 * all of the other Intent attributes become optional.</p>
158 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
159 * This can be used to provide extended information to the component.
160 * For example, if we have a action to send an e-mail message, we could
161 * also include extra pieces of data here to supply a subject, body,
162 * etc.</p>
163 * </ul>
164 *
165 * <p>Here are some examples of other operations you can specify as intents
166 * using these additional parameters:</p>
167 *
168 * <ul>
169 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
170 * Launch the home screen.</p>
171 * </li>
172 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
173 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
174 * vnd.android.cursor.item/phone}</i></b>
175 * -- Display the list of people's phone numbers, allowing the user to
176 * browse through them and pick one and return it to the parent activity.</p>
177 * </li>
178 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
180 * -- Display all pickers for data that can be opened with
181 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
182 * allowing the user to pick one of them and then some data inside of it
183 * and returning the resulting URI to the caller. This can be used,
184 * for example, in an e-mail application to allow the user to pick some
185 * data to include as an attachment.</p>
186 * </li>
187 * </ul>
188 *
189 * <p>There are a variety of standard Intent action and category constants
190 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700191 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700193 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700194 *
195 * <p>Put together, the set of actions, data types, categories, and extra data
196 * defines a language for the system allowing for the expression of phrases
197 * such as "call john smith's cell". As applications are added to the system,
198 * they can extend this language by adding new actions, types, and categories, or
199 * they can modify the behavior of existing phrases by supplying their own
200 * activities that handle them.</p>
201 *
202 * <a name="IntentResolution"></a>
203 * <h3>Intent Resolution</h3>
204 *
205 * <p>There are two primary forms of intents you will use.
206 *
207 * <ul>
208 * <li> <p><b>Explicit Intents</b> have specified a component (via
209 * {@link #setComponent} or {@link #setClass}), which provides the exact
210 * class to be run. Often these will not include any other information,
211 * simply being a way for an application to launch various internal
212 * activities it has as the user interacts with the application.
213 *
214 * <li> <p><b>Implicit Intents</b> have not specified a component;
215 * instead, they must include enough information for the system to
216 * determine which of the available components is best to run for that
217 * intent.
218 * </ul>
219 *
220 * <p>When using implicit intents, given such an arbitrary intent we need to
221 * know what to do with it. This is handled by the process of <em>Intent
222 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
223 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
224 * more activities/receivers) that can handle it.</p>
225 *
226 * <p>The intent resolution mechanism basically revolves around matching an
227 * Intent against all of the &lt;intent-filter&gt; descriptions in the
228 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
229 * objects explicitly registered with {@link Context#registerReceiver}.) More
230 * details on this can be found in the documentation on the {@link
231 * IntentFilter} class.</p>
232 *
233 * <p>There are three pieces of information in the Intent that are used for
234 * resolution: the action, type, and category. Using this information, a query
235 * is done on the {@link PackageManager} for a component that can handle the
236 * intent. The appropriate component is determined based on the intent
237 * information supplied in the <code>AndroidManifest.xml</code> file as
238 * follows:</p>
239 *
240 * <ul>
241 * <li> <p>The <b>action</b>, if given, must be listed by the component as
242 * one it handles.</p>
243 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
244 * already supplied in the Intent. Like the action, if a type is
245 * included in the intent (either explicitly or implicitly in its
246 * data), then this must be listed by the component as one it handles.</p>
247 * <li> For data that is not a <code>content:</code> URI and where no explicit
248 * type is included in the Intent, instead the <b>scheme</b> of the
249 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
250 * considered. Again like the action, if we are matching a scheme it
251 * must be listed by the component as one it can handle.
252 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
253 * by the activity as categories it handles. That is, if you include
254 * the categories {@link #CATEGORY_LAUNCHER} and
255 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
256 * with an intent that lists <em>both</em> of those categories.
257 * Activities will very often need to support the
258 * {@link #CATEGORY_DEFAULT} so that they can be found by
259 * {@link Context#startActivity Context.startActivity()}.</p>
260 * </ul>
261 *
262 * <p>For example, consider the Note Pad sample application that
263 * allows user to browse through a list of notes data and view details about
264 * individual items. Text in italics indicate places were you would replace a
265 * name with one specific to your own package.</p>
266 *
267 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
268 * package="<i>com.android.notepad</i>"&gt;
269 * &lt;application android:icon="@drawable/app_notes"
270 * android:label="@string/app_name"&gt;
271 *
272 * &lt;provider class=".NotePadProvider"
273 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
274 *
275 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.MAIN" /&gt;
278 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700279 * &lt;/intent-filter&gt;
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.VIEW" /&gt;
282 * &lt;action android:name="android.intent.action.EDIT" /&gt;
283 * &lt;action android:name="android.intent.action.PICK" /&gt;
284 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;/activity&gt;
293 *
294 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
295 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.VIEW" /&gt;
297 * &lt;action android:name="android.intent.action.EDIT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 *
302 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700303 * &lt;action android:name="android.intent.action.INSERT" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700306 * &lt;/intent-filter&gt;
307 *
308 * &lt;/activity&gt;
309 *
310 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
311 * android:theme="@android:style/Theme.Dialog"&gt;
312 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
314 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
316 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
317 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700318 * &lt;/intent-filter&gt;
319 * &lt;/activity&gt;
320 *
321 * &lt;/application&gt;
322 * &lt;/manifest&gt;</pre>
323 *
324 * <p>The first activity,
325 * <code>com.android.notepad.NotesList</code>, serves as our main
326 * entry into the app. It can do three things as described by its three intent
327 * templates:
328 * <ol>
329 * <li><pre>
330 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700331 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
332 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700333 * &lt;/intent-filter&gt;</pre>
334 * <p>This provides a top-level entry into the NotePad application: the standard
335 * MAIN action is a main entry point (not requiring any other information in
336 * the Intent), and the LAUNCHER category says that this entry point should be
337 * listed in the application launcher.</p>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
341 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
342 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
343 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700344 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700345 * &lt;/intent-filter&gt;</pre>
346 * <p>This declares the things that the activity can do on a directory of
347 * notes. The type being supported is given with the &lt;type&gt; tag, where
348 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
349 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
350 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
351 * The activity allows the user to view or edit the directory of data (via
352 * the VIEW and EDIT actions), or to pick a particular note and return it
353 * to the caller (via the PICK action). Note also the DEFAULT category
354 * supplied here: this is <em>required</em> for the
355 * {@link Context#startActivity Context.startActivity} method to resolve your
356 * activity when its component name is not explicitly specified.</p>
357 * <li><pre>
358 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700359 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
360 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700363 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700364 * the user without needing to know where it came from. The data type
365 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
366 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
367 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
368 * The GET_CONTENT action is similar to the PICK action, where the activity
369 * will return to its caller a piece of data selected by the user. Here,
370 * however, the caller specifies the type of data they desire instead of
371 * the type of data the user will be picking from.</p>
372 * </ol>
373 *
374 * <p>Given these capabilities, the following intents will resolve to the
375 * NotesList activity:</p>
376 *
377 * <ul>
378 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
379 * activities that can be used as top-level entry points into an
380 * application.</p>
381 * <li> <p><b>{ action=android.app.action.MAIN,
382 * category=android.app.category.LAUNCHER }</b> is the actual intent
383 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700384 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700385 * data=content://com.google.provider.NotePad/notes }</b>
386 * displays a list of all the notes under
387 * "content://com.google.provider.NotePad/notes", which
388 * the user can browse through and see the details on.</p>
389 * <li> <p><b>{ action=android.app.action.PICK
390 * data=content://com.google.provider.NotePad/notes }</b>
391 * provides a list of the notes under
392 * "content://com.google.provider.NotePad/notes", from which
393 * the user can pick a note whose data URL is returned back to the caller.</p>
394 * <li> <p><b>{ action=android.app.action.GET_CONTENT
395 * type=vnd.android.cursor.item/vnd.google.note }</b>
396 * is similar to the pick action, but allows the caller to specify the
397 * kind of data they want back so that the system can find the appropriate
398 * activity to pick something of that data type.</p>
399 * </ul>
400 *
401 * <p>The second activity,
402 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
403 * note entry and allows them to edit it. It can do two things as described
404 * by its two intent templates:
405 * <ol>
406 * <li><pre>
407 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700408 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
409 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
410 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
411 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700412 * &lt;/intent-filter&gt;</pre>
413 * <p>The first, primary, purpose of this activity is to let the user interact
414 * with a single note, as decribed by the MIME type
415 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
416 * either VIEW a note or allow the user to EDIT it. Again we support the
417 * DEFAULT category to allow the activity to be launched without explicitly
418 * specifying its component.</p>
419 * <li><pre>
420 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700421 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
422 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
423 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700424 * &lt;/intent-filter&gt;</pre>
425 * <p>The secondary use of this activity is to insert a new note entry into
426 * an existing directory of notes. This is used when the user creates a new
427 * note: the INSERT action is executed on the directory of notes, causing
428 * this activity to run and have the user create the new note data which
429 * it then adds to the content provider.</p>
430 * </ol>
431 *
432 * <p>Given these capabilities, the following intents will resolve to the
433 * NoteEditor activity:</p>
434 *
435 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700436 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700437 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 * shows the user the content of note <var>{ID}</var>.</p>
439 * <li> <p><b>{ action=android.app.action.EDIT
440 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
441 * allows the user to edit the content of note <var>{ID}</var>.</p>
442 * <li> <p><b>{ action=android.app.action.INSERT
443 * data=content://com.google.provider.NotePad/notes }</b>
444 * creates a new, empty note in the notes list at
445 * "content://com.google.provider.NotePad/notes"
446 * and allows the user to edit it. If they keep their changes, the URI
447 * of the newly created note is returned to the caller.</p>
448 * </ul>
449 *
450 * <p>The last activity,
451 * <code>com.android.notepad.TitleEditor</code>, allows the user to
452 * edit the title of a note. This could be implemented as a class that the
453 * application directly invokes (by explicitly setting its component in
454 * the Intent), but here we show a way you can publish alternative
455 * operations on existing data:</p>
456 *
457 * <pre>
458 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700459 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
463 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700464 * &lt;/intent-filter&gt;</pre>
465 *
466 * <p>In the single intent template here, we
467 * have created our own private action called
468 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
469 * edit the title of a note. It must be invoked on a specific note
470 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
471 * view and edit actions, but here displays and edits the title contained
472 * in the note data.
473 *
474 * <p>In addition to supporting the default category as usual, our title editor
475 * also supports two other standard categories: ALTERNATIVE and
476 * SELECTED_ALTERNATIVE. Implementing
477 * these categories allows others to find the special action it provides
478 * without directly knowing about it, through the
479 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
480 * more often to build dynamic menu items with
481 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
482 * template here was also supply an explicit name for the template
483 * (via <code>android:label="@string/resolve_title"</code>) to better control
484 * what the user sees when presented with this activity as an alternative
485 * action to the data they are viewing.
486 *
487 * <p>Given these capabilities, the following intent will resolve to the
488 * TitleEditor activity:</p>
489 *
490 * <ul>
491 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
492 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
493 * displays and allows the user to edit the title associated
494 * with note <var>{ID}</var>.</p>
495 * </ul>
496 *
497 * <h3>Standard Activity Actions</h3>
498 *
499 * <p>These are the current standard actions that Intent defines for launching
500 * activities (usually through {@link Context#startActivity}. The most
501 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
502 * {@link #ACTION_EDIT}.
503 *
504 * <ul>
505 * <li> {@link #ACTION_MAIN}
506 * <li> {@link #ACTION_VIEW}
507 * <li> {@link #ACTION_ATTACH_DATA}
508 * <li> {@link #ACTION_EDIT}
509 * <li> {@link #ACTION_PICK}
510 * <li> {@link #ACTION_CHOOSER}
511 * <li> {@link #ACTION_GET_CONTENT}
512 * <li> {@link #ACTION_DIAL}
513 * <li> {@link #ACTION_CALL}
514 * <li> {@link #ACTION_SEND}
515 * <li> {@link #ACTION_SENDTO}
516 * <li> {@link #ACTION_ANSWER}
517 * <li> {@link #ACTION_INSERT}
518 * <li> {@link #ACTION_DELETE}
519 * <li> {@link #ACTION_RUN}
520 * <li> {@link #ACTION_SYNC}
521 * <li> {@link #ACTION_PICK_ACTIVITY}
522 * <li> {@link #ACTION_SEARCH}
523 * <li> {@link #ACTION_WEB_SEARCH}
524 * <li> {@link #ACTION_FACTORY_TEST}
525 * </ul>
526 *
527 * <h3>Standard Broadcast Actions</h3>
528 *
529 * <p>These are the current standard actions that Intent defines for receiving
530 * broadcasts (usually through {@link Context#registerReceiver} or a
531 * &lt;receiver&gt; tag in a manifest).
532 *
533 * <ul>
534 * <li> {@link #ACTION_TIME_TICK}
535 * <li> {@link #ACTION_TIME_CHANGED}
536 * <li> {@link #ACTION_TIMEZONE_CHANGED}
537 * <li> {@link #ACTION_BOOT_COMPLETED}
538 * <li> {@link #ACTION_PACKAGE_ADDED}
539 * <li> {@link #ACTION_PACKAGE_CHANGED}
540 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 * <li> {@link #ACTION_PACKAGE_RESTARTED}
542 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000543 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
544 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * <li> {@link #ACTION_UID_REMOVED}
546 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700547 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700548 * <li> {@link #ACTION_POWER_DISCONNECTED}
549 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * </ul>
551 *
552 * <h3>Standard Categories</h3>
553 *
554 * <p>These are the current standard categories that can be used to further
555 * clarify an Intent via {@link #addCategory}.
556 *
557 * <ul>
558 * <li> {@link #CATEGORY_DEFAULT}
559 * <li> {@link #CATEGORY_BROWSABLE}
560 * <li> {@link #CATEGORY_TAB}
561 * <li> {@link #CATEGORY_ALTERNATIVE}
562 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
563 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_HOME}
566 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400568 * <li> {@link #CATEGORY_CAR_DOCK}
569 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500570 * <li> {@link #CATEGORY_LE_DESK_DOCK}
571 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200572 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700573 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800574 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661 * performed on a piece of data.
662 */
663 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900666 * Activity Action: Quick view the data. Launches a quick viewer for
667 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900668 * <p>Activities handling this intent action should handle the vast majority of
669 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700670 * <p>Quick viewers must render the quick view image locally, and must not send
671 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900672 * <p>Input: {@link #getData} is a mandatory content URI of the item to
673 * preview. {@link #getClipData} contains an optional list of content URIs
674 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
675 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700676 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
677 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700678 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900679 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700680 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
684
685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700686 * Used to indicate that some piece of data should be attached to some other
687 * place. For example, image data could be attached to a contact. It is up
688 * to the recipient to decide where the data should be attached; the intent
689 * does not specify the ultimate destination.
690 * <p>Input: {@link #getData} is URI of data to be attached.
691 * <p>Output: nothing.
692 */
693 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
694 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800695
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 /**
697 * Activity Action: Provide explicit editable access to the given data.
698 * <p>Input: {@link #getData} is URI of data to be edited.
699 * <p>Output: nothing.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
706 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
707 * The extras can contain type specific data to pass through to the editing/creating
708 * activity.
709 * <p>Output: The URI of the item that was picked. This must be a content:
710 * URI so that any receiver can access it.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Pick an item from the data, returning what was selected.
717 * <p>Input: {@link #getData} is URI containing a directory of data
718 * (vnd.android.cursor.dir/*) from which to pick an item.
719 * <p>Output: The URI of the item that was picked.
720 */
721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
722 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724 /**
725 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800727 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
728 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
730 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800731 * (value: ShortcutIconResource).</p>
732 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800733 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 * @see #EXTRA_SHORTCUT_INTENT
735 * @see #EXTRA_SHORTCUT_NAME
736 * @see #EXTRA_SHORTCUT_ICON
737 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
742
743 /**
744 * The name of the extra used to define the Intent of a shortcut.
745 *
746 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
751 /**
752 * The name of the extra used to define the name of a shortcut.
753 *
754 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800755 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700756 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
759 /**
760 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
761 *
762 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
767 /**
768 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
769 *
770 * @see #ACTION_CREATE_SHORTCUT
771 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
776 "android.intent.extra.shortcut.ICON_RESOURCE";
777
778 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500779 * An activity that provides a user interface for adjusting application preferences.
780 * Optional but recommended settings for all applications which have settings.
781 */
782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
783 public static final String ACTION_APPLICATION_PREFERENCES
784 = "android.intent.action.APPLICATION_PREFERENCES";
785
786 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700787 * Activity Action: Launch an activity showing the app information.
788 * For applications which install other applications (such as app stores), it is recommended
789 * to handle this action for providing the app information to the user.
790 *
791 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
792 * to be displayed.
793 * <p>Output: Nothing.
794 */
795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
796 public static final String ACTION_SHOW_APP_INFO
797 = "android.intent.action.SHOW_APP_INFO";
798
799 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800800 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700801 *
802 * @see Intent#ACTION_CREATE_SHORTCUT
803 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800804 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
805 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806 */
807 public static class ShortcutIconResource implements Parcelable {
808 /**
809 * The package name of the application containing the icon.
810 */
811 public String packageName;
812
813 /**
814 * The resource name of the icon, including package, name and type.
815 */
816 public String resourceName;
817
818 /**
819 * Creates a new ShortcutIconResource for the specified context and resource
820 * identifier.
821 *
822 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700823 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700825 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700827 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 ShortcutIconResource icon = new ShortcutIconResource();
829 icon.packageName = context.getPackageName();
830 icon.resourceName = context.getResources().getResourceName(resourceId);
831 return icon;
832 }
833
834 /**
835 * Used to read a ShortcutIconResource from a Parcel.
836 */
837 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
838 new Parcelable.Creator<ShortcutIconResource>() {
839
840 public ShortcutIconResource createFromParcel(Parcel source) {
841 ShortcutIconResource icon = new ShortcutIconResource();
842 icon.packageName = source.readString();
843 icon.resourceName = source.readString();
844 return icon;
845 }
846
847 public ShortcutIconResource[] newArray(int size) {
848 return new ShortcutIconResource[size];
849 }
850 };
851
852 /**
853 * No special parcel contents.
854 */
855 public int describeContents() {
856 return 0;
857 }
858
859 public void writeToParcel(Parcel dest, int flags) {
860 dest.writeString(packageName);
861 dest.writeString(resourceName);
862 }
863
864 @Override
865 public String toString() {
866 return resourceName;
867 }
868 }
869
870 /**
871 * Activity Action: Display an activity chooser, allowing the user to pick
872 * what they want to before proceeding. This can be used as an alternative
873 * to the standard activity picker that is displayed by the system when
874 * you try to start an activity with multiple possible matches, with these
875 * differences in behavior:
876 * <ul>
877 * <li>You can specify the title that will appear in the activity chooser.
878 * <li>The user does not have the option to make one of the matching
879 * activities a preferred activity, and all possible activities will
880 * always be shown even if one of them is currently marked as the
881 * preferred activity.
882 * </ul>
883 * <p>
884 * This action should be used when the user will naturally expect to
885 * select an activity in order to proceed. An example if when not to use
886 * it is when the user clicks on a "mailto:" link. They would naturally
887 * expect to go directly to their mail app, so startActivity() should be
888 * called directly: it will
889 * either launch the current preferred app, or put up a dialog allowing the
890 * user to pick an app to use and optionally marking that as preferred.
891 * <p>
892 * In contrast, if the user is selecting a menu item to send a picture
893 * they are viewing to someone else, there are many different things they
894 * may want to do at this point: send it through e-mail, upload it to a
895 * web service, etc. In this case the CHOOSER action should be used, to
896 * always present to the user a list of the things they can do, with a
897 * nice title given by the caller such as "Send this photo with:".
898 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700899 * If you need to grant URI permissions through a chooser, you must specify
900 * the permissions to be granted on the ACTION_CHOOSER Intent
901 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
902 * {@link #setClipData} to specify the URIs to be granted as well as
903 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
904 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
905 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700906 * As a convenience, an Intent of this form can be created with the
907 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700908 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
911 * and can optionally have a {@link #EXTRA_TITLE} field containing the
912 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700913 * <p>
914 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915 */
916 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
917 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
918
919 /**
920 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
921 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700922 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
923 * target intent, also optionally supplying a title. If the target
924 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
925 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
926 * set in the returned chooser intent, with its ClipData set appropriately:
927 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500928 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700929 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 * @param target The Intent that the user will be selecting an activity
931 * to perform.
932 * @param title Optional title that will be displayed in the chooser.
933 * @return Return a new Intent object that you can hand to
934 * {@link Context#startActivity(Intent) Context.startActivity()} and
935 * related methods.
936 */
937 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700938 return createChooser(target, title, null);
939 }
940
941 /**
942 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
943 *
944 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
945 * target intent, also optionally supplying a title. If the target
946 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
947 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
948 * set in the returned chooser intent, with its ClipData set appropriately:
949 * either a direct reflection of {@link #getClipData()} if that is non-null,
950 * or a new ClipData built from {@link #getData()}.</p>
951 *
952 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
953 * when the user makes a choice. This can be useful if the calling application wants
954 * to remember the last chosen target and surface it as a more prominent or one-touch
955 * affordance elsewhere in the UI for next time.</p>
956 *
957 * @param target The Intent that the user will be selecting an activity
958 * to perform.
959 * @param title Optional title that will be displayed in the chooser.
960 * @param sender Optional IntentSender to be called when a choice is made.
961 * @return Return a new Intent object that you can hand to
962 * {@link Context#startActivity(Intent) Context.startActivity()} and
963 * related methods.
964 */
965 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 Intent intent = new Intent(ACTION_CHOOSER);
967 intent.putExtra(EXTRA_INTENT, target);
968 if (title != null) {
969 intent.putExtra(EXTRA_TITLE, title);
970 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700971
Adam Powell0b3c1122014-10-09 12:50:14 -0700972 if (sender != null) {
973 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
974 }
975
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700976 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700977 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
978 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
979 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700980 if (permFlags != 0) {
981 ClipData targetClipData = target.getClipData();
982 if (targetClipData == null && target.getData() != null) {
983 ClipData.Item item = new ClipData.Item(target.getData());
984 String[] mimeTypes;
985 if (target.getType() != null) {
986 mimeTypes = new String[] { target.getType() };
987 } else {
988 mimeTypes = new String[] { };
989 }
990 targetClipData = new ClipData(null, mimeTypes, item);
991 }
992 if (targetClipData != null) {
993 intent.setClipData(targetClipData);
994 intent.addFlags(permFlags);
995 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700996 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700998 return intent;
999 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 /**
1002 * Activity Action: Allow the user to select a particular kind of data and
1003 * return it. This is different than {@link #ACTION_PICK} in that here we
1004 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001005 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001006 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001007 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * etc.
1009 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001010 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 * of data, such as a person contact, you set the MIME type to the kind of
1012 * data you want and launch it with {@link Context#startActivity(Intent)}.
1013 * The system will then launch the best application to select that kind
1014 * of data for you.
1015 * <p>
1016 * You may also be interested in any of a set of types of content the user
1017 * can pick. For example, an e-mail application that wants to allow the
1018 * user to add an attachment to an e-mail message can use this action to
1019 * bring up a list of all of the types of content the user can attach.
1020 * <p>
1021 * In this case, you should wrap the GET_CONTENT intent with a chooser
1022 * (through {@link #createChooser}), which will give the proper interface
1023 * for the user to pick how to send your data and allow you to specify
1024 * a prompt indicating what they are doing. You will usually specify a
1025 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1026 * broad range of content types the user can select from.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * only pick from data that can be represented as a stream. This is
1030 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1031 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001032 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001033 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001034 * is locally available on the device. For example, if this extra is set
1035 * to true then an image picker should not show any pictures that are available
1036 * from a remote server but not already on the local device (thus requiring
1037 * they be downloaded when opened).
1038 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001039 * If the caller can handle multiple returned items (the user performing
1040 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1041 * to indicate this.
1042 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1044 * that no URI is supplied in the intent, as there are no constraints on
1045 * where the returned data originally comes from. You may also include the
1046 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001048 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1049 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001050 * <p>
1051 * Output: The URI of the item that was picked. This must be a content:
1052 * URI so that any receiver can access it.
1053 */
1054 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1055 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1056 /**
1057 * Activity Action: Dial a number as specified by the data. This shows a
1058 * UI with the number being dialed, allowing the user to explicitly
1059 * initiate the call.
1060 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1061 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1062 * number.
1063 * <p>Output: nothing.
1064 */
1065 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1066 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1067 /**
1068 * Activity Action: Perform a call to someone specified by the data.
1069 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1070 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1071 * number.
1072 * <p>Output: nothing.
1073 *
1074 * <p>Note: there will be restrictions on which applications can initiate a
1075 * call; most applications should use the {@link #ACTION_DIAL}.
1076 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1077 * numbers. Applications can <strong>dial</strong> emergency numbers using
1078 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001079 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001080 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001081 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001082 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001083 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_CALL = "android.intent.action.CALL";
1087 /**
1088 * Activity Action: Perform a call to an emergency number specified by the
1089 * data.
1090 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1091 * tel: URI of an explicit phone number.
1092 * <p>Output: nothing.
1093 * @hide
1094 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001095 @SystemApi
1096 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001097 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1098 /**
1099 * Activity action: Perform a call to any number (emergency or not)
1100 * specified by the data.
1101 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1102 * tel: URI of an explicit phone number.
1103 * <p>Output: nothing.
1104 * @hide
1105 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001106 @SystemApi
1107 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001108 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001109
Santos Cordon15a13782015-03-31 18:32:31 -07001110 /**
fionaxuadfe7002017-02-17 17:20:46 -08001111 * Activity Action: Main entry point for carrier setup apps.
1112 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1113 * carrier service and typically require
1114 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1115 * fulfill their duties.
1116 */
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1119 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001120 * Activity Action: Send a message to someone specified by the data.
1121 * <p>Input: {@link #getData} is URI describing the target.
1122 * <p>Output: nothing.
1123 */
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1126 /**
1127 * Activity Action: Deliver some data to someone else. Who the data is
1128 * being delivered to is not specified; it is up to the receiver of this
1129 * action to ask the user where the data should be sent.
1130 * <p>
1131 * When launching a SEND intent, you should usually wrap it in a chooser
1132 * (through {@link #createChooser}), which will give the proper interface
1133 * for the user to pick how to send your data and allow you to specify
1134 * a prompt indicating what they are doing.
1135 * <p>
1136 * Input: {@link #getType} is the MIME type of the data being sent.
1137 * get*Extra can have either a {@link #EXTRA_TEXT}
1138 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1139 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1140 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1141 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001142 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1143 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1144 * your text with HTML formatting.
1145 * <p>
1146 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1147 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1148 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1149 * content: URIs and other advanced features of {@link ClipData}. If
1150 * using this approach, you still must supply the same data through the
1151 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1152 * for compatibility with old applications. If you don't set a ClipData,
1153 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001154 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001155 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1156 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1157 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1158 * be openable only as asset typed files using
1159 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1160 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001161 * Optional standard extras, which may be interpreted by some recipients as
1162 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1163 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1164 * <p>
1165 * Output: nothing.
1166 */
1167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1168 public static final String ACTION_SEND = "android.intent.action.SEND";
1169 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001170 * Activity Action: Deliver multiple data to someone else.
1171 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001172 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001173 * <p>
1174 * Input: {@link #getType} is the MIME type of the data being sent.
1175 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001176 * #EXTRA_STREAM} field, containing the data to be sent. If using
1177 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1178 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001179 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001180 * Multiple types are supported, and receivers should handle mixed types
1181 * whenever possible. The right way for the receiver to check them is to
1182 * use the content resolver on each URI. The intent sender should try to
1183 * put the most concrete mime type in the intent type, but it can fall
1184 * back to {@literal <type>/*} or {@literal *}/* as needed.
1185 * <p>
1186 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1187 * be image/jpg, but if you are sending image/jpg and image/png, then the
1188 * intent's type should be image/*.
1189 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001190 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1191 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1192 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1193 * content: URIs and other advanced features of {@link ClipData}. If
1194 * using this approach, you still must supply the same data through the
1195 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1196 * for compatibility with old applications. If you don't set a ClipData,
1197 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1198 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001199 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1200 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1201 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1202 * be openable only as asset typed files using
1203 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1204 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001205 * Optional standard extras, which may be interpreted by some recipients as
1206 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1207 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1208 * <p>
1209 * Output: nothing.
1210 */
1211 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1212 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1213 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001214 * Activity Action: Handle an incoming phone call.
1215 * <p>Input: nothing.
1216 * <p>Output: nothing.
1217 */
1218 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1220 /**
1221 * Activity Action: Insert an empty item into the given container.
1222 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1223 * in which to place the data.
1224 * <p>Output: URI of the new data that was created.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1228 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001229 * Activity Action: Create a new item in the given container, initializing it
1230 * from the current contents of the clipboard.
1231 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1232 * in which to place the data.
1233 * <p>Output: URI of the new data that was created.
1234 */
1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1237 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001238 * Activity Action: Delete the given data from its container.
1239 * <p>Input: {@link #getData} is URI of data to be deleted.
1240 * <p>Output: nothing.
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1244 /**
1245 * Activity Action: Run the data, whatever that means.
1246 * <p>Input: ? (Note: this is currently specific to the test harness.)
1247 * <p>Output: nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_RUN = "android.intent.action.RUN";
1251 /**
1252 * Activity Action: Perform a data synchronization.
1253 * <p>Input: ?
1254 * <p>Output: ?
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1258 /**
1259 * Activity Action: Pick an activity given an intent, returning the class
1260 * selected.
1261 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1262 * used with {@link PackageManager#queryIntentActivities} to determine the
1263 * set of activities from which to pick.
1264 * <p>Output: Class name of the activity that was selected.
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1268 /**
1269 * Activity Action: Perform a search.
1270 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1271 * is the text to search for. If empty, simply
1272 * enter your search results Activity with the search UI activated.
1273 * <p>Output: nothing.
1274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1277 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001278 * Activity Action: Start the platform-defined tutorial
1279 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1280 * is the text to search for. If empty, simply
1281 * enter your search results Activity with the search UI activated.
1282 * <p>Output: nothing.
1283 */
1284 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1285 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1286 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001287 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001288 * <p>
1289 * Input: {@link android.app.SearchManager#QUERY
1290 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1291 * a url starts with http or https, the site will be opened. If it is plain
1292 * text, Google search will be applied.
1293 * <p>
1294 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001295 */
1296 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1297 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001298
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299 /**
Jim Miller07994402012-05-02 14:22:27 -07001300 * Activity Action: Perform assist action.
1301 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001302 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1303 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001304 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1305 * information.
Jim Miller07994402012-05-02 14:22:27 -07001306 * Output: nothing.
1307 */
1308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001310
1311 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001312 * Activity Action: Perform voice assist action.
1313 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001314 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1315 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001316 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001317 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001318 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001319 */
Amith Yamasani16452032017-03-03 10:15:57 -08001320 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1323
1324 /**
Adam Skory7140a252013-09-11 12:04:58 +01001325 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1326 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001327 */
1328 public static final String EXTRA_ASSIST_PACKAGE
1329 = "android.intent.extra.ASSIST_PACKAGE";
1330
1331 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001332 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1333 * application package at the time the assist was invoked.
1334 */
1335 public static final String EXTRA_ASSIST_UID
1336 = "android.intent.extra.ASSIST_UID";
1337
1338 /**
Adam Skory7140a252013-09-11 12:04:58 +01001339 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1340 * information supplied by the current foreground app at the time of the assist request.
1341 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001342 */
1343 public static final String EXTRA_ASSIST_CONTEXT
1344 = "android.intent.extra.ASSIST_CONTEXT";
1345
Jim Miller07994402012-05-02 14:22:27 -07001346 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001347 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1348 * keyboard as the primary input device for assistance.
1349 */
1350 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1351 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1352
1353 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001354 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1355 * that was used to invoke the assist.
1356 */
1357 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1358 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1359
1360 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001361 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001362 * <p>Input: Nothing.
1363 * <p>Output: nothing.
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1367 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001368 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001369 * <p>Input: Nothing.
1370 * <p>Output: Nothing.
1371 */
1372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1373 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1374
1375 /**
1376 * Activity Action: Show activity for reporting a bug.
1377 * <p>Input: Nothing.
1378 * <p>Output: Nothing.
1379 */
1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1382
1383 /**
1384 * Activity Action: Main entry point for factory tests. Only used when
1385 * the device is booting in factory test node. The implementing package
1386 * must be installed in the system image.
1387 * <p>Input: nothing
1388 * <p>Output: nothing
1389 */
1390 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1391
1392 /**
1393 * Activity Action: The user pressed the "call" button to go to the dialer
1394 * or other appropriate UI for placing a call.
1395 * <p>Input: Nothing.
1396 * <p>Output: Nothing.
1397 */
1398 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1399 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1400
1401 /**
1402 * Activity Action: Start Voice Command.
1403 * <p>Input: Nothing.
1404 * <p>Output: Nothing.
1405 */
1406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1407 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001408
1409 /**
1410 * Activity Action: Start action associated with long pressing on the
1411 * search key.
1412 * <p>Input: Nothing.
1413 * <p>Output: Nothing.
1414 */
1415 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1416 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001417
Jacek Surazski86b6c532009-05-13 14:38:28 +02001418 /**
1419 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1420 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001421 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001422 * <p>Input: No data is specified. The bug report is passed in using
1423 * an {@link #EXTRA_BUG_REPORT} field.
1424 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001425 *
1426 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001430
1431 /**
1432 * Activity Action: Show power usage information to the user.
1433 * <p>Input: Nothing.
1434 * <p>Output: Nothing.
1435 */
1436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1437 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001438
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001439 /**
1440 * Activity Action: Setup wizard to launch after a platform update. This
1441 * activity should have a string meta-data field associated with it,
1442 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1443 * the platform for setup. The activity will be launched only if
1444 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1445 * same value.
1446 * <p>Input: Nothing.
1447 * <p>Output: Nothing.
1448 * @hide
1449 */
1450 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1451 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001452
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001453 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001454 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1455 * <p>Input: Nothing.
1456 * <p>Output: Nothing.
1457 * @hide
1458 */
1459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1460 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001461 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001462
1463 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001464 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1465 * <p>Input: Nothing.
1466 * <p>Output: Nothing.
1467 * @hide
1468 */
1469 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1470 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001471 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001472
1473 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001474 * Activity Action: Show settings for managing network data usage of a
1475 * specific application. Applications should define an activity that offers
1476 * options to control data usage.
1477 */
1478 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1479 public static final String ACTION_MANAGE_NETWORK_USAGE =
1480 "android.intent.action.MANAGE_NETWORK_USAGE";
1481
1482 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001483 * Activity Action: Launch application installer.
1484 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001485 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001486 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1487 * you can also use "package:<package-name>" to install an application for the
1488 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001489 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1490 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1491 * <p>
1492 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1493 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001494 * <p>
1495 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1496 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1497 * in order to launch the application installer.
1498 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001499 *
1500 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1501 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1502 * @see #EXTRA_RETURN_RESULT
1503 */
1504 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1505 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1506
1507 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001508 * Activity Action: Launch ephemeral installer.
1509 * <p>
1510 * Input: The data must be a http: URI that the ephemeral application is registered
1511 * to handle.
1512 * <p class="note">
1513 * This is a protected intent that can only be sent by the system.
1514 * </p>
1515 *
1516 * @hide
1517 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001518 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1519 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1520 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1521
1522 /**
1523 * Service Action: Resolve ephemeral application.
1524 * <p>
1525 * The system will have a persistent connection to this service.
1526 * This is a protected intent that can only be sent by the system.
1527 * </p>
1528 *
1529 * @hide
1530 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001531 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1532 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1533 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1534
1535 /**
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001536 * Activity Action: Launch ephemeral settings.
1537 *
1538 * <p class="note">
1539 * This is a protected intent that can only be sent by the system.
1540 * </p>
1541 *
1542 * @hide
1543 */
1544 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1545 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1546 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1547
1548 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001549 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1550 * package. Specifies the installer package name; this package will receive the
1551 * {@link #ACTION_APP_ERROR} intent.
1552 */
1553 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1554 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1555
1556 /**
1557 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1558 * package. Specifies that the application being installed should not be
1559 * treated as coming from an unknown source, but as coming from the app
1560 * invoking the Intent. For this to work you must start the installer with
1561 * startActivityForResult().
1562 */
1563 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1564 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1565
1566 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001567 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1568 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001569 * data field originated from.
1570 */
rich cannings706e8ba2012-08-20 13:20:14 -07001571 public static final String EXTRA_ORIGINATING_URI
1572 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001573
1574 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001575 * This extra can be used with any Intent used to launch an activity, supplying information
1576 * about who is launching that activity. This field contains a {@link android.net.Uri}
1577 * object, typically an http: or https: URI of the web site that the referral came from;
1578 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1579 * a native application that it came from.
1580 *
1581 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1582 * instead of directly retrieving the extra. It is also valid for applications to
1583 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1584 * a string, not a Uri; the field here, if supplied, will always take precedence,
1585 * however.</p>
1586 *
1587 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001588 */
1589 public static final String EXTRA_REFERRER
1590 = "android.intent.extra.REFERRER";
1591
1592 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001593 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1594 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1595 * not be created, in particular when Intent extras are supplied through the
1596 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1597 * schemes.
1598 *
1599 * @see #EXTRA_REFERRER
1600 */
1601 public static final String EXTRA_REFERRER_NAME
1602 = "android.intent.extra.REFERRER_NAME";
1603
1604 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001605 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001606 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001607 * @hide
1608 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001609 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001610 public static final String EXTRA_ORIGINATING_UID
1611 = "android.intent.extra.ORIGINATING_UID";
1612
1613 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001614 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1615 * package. Tells the installer UI to skip the confirmation with the user
1616 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001617 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1618 * will no longer show an interstitial message about updating existing
1619 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001620 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001621 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001622 public static final String EXTRA_ALLOW_REPLACE
1623 = "android.intent.extra.ALLOW_REPLACE";
1624
1625 /**
1626 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1627 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1628 * return to the application the result code of the install/uninstall. The returned result
1629 * code will be {@link android.app.Activity#RESULT_OK} on success or
1630 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1631 */
1632 public static final String EXTRA_RETURN_RESULT
1633 = "android.intent.extra.RETURN_RESULT";
1634
1635 /**
1636 * Package manager install result code. @hide because result codes are not
1637 * yet ready to be exposed.
1638 */
1639 public static final String EXTRA_INSTALL_RESULT
1640 = "android.intent.extra.INSTALL_RESULT";
1641
1642 /**
1643 * Activity Action: Launch application uninstaller.
1644 * <p>
1645 * Input: The data must be a package: URI whose scheme specific part is
1646 * the package name of the current installed package to be uninstalled.
1647 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1648 * <p>
1649 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1650 * succeeded.
1651 */
1652 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1653 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1654
1655 /**
msnider3c191b82017-01-23 14:23:16 -08001656 * Activity Action: Launch application uninstaller.
1657 * <p>
1658 * Input: The data must be a package: URI whose scheme specific part is
1659 * the package name of the current installed package to be uninstalled.
1660 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1661 * <p>
1662 * Output: Nothing.
1663 * </p>
1664 */
1665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1666 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1667
1668 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001669 * Specify whether the package should be uninstalled for all users.
1670 * @hide because these should not be part of normal application flow.
1671 */
1672 public static final String EXTRA_UNINSTALL_ALL_USERS
1673 = "android.intent.extra.UNINSTALL_ALL_USERS";
1674
1675 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001676 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1677 * describing the last run version of the platform that was setup.
1678 * @hide
1679 */
1680 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1681
Svet Ganov3695b8a2015-03-24 16:30:25 -07001682 /**
1683 * Activity action: Launch UI to manage the permissions of an app.
1684 * <p>
1685 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1686 * will be managed by the launched UI.
1687 * </p>
1688 * <p>
1689 * Output: Nothing.
1690 * </p>
1691 *
1692 * @see #EXTRA_PACKAGE_NAME
1693 *
1694 * @hide
1695 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001696 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001697 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1698 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1699 "android.intent.action.MANAGE_APP_PERMISSIONS";
1700
1701 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001702 * Activity action: Launch UI to manage permissions.
1703 * <p>
1704 * Input: Nothing.
1705 * </p>
1706 * <p>
1707 * Output: Nothing.
1708 * </p>
1709 *
1710 * @hide
1711 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001712 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1714 public static final String ACTION_MANAGE_PERMISSIONS =
1715 "android.intent.action.MANAGE_PERMISSIONS";
1716
1717 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001718 * Activity action: Launch UI to review permissions for an app.
1719 * The system uses this intent if permission review for apps not
1720 * supporting the new runtime permissions model is enabled. In
1721 * this mode a permission review is required before any of the
1722 * app components can run.
1723 * <p>
1724 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1725 * permissions will be reviewed (mandatory).
1726 * </p>
1727 * <p>
1728 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1729 * be fired after the permission review (optional).
1730 * </p>
1731 * <p>
1732 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1733 * be invoked after the permission review (optional).
1734 * </p>
1735 * <p>
1736 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1737 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1738 * </p>
1739 * <p>
1740 * Output: Nothing.
1741 * </p>
1742 *
1743 * @see #EXTRA_PACKAGE_NAME
1744 * @see #EXTRA_INTENT
1745 * @see #EXTRA_REMOTE_CALLBACK
1746 * @see #EXTRA_RESULT_NEEDED
1747 *
1748 * @hide
1749 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001750 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001751 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1752 public static final String ACTION_REVIEW_PERMISSIONS =
1753 "android.intent.action.REVIEW_PERMISSIONS";
1754
1755 /**
1756 * Intent extra: A callback for reporting remote result as a bundle.
1757 * <p>
1758 * Type: IRemoteCallback
1759 * </p>
1760 *
1761 * @hide
1762 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001763 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001764 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1765
1766 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001767 * Intent extra: An app package name.
1768 * <p>
1769 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001770 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001771 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001772 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001773 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1774
1775 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001776 * Intent extra: An app split name.
1777 * <p>
1778 * Type: String
1779 * </p>
1780 * @hide
1781 */
1782 @SystemApi
1783 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1784
1785 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001786 * Intent extra: An extra for specifying whether a result is needed.
1787 * <p>
1788 * Type: boolean
1789 * </p>
1790 *
1791 * @hide
1792 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001793 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001794 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1795
1796 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001797 * Activity action: Launch UI to manage which apps have a given permission.
1798 * <p>
1799 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1800 * to which will be managed by the launched UI.
1801 * </p>
1802 * <p>
1803 * Output: Nothing.
1804 * </p>
1805 *
1806 * @see #EXTRA_PERMISSION_NAME
1807 *
1808 * @hide
1809 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001810 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001811 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1812 public static final String ACTION_MANAGE_PERMISSION_APPS =
1813 "android.intent.action.MANAGE_PERMISSION_APPS";
1814
1815 /**
1816 * Intent extra: The name of a permission.
1817 * <p>
1818 * Type: String
1819 * </p>
1820 *
1821 * @hide
1822 */
1823 @SystemApi
1824 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1825
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001826 // ---------------------------------------------------------------------
1827 // ---------------------------------------------------------------------
1828 // Standard intent broadcast actions (see action variable).
1829
1830 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001831 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1832 * <p>
1833 * For historical reasons, the name of this broadcast action refers to the power
1834 * state of the screen but it is actually sent in response to changes in the
1835 * overall interactive state of the device.
1836 * </p><p>
1837 * This broadcast is sent when the device becomes non-interactive which may have
1838 * nothing to do with the screen turning off. To determine the
1839 * actual state of the screen, use {@link android.view.Display#getState}.
1840 * </p><p>
1841 * See {@link android.os.PowerManager#isInteractive} for details.
1842 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001843 * You <em>cannot</em> receive this through components declared in
1844 * manifests, only by explicitly registering for it with
1845 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1846 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001847 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001848 * <p class="note">This is a protected intent that can only be sent
1849 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001850 */
1851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1852 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001853
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001854 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001855 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1856 * <p>
1857 * For historical reasons, the name of this broadcast action refers to the power
1858 * state of the screen but it is actually sent in response to changes in the
1859 * overall interactive state of the device.
1860 * </p><p>
1861 * This broadcast is sent when the device becomes interactive which may have
1862 * nothing to do with the screen turning on. To determine the
1863 * actual state of the screen, use {@link android.view.Display#getState}.
1864 * </p><p>
1865 * See {@link android.os.PowerManager#isInteractive} for details.
1866 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001867 * You <em>cannot</em> receive this through components declared in
1868 * manifests, only by explicitly registering for it with
1869 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1870 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001871 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001872 * <p class="note">This is a protected intent that can only be sent
1873 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001874 */
1875 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1876 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001877
1878 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001879 * Broadcast Action: Sent after the system stops dreaming.
1880 *
1881 * <p class="note">This is a protected intent that can only be sent by the system.
1882 * It is only sent to registered receivers.</p>
1883 */
1884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1885 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1886
1887 /**
1888 * Broadcast Action: Sent after the system starts dreaming.
1889 *
1890 * <p class="note">This is a protected intent that can only be sent by the system.
1891 * It is only sent to registered receivers.</p>
1892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1894 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1895
1896 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001897 * 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 -07001898 * keyguard is gone).
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 Projectb2a3dd82009-03-09 11:52:12 -07001902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001904 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001906 /**
1907 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001908 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001909 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001910 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1911 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001912 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001913 * <p class="note">This is a protected intent that can only be sent
1914 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001915 */
1916 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1917 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1918 /**
1919 * Broadcast Action: The time was set.
1920 */
1921 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1922 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1923 /**
1924 * Broadcast Action: The date has changed.
1925 */
1926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1927 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1928 /**
1929 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1930 * <ul>
1931 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1932 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001933 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001934 * <p class="note">This is a protected intent that can only be sent
1935 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001936 */
1937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1938 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1939 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001940 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1941 * DNS entries should be tossed.
1942 * @hide
1943 */
1944 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1945 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1946 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001947 * Alarm Changed Action: This is broadcast when the AlarmClock
1948 * application's alarm is set or unset. It is used by the
1949 * AlarmClock application and the StatusBar service.
1950 * @hide
1951 */
1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001954
1955 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001956 * Broadcast Action: This is broadcast once, after the user has finished
1957 * booting, but while still in the "locked" state. It can be used to perform
1958 * application-specific initialization, such as installing alarms. You must
1959 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1960 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001961 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001962 * This broadcast is sent immediately at boot by all devices (regardless of
1963 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1964 * higher. Upon receipt of this broadcast, the user is still locked and only
1965 * device-protected storage can be accessed safely. If you want to access
1966 * credential-protected storage, you need to wait for the user to be
1967 * unlocked (typically by entering their lock pattern or PIN for the first
1968 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1969 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1970 * <p>
1971 * To receive this broadcast, your receiver component must be marked as
1972 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001973 * <p class="note">
1974 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001975 *
1976 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1979 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1980
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001981 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001982 * Broadcast Action: This is broadcast once, after the user has finished
1983 * booting. It can be used to perform application-specific initialization,
1984 * such as installing alarms. You must hold the
1985 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1986 * order to receive this broadcast.
1987 * <p>
1988 * This broadcast is sent at boot by all devices (both with and without
1989 * direct boot support). Upon receipt of this broadcast, the user is
1990 * unlocked and both device-protected and credential-protected storage can
1991 * accessed safely.
1992 * <p>
1993 * If you need to run while the user is still locked (before they've entered
1994 * their lock pattern or PIN for the first time), you can listen for the
1995 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1996 * <p class="note">
1997 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001998 */
1999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002000 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002001 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002002
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002003 /**
2004 * Broadcast Action: This is broadcast when a user action should request a
2005 * temporary system dialog to dismiss. Some examples of temporary system
2006 * dialogs are the notification window-shade and the recent tasks dialog.
2007 */
2008 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2009 /**
2010 * Broadcast Action: Trigger the download and eventual installation
2011 * of a package.
2012 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002013 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002014 * <p class="note">This is a protected intent that can only be sent
2015 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002016 *
2017 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002018 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002019 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2022 /**
2023 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002024 * device. The data contains the name of the package. Note that the
2025 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002026 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002027 * <ul>
2028 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2029 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2030 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2031 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002032 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2038 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002039 * Broadcast Action: A new version of an application package has been
2040 * installed, replacing an existing version that was previously installed.
2041 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002042 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002043 * <ul>
2044 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2045 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002046 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002047 * <p class="note">This is a protected intent that can only be sent
2048 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002049 */
2050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2051 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2052 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002053 * Broadcast Action: A new version of your application has been installed
2054 * over an existing one. This is only sent to the application that was
2055 * replaced. It does not contain any additional data; to receive it, just
2056 * use an intent filter for this action.
2057 *
2058 * <p class="note">This is a protected intent that can only be sent
2059 * by the system.
2060 */
2061 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2062 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2063 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002064 * Broadcast Action: An existing application package has been removed from
2065 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002066 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002067 * <ul>
2068 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2069 * to the package.
2070 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2071 * application -- data and code -- is being removed.
2072 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2073 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2074 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002075 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002076 * <p class="note">This is a protected intent that can only be sent
2077 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002078 */
2079 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2080 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2081 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002082 * Broadcast Action: An existing application package has been completely
2083 * removed from the device. The data contains the name of the package.
2084 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2085 * {@link #EXTRA_DATA_REMOVED} is true and
2086 * {@link #EXTRA_REPLACING} is false of that broadcast.
2087 *
2088 * <ul>
2089 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2090 * to the package.
2091 * </ul>
2092 *
2093 * <p class="note">This is a protected intent that can only be sent
2094 * by the system.
2095 */
2096 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2097 public static final String ACTION_PACKAGE_FULLY_REMOVED
2098 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2099 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002100 * Broadcast Action: An existing application package has been changed (for
2101 * example, a component has been enabled or disabled). The data contains
2102 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002103 * <ul>
2104 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002105 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002106 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002107 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2108 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002109 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002110 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002111 * <p class="note">This is a protected intent that can only be sent
2112 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 */
2114 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2115 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2116 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002117 * @hide
2118 * Broadcast Action: Ask system services if there is any reason to
2119 * restart the given package. The data contains the name of the
2120 * package.
2121 * <ul>
2122 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2123 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2124 * </ul>
2125 *
2126 * <p class="note">This is a protected intent that can only be sent
2127 * by the system.
2128 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002129 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2131 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2132 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 * Broadcast Action: The user has restarted a package, and all of its
2134 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002135 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002136 * be removed. Note that the restarted package does <em>not</em>
2137 * receive this broadcast.
2138 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002139 * <ul>
2140 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2141 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002142 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002143 * <p class="note">This is a protected intent that can only be sent
2144 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002145 */
2146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2147 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2148 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002149 * Broadcast Action: The user has cleared the data of a package. This should
2150 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002151 * its persistent data is erased and this broadcast sent.
2152 * Note that the cleared package does <em>not</em>
2153 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002154 * <ul>
2155 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2156 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002157 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002158 * <p class="note">This is a protected intent that can only be sent
2159 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002160 */
2161 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2162 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2163 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002164 * Broadcast Action: Packages have been suspended.
2165 * <p>Includes the following extras:
2166 * <ul>
2167 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2168 * </ul>
2169 *
2170 * <p class="note">This is a protected intent that can only be sent
2171 * by the system. It is only sent to registered receivers.
2172 */
2173 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2174 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2175 /**
2176 * Broadcast Action: Packages have been unsuspended.
2177 * <p>Includes the following extras:
2178 * <ul>
2179 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2180 * </ul>
2181 *
2182 * <p class="note">This is a protected intent that can only be sent
2183 * by the system. It is only sent to registered receivers.
2184 */
2185 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2186 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2187 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002188 * Broadcast Action: A user ID has been removed from the system. The user
2189 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002190 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002191 * <p class="note">This is a protected intent that can only be sent
2192 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002193 */
2194 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2195 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002196
2197 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002198 * Broadcast Action: Sent to the installer package of an application when
2199 * that application is first launched (that is the first time it is moved
2200 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002201 *
2202 * <p class="note">This is a protected intent that can only be sent
2203 * by the system.
2204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2207
2208 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002209 * Broadcast Action: Sent to the system package verifier when a package
2210 * needs to be verified. The data contains the package URI.
2211 * <p class="note">
2212 * This is a protected intent that can only be sent by the system.
2213 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2216 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2217
2218 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002219 * Broadcast Action: Sent to the system package verifier when a package is
2220 * verified. The data contains the package URI.
2221 * <p class="note">
2222 * This is a protected intent that can only be sent by the system.
2223 */
2224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2225 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2226
2227 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002228 * Broadcast Action: Sent to the system intent filter verifier when an
2229 * intent filter needs to be verified. The data contains the filter data
2230 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002231 * <p class="note">
2232 * This is a protected intent that can only be sent by the system.
2233 * </p>
2234 *
2235 * @hide
2236 */
2237 @SystemApi
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2240
2241 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002242 * Broadcast Action: Resources for a set of packages (which were
2243 * previously unavailable) are currently
2244 * available since the media on which they exist is available.
2245 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2246 * list of packages whose availability changed.
2247 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2248 * list of uids of packages whose availability changed.
2249 * Note that the
2250 * packages in this list do <em>not</em> receive this broadcast.
2251 * The specified set of packages are now available on the system.
2252 * <p>Includes the following extras:
2253 * <ul>
2254 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2255 * whose resources(were previously unavailable) are currently available.
2256 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2257 * packages whose resources(were previously unavailable)
2258 * are currently available.
2259 * </ul>
2260 *
2261 * <p class="note">This is a protected intent that can only be sent
2262 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002263 */
2264 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002265 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2266 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002267
2268 /**
2269 * Broadcast Action: Resources for a set of packages are currently
2270 * unavailable since the media on which they exist is unavailable.
2271 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2272 * list of packages whose availability changed.
2273 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2274 * list of uids of packages whose availability changed.
2275 * The specified set of packages can no longer be
2276 * launched and are practically unavailable on the system.
2277 * <p>Inclues the following extras:
2278 * <ul>
2279 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2280 * whose resources are no longer available.
2281 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2282 * whose resources are no longer available.
2283 * </ul>
2284 *
2285 * <p class="note">This is a protected intent that can only be sent
2286 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002287 */
2288 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002289 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002290 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002291
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002292 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002293 * Broadcast Action: preferred activities have changed *explicitly*.
2294 *
2295 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2296 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2297 * be sent.
2298 *
2299 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2300 *
2301 * @hide
2302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2305 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2306
2307
2308 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002309 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002310 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002311 * This should <em>only</em> be used to determine when the wallpaper
2312 * has changed to show the new wallpaper to the user. You should certainly
2313 * never, in response to this, change the wallpaper or other attributes of
2314 * it such as the suggested size. That would be crazy, right? You'd cause
2315 * all kinds of loops, especially if other apps are doing similar things,
2316 * right? Of course. So please don't do this.
2317 *
2318 * @deprecated Modern applications should use
2319 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2320 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2321 * shown behind their UI, rather than watching for this broadcast and
2322 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002323 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002324 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002325 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2326 /**
2327 * Broadcast Action: The current device {@link android.content.res.Configuration}
2328 * (orientation, locale, etc) has changed. When such a change happens, the
2329 * UIs (view hierarchy) will need to be rebuilt based on this new
2330 * information; for the most part, applications don't need to worry about
2331 * this, because the system will take care of stopping and restarting the
2332 * application to make sure it sees the new changes. Some system code that
2333 * can not be restarted will need to watch for this action and handle it
2334 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002335 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002336 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002337 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002338 * in manifests, only by explicitly registering for it with
2339 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2340 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002341 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002342 * <p class="note">This is a protected intent that can only be sent
2343 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002344 *
2345 * @see android.content.res.Configuration
2346 */
2347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2348 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2349 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002350 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002351 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002352 * <p class="note">This is a protected intent that can only be sent
2353 * by the system.
2354 */
2355 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2356 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2357 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002358 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2359 * charging state, level, and other information about the battery.
2360 * See {@link android.os.BatteryManager} for documentation on the
2361 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002362 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002363 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002364 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002365 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002366 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002367 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2368 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2369 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2370 * broadcasts that are sent and can be received through manifest
2371 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002372 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002373 * <p class="note">This is a protected intent that can only be sent
2374 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002375 */
2376 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2377 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2378 /**
2379 * Broadcast Action: Indicates low battery condition on the device.
2380 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002381 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002382 * <p class="note">This is a protected intent that can only be sent
2383 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002384 */
2385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2386 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2387 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002388 * Broadcast Action: Indicates the battery is now okay after being low.
2389 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2390 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002391 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002392 * <p class="note">This is a protected intent that can only be sent
2393 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002394 */
2395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2396 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2397 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002398 * Broadcast Action: External power has been connected to the device.
2399 * This is intended for applications that wish to register specifically to this notification.
2400 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2401 * stay active to receive this notification. This action can be used to implement actions
2402 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002403 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002404 * <p class="note">This is a protected intent that can only be sent
2405 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002406 */
2407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002408 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002409 /**
2410 * Broadcast Action: External power has been removed from the device.
2411 * This is intended for applications that wish to register specifically to this notification.
2412 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2413 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002414 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002415 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002416 * <p class="note">This is a protected intent that can only be sent
2417 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002418 */
2419 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002420 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002421 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002422 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002423 * Broadcast Action: Device is shutting down.
2424 * This is broadcast when the device is being shut down (completely turned
2425 * off, not sleeping). Once the broadcast is complete, the final shutdown
2426 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002427 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002428 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002429 * <p class="note">This is a protected intent that can only be sent
2430 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002431 * <p>May include the following extras:
2432 * <ul>
2433 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2434 * shutdown is only for userspace processes. If not set, assumed to be false.
2435 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002438 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002439 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002440 * Activity Action: Start this activity to request system shutdown.
2441 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002442 * to request confirmation from the user before shutting down. The optional boolean
2443 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2444 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002445 *
2446 * <p class="note">This is a protected intent that can only be sent
2447 * by the system.
2448 *
2449 * {@hide}
2450 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002451 public static final String ACTION_REQUEST_SHUTDOWN
2452 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002453 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002454 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002455 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002456 * <p class="note">
2457 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002458 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002459 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2460 * or above, this broadcast will no longer be delivered to any
2461 * {@link BroadcastReceiver} defined in your manifest. Instead,
2462 * apps are strongly encouraged to use the improved
2463 * {@link Context#getCacheDir()} behavior so the system can
2464 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 */
2466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002467 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2469 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002470 * Broadcast Action: Indicates low storage space condition on the device no
2471 * longer exists
2472 * <p class="note">
2473 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002474 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002475 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2476 * or above, this broadcast will no longer be delivered to any
2477 * {@link BroadcastReceiver} defined in your manifest. Instead,
2478 * apps are strongly encouraged to use the improved
2479 * {@link Context#getCacheDir()} behavior so the system can
2480 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002481 */
2482 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002483 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002484 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2485 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002486 * Broadcast Action: A sticky broadcast that indicates a storage space full
2487 * condition on the device. This is intended for activities that want to be
2488 * able to fill the data partition completely, leaving only enough free
2489 * space to prevent system-wide SQLite failures.
2490 * <p class="note">
2491 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002492 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002493 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2494 * or above, this broadcast will no longer be delivered to any
2495 * {@link BroadcastReceiver} defined in your manifest. Instead,
2496 * apps are strongly encouraged to use the improved
2497 * {@link Context#getCacheDir()} behavior so the system can
2498 * automatically free up storage when needed.
2499 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002502 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002503 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2504 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002505 * Broadcast Action: Indicates storage space full condition on the device no
2506 * longer exists.
2507 * <p class="note">
2508 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002509 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002510 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2511 * or above, this broadcast will no longer be delivered to any
2512 * {@link BroadcastReceiver} defined in your manifest. Instead,
2513 * apps are strongly encouraged to use the improved
2514 * {@link Context#getCacheDir()} behavior so the system can
2515 * automatically free up storage when needed.
2516 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002517 */
2518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002519 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002520 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2521 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002522 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2523 * and package management should be started.
2524 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2525 * notification.
2526 */
2527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2528 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2529 /**
2530 * Broadcast Action: The device has entered USB Mass Storage mode.
2531 * This is used mainly for the USB Settings panel.
2532 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2533 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002534 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002535 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002536 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002537 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2538
2539 /**
2540 * Broadcast Action: The device has exited USB Mass Storage mode.
2541 * This is used mainly for the USB Settings panel.
2542 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2543 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002544 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002546 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2548
2549 /**
2550 * Broadcast Action: External media has been removed.
2551 * The path to the mount point for the removed media is contained in the Intent.mData field.
2552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2554 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2555
2556 /**
2557 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002558 * 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 -07002559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2562
2563 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002564 * Broadcast Action: External media is present, and being disk-checked
2565 * 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 -08002566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2569
2570 /**
2571 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2572 * 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 -08002573 */
2574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2575 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2576
2577 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002578 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002579 * 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 -07002580 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2581 * media was mounted read only.
2582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2584 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2585
2586 /**
2587 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002588 * 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 -07002589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2592
2593 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002594 * Broadcast Action: External media is no longer being shared via USB mass storage.
2595 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2596 *
2597 * @hide
2598 */
2599 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2600
2601 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002602 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
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_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2607
2608 /**
2609 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002610 * 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 -07002611 */
2612 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2613 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2614
2615 /**
2616 * Broadcast Action: User has expressed the desire to remove the external storage media.
2617 * Applications should close all files they have open within the mount point when they receive this intent.
2618 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2622
2623 /**
2624 * Broadcast Action: The media scanner has started scanning a directory.
2625 * The path to the directory being scanned is contained in the Intent.mData field.
2626 */
2627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2629
2630 /**
2631 * Broadcast Action: The media scanner has finished scanning a directory.
2632 * The path to the scanned directory is contained in the Intent.mData field.
2633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2636
2637 /**
2638 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2639 * The path to the file is contained in the Intent.mData field.
2640 */
2641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2642 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2643
2644 /**
2645 * Broadcast Action: The "Media Button" was pressed. Includes a single
2646 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2647 * caused the broadcast.
2648 */
2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2651
2652 /**
2653 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2654 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2655 * caused the broadcast.
2656 */
2657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2658 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2659
2660 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2661 // location; they are not general-purpose actions.
2662
2663 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002664 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002665 */
2666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2667 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2668 "android.intent.action.GTALK_CONNECTED";
2669
2670 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002671 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002672 */
2673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2674 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2675 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002676
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002677 /**
2678 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002679 */
2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2681 public static final String ACTION_INPUT_METHOD_CHANGED =
2682 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002683
2684 /**
2685 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2686 * more radios have been turned off or on. The intent will have the following extra value:</p>
2687 * <ul>
2688 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2689 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2690 * turned off</li>
2691 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002692 *
Peng Xua35b5532016-01-20 00:05:45 -08002693 * <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 -07002694 */
2695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2696 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2697
2698 /**
2699 * Broadcast Action: Some content providers have parts of their namespace
2700 * where they publish new events or items that the user may be especially
2701 * interested in. For these things, they may broadcast this action when the
2702 * set of interesting items change.
2703 *
2704 * For example, GmailProvider sends this notification when the set of unread
2705 * mail in the inbox changes.
2706 *
2707 * <p>The data of the intent identifies which part of which provider
2708 * changed. When queried through the content resolver, the data URI will
2709 * return the data set in question.
2710 *
2711 * <p>The intent will have the following extra values:
2712 * <ul>
2713 * <li><em>count</em> - The number of items in the data set. This is the
2714 * same as the number of items in the cursor returned by querying the
2715 * data URI. </li>
2716 * </ul>
2717 *
2718 * This intent will be sent at boot (if the count is non-zero) and when the
2719 * data set changes. It is possible for the data set to change without the
2720 * count changing (for example, if a new unread message arrives in the same
2721 * sync operation in which a message is archived). The phone should still
2722 * ring/vibrate/etc as normal in this case.
2723 */
2724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2725 public static final String ACTION_PROVIDER_CHANGED =
2726 "android.intent.action.PROVIDER_CHANGED";
2727
2728 /**
2729 * Broadcast Action: Wired Headset plugged in or unplugged.
2730 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002731 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2732 * and documentation.
2733 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002734 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002735 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002738 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002739
2740 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002741 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2742 * <ul>
2743 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2744 * </ul>
2745 *
2746 * <p class="note">This is a protected intent that can only be sent
2747 * by the system.
2748 *
2749 * @hide
2750 */
2751 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2752 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2753 = "android.intent.action.ADVANCED_SETTINGS";
2754
2755 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002756 * Broadcast Action: Sent after application restrictions are changed.
2757 *
2758 * <p class="note">This is a protected intent that can only be sent
2759 * by the system.</p>
2760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2763 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2764
2765 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002766 * Broadcast Action: An outgoing call is about to be placed.
2767 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002768 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002770 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002771 * the phone number originally intended to be dialed.</li>
2772 * </ul>
2773 * <p>Once the broadcast is finished, the resultData is used as the actual
2774 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002775 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002776 * outgoing call in turn: for example, a parental control application
2777 * might verify that the user is authorized to place the call at that
2778 * time, then a number-rewriting application might add an area code if
2779 * one was not specified.</p>
2780 * <p>For consistency, any receiver whose purpose is to prohibit phone
2781 * calls should have a priority of 0, to ensure it will see the final
2782 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002783 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002784 * should have a positive priority.
2785 * Negative priorities are reserved for the system for this broadcast;
2786 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002787 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2788 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002789 * <p>Emergency calls cannot be intercepted using this mechanism, and
2790 * other calls cannot be modified to call emergency numbers using this
2791 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002792 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2793 * call to use their own service instead. Those apps should first prevent
2794 * the call from being placed by setting resultData to <code>null</code>
2795 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002796 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002797 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2798 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002799 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002800 * <p class="note">This is a protected intent that can only be sent
2801 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 */
2803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2804 public static final String ACTION_NEW_OUTGOING_CALL =
2805 "android.intent.action.NEW_OUTGOING_CALL";
2806
2807 /**
2808 * Broadcast Action: Have the device reboot. This is only for use by
2809 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002810 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002811 * <p class="note">This is a protected intent that can only be sent
2812 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 */
2814 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2815 public static final String ACTION_REBOOT =
2816 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002817
Wei Huang97ecc9c2009-05-11 17:44:20 -07002818 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002819 * Broadcast Action: A sticky broadcast for changes in the physical
2820 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002821 *
2822 * <p>The intent will have the following extra values:
2823 * <ul>
2824 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002825 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002826 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002827 * <p>This is intended for monitoring the current physical dock state.
2828 * See {@link android.app.UiModeManager} for the normal API dealing with
2829 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002830 */
2831 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_DOCK_EVENT =
2833 "android.intent.action.DOCK_EVENT";
2834
2835 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002836 * Broadcast Action: A broadcast when idle maintenance can be started.
2837 * This means that the user is not interacting with the device and is
2838 * not expected to do so soon. Typical use of the idle maintenance is
2839 * to perform somehow expensive tasks that can be postponed at a moment
2840 * when they will not degrade user experience.
2841 * <p>
2842 * <p class="note">In order to keep the device responsive in case of an
2843 * unexpected user interaction, implementations of a maintenance task
2844 * should be interruptible. In such a scenario a broadcast with action
2845 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2846 * should not do the maintenance work in
2847 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2848 * maintenance service by {@link Context#startService(Intent)}. Also
2849 * you should hold a wake lock while your maintenance service is running
2850 * to prevent the device going to sleep.
2851 * </p>
2852 * <p>
2853 * <p class="note">This is a protected intent that can only be sent by
2854 * the system.
2855 * </p>
2856 *
2857 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002858 *
2859 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002860 */
2861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2862 public static final String ACTION_IDLE_MAINTENANCE_START =
2863 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2864
2865 /**
2866 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2867 * This means that the user was not interacting with the device as a result
2868 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2869 * was sent and now the user started interacting with the device. Typical
2870 * use of the idle maintenance is to perform somehow expensive tasks that
2871 * can be postponed at a moment when they will not degrade user experience.
2872 * <p>
2873 * <p class="note">In order to keep the device responsive in case of an
2874 * unexpected user interaction, implementations of a maintenance task
2875 * should be interruptible. Hence, on receiving a broadcast with this
2876 * action, the maintenance task should be interrupted as soon as possible.
2877 * In other words, you should not do the maintenance work in
2878 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2879 * maintenance service that was started on receiving of
2880 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2881 * lock you acquired when your maintenance service started.
2882 * </p>
2883 * <p class="note">This is a protected intent that can only be sent
2884 * by the system.
2885 *
2886 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002887 *
2888 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002889 */
2890 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2891 public static final String ACTION_IDLE_MAINTENANCE_END =
2892 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2893
2894 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002895 * Broadcast Action: a remote intent is to be broadcasted.
2896 *
2897 * A remote intent is used for remote RPC between devices. The remote intent
2898 * is serialized and sent from one device to another device. The receiving
2899 * device parses the remote intent and broadcasts it. Note that anyone can
2900 * broadcast a remote intent. However, if the intent receiver of the remote intent
2901 * does not trust intent broadcasts from arbitrary intent senders, it should require
2902 * the sender to hold certain permissions so only trusted sender's broadcast will be
2903 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002904 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002905 */
2906 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002907 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002908
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002909 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002910 * Broadcast Action: This is broadcast once when the user is booting after a
2911 * system update. It can be used to perform cleanup or upgrades after a
2912 * system update.
2913 * <p>
2914 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2915 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2916 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2917 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002918 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002919 * @hide
2920 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002921 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002922 public static final String ACTION_PRE_BOOT_COMPLETED =
2923 "android.intent.action.PRE_BOOT_COMPLETED";
2924
Amith Yamasani13593602012-03-22 16:16:17 -07002925 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002926 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002927 * on restricted users. The broadcast intent contains an extra
2928 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2929 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2930 * String[] depending on the restriction type.<p/>
2931 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002932 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2933 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2934 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002935 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2936 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002937 * @see RestrictionEntry
2938 */
2939 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2940 "android.intent.action.GET_RESTRICTION_ENTRIES";
2941
2942 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002943 * Sent the first time a user is starting, to allow system apps to
2944 * perform one time initialization. (This will not be seen by third
2945 * party applications because a newly initialized user does not have any
2946 * third party applications installed for it.) This is sent early in
2947 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002948 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2949 * broadcast, since it is part of a visible user interaction; be as quick
2950 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002951 */
2952 public static final String ACTION_USER_INITIALIZE =
2953 "android.intent.action.USER_INITIALIZE";
2954
2955 /**
2956 * Sent when a user switch is happening, causing the process's user to be
2957 * brought to the foreground. This is only sent to receivers registered
2958 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2959 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002960 * foreground. This is sent as a foreground
2961 * broadcast, since it is part of a visible user interaction; be as quick
2962 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002963 */
2964 public static final String ACTION_USER_FOREGROUND =
2965 "android.intent.action.USER_FOREGROUND";
2966
2967 /**
2968 * Sent when a user switch is happening, causing the process's user to be
2969 * sent to the background. This is only sent to receivers registered
2970 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2971 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002972 * background. This is sent as a foreground
2973 * broadcast, since it is part of a visible user interaction; be as quick
2974 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002975 */
2976 public static final String ACTION_USER_BACKGROUND =
2977 "android.intent.action.USER_BACKGROUND";
2978
2979 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002980 * Broadcast sent to the system when a user is added. Carries an extra
2981 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2982 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002983 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002984 * @hide
2985 */
2986 public static final String ACTION_USER_ADDED =
2987 "android.intent.action.USER_ADDED";
2988
2989 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002990 * Broadcast sent by the system when a user is started. Carries an extra
2991 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002992 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002993 * that has been started. This is sent as a foreground
2994 * broadcast, since it is part of a visible user interaction; be as quick
2995 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002996 * @hide
2997 */
2998 public static final String ACTION_USER_STARTED =
2999 "android.intent.action.USER_STARTED";
3000
3001 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003002 * Broadcast sent when a user is in the process of starting. Carries an extra
3003 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3004 * sent to registered receivers, not manifest receivers. It is sent to all
3005 * users (including the one that is being started). You must hold
3006 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3007 * this broadcast. This is sent as a background broadcast, since
3008 * its result is not part of the primary UX flow; to safely keep track of
3009 * started/stopped state of a user you can use this in conjunction with
3010 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3011 * other user state broadcasts since those are foreground broadcasts so can
3012 * execute in a different order.
3013 * @hide
3014 */
3015 public static final String ACTION_USER_STARTING =
3016 "android.intent.action.USER_STARTING";
3017
3018 /**
3019 * Broadcast sent when a user is going to be stopped. Carries an extra
3020 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3021 * sent to registered receivers, not manifest receivers. It is sent to all
3022 * users (including the one that is being stopped). You must hold
3023 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3024 * this broadcast. The user will not stop until all receivers have
3025 * handled the broadcast. This is sent as a background broadcast, since
3026 * its result is not part of the primary UX flow; to safely keep track of
3027 * started/stopped state of a user you can use this in conjunction with
3028 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3029 * other user state broadcasts since those are foreground broadcasts so can
3030 * execute in a different order.
3031 * @hide
3032 */
3033 public static final String ACTION_USER_STOPPING =
3034 "android.intent.action.USER_STOPPING";
3035
3036 /**
3037 * Broadcast sent to the system when a user is stopped. Carries an extra
3038 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3039 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3040 * specific package. This is only sent to registered receivers, not manifest
3041 * receivers. It is sent to all running users <em>except</em> the one that
3042 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003043 * @hide
3044 */
3045 public static final String ACTION_USER_STOPPED =
3046 "android.intent.action.USER_STOPPED";
3047
3048 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003049 * 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 -07003050 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003051 * one that has been removed. The user will not be completely removed until all receivers have
3052 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003053 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003054 * @hide
3055 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003056 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003057 public static final String ACTION_USER_REMOVED =
3058 "android.intent.action.USER_REMOVED";
3059
3060 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003061 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003062 * the userHandle of the user to become the current one. This is only sent to
3063 * registered receivers, not manifest receivers. It is sent to all running users.
3064 * You must hold
3065 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003066 * @hide
3067 */
3068 public static final String ACTION_USER_SWITCHED =
3069 "android.intent.action.USER_SWITCHED";
3070
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003071 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003072 * Broadcast Action: Sent when the credential-encrypted private storage has
3073 * become unlocked for the target user. This is only sent to registered
3074 * receivers, not manifest receivers.
3075 */
3076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3077 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3078
3079 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003080 * Broadcast sent to the system when a user's information changes. Carries an extra
3081 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003082 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003083 * @hide
3084 */
3085 public static final String ACTION_USER_INFO_CHANGED =
3086 "android.intent.action.USER_INFO_CHANGED";
3087
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003088 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003089 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3090 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003091 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3092 * that need to display merged content across both primary and managed profiles need to
3093 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003094 * not manifest receivers.
3095 */
3096 public static final String ACTION_MANAGED_PROFILE_ADDED =
3097 "android.intent.action.MANAGED_PROFILE_ADDED";
3098
3099 /**
3100 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003101 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3102 * Only applications (for example Launchers) that need to display merged content across both
3103 * primary and managed profiles need to worry about this broadcast. This is only sent to
3104 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003105 */
3106 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3107 "android.intent.action.MANAGED_PROFILE_REMOVED";
3108
3109 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003110 * Broadcast sent to the primary user when the credential-encrypted private storage for
3111 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3112 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3113 * Launchers) that need to display merged content across both primary and managed profiles
3114 * need to worry about this broadcast. This is only sent to registered receivers,
3115 * not manifest receivers.
3116 */
3117 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3118 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3119
3120 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003121 * Broadcast sent to the primary user when an associated managed profile has become available.
3122 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003123 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3124 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3125 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003126 */
Rubin Xue95057a2016-04-01 16:49:25 +01003127 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3128 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3129
3130 /**
3131 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3132 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3133 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3134 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3135 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3136 */
3137 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3138 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003139
3140 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003141 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3142 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3143 * the device was locked or unlocked.
3144 *
3145 * This is only sent to registered receivers.
3146 *
3147 * @hide
3148 */
3149 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3150 "android.intent.action.DEVICE_LOCKED_CHANGED";
3151
3152 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003153 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3154 */
3155 public static final String ACTION_QUICK_CLOCK =
3156 "android.intent.action.QUICK_CLOCK";
3157
Michael Wright0087a142013-02-05 16:29:39 -08003158 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003159 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003160 * @hide
3161 */
3162 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003163 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003164
Justin Kohd378ad72013-04-01 12:18:26 -07003165 /**
3166 * Broadcast Action: A global button was pressed. Includes a single
3167 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3168 * caused the broadcast.
3169 * @hide
3170 */
3171 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3172
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003173 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003174 * Broadcast Action: Sent when media resource is granted.
3175 * <p>
3176 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3177 * granted.
3178 * </p>
3179 * <p class="note">
3180 * This is a protected intent that can only be sent by the system.
3181 * </p>
3182 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003183 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003184 * </p>
3185 *
3186 * @hide
3187 */
3188 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3189 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3190
3191 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003192 * Broadcast Action: An overlay package has been installed. The data
3193 * contains the name of the added overlay package.
3194 * @hide
3195 */
3196 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3197
3198 /**
3199 * Broadcast Action: An overlay package has changed. The data contains the
3200 * name of the overlay package which has changed. This is broadcast on all
3201 * changes to the OverlayInfo returned by {@link
3202 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3203 * most common change is a state change that will change whether the
3204 * overlay is enabled or not.
3205 * @hide
3206 */
3207 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3208
3209 /**
3210 * Broadcast Action: An overlay package has been removed. The data contains
3211 * the name of the overlay package which has been removed.
3212 * @hide
3213 */
3214 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3215
3216 /**
3217 * Broadcast Action: The order of a package's list of overlay packages has
3218 * changed. The data contains the package name of the overlay package that
3219 * had its position in the list adjusted.
3220 * @hide
3221 */
3222 public static final String
3223 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3224
3225 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003226 * Activity Action: Allow the user to select and return one or more existing
3227 * documents. When invoked, the system will display the various
3228 * {@link DocumentsProvider} instances installed on the device, letting the
3229 * user interactively navigate through them. These documents include local
3230 * media, such as photos and video, and documents provided by installed
3231 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003232 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003233 * Each document is represented as a {@code content://} URI backed by a
3234 * {@link DocumentsProvider}, which can be opened as a stream with
3235 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3236 * {@link android.provider.DocumentsContract.Document} metadata.
3237 * <p>
3238 * All selected documents are returned to the calling application with
3239 * persistable read and write permission grants. If you want to maintain
3240 * access to the documents across device reboots, you need to explicitly
3241 * take the persistable permissions using
3242 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3243 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003244 * Callers must indicate the acceptable document MIME types through
3245 * {@link #setType(String)}. For example, to select photos, use
3246 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3247 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3248 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003249 * <p>
3250 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003251 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3252 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003253 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003254 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3255 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003256 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003257 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003258 * Callers can set a document URI through
3259 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3260 * location of documents navigator. System will do its best to launch the
3261 * navigator in the specified document if it's a folder, or the folder that
3262 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003263 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003264 * Output: The URI of the item that was picked, returned in
3265 * {@link #getData()}. This must be a {@code content://} URI so that any
3266 * receiver can access it. If multiple documents were selected, they are
3267 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003268 *
3269 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003270 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003271 * @see #ACTION_CREATE_DOCUMENT
3272 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003273 */
3274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3275 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3276
3277 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003278 * Activity Action: Allow the user to create a new document. When invoked,
3279 * the system will display the various {@link DocumentsProvider} instances
3280 * installed on the device, letting the user navigate through them. The
3281 * returned document may be a newly created document with no content, or it
3282 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003283 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003284 * Each document is represented as a {@code content://} URI backed by a
3285 * {@link DocumentsProvider}, which can be opened as a stream with
3286 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3287 * {@link android.provider.DocumentsContract.Document} metadata.
3288 * <p>
3289 * Callers must indicate the concrete MIME type of the document being
3290 * created by setting {@link #setType(String)}. This MIME type cannot be
3291 * changed after the document is created.
3292 * <p>
3293 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3294 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003295 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003296 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3297 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003298 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003299 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003300 * Callers can set a document URI through
3301 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3302 * location of documents navigator. System will do its best to launch the
3303 * navigator in the specified document if it's a folder, or the folder that
3304 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003305 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003306 * Output: The URI of the item that was created. This must be a
3307 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003308 *
3309 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003310 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003311 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003312 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003313 */
3314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3315 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3316
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003317 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003318 * Activity Action: Allow the user to pick a directory subtree. When
3319 * invoked, the system will display the various {@link DocumentsProvider}
3320 * instances installed on the device, letting the user navigate through
3321 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003322 * <p>
3323 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003324 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3325 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3326 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003327 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003328 * Callers can set a document URI through
3329 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3330 * location of documents navigator. System will do its best to launch the
3331 * navigator in the specified document if it's a folder, or the folder that
3332 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003333 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003334 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003335 *
3336 * @see DocumentsContract
3337 */
3338 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003339 public static final String
3340 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003341
Felipe Lemec7b1f892016-01-15 15:02:31 -08003342 /**
Peng Xua35b5532016-01-20 00:05:45 -08003343 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3344 * exisiting sensor being disconnected.
3345 *
3346 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3347 *
3348 * {@hide}
3349 */
3350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3351 public static final String
3352 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3353
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003354 /**
3355 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3356 *
3357 * {@hide}
3358 */
3359 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003360 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3361
Christopher Tate6597e342015-02-17 12:15:25 -08003362 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003363 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3364 * is about to be performed.
3365 * @hide
3366 */
3367 @SystemApi
3368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3369 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3370 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3371
3372 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003373 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3374 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3375 *
3376 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3377 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003378 * @hide
3379 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003380 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003381 public static final String EXTRA_FORCE_MASTER_CLEAR =
3382 "android.intent.extra.FORCE_MASTER_CLEAR";
3383
3384 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003385 * A broadcast action to trigger a factory reset.
3386 *
3387 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3388 *
3389 * <p>Not for use by third-party applications.
3390 *
3391 * @see #EXTRA_FORCE_MASTER_CLEAR
3392 *
3393 * {@hide}
3394 */
3395 @SystemApi
3396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3397 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3398
3399 /**
3400 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3401 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3402 *
3403 * <p>Not for use by third-party applications.
3404 *
3405 * @hide
3406 */
3407 @SystemApi
3408 public static final String EXTRA_FORCE_FACTORY_RESET =
3409 "android.intent.extra.FORCE_FACTORY_RESET";
3410
3411 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003412 * Broadcast action: report that a settings element is being restored from backup. The intent
3413 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3414 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3415 * is the value of that settings entry prior to the restore operation. All of these values are
3416 * represented as strings.
3417 *
3418 * <p>This broadcast is sent only for settings provider entries known to require special handling
3419 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3420 * the provider's backup agent implementation.
3421 *
3422 * @see #EXTRA_SETTING_NAME
3423 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3424 * @see #EXTRA_SETTING_NEW_VALUE
3425 * {@hide}
3426 */
3427 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3428
3429 /** {@hide} */
3430 public static final String EXTRA_SETTING_NAME = "setting_name";
3431 /** {@hide} */
3432 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3433 /** {@hide} */
3434 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3435
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003436 /**
3437 * Activity Action: Process a piece of text.
3438 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3439 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3440 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3441 */
3442 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3443 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003444
3445 /**
3446 * Broadcast Action: The sim card state has changed.
3447 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3448 * because TelephonyIntents is an internal class.
3449 * @hide
3450 */
3451 @SystemApi
3452 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3453 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3454
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003455 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003456 * The name of the extra used to define the text to be processed, as a
3457 * CharSequence. Note that this may be a styled CharSequence, so you must use
3458 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003459 */
3460 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3461 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003462 * 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 +00003463 */
3464 public static final String EXTRA_PROCESS_TEXT_READONLY =
3465 "android.intent.extra.PROCESS_TEXT_READONLY";
3466
Bryce Leebc58f592015-09-25 16:43:01 -07003467 /**
3468 * Broadcast action: reports when a new thermal event has been reached. When the device
3469 * is reaching its maximum temperatue, the thermal level reported
3470 * {@hide}
3471 */
3472 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3473 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3474
3475 /** {@hide} */
3476 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3477
3478 /**
3479 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003480 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003481 * {@hide}
3482 */
3483 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3484
3485 /**
3486 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003487 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003488 * {@hide}
3489 */
3490 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3491
3492 /**
3493 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003494 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003495 * {@hide}
3496 */
3497 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3498
3499
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003500 // ---------------------------------------------------------------------
3501 // ---------------------------------------------------------------------
3502 // Standard intent categories (see addCategory()).
3503
3504 /**
3505 * Set if the activity should be an option for the default action
3506 * (center press) to perform on a piece of data. Setting this will
3507 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003508 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003509 * Intent when initiating an action -- it is for use in intent filters
3510 * specified in packages.
3511 */
3512 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3513 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3514 /**
3515 * Activities that can be safely invoked from a browser must support this
3516 * category. For example, if the user is viewing a web page or an e-mail
3517 * and clicks on a link in the text, the Intent generated execute that
3518 * link will require the BROWSABLE category, so that only activities
3519 * supporting this category will be considered as possible actions. By
3520 * supporting this category, you are promising that there is nothing
3521 * damaging (without user intervention) that can happen by invoking any
3522 * matching Intent.
3523 */
3524 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3525 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3526 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003527 * Categories for activities that can participate in voice interaction.
3528 * An activity that supports this category must be prepared to run with
3529 * no UI shown at all (though in some case it may have a UI shown), and
3530 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3531 */
3532 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3533 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3534 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003535 * Set if the activity should be considered as an alternative action to
3536 * the data the user is currently viewing. See also
3537 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3538 * applies to the selection in a list of items.
3539 *
3540 * <p>Supporting this category means that you would like your activity to be
3541 * displayed in the set of alternative things the user can do, usually as
3542 * part of the current activity's options menu. You will usually want to
3543 * include a specific label in the &lt;intent-filter&gt; of this action
3544 * describing to the user what it does.
3545 *
3546 * <p>The action of IntentFilter with this category is important in that it
3547 * describes the specific action the target will perform. This generally
3548 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3549 * a specific name such as "com.android.camera.action.CROP. Only one
3550 * alternative of any particular action will be shown to the user, so using
3551 * a specific action like this makes sure that your alternative will be
3552 * displayed while also allowing other applications to provide their own
3553 * overrides of that particular action.
3554 */
3555 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3556 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3557 /**
3558 * Set if the activity should be considered as an alternative selection
3559 * action to the data the user has currently selected. This is like
3560 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3561 * of items from which the user can select, giving them alternatives to the
3562 * default action that will be performed on it.
3563 */
3564 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3565 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3566 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003567 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003568 */
3569 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3570 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3571 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003572 * Should be displayed in the top-level launcher.
3573 */
3574 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3575 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3576 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003577 * Indicates an activity optimized for Leanback mode, and that should
3578 * be displayed in the Leanback launcher.
3579 */
3580 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3581 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3582 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003583 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3584 * @hide
3585 */
3586 @SystemApi
3587 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3588 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003589 * Provides information about the package it is in; typically used if
3590 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3591 * a front-door to the user without having to be shown in the all apps list.
3592 */
3593 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3594 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3595 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003596 * This is the home activity, that is the first activity that is displayed
3597 * when the device boots.
3598 */
3599 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3600 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3601 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003602 * This is the home activity that is displayed when the device is finished setting up and ready
3603 * for use.
3604 * @hide
3605 */
3606 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3607 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3608 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003609 * This is the setup wizard activity, that is the first activity that is displayed
3610 * when the user sets up the device for the first time.
3611 * @hide
3612 */
3613 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3614 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3615 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003616 * This activity is a preference panel.
3617 */
3618 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3619 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3620 /**
3621 * This activity is a development preference panel.
3622 */
3623 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3624 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3625 /**
3626 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003627 */
3628 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3629 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3630 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003631 * This activity allows the user to browse and download new applications.
3632 */
3633 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3634 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3635 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003636 * This activity may be exercised by the monkey or other automated test tools.
3637 */
3638 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3639 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3640 /**
3641 * To be used as a test (not part of the normal user experience).
3642 */
3643 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3644 /**
3645 * To be used as a unit test (run through the Test Harness).
3646 */
3647 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3648 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003649 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003650 * experience).
3651 */
3652 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003654 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003655 * Used to indicate that an intent only wants URIs that can be opened with
3656 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3657 * must support at least the columns defined in {@link OpenableColumns} when
3658 * queried.
3659 *
3660 * @see #ACTION_GET_CONTENT
3661 * @see #ACTION_OPEN_DOCUMENT
3662 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003663 */
3664 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3665 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3666
3667 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003668 * Used to indicate that an intent filter can accept files which are not necessarily
3669 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3670 * at least streamable via
3671 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3672 * using one of the stream types exposed via
3673 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3674 *
3675 * @see #ACTION_SEND
3676 * @see #ACTION_SEND_MULTIPLE
3677 */
3678 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3679 public static final String CATEGORY_TYPED_OPENABLE =
3680 "android.intent.category.TYPED_OPENABLE";
3681
3682 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003683 * To be used as code under test for framework instrumentation tests.
3684 */
3685 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3686 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003687 /**
3688 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003689 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3690 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003691 */
3692 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3693 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3694 /**
3695 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003696 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3697 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003698 */
3699 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3700 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003701 /**
3702 * An activity to run when device is inserted into a analog (low end) dock.
3703 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3704 * information, see {@link android.app.UiModeManager}.
3705 */
3706 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3707 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3708
3709 /**
3710 * An activity to run when device is inserted into a digital (high end) dock.
3711 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3712 * information, see {@link android.app.UiModeManager}.
3713 */
3714 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3715 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003716
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003717 /**
3718 * Used to indicate that the activity can be used in a car environment.
3719 */
3720 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3721 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3722
Zak Cohendb6ca492017-01-26 14:09:00 -08003723 /**
3724 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3725 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3726 * information, see {@link android.app.UiModeManager}.
3727 */
3728 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3729 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003730 // ---------------------------------------------------------------------
3731 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003732 // Application launch intent categories (see addCategory()).
3733
3734 /**
3735 * Used with {@link #ACTION_MAIN} to launch the browser application.
3736 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003737 * <p>NOTE: This should not be used as the primary key of an Intent,
3738 * since it will not result in the app launching with the correct
3739 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003740 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003741 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003742 */
3743 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3744 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3745
3746 /**
3747 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3748 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003749 * <p>NOTE: This should not be used as the primary key of an Intent,
3750 * since it will not result in the app launching with the correct
3751 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003752 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003753 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003754 */
3755 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3756 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3757
3758 /**
3759 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3760 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003761 * <p>NOTE: This should not be used as the primary key of an Intent,
3762 * since it will not result in the app launching with the correct
3763 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003764 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003765 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003766 */
3767 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3768 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3769
3770 /**
3771 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3772 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003773 * <p>NOTE: This should not be used as the primary key of an Intent,
3774 * since it will not result in the app launching with the correct
3775 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003776 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003777 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003778 */
3779 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3780 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3781
3782 /**
3783 * Used with {@link #ACTION_MAIN} to launch the email application.
3784 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003785 * <p>NOTE: This should not be used as the primary key of an Intent,
3786 * since it will not result in the app launching with the correct
3787 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003788 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003789 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003790 */
3791 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3792 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3793
3794 /**
3795 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3796 * The activity should be able to view and manipulate image and video files
3797 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003798 * <p>NOTE: This should not be used as the primary key of an Intent,
3799 * since it will not result in the app launching with the correct
3800 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003801 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003802 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003803 */
3804 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3805 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3806
3807 /**
3808 * Used with {@link #ACTION_MAIN} to launch the maps application.
3809 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003810 * <p>NOTE: This should not be used as the primary key of an Intent,
3811 * since it will not result in the app launching with the correct
3812 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003813 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003814 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003815 */
3816 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3817 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3818
3819 /**
3820 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3821 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003822 * <p>NOTE: This should not be used as the primary key of an Intent,
3823 * since it will not result in the app launching with the correct
3824 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003825 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003826 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003827 */
3828 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3829 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3830
3831 /**
3832 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003833 * The activity should be able to play, browse, or manipulate music files
3834 * stored on the device.
3835 * <p>NOTE: This should not be used as the primary key of an Intent,
3836 * since it will not result in the app launching with the correct
3837 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003838 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003839 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003840 */
3841 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3842 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3843
3844 // ---------------------------------------------------------------------
3845 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003846 // Standard extra data keys.
3847
3848 /**
3849 * The initial data to place in a newly created record. Use with
3850 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3851 * fields as would be given to the underlying ContentProvider.insert()
3852 * call.
3853 */
3854 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3855
3856 /**
3857 * A constant CharSequence that is associated with the Intent, used with
3858 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3859 * this may be a styled CharSequence, so you must use
3860 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3861 * retrieve it.
3862 */
3863 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3864
3865 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003866 * A constant String that is associated with the Intent, used with
3867 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3868 * as HTML formatted text. Note that you <em>must</em> also supply
3869 * {@link #EXTRA_TEXT}.
3870 */
3871 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3872
3873 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00003874 * A content: URI holding a stream of data associated with the Intent,
3875 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003876 */
3877 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3878
3879 /**
3880 * A String[] holding e-mail addresses that should be delivered to.
3881 */
3882 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3883
3884 /**
3885 * A String[] holding e-mail addresses that should be carbon copied.
3886 */
3887 public static final String EXTRA_CC = "android.intent.extra.CC";
3888
3889 /**
3890 * A String[] holding e-mail addresses that should be blind carbon copied.
3891 */
3892 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3893
3894 /**
3895 * A constant string holding the desired subject line of a message.
3896 */
3897 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3898
3899 /**
3900 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003901 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003902 */
3903 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3904
3905 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003906 * An int representing the user id to be used.
3907 *
3908 * @hide
3909 */
3910 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3911
3912 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003913 * An int representing the task id to be retrieved. This is used when a launch from recents is
3914 * intercepted by another action such as credentials confirmation to remember which task should
3915 * be resumed when complete.
3916 *
3917 * @hide
3918 */
3919 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3920
3921 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003922 * An Intent[] describing additional, alternate choices you would like shown with
3923 * {@link #ACTION_CHOOSER}.
3924 *
3925 * <p>An app may be capable of providing several different payload types to complete a
3926 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3927 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3928 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3929 * photo data or a hosted link where the photos can be viewed.</p>
3930 *
3931 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3932 * first/primary/preferred intent in the set. Additional intents specified in
3933 * this extra are ordered; by default intents that appear earlier in the array will be
3934 * preferred over intents that appear later in the array as matches for the same
3935 * target component. To alter this preference, a calling app may also supply
3936 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3937 */
3938 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3939
3940 /**
Adam Powell52c39212016-04-07 15:14:18 -07003941 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3942 * and omitted from a list of components presented to the user.
3943 *
3944 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3945 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3946 * from your own package or other apps from your organization if the idea of sending to those
3947 * targets would be redundant with other app functionality. Filtered components will not
3948 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3949 */
3950 public static final String EXTRA_EXCLUDE_COMPONENTS
3951 = "android.intent.extra.EXCLUDE_COMPONENTS";
3952
3953 /**
3954 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3955 * describing additional high-priority deep-link targets for the chooser to present to the user.
3956 *
3957 * <p>Targets provided in this way will be presented inline with all other targets provided
3958 * by services from other apps. They will be prioritized before other service targets, but
3959 * after those targets provided by sources that the user has manually pinned to the front.</p>
3960 *
3961 * @see #ACTION_CHOOSER
3962 */
3963 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3964
3965 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003966 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3967 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3968 *
3969 * <p>An app preparing an action for another app to complete may wish to allow the user to
3970 * disambiguate between several options for completing the action based on the chosen target
3971 * or otherwise refine the action before it is invoked.
3972 * </p>
3973 *
3974 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3975 * <ul>
3976 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3977 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3978 * chosen target beyond the first</li>
3979 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3980 * should fill in and send once the disambiguation is complete</li>
3981 * </ul>
3982 */
3983 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3984 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3985
3986 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003987 * An {@code ArrayList} of {@code String} annotations describing content for
3988 * {@link #ACTION_CHOOSER}.
3989 *
3990 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3991 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3992 *
3993 * <p>Annotations should describe the major components or topics of the content. It is up to
3994 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3995 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3996 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3997 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3998 * use the following annotations when applicable:</p>
3999 * <ul>
4000 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4001 * health & beauty, and office supplies.</li>
4002 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4003 * happy, and sad.</li>
4004 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4005 * face, finger, standing, and walking.</li>
4006 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4007 * child, and baby.</li>
4008 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4009 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4010 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4011 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4012 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4013 * flowers.</li>
4014 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4015 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4016 * sunglasses, jewelry, handbags and clothing.</li>
4017 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4018 * paper, and silk.</li>
4019 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4020 * cars, and boats.</li>
4021 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4022 * posters.</li>
4023 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4024 * and designs of houses.</li>
4025 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4026 * Christmas and Thanksgiving.</li>
4027 * </ul>
4028 */
4029 public static final String EXTRA_CONTENT_ANNOTATIONS
4030 = "android.intent.extra.CONTENT_ANNOTATIONS";
4031
4032 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004033 * A {@link ResultReceiver} used to return data back to the sender.
4034 *
4035 * <p>Used to complete an app-specific
4036 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4037 *
4038 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4039 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4040 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4041 * when the user selects a target component from the chooser. It is up to the recipient
4042 * to send a result to this ResultReceiver to signal that disambiguation is complete
4043 * and that the chooser should invoke the user's choice.</p>
4044 *
4045 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4046 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4047 * to match and fill in the final Intent or ChooserTarget before starting it.
4048 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4049 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4050 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4051 *
4052 * <p>The result code passed to the ResultReceiver should be
4053 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4054 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4055 * the chooser should finish without starting a target.</p>
4056 */
4057 public static final String EXTRA_RESULT_RECEIVER
4058 = "android.intent.extra.RESULT_RECEIVER";
4059
4060 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004061 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004062 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004063 */
4064 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4065
4066 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004067 * A Parcelable[] of {@link Intent} or
4068 * {@link android.content.pm.LabeledIntent} objects as set with
4069 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4070 * a the front of the list of choices, when shown to the user with a
4071 * {@link #ACTION_CHOOSER}.
4072 */
4073 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4074
4075 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004076 * A {@link IntentSender} to start after ephemeral installation success.
4077 * @hide
4078 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004079 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4080
4081 /**
4082 * A {@link IntentSender} to start after ephemeral installation failure.
4083 * @hide
4084 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004085 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4086
4087 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004088 * The host name that triggered an ephemeral resolution.
4089 * @hide
4090 */
4091 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4092
4093 /**
4094 * An opaque token to track ephemeral resolution.
4095 * @hide
4096 */
4097 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4098
4099 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004100 * The version code of the app to install components from.
4101 * @hide
4102 */
4103 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4104
4105 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004106 * A Bundle forming a mapping of potential target package names to different extras Bundles
4107 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4108 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4109 * be currently installed on the device.
4110 *
4111 * <p>An application may choose to provide alternate extras for the case where a user
4112 * selects an activity from a predetermined set of target packages. If the activity
4113 * the user selects from the chooser belongs to a package with its package name as
4114 * a key in this bundle, the corresponding extras for that package will be merged with
4115 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4116 * extra has the same key as an extra already present in the intent it will overwrite
4117 * the extra from the intent.</p>
4118 *
4119 * <p><em>Examples:</em>
4120 * <ul>
4121 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4122 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4123 * parameters for that target.</li>
4124 * <li>An application may offer additional metadata for known targets of a given intent
4125 * to pass along information only relevant to that target such as account or content
4126 * identifiers already known to that application.</li>
4127 * </ul></p>
4128 */
4129 public static final String EXTRA_REPLACEMENT_EXTRAS =
4130 "android.intent.extra.REPLACEMENT_EXTRAS";
4131
4132 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004133 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4134 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4135 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4136 * {@link ComponentName} of the chosen component.
4137 *
4138 * <p>In some situations this callback may never come, for example if the user abandons
4139 * the chooser, switches to another task or any number of other reasons. Apps should not
4140 * be written assuming that this callback will always occur.</p>
4141 */
4142 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4143 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4144
4145 /**
4146 * The {@link ComponentName} chosen by the user to complete an action.
4147 *
4148 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4149 */
4150 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4151
4152 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004153 * A {@link android.view.KeyEvent} object containing the event that
4154 * triggered the creation of the Intent it is in.
4155 */
4156 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4157
4158 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004159 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4160 * before shutting down.
4161 *
4162 * {@hide}
4163 */
4164 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4165
4166 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004167 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4168 * requested by the user.
4169 *
4170 * {@hide}
4171 */
4172 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4173 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4174
4175 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004176 * 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 -07004177 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4178 * of restarting the application.
4179 */
4180 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4181
4182 /**
4183 * A String holding the phone number originally entered in
4184 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4185 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4186 */
4187 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004188
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004189 /**
4190 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4191 * intents to supply the uid the package had been assigned. Also an optional
4192 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4193 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4194 * purpose.
4195 */
4196 public static final String EXTRA_UID = "android.intent.extra.UID";
4197
4198 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004199 * @hide String array of package names.
4200 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004201 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004202 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4203
4204 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004205 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4206 * intents to indicate whether this represents a full uninstall (removing
4207 * both the code and its data) or a partial uninstall (leaving its data,
4208 * implying that this is an update).
4209 */
4210 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004211
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004212 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004213 * @hide
4214 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4215 * intents to indicate that at this point the package has been removed for
4216 * all users on the device.
4217 */
4218 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4219 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4220
4221 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004222 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4223 * intents to indicate that this is a replacement of the package, so this
4224 * broadcast will immediately be followed by an add broadcast for a
4225 * different version of the same package.
4226 */
4227 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004228
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004229 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004230 * Used as an int extra field in {@link android.app.AlarmManager} intents
4231 * to tell the application being invoked how many pending alarms are being
4232 * delievered with the intent. For one-shot alarms this will always be 1.
4233 * For recurring alarms, this might be greater than 1 if the device was
4234 * asleep or powered off at the time an earlier alarm would have been
4235 * delivered.
4236 */
4237 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004238
Jacek Surazski86b6c532009-05-13 14:38:28 +02004239 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004240 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4241 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004242 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4243 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004244 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4245 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4246 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004247 */
4248 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4249
4250 /**
4251 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4252 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004253 */
4254 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4255
4256 /**
4257 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4258 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004259 */
4260 public static final int EXTRA_DOCK_STATE_DESK = 1;
4261
4262 /**
4263 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4264 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004265 */
4266 public static final int EXTRA_DOCK_STATE_CAR = 2;
4267
4268 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004269 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4270 * to represent that the phone is in a analog (low end) dock.
4271 */
4272 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4273
4274 /**
4275 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4276 * to represent that the phone is in a digital (high end) dock.
4277 */
4278 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4279
4280 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004281 * Boolean that can be supplied as meta-data with a dock activity, to
4282 * indicate that the dock should take over the home key when it is active.
4283 */
4284 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004285
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004286 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004287 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4288 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004289 */
4290 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4291
4292 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004293 * Used in the extra field in the remote intent. It's astring token passed with the
4294 * remote intent.
4295 */
4296 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4297 "android.intent.extra.remote_intent_token";
4298
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004299 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004300 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004301 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004302 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004303 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004304 "android.intent.extra.changed_component_name";
4305
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004306 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004307 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004308 * and contains a string array of all of the components that have changed. If
4309 * the state of the overall package has changed, then it will contain an entry
4310 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004311 */
4312 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4313 "android.intent.extra.changed_component_name_list";
4314
4315 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004316 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004317 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004318 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4319 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4320 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004321 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004322 */
4323 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4324 "android.intent.extra.changed_package_list";
4325
4326 /**
4327 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004328 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4329 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004330 * and contains an integer array of uids of all of the components
4331 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004332 */
4333 public static final String EXTRA_CHANGED_UID_LIST =
4334 "android.intent.extra.changed_uid_list";
4335
4336 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004337 * @hide
4338 * Magic extra system code can use when binding, to give a label for
4339 * who it is that has bound to a service. This is an integer giving
4340 * a framework string resource that can be displayed to the user.
4341 */
4342 public static final String EXTRA_CLIENT_LABEL =
4343 "android.intent.extra.client_label";
4344
4345 /**
4346 * @hide
4347 * Magic extra system code can use when binding, to give a PendingIntent object
4348 * that can be launched for the user to disable the system's use of this
4349 * service.
4350 */
4351 public static final String EXTRA_CLIENT_INTENT =
4352 "android.intent.extra.client_intent";
4353
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004354 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004355 * Extra used to indicate that an intent should only return data that is on
4356 * the local device. This is a boolean extra; the default is false. If true,
4357 * an implementation should only allow the user to select data that is
4358 * already on the device, not requiring it be downloaded from a remote
4359 * service when opened.
4360 *
4361 * @see #ACTION_GET_CONTENT
4362 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004363 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004364 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004365 */
4366 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004367 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004368
Amith Yamasani13593602012-03-22 16:16:17 -07004369 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004370 * Extra used to indicate that an intent can allow the user to select and
4371 * return multiple items. This is a boolean extra; the default is false. If
4372 * true, an implementation is allowed to present the user with a UI where
4373 * they can pick multiple items that are all returned to the caller. When
4374 * this happens, they should be returned as the {@link #getClipData()} part
4375 * of the result Intent.
4376 *
4377 * @see #ACTION_GET_CONTENT
4378 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004379 */
4380 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004381 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004382
4383 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004384 * The integer userHandle carried with broadcast intents related to addition, removal and
4385 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4386 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4387 *
Amith Yamasani13593602012-03-22 16:16:17 -07004388 * @hide
4389 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004390 public static final String EXTRA_USER_HANDLE =
4391 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004392
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004393 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004394 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4395 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4396 */
4397 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004398 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004399
4400 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004401 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004402 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4403 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004404 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004405 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4406
4407 /**
4408 * Extra sent in the intent to the BroadcastReceiver that handles
4409 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4410 * the restrictions as key/value pairs.
4411 */
4412 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4413 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004414
Amith Yamasani86118ba2013-03-28 14:33:16 -07004415 /**
4416 * Extra used in the response from a BroadcastReceiver that handles
4417 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4418 */
4419 public static final String EXTRA_RESTRICTIONS_INTENT =
4420 "android.intent.extra.restrictions_intent";
4421
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004422 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004423 * Extra used to communicate a set of acceptable MIME types. The type of the
4424 * extra is {@code String[]}. Values may be a combination of concrete MIME
4425 * types (such as "image/png") and/or partial MIME types (such as
4426 * "audio/*").
4427 *
4428 * @see #ACTION_GET_CONTENT
4429 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004430 */
4431 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4432
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004433 /**
4434 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4435 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004436 * When this is true, hardware devices can use this information to determine that
4437 * they shouldn't do a complete shutdown of their device since this is not a
4438 * complete shutdown down to the kernel, but only user space restarting.
4439 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004440 */
4441 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4442 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4443
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004444 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004445 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4446 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4447 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4448 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004449 *
4450 * @hide for internal use only.
4451 */
4452 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4453 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004454 /** @hide */
4455 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4456 /** @hide */
4457 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4458 /** @hide */
4459 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004460
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004461 /** {@hide} */
4462 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4463
Rubin Xue8490f12015-06-25 12:17:48 +01004464 /** {@hide} */
4465 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4466
Santos Cordon15a13782015-03-31 18:32:31 -07004467 /**
4468 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4469 * activation request.
4470 * TODO: Add information about the structure and response data used with the pending intent.
4471 * @hide
4472 */
4473 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4474 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4475
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004476 /**
4477 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004478 *
4479 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004480 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004481 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004482 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4483
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004484 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004485 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4486 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4487 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004488 *
4489 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004490 * @see #ACTION_QUICK_VIEW
4491 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004492 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004493 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004494 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4495 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004496
4497 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004498 * An optional extra of {@code String[]} indicating which quick view features should be made
4499 * available to the user in the quick view UI while handing a
4500 * {@link Intent#ACTION_QUICK_VIEW} intent.
4501 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4502 * Quick viewer can implement features not listed below.
4503 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4504 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4505 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4506 * <p>
4507 * Requirements:
4508 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4509 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4510 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4511 * internal policies.
4512 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4513 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4514 * disable or hide features.
4515 *
4516 * @see #ACTION_QUICK_VIEW
4517 */
4518 public static final String EXTRA_QUICK_VIEW_FEATURES =
4519 "android.intent.extra.QUICK_VIEW_FEATURES";
4520
4521 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004522 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004523 * When a profile goes into quiet mode, all apps in the profile are killed and the
4524 * profile user is stopped. Widgets originating from the profile are masked, and app
4525 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004526 */
4527 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004528
4529 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004530 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004531 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004532 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4533 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004534 *
4535 * @hide
4536 */
4537 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4538 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4539
4540 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004541 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4542 * whether to show the chooser or not when there is only one application available
4543 * to choose from.
4544 *
4545 * @hide
4546 */
4547 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4548 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4549
4550 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004551 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004552 * to represent that a video codec is allowed to use.
4553 *
4554 * @hide
4555 */
4556 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4557
4558 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004559 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004560 * to represent that a audio codec is allowed to use.
4561 *
4562 * @hide
4563 */
4564 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4565
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004566 // ---------------------------------------------------------------------
4567 // ---------------------------------------------------------------------
4568 // Intent flags (see mFlags variable).
4569
Tor Norbyed9273d62013-05-30 15:59:53 -07004570 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004571 @IntDef(flag = true, value = {
4572 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4573 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004574 @Retention(RetentionPolicy.SOURCE)
4575 public @interface GrantUriMode {}
4576
Jeff Sharkey846318a2014-04-04 12:12:41 -07004577 /** @hide */
4578 @IntDef(flag = true, value = {
4579 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4580 @Retention(RetentionPolicy.SOURCE)
4581 public @interface AccessUriMode {}
4582
4583 /**
4584 * Test if given mode flags specify an access mode, which must be at least
4585 * read and/or write.
4586 *
4587 * @hide
4588 */
4589 public static boolean isAccessUriMode(int modeFlags) {
4590 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4591 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4592 }
4593
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004594 /**
4595 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004596 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004597 * specified in its ClipData. When applying to an Intent's ClipData,
4598 * all URIs as well as recursive traversals through data or other ClipData
4599 * in Intent items will be granted; only the grant flags of the top-level
4600 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004601 */
4602 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4603 /**
4604 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004605 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004606 * specified in its ClipData. When applying to an Intent's ClipData,
4607 * all URIs as well as recursive traversals through data or other ClipData
4608 * in Intent items will be granted; only the grant flags of the top-level
4609 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004610 */
4611 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4612 /**
4613 * Can be set by the caller to indicate that this Intent is coming from
4614 * a background operation, not from direct user interaction.
4615 */
4616 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4617 /**
4618 * A flag you can enable for debugging: when set, log messages will be
4619 * printed during the resolution of this intent to show you what has
4620 * been found to create the final resolved list.
4621 */
4622 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004623 /**
4624 * If set, this intent will not match any components in packages that
4625 * are currently stopped. If this is not set, then the default behavior
4626 * is to include such applications in the result.
4627 */
4628 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4629 /**
4630 * If set, this intent will always match any components in packages that
4631 * are currently stopped. This is the default behavior when
4632 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4633 * flags are set, this one wins (it allows overriding of exclude for
4634 * places where the framework may automatically set the exclude flag).
4635 */
4636 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004637
4638 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004639 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004640 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004641 * persisted across device reboots until explicitly revoked with
4642 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4643 * grant for possible persisting; the receiving application must call
4644 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4645 * actually persist.
4646 *
4647 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4648 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4649 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004650 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004651 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004652 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004653
4654 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004655 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4656 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4657 * applies to any URI that is a prefix match against the original granted
4658 * URI. (Without this flag, the URI must match exactly for access to be
4659 * granted.) Another URI is considered a prefix match only when scheme,
4660 * authority, and all path segments defined by the prefix are an exact
4661 * match.
4662 */
4663 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4664
4665 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004666 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004667 * homework and verified that they correctly handle packages and components
4668 * that come and go over time. In particular:
4669 * <ul>
4670 * <li>Apps installed on external storage, which will appear to be
4671 * uninstalled while the the device is ejected.
4672 * <li>Apps with encryption unaware components, which will appear to not
4673 * exist while the device is locked.
4674 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004675 *
4676 * @hide
4677 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004678 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004679
4680 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004681 * Internal flag used to indicate ephemeral applications should not be
4682 * considered when resolving the intent.
4683 *
4684 * @hide
4685 */
4686 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4687
4688 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004689 * If set, the new activity is not kept in the history stack. As soon as
4690 * the user navigates away from it, the activity is finished. This may also
4691 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4692 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004693 *
4694 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4695 * is never invoked when the current activity starts a new activity which
4696 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004697 */
4698 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4699 /**
4700 * If set, the activity will not be launched if it is already running
4701 * at the top of the history stack.
4702 */
4703 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4704 /**
4705 * If set, this activity will become the start of a new task on this
4706 * history stack. A task (from the activity that started it to the
4707 * next task activity) defines an atomic group of activities that the
4708 * user can move to. Tasks can be moved to the foreground and background;
4709 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004710 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004711 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4712 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004713 *
4714 * <p>This flag is generally used by activities that want
4715 * to present a "launcher" style behavior: they give the user a list of
4716 * separate things that can be done, which otherwise run completely
4717 * independently of the activity launching them.
4718 *
4719 * <p>When using this flag, if a task is already running for the activity
4720 * you are now starting, then a new activity will not be started; instead,
4721 * the current task will simply be brought to the front of the screen with
4722 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4723 * to disable this behavior.
4724 *
4725 * <p>This flag can not be used when the caller is requesting a result from
4726 * the activity being launched.
4727 */
4728 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4729 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004730 * This flag is used to create a new task and launch an activity into it.
4731 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4732 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4733 * search through existing tasks for ones matching this Intent. Only if no such
4734 * task is found would a new task be created. When paired with
4735 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4736 * the search for a matching task and unconditionally start a new task.
4737 *
4738 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4739 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004740 * top-level application launcher.</strong> Used in conjunction with
4741 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4742 * behavior of bringing an existing task to the foreground. When set,
4743 * a new task is <em>always</em> started to host the Activity for the
4744 * Intent, regardless of whether there is already an existing task running
4745 * the same thing.
4746 *
4747 * <p><strong>Because the default system does not include graphical task management,
4748 * you should not use this flag unless you provide some way for a user to
4749 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004750 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004751 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4752 * creating new document tasks.
4753 *
4754 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004755 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004756 *
Scott Main7aee61f2011-02-08 11:25:01 -08004757 * <p>See
4758 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4759 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004760 *
4761 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4762 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004763 */
4764 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4765 /**
4766 * If set, and the activity being launched is already running in the
4767 * current task, then instead of launching a new instance of that activity,
4768 * all of the other activities on top of it will be closed and this Intent
4769 * will be delivered to the (now on top) old activity as a new Intent.
4770 *
4771 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4772 * If D calls startActivity() with an Intent that resolves to the component
4773 * of activity B, then C and D will be finished and B receive the given
4774 * Intent, resulting in the stack now being: A, B.
4775 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004776 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004777 * either receive the new intent you are starting here in its
4778 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004779 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004780 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4781 * the same intent, then it will be finished and re-created; for all other
4782 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4783 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004784 *
4785 * <p>This launch mode can also be used to good effect in conjunction with
4786 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4787 * of a task, it will bring any currently running instance of that task
4788 * to the foreground, and then clear it to its root state. This is
4789 * especially useful, for example, when launching an activity from the
4790 * notification manager.
4791 *
Scott Main7aee61f2011-02-08 11:25:01 -08004792 * <p>See
4793 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4794 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004795 */
4796 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4797 /**
4798 * If set and this intent is being used to launch a new activity from an
4799 * existing one, then the reply target of the existing activity will be
4800 * transfered to the new activity. This way the new activity can call
4801 * {@link android.app.Activity#setResult} and have that result sent back to
4802 * the reply target of the original activity.
4803 */
4804 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4805 /**
4806 * If set and this intent is being used to launch a new activity from an
4807 * existing one, the current activity will not be counted as the top
4808 * activity for deciding whether the new intent should be delivered to
4809 * the top instead of starting a new one. The previous activity will
4810 * be used as the top, with the assumption being that the current activity
4811 * will finish itself immediately.
4812 */
4813 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4814 /**
4815 * If set, the new activity is not kept in the list of recently launched
4816 * activities.
4817 */
4818 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4819 /**
4820 * This flag is not normally set by application code, but set for you by
4821 * the system as described in the
4822 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4823 * launchMode} documentation for the singleTask mode.
4824 */
4825 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4826 /**
4827 * If set, and this activity is either being started in a new task or
4828 * bringing to the top an existing task, then it will be launched as
4829 * the front door of the task. This will result in the application of
4830 * any affinities needed to have that task in the proper state (either
4831 * moving activities to or from it), or simply resetting that task to
4832 * its initial state if needed.
4833 */
4834 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4835 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004836 * This flag is not normally set by application code, but set for you by
4837 * the system if this activity is being launched from history
4838 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004839 */
4840 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004841 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004842 * @deprecated As of API 21 this performs identically to
4843 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004844 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004845 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004846 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004847 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004848 * This flag is used to open a document into a new task rooted at the activity launched
4849 * by this Intent. Through the use of this flag, or its equivalent attribute,
4850 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004851 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004852 *
Craig Mautner026596b2014-05-21 15:35:44 -07004853 * <p>The use of the activity attribute form of this,
4854 * {@link android.R.attr#documentLaunchMode}, is
4855 * preferred over the Intent flag described here. The attribute form allows the
4856 * Activity to specify multiple document behavior for all launchers of the Activity
4857 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004858 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004859 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4860 * it is kept after the activity is finished is different than the use of
4861 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4862 * this flag is being used to create a new recents entry, then by default that entry
4863 * will be removed once the activity is finished. You can modify this behavior with
4864 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4865 *
Craig Mautner026596b2014-05-21 15:35:44 -07004866 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4867 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4868 * equivalent of the Activity manifest specifying {@link
4869 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4870 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4871 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004872 *
Craig Mautner026596b2014-05-21 15:35:44 -07004873 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004874 *
Craig Mautner026596b2014-05-21 15:35:44 -07004875 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004876 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4877 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004878 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004879 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004880 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004881 * callback from occurring on the current frontmost activity before it is
4882 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004883 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004884 * <p>Typically, an activity can rely on that callback to indicate that an
4885 * explicit user action has caused their activity to be moved out of the
4886 * foreground. The callback marks an appropriate point in the activity's
4887 * lifecycle for it to dismiss any notifications that it intends to display
4888 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004889 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004890 * <p>If an activity is ever started via any non-user-driven events such as
4891 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4892 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004893 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004894 */
4895 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004896 /**
4897 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4898 * this flag will cause the launched activity to be brought to the front of its
4899 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004900 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004901 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4902 * If D calls startActivity() with an Intent that resolves to the component
4903 * of activity B, then B will be brought to the front of the history stack,
4904 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004905 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004906 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004907 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004908 */
4909 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004910 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004911 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4912 * this flag will prevent the system from applying an activity transition
4913 * animation to go to the next activity state. This doesn't mean an
4914 * animation will never run -- if another activity change happens that doesn't
4915 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004916 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004917 * when you are going to do a series of activity operations but the
4918 * animation seen by the user shouldn't be driven by the first activity
4919 * change but rather a later one.
4920 */
4921 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4922 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004923 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4924 * this flag will cause any existing task that would be associated with the
4925 * activity to be cleared before the activity is started. That is, the activity
4926 * becomes the new root of an otherwise empty task, and any old activities
4927 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4928 */
4929 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4930 /**
4931 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4932 * this flag will cause a newly launching task to be placed on top of the current
4933 * home activity task (if there is one). That is, pressing back from the task
4934 * will always return the user to home even if that was not the last activity they
4935 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4936 */
4937 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4938 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004939 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4940 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004941 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004942 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004943 * this flag. When set and the task's activity is finished, the recents
4944 * entry will remain in the interface for the user to re-launch it, like a
4945 * recents entry for a top-level application.
4946 * <p>
4947 * The receiving activity can override this request with
4948 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4949 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004950 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004951 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004952 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004953
4954 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004955 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4956 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004957 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4958 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004959 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004960 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004961
4962 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004963 * If set, when sending a broadcast only registered receivers will be
4964 * called -- no BroadcastReceiver components will be launched.
4965 */
4966 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004967 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004968 * If set, when sending a broadcast the new broadcast will replace
4969 * any existing pending broadcast that matches it. Matching is defined
4970 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4971 * true for the intents of the two broadcasts. When a match is found,
4972 * the new broadcast (and receivers associated with it) will replace the
4973 * existing one in the pending broadcast list, remaining at the same
4974 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004975 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004976 * <p>This flag is most typically used with sticky broadcasts, which
4977 * only care about delivering the most recent values of the broadcast
4978 * to their receivers.
4979 */
4980 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4981 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004982 * If set, when sending a broadcast the recipient is allowed to run at
4983 * foreground priority, with a shorter timeout interval. During normal
4984 * broadcasts the receivers are not automatically hoisted out of the
4985 * background priority class.
4986 */
4987 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4988 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004989 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4990 * They can still propagate results through to later receivers, but they can not prevent
4991 * later receivers from seeing the broadcast.
4992 */
4993 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4994 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004995 * If set, when sending a broadcast <i>before boot has completed</i> only
4996 * registered receivers will be called -- no BroadcastReceiver components
4997 * will be launched. Sticky intent state will be recorded properly even
4998 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4999 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005000 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005001 * <p>This flag is only for use by system sevices as a convenience to
5002 * avoid having to implement a more complex mechanism around detection
5003 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005004 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005005 * @hide
5006 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005007 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005008 /**
5009 * Set when this broadcast is for a boot upgrade, a special mode that
5010 * allows the broadcast to be sent before the system is ready and launches
5011 * the app process with no providers running in it.
5012 * @hide
5013 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005014 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005015 /**
5016 * If set, the broadcast will always go to manifest receivers in background (cached
5017 * or not running) apps, regardless of whether that would be done by default. By
5018 * default they will only receive broadcasts if the broadcast has specified an
5019 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005020 *
5021 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5022 * the broadcast code there must also be changed to match.
5023 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005024 * @hide
5025 */
5026 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5027 /**
5028 * If set, the broadcast will never go to manifest receivers in background (cached
5029 * or not running) apps, regardless of whether that would be done by default. By
5030 * default they will receive broadcasts if the broadcast has specified an
5031 * explicit component or package name.
5032 * @hide
5033 */
5034 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005035 /**
5036 * If set, this broadcast is being sent from the shell.
5037 * @hide
5038 */
5039 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005041 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005042 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5043 * will not receive broadcasts.
5044 *
5045 * <em>This flag has no effect when used by an Instant App.</em>
5046 */
5047 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5048
5049 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005050 * @hide Flags that can't be changed with PendingIntent.
5051 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005052 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5053 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5054 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005055
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005056 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005057 // ---------------------------------------------------------------------
5058 // toUri() and parseUri() options.
5059
5060 /**
5061 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5062 * always has the "intent:" scheme. This syntax can be used when you want
5063 * to later disambiguate between URIs that are intended to describe an
5064 * Intent vs. all others that should be treated as raw URIs. When used
5065 * with {@link #parseUri}, any other scheme will result in a generic
5066 * VIEW action for that raw URI.
5067 */
5068 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005069
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005070 /**
5071 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5072 * always has the "android-app:" scheme. This is a variation of
5073 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5074 * http/https URI being delivered to a specific package name. The format
5075 * is:
5076 *
5077 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005078 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005079 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005080 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5081 * you must also include a scheme; including a path also requires both a host and a scheme.
5082 * The final #Intent; fragment can be used without a scheme, host, or path.
5083 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005084 * used with intents that have a {@link #setSelector}, since the base intent
5085 * will always have an explicit package name.</p>
5086 *
5087 * <p>Some examples of how this scheme maps to Intent objects:</p>
5088 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5089 * <colgroup align="left" />
5090 * <colgroup align="left" />
5091 * <thead>
5092 * <tr><th>URI</th> <th>Intent</th></tr>
5093 * </thead>
5094 *
5095 * <tbody>
5096 * <tr><td><code>android-app://com.example.app</code></td>
5097 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5098 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5099 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5100 * </table></td>
5101 * </tr>
5102 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5103 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5104 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5105 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5106 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5107 * </table></td>
5108 * </tr>
5109 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5110 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5111 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5112 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5113 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5114 * </table></td>
5115 * </tr>
5116 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5117 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5118 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5119 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5120 * </table></td>
5121 * </tr>
5122 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5123 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5124 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5125 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5126 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5127 * </table></td>
5128 * </tr>
5129 * <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>
5130 * <td><table border="" style="margin:0" >
5131 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5132 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5133 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5134 * </table></td>
5135 * </tr>
5136 * </tbody>
5137 * </table>
5138 */
5139 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5140
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005141 /**
5142 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5143 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5144 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5145 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5146 * generated Intent can not cause unexpected data access to happen.
5147 *
5148 * <p>If you do not trust the source of the URI being parsed, you should still do further
5149 * processing to protect yourself from it. In particular, when using it to start an
5150 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5151 * that can handle it.</p>
5152 */
5153 public static final int URI_ALLOW_UNSAFE = 1<<2;
5154
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005155 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005156
5157 private String mAction;
5158 private Uri mData;
5159 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005160 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005161 private ComponentName mComponent;
5162 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005163 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005164 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005165 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005166 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005167 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005168 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005169 /** Token to track instant app launches. Local only; do not copy cross-process. */
5170 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005171
5172 // ---------------------------------------------------------------------
5173
5174 /**
5175 * Create an empty intent.
5176 */
5177 public Intent() {
5178 }
5179
5180 /**
5181 * Copy constructor.
5182 */
5183 public Intent(Intent o) {
5184 this.mAction = o.mAction;
5185 this.mData = o.mData;
5186 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005187 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005188 this.mComponent = o.mComponent;
5189 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005190 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005191 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005192 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005193 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005194 }
5195 if (o.mExtras != null) {
5196 this.mExtras = new Bundle(o.mExtras);
5197 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005198 if (o.mSourceBounds != null) {
5199 this.mSourceBounds = new Rect(o.mSourceBounds);
5200 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005201 if (o.mSelector != null) {
5202 this.mSelector = new Intent(o.mSelector);
5203 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005204 if (o.mClipData != null) {
5205 this.mClipData = new ClipData(o.mClipData);
5206 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005207 }
5208
5209 @Override
5210 public Object clone() {
5211 return new Intent(this);
5212 }
5213
5214 private Intent(Intent o, boolean all) {
5215 this.mAction = o.mAction;
5216 this.mData = o.mData;
5217 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005218 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005219 this.mComponent = o.mComponent;
5220 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005221 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005222 }
5223 }
5224
5225 /**
5226 * Make a clone of only the parts of the Intent that are relevant for
5227 * filter matching: the action, data, type, component, and categories.
5228 */
5229 public Intent cloneFilter() {
5230 return new Intent(this, false);
5231 }
5232
5233 /**
5234 * Create an intent with a given action. All other fields (data, type,
5235 * class) are null. Note that the action <em>must</em> be in a
5236 * namespace because Intents are used globally in the system -- for
5237 * example the system VIEW action is android.intent.action.VIEW; an
5238 * application's custom action would be something like
5239 * com.google.app.myapp.CUSTOM_ACTION.
5240 *
5241 * @param action The Intent action, such as ACTION_VIEW.
5242 */
5243 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005244 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005245 }
5246
5247 /**
5248 * Create an intent with a given action and for a given data url. Note
5249 * that the action <em>must</em> be in a namespace because Intents are
5250 * used globally in the system -- for example the system VIEW action is
5251 * android.intent.action.VIEW; an application's custom action would be
5252 * something like com.google.app.myapp.CUSTOM_ACTION.
5253 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005254 * <p><em>Note: scheme and host name matching in the Android framework is
5255 * case-sensitive, unlike the formal RFC. As a result,
5256 * you should always ensure that you write your Uri with these elements
5257 * using lower case letters, and normalize any Uris you receive from
5258 * outside of Android to ensure the scheme and host is lower case.</em></p>
5259 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005260 * @param action The Intent action, such as ACTION_VIEW.
5261 * @param uri The Intent data URI.
5262 */
5263 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005264 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005265 mData = uri;
5266 }
5267
5268 /**
5269 * Create an intent for a specific component. All other fields (action, data,
5270 * type, class) are null, though they can be modified later with explicit
5271 * calls. This provides a convenient way to create an intent that is
5272 * intended to execute a hard-coded class name, rather than relying on the
5273 * system to find an appropriate class for you; see {@link #setComponent}
5274 * for more information on the repercussions of this.
5275 *
5276 * @param packageContext A Context of the application package implementing
5277 * this class.
5278 * @param cls The component class that is to be used for the intent.
5279 *
5280 * @see #setClass
5281 * @see #setComponent
5282 * @see #Intent(String, android.net.Uri , Context, Class)
5283 */
5284 public Intent(Context packageContext, Class<?> cls) {
5285 mComponent = new ComponentName(packageContext, cls);
5286 }
5287
5288 /**
5289 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005290 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005291 * construct the Intent and then calling {@link #setClass} to set its
5292 * class.
5293 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005294 * <p><em>Note: scheme and host name matching in the Android framework is
5295 * case-sensitive, unlike the formal RFC. As a result,
5296 * you should always ensure that you write your Uri with these elements
5297 * using lower case letters, and normalize any Uris you receive from
5298 * outside of Android to ensure the scheme and host is lower case.</em></p>
5299 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005300 * @param action The Intent action, such as ACTION_VIEW.
5301 * @param uri The Intent data URI.
5302 * @param packageContext A Context of the application package implementing
5303 * this class.
5304 * @param cls The component class that is to be used for the intent.
5305 *
5306 * @see #Intent(String, android.net.Uri)
5307 * @see #Intent(Context, Class)
5308 * @see #setClass
5309 * @see #setComponent
5310 */
5311 public Intent(String action, Uri uri,
5312 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005313 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005314 mData = uri;
5315 mComponent = new ComponentName(packageContext, cls);
5316 }
5317
5318 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005319 * Create an intent to launch the main (root) activity of a task. This
5320 * is the Intent that is started when the application's is launched from
5321 * Home. For anything else that wants to launch an application in the
5322 * same way, it is important that they use an Intent structured the same
5323 * way, and can use this function to ensure this is the case.
5324 *
5325 * <p>The returned Intent has the given Activity component as its explicit
5326 * component, {@link #ACTION_MAIN} as its action, and includes the
5327 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5328 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5329 * to do that through {@link #addFlags(int)} on the returned Intent.
5330 *
5331 * @param mainActivity The main activity component that this Intent will
5332 * launch.
5333 * @return Returns a newly created Intent that can be used to launch the
5334 * activity as a main application entry.
5335 *
5336 * @see #setClass
5337 * @see #setComponent
5338 */
5339 public static Intent makeMainActivity(ComponentName mainActivity) {
5340 Intent intent = new Intent(ACTION_MAIN);
5341 intent.setComponent(mainActivity);
5342 intent.addCategory(CATEGORY_LAUNCHER);
5343 return intent;
5344 }
5345
5346 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005347 * Make an Intent for the main activity of an application, without
5348 * specifying a specific activity to run but giving a selector to find
5349 * the activity. This results in a final Intent that is structured
5350 * the same as when the application is launched from
5351 * Home. For anything else that wants to launch an application in the
5352 * same way, it is important that they use an Intent structured the same
5353 * way, and can use this function to ensure this is the case.
5354 *
5355 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5356 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5357 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5358 * to do that through {@link #addFlags(int)} on the returned Intent.
5359 *
5360 * @param selectorAction The action name of the Intent's selector.
5361 * @param selectorCategory The name of a category to add to the Intent's
5362 * selector.
5363 * @return Returns a newly created Intent that can be used to launch the
5364 * activity as a main application entry.
5365 *
5366 * @see #setSelector(Intent)
5367 */
5368 public static Intent makeMainSelectorActivity(String selectorAction,
5369 String selectorCategory) {
5370 Intent intent = new Intent(ACTION_MAIN);
5371 intent.addCategory(CATEGORY_LAUNCHER);
5372 Intent selector = new Intent();
5373 selector.setAction(selectorAction);
5374 selector.addCategory(selectorCategory);
5375 intent.setSelector(selector);
5376 return intent;
5377 }
5378
5379 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005380 * Make an Intent that can be used to re-launch an application's task
5381 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5382 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5383 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5384 *
5385 * @param mainActivity The activity component that is the root of the
5386 * task; this is the activity that has been published in the application's
5387 * manifest as the main launcher icon.
5388 *
5389 * @return Returns a newly created Intent that can be used to relaunch the
5390 * activity's task in its root state.
5391 */
5392 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5393 Intent intent = makeMainActivity(mainActivity);
5394 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5395 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5396 return intent;
5397 }
5398
5399 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005400 * Call {@link #parseUri} with 0 flags.
5401 * @deprecated Use {@link #parseUri} instead.
5402 */
5403 @Deprecated
5404 public static Intent getIntent(String uri) throws URISyntaxException {
5405 return parseUri(uri, 0);
5406 }
Tom Taylord4a47292009-12-21 13:59:18 -08005407
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005408 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005409 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005410 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005411 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005412 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005413 *
5414 * <p>The URI given here must not be relative -- that is, it must include
5415 * the scheme and full path.
5416 *
5417 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005418 * @param flags Additional processing flags. Either 0,
5419 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005420 *
5421 * @return Intent The newly created Intent object.
5422 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005423 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5424 * it bad (as parsed by the Uri class) or the Intent data within the
5425 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005426 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005427 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005428 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005429 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005430 int i = 0;
5431 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005432 final boolean androidApp = uri.startsWith("android-app:");
5433
5434 // Validate intent scheme if requested.
5435 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5436 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005437 Intent intent = new Intent(ACTION_VIEW);
5438 try {
5439 intent.setData(Uri.parse(uri));
5440 } catch (IllegalArgumentException e) {
5441 throw new URISyntaxException(uri, e.getMessage());
5442 }
5443 return intent;
5444 }
5445 }
Tom Taylord4a47292009-12-21 13:59:18 -08005446
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005447 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005448 // simple case
5449 if (i == -1) {
5450 if (!androidApp) {
5451 return new Intent(ACTION_VIEW, Uri.parse(uri));
5452 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005453
5454 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005455 } else if (!uri.startsWith("#Intent;", i)) {
5456 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005457 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005458 } else {
5459 i = -1;
5460 }
5461 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005462
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005463 // new format
5464 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005465 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005466 boolean explicitAction = false;
5467 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468
5469 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005470 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005471 String data;
5472 if (i >= 0) {
5473 data = uri.substring(0, i);
5474 i += 8; // length of "#Intent;"
5475 } else {
5476 data = uri;
5477 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005478
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005479 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005480 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005481 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005482 if (eq < 0) eq = i-1;
5483 int semi = uri.indexOf(';', i);
5484 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005485
5486 // action
5487 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005488 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005489 if (!inSelector) {
5490 explicitAction = true;
5491 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005492 }
5493
5494 // categories
5495 else if (uri.startsWith("category=", i)) {
5496 intent.addCategory(value);
5497 }
5498
5499 // type
5500 else if (uri.startsWith("type=", i)) {
5501 intent.mType = value;
5502 }
5503
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005504 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005505 else if (uri.startsWith("launchFlags=", i)) {
5506 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005507 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5508 intent.mFlags &= ~IMMUTABLE_FLAGS;
5509 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005510 }
5511
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005512 // package
5513 else if (uri.startsWith("package=", i)) {
5514 intent.mPackage = value;
5515 }
5516
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005517 // component
5518 else if (uri.startsWith("component=", i)) {
5519 intent.mComponent = ComponentName.unflattenFromString(value);
5520 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005521
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005522 // scheme
5523 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005524 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005525 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005526 } else {
5527 scheme = value;
5528 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005529 }
5530
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005531 // source bounds
5532 else if (uri.startsWith("sourceBounds=", i)) {
5533 intent.mSourceBounds = Rect.unflattenFromString(value);
5534 }
5535
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005536 // selector
5537 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5538 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005539 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005540 }
5541
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005542 // extra
5543 else {
5544 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005545 // create Bundle if it doesn't already exist
5546 if (intent.mExtras == null) intent.mExtras = new Bundle();
5547 Bundle b = intent.mExtras;
5548 // add EXTRA
5549 if (uri.startsWith("S.", i)) b.putString(key, value);
5550 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5551 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5552 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5553 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5554 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5555 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5556 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5557 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5558 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5559 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005560
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005561 // move to the next item
5562 i = semi + 1;
5563 }
5564
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005565 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005566 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005567 if (baseIntent.mPackage == null) {
5568 baseIntent.setSelector(intent);
5569 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005570 intent = baseIntent;
5571 }
5572
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005573 if (data != null) {
5574 if (data.startsWith("intent:")) {
5575 data = data.substring(7);
5576 if (scheme != null) {
5577 data = scheme + ':' + data;
5578 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005579 } else if (data.startsWith("android-app:")) {
5580 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5581 // Correctly formed android-app, first part is package name.
5582 int end = data.indexOf('/', 14);
5583 if (end < 0) {
5584 // All we have is a package name.
5585 intent.mPackage = data.substring(14);
5586 if (!explicitAction) {
5587 intent.setAction(ACTION_MAIN);
5588 }
5589 data = "";
5590 } else {
5591 // Target the Intent at the given package name always.
5592 String authority = null;
5593 intent.mPackage = data.substring(14, end);
5594 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005595 if ((end+1) < data.length()) {
5596 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5597 // Found a scheme, remember it.
5598 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005599 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005600 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5601 // Found a authority, remember it.
5602 authority = data.substring(end+1, newEnd);
5603 end = newEnd;
5604 }
5605 } else {
5606 // All we have is a scheme.
5607 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005608 }
5609 }
5610 if (scheme == null) {
5611 // If there was no scheme, then this just targets the package.
5612 if (!explicitAction) {
5613 intent.setAction(ACTION_MAIN);
5614 }
5615 data = "";
5616 } else if (authority == null) {
5617 data = scheme + ":";
5618 } else {
5619 data = scheme + "://" + authority + data.substring(end);
5620 }
5621 }
5622 } else {
5623 data = "";
5624 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005625 }
Tom Taylord4a47292009-12-21 13:59:18 -08005626
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005627 if (data.length() > 0) {
5628 try {
5629 intent.mData = Uri.parse(data);
5630 } catch (IllegalArgumentException e) {
5631 throw new URISyntaxException(uri, e.getMessage());
5632 }
5633 }
5634 }
Tom Taylord4a47292009-12-21 13:59:18 -08005635
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005636 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005637
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005638 } catch (IndexOutOfBoundsException e) {
5639 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5640 }
5641 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005643 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005644 return getIntentOld(uri, 0);
5645 }
5646
5647 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005648 Intent intent;
5649
5650 int i = uri.lastIndexOf('#');
5651 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005652 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005653 final int intentFragmentStart = i;
5654 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005655
5656 i++;
5657
5658 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005659 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005660 i += 7;
5661 int j = uri.indexOf(')', i);
5662 action = uri.substring(i, j);
5663 i = j + 1;
5664 }
5665
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005666 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005667
5668 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005669 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005670 i += 11;
5671 int j = uri.indexOf(')', i);
5672 while (i < j) {
5673 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005674 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005675 if (i < sep) {
5676 intent.addCategory(uri.substring(i, sep));
5677 }
5678 i = sep + 1;
5679 }
5680 i = j + 1;
5681 }
5682
5683 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005684 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005685 i += 5;
5686 int j = uri.indexOf(')', i);
5687 intent.mType = uri.substring(i, j);
5688 i = j + 1;
5689 }
5690
5691 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005692 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005693 i += 12;
5694 int j = uri.indexOf(')', i);
5695 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005696 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5697 intent.mFlags &= ~IMMUTABLE_FLAGS;
5698 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005699 i = j + 1;
5700 }
5701
5702 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005703 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 i += 10;
5705 int j = uri.indexOf(')', i);
5706 int sep = uri.indexOf('!', i);
5707 if (sep >= 0 && sep < j) {
5708 String pkg = uri.substring(i, sep);
5709 String cls = uri.substring(sep + 1, j);
5710 intent.mComponent = new ComponentName(pkg, cls);
5711 }
5712 i = j + 1;
5713 }
5714
5715 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005716 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005717 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005718
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005719 final int closeParen = uri.indexOf(')', i);
5720 if (closeParen == -1) throw new URISyntaxException(uri,
5721 "EXTRA missing trailing ')'", i);
5722
5723 while (i < closeParen) {
5724 // fetch the key value
5725 int j = uri.indexOf('=', i);
5726 if (j <= i + 1 || i >= closeParen) {
5727 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5728 }
5729 char type = uri.charAt(i);
5730 i++;
5731 String key = uri.substring(i, j);
5732 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005734 // get type-value
5735 j = uri.indexOf('!', i);
5736 if (j == -1 || j >= closeParen) j = closeParen;
5737 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5738 String value = uri.substring(i, j);
5739 i = j;
5740
5741 // create Bundle if it doesn't already exist
5742 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005743
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005744 // add item to bundle
5745 try {
5746 switch (type) {
5747 case 'S':
5748 intent.mExtras.putString(key, Uri.decode(value));
5749 break;
5750 case 'B':
5751 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5752 break;
5753 case 'b':
5754 intent.mExtras.putByte(key, Byte.parseByte(value));
5755 break;
5756 case 'c':
5757 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5758 break;
5759 case 'd':
5760 intent.mExtras.putDouble(key, Double.parseDouble(value));
5761 break;
5762 case 'f':
5763 intent.mExtras.putFloat(key, Float.parseFloat(value));
5764 break;
5765 case 'i':
5766 intent.mExtras.putInt(key, Integer.parseInt(value));
5767 break;
5768 case 'l':
5769 intent.mExtras.putLong(key, Long.parseLong(value));
5770 break;
5771 case 's':
5772 intent.mExtras.putShort(key, Short.parseShort(value));
5773 break;
5774 default:
5775 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5776 }
5777 } catch (NumberFormatException e) {
5778 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5779 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005780
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005781 char ch = uri.charAt(i);
5782 if (ch == ')') break;
5783 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5784 i++;
5785 }
5786 }
5787
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005788 if (isIntentFragment) {
5789 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5790 } else {
5791 intent.mData = Uri.parse(uri);
5792 }
Tom Taylord4a47292009-12-21 13:59:18 -08005793
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005794 if (intent.mAction == null) {
5795 // By default, if no action is specified, then use VIEW.
5796 intent.mAction = ACTION_VIEW;
5797 }
5798
5799 } else {
5800 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5801 }
5802
5803 return intent;
5804 }
5805
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005806 /** @hide */
5807 public interface CommandOptionHandler {
5808 boolean handleOption(String opt, ShellCommand cmd);
5809 }
5810
5811 /** @hide */
5812 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5813 throws URISyntaxException {
5814 Intent intent = new Intent();
5815 Intent baseIntent = intent;
5816 boolean hasIntentInfo = false;
5817
5818 Uri data = null;
5819 String type = null;
5820
5821 String opt;
5822 while ((opt=cmd.getNextOption()) != null) {
5823 switch (opt) {
5824 case "-a":
5825 intent.setAction(cmd.getNextArgRequired());
5826 if (intent == baseIntent) {
5827 hasIntentInfo = true;
5828 }
5829 break;
5830 case "-d":
5831 data = Uri.parse(cmd.getNextArgRequired());
5832 if (intent == baseIntent) {
5833 hasIntentInfo = true;
5834 }
5835 break;
5836 case "-t":
5837 type = cmd.getNextArgRequired();
5838 if (intent == baseIntent) {
5839 hasIntentInfo = true;
5840 }
5841 break;
5842 case "-c":
5843 intent.addCategory(cmd.getNextArgRequired());
5844 if (intent == baseIntent) {
5845 hasIntentInfo = true;
5846 }
5847 break;
5848 case "-e":
5849 case "--es": {
5850 String key = cmd.getNextArgRequired();
5851 String value = cmd.getNextArgRequired();
5852 intent.putExtra(key, value);
5853 }
5854 break;
5855 case "--esn": {
5856 String key = cmd.getNextArgRequired();
5857 intent.putExtra(key, (String) null);
5858 }
5859 break;
5860 case "--ei": {
5861 String key = cmd.getNextArgRequired();
5862 String value = cmd.getNextArgRequired();
5863 intent.putExtra(key, Integer.decode(value));
5864 }
5865 break;
5866 case "--eu": {
5867 String key = cmd.getNextArgRequired();
5868 String value = cmd.getNextArgRequired();
5869 intent.putExtra(key, Uri.parse(value));
5870 }
5871 break;
5872 case "--ecn": {
5873 String key = cmd.getNextArgRequired();
5874 String value = cmd.getNextArgRequired();
5875 ComponentName cn = ComponentName.unflattenFromString(value);
5876 if (cn == null)
5877 throw new IllegalArgumentException("Bad component name: " + value);
5878 intent.putExtra(key, cn);
5879 }
5880 break;
5881 case "--eia": {
5882 String key = cmd.getNextArgRequired();
5883 String value = cmd.getNextArgRequired();
5884 String[] strings = value.split(",");
5885 int[] list = new int[strings.length];
5886 for (int i = 0; i < strings.length; i++) {
5887 list[i] = Integer.decode(strings[i]);
5888 }
5889 intent.putExtra(key, list);
5890 }
5891 break;
5892 case "--eial": {
5893 String key = cmd.getNextArgRequired();
5894 String value = cmd.getNextArgRequired();
5895 String[] strings = value.split(",");
5896 ArrayList<Integer> list = new ArrayList<>(strings.length);
5897 for (int i = 0; i < strings.length; i++) {
5898 list.add(Integer.decode(strings[i]));
5899 }
5900 intent.putExtra(key, list);
5901 }
5902 break;
5903 case "--el": {
5904 String key = cmd.getNextArgRequired();
5905 String value = cmd.getNextArgRequired();
5906 intent.putExtra(key, Long.valueOf(value));
5907 }
5908 break;
5909 case "--ela": {
5910 String key = cmd.getNextArgRequired();
5911 String value = cmd.getNextArgRequired();
5912 String[] strings = value.split(",");
5913 long[] list = new long[strings.length];
5914 for (int i = 0; i < strings.length; i++) {
5915 list[i] = Long.valueOf(strings[i]);
5916 }
5917 intent.putExtra(key, list);
5918 hasIntentInfo = true;
5919 }
5920 break;
5921 case "--elal": {
5922 String key = cmd.getNextArgRequired();
5923 String value = cmd.getNextArgRequired();
5924 String[] strings = value.split(",");
5925 ArrayList<Long> list = new ArrayList<>(strings.length);
5926 for (int i = 0; i < strings.length; i++) {
5927 list.add(Long.valueOf(strings[i]));
5928 }
5929 intent.putExtra(key, list);
5930 hasIntentInfo = true;
5931 }
5932 break;
5933 case "--ef": {
5934 String key = cmd.getNextArgRequired();
5935 String value = cmd.getNextArgRequired();
5936 intent.putExtra(key, Float.valueOf(value));
5937 hasIntentInfo = true;
5938 }
5939 break;
5940 case "--efa": {
5941 String key = cmd.getNextArgRequired();
5942 String value = cmd.getNextArgRequired();
5943 String[] strings = value.split(",");
5944 float[] list = new float[strings.length];
5945 for (int i = 0; i < strings.length; i++) {
5946 list[i] = Float.valueOf(strings[i]);
5947 }
5948 intent.putExtra(key, list);
5949 hasIntentInfo = true;
5950 }
5951 break;
5952 case "--efal": {
5953 String key = cmd.getNextArgRequired();
5954 String value = cmd.getNextArgRequired();
5955 String[] strings = value.split(",");
5956 ArrayList<Float> list = new ArrayList<>(strings.length);
5957 for (int i = 0; i < strings.length; i++) {
5958 list.add(Float.valueOf(strings[i]));
5959 }
5960 intent.putExtra(key, list);
5961 hasIntentInfo = true;
5962 }
5963 break;
5964 case "--esa": {
5965 String key = cmd.getNextArgRequired();
5966 String value = cmd.getNextArgRequired();
5967 // Split on commas unless they are preceeded by an escape.
5968 // The escape character must be escaped for the string and
5969 // again for the regex, thus four escape characters become one.
5970 String[] strings = value.split("(?<!\\\\),");
5971 intent.putExtra(key, strings);
5972 hasIntentInfo = true;
5973 }
5974 break;
5975 case "--esal": {
5976 String key = cmd.getNextArgRequired();
5977 String value = cmd.getNextArgRequired();
5978 // Split on commas unless they are preceeded by an escape.
5979 // The escape character must be escaped for the string and
5980 // again for the regex, thus four escape characters become one.
5981 String[] strings = value.split("(?<!\\\\),");
5982 ArrayList<String> list = new ArrayList<>(strings.length);
5983 for (int i = 0; i < strings.length; i++) {
5984 list.add(strings[i]);
5985 }
5986 intent.putExtra(key, list);
5987 hasIntentInfo = true;
5988 }
5989 break;
5990 case "--ez": {
5991 String key = cmd.getNextArgRequired();
5992 String value = cmd.getNextArgRequired().toLowerCase();
5993 // Boolean.valueOf() results in false for anything that is not "true", which is
5994 // error-prone in shell commands
5995 boolean arg;
5996 if ("true".equals(value) || "t".equals(value)) {
5997 arg = true;
5998 } else if ("false".equals(value) || "f".equals(value)) {
5999 arg = false;
6000 } else {
6001 try {
6002 arg = Integer.decode(value) != 0;
6003 } catch (NumberFormatException ex) {
6004 throw new IllegalArgumentException("Invalid boolean value: " + value);
6005 }
6006 }
6007
6008 intent.putExtra(key, arg);
6009 }
6010 break;
6011 case "-n": {
6012 String str = cmd.getNextArgRequired();
6013 ComponentName cn = ComponentName.unflattenFromString(str);
6014 if (cn == null)
6015 throw new IllegalArgumentException("Bad component name: " + str);
6016 intent.setComponent(cn);
6017 if (intent == baseIntent) {
6018 hasIntentInfo = true;
6019 }
6020 }
6021 break;
6022 case "-p": {
6023 String str = cmd.getNextArgRequired();
6024 intent.setPackage(str);
6025 if (intent == baseIntent) {
6026 hasIntentInfo = true;
6027 }
6028 }
6029 break;
6030 case "-f":
6031 String str = cmd.getNextArgRequired();
6032 intent.setFlags(Integer.decode(str).intValue());
6033 break;
6034 case "--grant-read-uri-permission":
6035 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6036 break;
6037 case "--grant-write-uri-permission":
6038 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6039 break;
6040 case "--grant-persistable-uri-permission":
6041 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6042 break;
6043 case "--grant-prefix-uri-permission":
6044 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6045 break;
6046 case "--exclude-stopped-packages":
6047 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6048 break;
6049 case "--include-stopped-packages":
6050 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6051 break;
6052 case "--debug-log-resolution":
6053 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6054 break;
6055 case "--activity-brought-to-front":
6056 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6057 break;
6058 case "--activity-clear-top":
6059 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6060 break;
6061 case "--activity-clear-when-task-reset":
6062 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6063 break;
6064 case "--activity-exclude-from-recents":
6065 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6066 break;
6067 case "--activity-launched-from-history":
6068 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6069 break;
6070 case "--activity-multiple-task":
6071 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6072 break;
6073 case "--activity-no-animation":
6074 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6075 break;
6076 case "--activity-no-history":
6077 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6078 break;
6079 case "--activity-no-user-action":
6080 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6081 break;
6082 case "--activity-previous-is-top":
6083 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6084 break;
6085 case "--activity-reorder-to-front":
6086 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6087 break;
6088 case "--activity-reset-task-if-needed":
6089 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6090 break;
6091 case "--activity-single-top":
6092 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6093 break;
6094 case "--activity-clear-task":
6095 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6096 break;
6097 case "--activity-task-on-home":
6098 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6099 break;
6100 case "--receiver-registered-only":
6101 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6102 break;
6103 case "--receiver-replace-pending":
6104 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6105 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006106 case "--receiver-foreground":
6107 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6108 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006109 case "--receiver-no-abort":
6110 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6111 break;
6112 case "--receiver-include-background":
6113 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6114 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006115 case "--selector":
6116 intent.setDataAndType(data, type);
6117 intent = new Intent();
6118 break;
6119 default:
6120 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6121 // Okay, caller handled this option.
6122 } else {
6123 throw new IllegalArgumentException("Unknown option: " + opt);
6124 }
6125 break;
6126 }
6127 }
6128 intent.setDataAndType(data, type);
6129
6130 final boolean hasSelector = intent != baseIntent;
6131 if (hasSelector) {
6132 // A selector was specified; fix up.
6133 baseIntent.setSelector(intent);
6134 intent = baseIntent;
6135 }
6136
6137 String arg = cmd.getNextArg();
6138 baseIntent = null;
6139 if (arg == null) {
6140 if (hasSelector) {
6141 // If a selector has been specified, and no arguments
6142 // have been supplied for the main Intent, then we can
6143 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6144 // need to have a component name specified yet, the
6145 // selector will take care of that.
6146 baseIntent = new Intent(Intent.ACTION_MAIN);
6147 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6148 }
6149 } else if (arg.indexOf(':') >= 0) {
6150 // The argument is a URI. Fully parse it, and use that result
6151 // to fill in any data not specified so far.
6152 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6153 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6154 } else if (arg.indexOf('/') >= 0) {
6155 // The argument is a component name. Build an Intent to launch
6156 // it.
6157 baseIntent = new Intent(Intent.ACTION_MAIN);
6158 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6159 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6160 } else {
6161 // Assume the argument is a package name.
6162 baseIntent = new Intent(Intent.ACTION_MAIN);
6163 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6164 baseIntent.setPackage(arg);
6165 }
6166 if (baseIntent != null) {
6167 Bundle extras = intent.getExtras();
6168 intent.replaceExtras((Bundle)null);
6169 Bundle uriExtras = baseIntent.getExtras();
6170 baseIntent.replaceExtras((Bundle)null);
6171 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6172 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6173 for (String c : cats) {
6174 baseIntent.removeCategory(c);
6175 }
6176 }
6177 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6178 if (extras == null) {
6179 extras = uriExtras;
6180 } else if (uriExtras != null) {
6181 uriExtras.putAll(extras);
6182 extras = uriExtras;
6183 }
6184 intent.replaceExtras(extras);
6185 hasIntentInfo = true;
6186 }
6187
6188 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6189 return intent;
6190 }
6191
6192 /** @hide */
6193 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6194 final String[] lines = new String[] {
6195 "<INTENT> specifications include these flags and arguments:",
6196 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6197 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6198 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6199 " [--esn <EXTRA_KEY> ...]",
6200 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6201 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6202 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6203 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6204 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6205 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6206 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6207 " (mutiple extras passed as Integer[])",
6208 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6209 " (mutiple extras passed as List<Integer>)",
6210 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6211 " (mutiple extras passed as Long[])",
6212 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6213 " (mutiple extras passed as List<Long>)",
6214 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6215 " (mutiple extras passed as Float[])",
6216 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6217 " (mutiple extras passed as List<Float>)",
6218 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6219 " (mutiple extras passed as String[]; to embed a comma into a string,",
6220 " escape it using \"\\,\")",
6221 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6222 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6223 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006224 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006225 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6226 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6227 " [--debug-log-resolution] [--exclude-stopped-packages]",
6228 " [--include-stopped-packages]",
6229 " [--activity-brought-to-front] [--activity-clear-top]",
6230 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6231 " [--activity-launched-from-history] [--activity-multiple-task]",
6232 " [--activity-no-animation] [--activity-no-history]",
6233 " [--activity-no-user-action] [--activity-previous-is-top]",
6234 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6235 " [--activity-single-top] [--activity-clear-task]",
6236 " [--activity-task-on-home]",
6237 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006238 " [--receiver-foreground] [--receiver-no-abort]",
6239 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006240 " [--selector]",
6241 " [<URI> | <PACKAGE> | <COMPONENT>]"
6242 };
6243 for (String line : lines) {
6244 pw.print(prefix);
6245 pw.println(line);
6246 }
6247 }
6248
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006249 /**
6250 * Retrieve the general action to be performed, such as
6251 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6252 * the information in the intent should be interpreted -- most importantly,
6253 * what to do with the data returned by {@link #getData}.
6254 *
6255 * @return The action of this intent or null if none is specified.
6256 *
6257 * @see #setAction
6258 */
6259 public String getAction() {
6260 return mAction;
6261 }
6262
6263 /**
6264 * Retrieve data this intent is operating on. This URI specifies the name
6265 * of the data; often it uses the content: scheme, specifying data in a
6266 * content provider. Other schemes may be handled by specific activities,
6267 * such as http: by the web browser.
6268 *
6269 * @return The URI of the data this intent is targeting or null.
6270 *
6271 * @see #getScheme
6272 * @see #setData
6273 */
6274 public Uri getData() {
6275 return mData;
6276 }
6277
6278 /**
6279 * The same as {@link #getData()}, but returns the URI as an encoded
6280 * String.
6281 */
6282 public String getDataString() {
6283 return mData != null ? mData.toString() : null;
6284 }
6285
6286 /**
6287 * Return the scheme portion of the intent's data. If the data is null or
6288 * does not include a scheme, null is returned. Otherwise, the scheme
6289 * prefix without the final ':' is returned, i.e. "http".
6290 *
6291 * <p>This is the same as calling getData().getScheme() (and checking for
6292 * null data).
6293 *
6294 * @return The scheme of this intent.
6295 *
6296 * @see #getData
6297 */
6298 public String getScheme() {
6299 return mData != null ? mData.getScheme() : null;
6300 }
6301
6302 /**
6303 * Retrieve any explicit MIME type included in the intent. This is usually
6304 * null, as the type is determined by the intent data.
6305 *
6306 * @return If a type was manually set, it is returned; else null is
6307 * returned.
6308 *
6309 * @see #resolveType(ContentResolver)
6310 * @see #setType
6311 */
6312 public String getType() {
6313 return mType;
6314 }
6315
6316 /**
6317 * Return the MIME data type of this intent. If the type field is
6318 * explicitly set, that is simply returned. Otherwise, if the data is set,
6319 * the type of that data is returned. If neither fields are set, a null is
6320 * returned.
6321 *
6322 * @return The MIME type of this intent.
6323 *
6324 * @see #getType
6325 * @see #resolveType(ContentResolver)
6326 */
6327 public String resolveType(Context context) {
6328 return resolveType(context.getContentResolver());
6329 }
6330
6331 /**
6332 * Return the MIME data type of this intent. If the type field is
6333 * explicitly set, that is simply returned. Otherwise, if the data is set,
6334 * the type of that data is returned. If neither fields are set, a null is
6335 * returned.
6336 *
6337 * @param resolver A ContentResolver that can be used to determine the MIME
6338 * type of the intent's data.
6339 *
6340 * @return The MIME type of this intent.
6341 *
6342 * @see #getType
6343 * @see #resolveType(Context)
6344 */
6345 public String resolveType(ContentResolver resolver) {
6346 if (mType != null) {
6347 return mType;
6348 }
6349 if (mData != null) {
6350 if ("content".equals(mData.getScheme())) {
6351 return resolver.getType(mData);
6352 }
6353 }
6354 return null;
6355 }
6356
6357 /**
6358 * Return the MIME data type of this intent, only if it will be needed for
6359 * intent resolution. This is not generally useful for application code;
6360 * it is used by the frameworks for communicating with back-end system
6361 * services.
6362 *
6363 * @param resolver A ContentResolver that can be used to determine the MIME
6364 * type of the intent's data.
6365 *
6366 * @return The MIME type of this intent, or null if it is unknown or not
6367 * needed.
6368 */
6369 public String resolveTypeIfNeeded(ContentResolver resolver) {
6370 if (mComponent != null) {
6371 return mType;
6372 }
6373 return resolveType(resolver);
6374 }
6375
6376 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006377 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006378 *
6379 * @param category The category to check.
6380 *
6381 * @return boolean True if the intent contains the category, else false.
6382 *
6383 * @see #getCategories
6384 * @see #addCategory
6385 */
6386 public boolean hasCategory(String category) {
6387 return mCategories != null && mCategories.contains(category);
6388 }
6389
6390 /**
6391 * Return the set of all categories in the intent. If there are no categories,
6392 * returns NULL.
6393 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006394 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006395 *
6396 * @see #hasCategory
6397 * @see #addCategory
6398 */
6399 public Set<String> getCategories() {
6400 return mCategories;
6401 }
6402
6403 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006404 * Return the specific selector associated with this Intent. If there is
6405 * none, returns null. See {@link #setSelector} for more information.
6406 *
6407 * @see #setSelector
6408 */
6409 public Intent getSelector() {
6410 return mSelector;
6411 }
6412
6413 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006414 * Return the {@link ClipData} associated with this Intent. If there is
6415 * none, returns null. See {@link #setClipData} for more information.
6416 *
John Spurlock125d1332013-11-25 11:58:37 -05006417 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006418 */
6419 public ClipData getClipData() {
6420 return mClipData;
6421 }
6422
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006423 /** @hide */
6424 public int getContentUserHint() {
6425 return mContentUserHint;
6426 }
6427
Todd Kennedyb3b431302017-03-20 16:05:48 -07006428 /** @hide */
6429 public String getLaunchToken() {
6430 return mLaunchToken;
6431 }
6432
6433 /** @hide */
6434 public void setLaunchToken(String launchToken) {
6435 mLaunchToken = launchToken;
6436 }
6437
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006438 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006439 * Sets the ClassLoader that will be used when unmarshalling
6440 * any Parcelable values from the extras of this Intent.
6441 *
6442 * @param loader a ClassLoader, or null to use the default loader
6443 * at the time of unmarshalling.
6444 */
6445 public void setExtrasClassLoader(ClassLoader loader) {
6446 if (mExtras != null) {
6447 mExtras.setClassLoader(loader);
6448 }
6449 }
6450
6451 /**
6452 * Returns true if an extra value is associated with the given name.
6453 * @param name the extra's name
6454 * @return true if the given extra is present.
6455 */
6456 public boolean hasExtra(String name) {
6457 return mExtras != null && mExtras.containsKey(name);
6458 }
6459
6460 /**
6461 * Returns true if the Intent's extras contain a parcelled file descriptor.
6462 * @return true if the Intent contains a parcelled file descriptor.
6463 */
6464 public boolean hasFileDescriptors() {
6465 return mExtras != null && mExtras.hasFileDescriptors();
6466 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006467
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006468 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006469 public void setAllowFds(boolean allowFds) {
6470 if (mExtras != null) {
6471 mExtras.setAllowFds(allowFds);
6472 }
6473 }
6474
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006475 /** {@hide} */
6476 public void setDefusable(boolean defusable) {
6477 if (mExtras != null) {
6478 mExtras.setDefusable(defusable);
6479 }
6480 }
6481
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006482 /**
6483 * Retrieve extended data from the intent.
6484 *
6485 * @param name The name of the desired item.
6486 *
6487 * @return the value of an item that previously added with putExtra()
6488 * or null if none was found.
6489 *
6490 * @deprecated
6491 * @hide
6492 */
6493 @Deprecated
6494 public Object getExtra(String name) {
6495 return getExtra(name, null);
6496 }
6497
6498 /**
6499 * Retrieve extended data from the intent.
6500 *
6501 * @param name The name of the desired item.
6502 * @param defaultValue the value to be returned if no value of the desired
6503 * type is stored with the given name.
6504 *
6505 * @return the value of an item that previously added with putExtra()
6506 * or the default value if none was found.
6507 *
6508 * @see #putExtra(String, boolean)
6509 */
6510 public boolean getBooleanExtra(String name, boolean defaultValue) {
6511 return mExtras == null ? defaultValue :
6512 mExtras.getBoolean(name, defaultValue);
6513 }
6514
6515 /**
6516 * Retrieve extended data from the intent.
6517 *
6518 * @param name The name of the desired item.
6519 * @param defaultValue the value to be returned if no value of the desired
6520 * type is stored with the given name.
6521 *
6522 * @return the value of an item that previously added with putExtra()
6523 * or the default value if none was found.
6524 *
6525 * @see #putExtra(String, byte)
6526 */
6527 public byte getByteExtra(String name, byte defaultValue) {
6528 return mExtras == null ? defaultValue :
6529 mExtras.getByte(name, defaultValue);
6530 }
6531
6532 /**
6533 * Retrieve extended data from the intent.
6534 *
6535 * @param name The name of the desired item.
6536 * @param defaultValue the value to be returned if no value of the desired
6537 * type is stored with the given name.
6538 *
6539 * @return the value of an item that previously added with putExtra()
6540 * or the default value if none was found.
6541 *
6542 * @see #putExtra(String, short)
6543 */
6544 public short getShortExtra(String name, short defaultValue) {
6545 return mExtras == null ? defaultValue :
6546 mExtras.getShort(name, defaultValue);
6547 }
6548
6549 /**
6550 * Retrieve extended data from the intent.
6551 *
6552 * @param name The name of the desired item.
6553 * @param defaultValue the value to be returned if no value of the desired
6554 * type is stored with the given name.
6555 *
6556 * @return the value of an item that previously added with putExtra()
6557 * or the default value if none was found.
6558 *
6559 * @see #putExtra(String, char)
6560 */
6561 public char getCharExtra(String name, char defaultValue) {
6562 return mExtras == null ? defaultValue :
6563 mExtras.getChar(name, defaultValue);
6564 }
6565
6566 /**
6567 * Retrieve extended data from the intent.
6568 *
6569 * @param name The name of the desired item.
6570 * @param defaultValue the value to be returned if no value of the desired
6571 * type is stored with the given name.
6572 *
6573 * @return the value of an item that previously added with putExtra()
6574 * or the default value if none was found.
6575 *
6576 * @see #putExtra(String, int)
6577 */
6578 public int getIntExtra(String name, int defaultValue) {
6579 return mExtras == null ? defaultValue :
6580 mExtras.getInt(name, defaultValue);
6581 }
6582
6583 /**
6584 * Retrieve extended data from the intent.
6585 *
6586 * @param name The name of the desired item.
6587 * @param defaultValue the value to be returned if no value of the desired
6588 * type is stored with the given name.
6589 *
6590 * @return the value of an item that previously added with putExtra()
6591 * or the default value if none was found.
6592 *
6593 * @see #putExtra(String, long)
6594 */
6595 public long getLongExtra(String name, long defaultValue) {
6596 return mExtras == null ? defaultValue :
6597 mExtras.getLong(name, defaultValue);
6598 }
6599
6600 /**
6601 * Retrieve extended data from the intent.
6602 *
6603 * @param name The name of the desired item.
6604 * @param defaultValue the value to be returned if no value of the desired
6605 * type is stored with the given name.
6606 *
6607 * @return the value of an item that previously added with putExtra(),
6608 * or the default value if no such item is present
6609 *
6610 * @see #putExtra(String, float)
6611 */
6612 public float getFloatExtra(String name, float defaultValue) {
6613 return mExtras == null ? defaultValue :
6614 mExtras.getFloat(name, defaultValue);
6615 }
6616
6617 /**
6618 * Retrieve extended data from the intent.
6619 *
6620 * @param name The name of the desired item.
6621 * @param defaultValue the value to be returned if no value of the desired
6622 * type is stored with the given name.
6623 *
6624 * @return the value of an item that previously added with putExtra()
6625 * or the default value if none was found.
6626 *
6627 * @see #putExtra(String, double)
6628 */
6629 public double getDoubleExtra(String name, double defaultValue) {
6630 return mExtras == null ? defaultValue :
6631 mExtras.getDouble(name, defaultValue);
6632 }
6633
6634 /**
6635 * Retrieve extended data from the intent.
6636 *
6637 * @param name The name of the desired item.
6638 *
6639 * @return the value of an item that previously added with putExtra()
6640 * or null if no String value was found.
6641 *
6642 * @see #putExtra(String, String)
6643 */
6644 public String getStringExtra(String name) {
6645 return mExtras == null ? null : mExtras.getString(name);
6646 }
6647
6648 /**
6649 * Retrieve extended data from the intent.
6650 *
6651 * @param name The name of the desired item.
6652 *
6653 * @return the value of an item that previously added with putExtra()
6654 * or null if no CharSequence value was found.
6655 *
6656 * @see #putExtra(String, CharSequence)
6657 */
6658 public CharSequence getCharSequenceExtra(String name) {
6659 return mExtras == null ? null : mExtras.getCharSequence(name);
6660 }
6661
6662 /**
6663 * Retrieve extended data from the intent.
6664 *
6665 * @param name The name of the desired item.
6666 *
6667 * @return the value of an item that previously added with putExtra()
6668 * or null if no Parcelable value was found.
6669 *
6670 * @see #putExtra(String, Parcelable)
6671 */
6672 public <T extends Parcelable> T getParcelableExtra(String name) {
6673 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6674 }
6675
6676 /**
6677 * Retrieve extended data from the intent.
6678 *
6679 * @param name The name of the desired item.
6680 *
6681 * @return the value of an item that previously added with putExtra()
6682 * or null if no Parcelable[] value was found.
6683 *
6684 * @see #putExtra(String, Parcelable[])
6685 */
6686 public Parcelable[] getParcelableArrayExtra(String name) {
6687 return mExtras == null ? null : mExtras.getParcelableArray(name);
6688 }
6689
6690 /**
6691 * Retrieve extended data from the intent.
6692 *
6693 * @param name The name of the desired item.
6694 *
6695 * @return the value of an item that previously added with putExtra()
6696 * or null if no ArrayList<Parcelable> value was found.
6697 *
6698 * @see #putParcelableArrayListExtra(String, ArrayList)
6699 */
6700 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6701 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6702 }
6703
6704 /**
6705 * Retrieve extended data from the intent.
6706 *
6707 * @param name The name of the desired item.
6708 *
6709 * @return the value of an item that previously added with putExtra()
6710 * or null if no Serializable value was found.
6711 *
6712 * @see #putExtra(String, Serializable)
6713 */
6714 public Serializable getSerializableExtra(String name) {
6715 return mExtras == null ? null : mExtras.getSerializable(name);
6716 }
6717
6718 /**
6719 * Retrieve extended data from the intent.
6720 *
6721 * @param name The name of the desired item.
6722 *
6723 * @return the value of an item that previously added with putExtra()
6724 * or null if no ArrayList<Integer> value was found.
6725 *
6726 * @see #putIntegerArrayListExtra(String, ArrayList)
6727 */
6728 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6729 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6730 }
6731
6732 /**
6733 * Retrieve extended data from the intent.
6734 *
6735 * @param name The name of the desired item.
6736 *
6737 * @return the value of an item that previously added with putExtra()
6738 * or null if no ArrayList<String> value was found.
6739 *
6740 * @see #putStringArrayListExtra(String, ArrayList)
6741 */
6742 public ArrayList<String> getStringArrayListExtra(String name) {
6743 return mExtras == null ? null : mExtras.getStringArrayList(name);
6744 }
6745
6746 /**
6747 * Retrieve extended data from the intent.
6748 *
6749 * @param name The name of the desired item.
6750 *
6751 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006752 * or null if no ArrayList<CharSequence> value was found.
6753 *
6754 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6755 */
6756 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6757 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6758 }
6759
6760 /**
6761 * Retrieve extended data from the intent.
6762 *
6763 * @param name The name of the desired item.
6764 *
6765 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006766 * or null if no boolean array value was found.
6767 *
6768 * @see #putExtra(String, boolean[])
6769 */
6770 public boolean[] getBooleanArrayExtra(String name) {
6771 return mExtras == null ? null : mExtras.getBooleanArray(name);
6772 }
6773
6774 /**
6775 * Retrieve extended data from the intent.
6776 *
6777 * @param name The name of the desired item.
6778 *
6779 * @return the value of an item that previously added with putExtra()
6780 * or null if no byte array value was found.
6781 *
6782 * @see #putExtra(String, byte[])
6783 */
6784 public byte[] getByteArrayExtra(String name) {
6785 return mExtras == null ? null : mExtras.getByteArray(name);
6786 }
6787
6788 /**
6789 * Retrieve extended data from the intent.
6790 *
6791 * @param name The name of the desired item.
6792 *
6793 * @return the value of an item that previously added with putExtra()
6794 * or null if no short array value was found.
6795 *
6796 * @see #putExtra(String, short[])
6797 */
6798 public short[] getShortArrayExtra(String name) {
6799 return mExtras == null ? null : mExtras.getShortArray(name);
6800 }
6801
6802 /**
6803 * Retrieve extended data from the intent.
6804 *
6805 * @param name The name of the desired item.
6806 *
6807 * @return the value of an item that previously added with putExtra()
6808 * or null if no char array value was found.
6809 *
6810 * @see #putExtra(String, char[])
6811 */
6812 public char[] getCharArrayExtra(String name) {
6813 return mExtras == null ? null : mExtras.getCharArray(name);
6814 }
6815
6816 /**
6817 * Retrieve extended data from the intent.
6818 *
6819 * @param name The name of the desired item.
6820 *
6821 * @return the value of an item that previously added with putExtra()
6822 * or null if no int array value was found.
6823 *
6824 * @see #putExtra(String, int[])
6825 */
6826 public int[] getIntArrayExtra(String name) {
6827 return mExtras == null ? null : mExtras.getIntArray(name);
6828 }
6829
6830 /**
6831 * Retrieve extended data from the intent.
6832 *
6833 * @param name The name of the desired item.
6834 *
6835 * @return the value of an item that previously added with putExtra()
6836 * or null if no long array value was found.
6837 *
6838 * @see #putExtra(String, long[])
6839 */
6840 public long[] getLongArrayExtra(String name) {
6841 return mExtras == null ? null : mExtras.getLongArray(name);
6842 }
6843
6844 /**
6845 * Retrieve extended data from the intent.
6846 *
6847 * @param name The name of the desired item.
6848 *
6849 * @return the value of an item that previously added with putExtra()
6850 * or null if no float array value was found.
6851 *
6852 * @see #putExtra(String, float[])
6853 */
6854 public float[] getFloatArrayExtra(String name) {
6855 return mExtras == null ? null : mExtras.getFloatArray(name);
6856 }
6857
6858 /**
6859 * Retrieve extended data from the intent.
6860 *
6861 * @param name The name of the desired item.
6862 *
6863 * @return the value of an item that previously added with putExtra()
6864 * or null if no double array value was found.
6865 *
6866 * @see #putExtra(String, double[])
6867 */
6868 public double[] getDoubleArrayExtra(String name) {
6869 return mExtras == null ? null : mExtras.getDoubleArray(name);
6870 }
6871
6872 /**
6873 * Retrieve extended data from the intent.
6874 *
6875 * @param name The name of the desired item.
6876 *
6877 * @return the value of an item that previously added with putExtra()
6878 * or null if no String array value was found.
6879 *
6880 * @see #putExtra(String, String[])
6881 */
6882 public String[] getStringArrayExtra(String name) {
6883 return mExtras == null ? null : mExtras.getStringArray(name);
6884 }
6885
6886 /**
6887 * Retrieve extended data from the intent.
6888 *
6889 * @param name The name of the desired item.
6890 *
6891 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006892 * or null if no CharSequence array value was found.
6893 *
6894 * @see #putExtra(String, CharSequence[])
6895 */
6896 public CharSequence[] getCharSequenceArrayExtra(String name) {
6897 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6898 }
6899
6900 /**
6901 * Retrieve extended data from the intent.
6902 *
6903 * @param name The name of the desired item.
6904 *
6905 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006906 * or null if no Bundle value was found.
6907 *
6908 * @see #putExtra(String, Bundle)
6909 */
6910 public Bundle getBundleExtra(String name) {
6911 return mExtras == null ? null : mExtras.getBundle(name);
6912 }
6913
6914 /**
6915 * Retrieve extended data from the intent.
6916 *
6917 * @param name The name of the desired item.
6918 *
6919 * @return the value of an item that previously added with putExtra()
6920 * or null if no IBinder value was found.
6921 *
6922 * @see #putExtra(String, IBinder)
6923 *
6924 * @deprecated
6925 * @hide
6926 */
6927 @Deprecated
6928 public IBinder getIBinderExtra(String name) {
6929 return mExtras == null ? null : mExtras.getIBinder(name);
6930 }
6931
6932 /**
6933 * Retrieve extended data from the intent.
6934 *
6935 * @param name The name of the desired item.
6936 * @param defaultValue The default value to return in case no item is
6937 * associated with the key 'name'
6938 *
6939 * @return the value of an item that previously added with putExtra()
6940 * or defaultValue if none was found.
6941 *
6942 * @see #putExtra
6943 *
6944 * @deprecated
6945 * @hide
6946 */
6947 @Deprecated
6948 public Object getExtra(String name, Object defaultValue) {
6949 Object result = defaultValue;
6950 if (mExtras != null) {
6951 Object result2 = mExtras.get(name);
6952 if (result2 != null) {
6953 result = result2;
6954 }
6955 }
6956
6957 return result;
6958 }
6959
6960 /**
6961 * Retrieves a map of extended data from the intent.
6962 *
6963 * @return the map of all extras previously added with putExtra(),
6964 * or null if none have been added.
6965 */
6966 public Bundle getExtras() {
6967 return (mExtras != null)
6968 ? new Bundle(mExtras)
6969 : null;
6970 }
6971
6972 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006973 * Filter extras to only basic types.
6974 * @hide
6975 */
6976 public void removeUnsafeExtras() {
6977 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006978 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006979 }
6980 }
6981
6982 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006983 * Retrieve any special flags associated with this intent. You will
6984 * normally just set them with {@link #setFlags} and let the system
6985 * take the appropriate action with them.
6986 *
6987 * @return int The currently set flags.
6988 *
6989 * @see #setFlags
6990 */
6991 public int getFlags() {
6992 return mFlags;
6993 }
6994
Dianne Hackborne7f97212011-02-24 14:40:20 -08006995 /** @hide */
6996 public boolean isExcludingStopped() {
6997 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6998 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6999 }
7000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007001 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007002 * Retrieve the application package name this Intent is limited to. When
7003 * resolving an Intent, if non-null this limits the resolution to only
7004 * components in the given application package.
7005 *
7006 * @return The name of the application package for the Intent.
7007 *
7008 * @see #resolveActivity
7009 * @see #setPackage
7010 */
7011 public String getPackage() {
7012 return mPackage;
7013 }
7014
7015 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007016 * Retrieve the concrete component associated with the intent. When receiving
7017 * an intent, this is the component that was found to best handle it (that is,
7018 * yourself) and will always be non-null; in all other cases it will be
7019 * null unless explicitly set.
7020 *
7021 * @return The name of the application component to handle the intent.
7022 *
7023 * @see #resolveActivity
7024 * @see #setComponent
7025 */
7026 public ComponentName getComponent() {
7027 return mComponent;
7028 }
7029
7030 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007031 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7032 * used as a hint to the receiver for animations and the like. Null means that there
7033 * is no source bounds.
7034 */
7035 public Rect getSourceBounds() {
7036 return mSourceBounds;
7037 }
7038
7039 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007040 * Return the Activity component that should be used to handle this intent.
7041 * The appropriate component is determined based on the information in the
7042 * intent, evaluated as follows:
7043 *
7044 * <p>If {@link #getComponent} returns an explicit class, that is returned
7045 * without any further consideration.
7046 *
7047 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7048 * category to be considered.
7049 *
7050 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7051 * action.
7052 *
7053 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7054 * this type.
7055 *
7056 * <p>If {@link #addCategory} has added any categories, the activity must
7057 * handle ALL of the categories specified.
7058 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007059 * <p>If {@link #getPackage} is non-NULL, only activity components in
7060 * that application package will be considered.
7061 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007062 * <p>If there are no activities that satisfy all of these conditions, a
7063 * null string is returned.
7064 *
7065 * <p>If multiple activities are found to satisfy the intent, the one with
7066 * the highest priority will be used. If there are multiple activities
7067 * with the same priority, the system will either pick the best activity
7068 * based on user preference, or resolve to a system class that will allow
7069 * the user to pick an activity and forward from there.
7070 *
7071 * <p>This method is implemented simply by calling
7072 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7073 * true.</p>
7074 * <p> This API is called for you as part of starting an activity from an
7075 * intent. You do not normally need to call it yourself.</p>
7076 *
7077 * @param pm The package manager with which to resolve the Intent.
7078 *
7079 * @return Name of the component implementing an activity that can
7080 * display the intent.
7081 *
7082 * @see #setComponent
7083 * @see #getComponent
7084 * @see #resolveActivityInfo
7085 */
7086 public ComponentName resolveActivity(PackageManager pm) {
7087 if (mComponent != null) {
7088 return mComponent;
7089 }
7090
7091 ResolveInfo info = pm.resolveActivity(
7092 this, PackageManager.MATCH_DEFAULT_ONLY);
7093 if (info != null) {
7094 return new ComponentName(
7095 info.activityInfo.applicationInfo.packageName,
7096 info.activityInfo.name);
7097 }
7098
7099 return null;
7100 }
7101
7102 /**
7103 * Resolve the Intent into an {@link ActivityInfo}
7104 * describing the activity that should execute the intent. Resolution
7105 * follows the same rules as described for {@link #resolveActivity}, but
7106 * you get back the completely information about the resolved activity
7107 * instead of just its class name.
7108 *
7109 * @param pm The package manager with which to resolve the Intent.
7110 * @param flags Addition information to retrieve as per
7111 * {@link PackageManager#getActivityInfo(ComponentName, int)
7112 * PackageManager.getActivityInfo()}.
7113 *
7114 * @return PackageManager.ActivityInfo
7115 *
7116 * @see #resolveActivity
7117 */
7118 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7119 ActivityInfo ai = null;
7120 if (mComponent != null) {
7121 try {
7122 ai = pm.getActivityInfo(mComponent, flags);
7123 } catch (PackageManager.NameNotFoundException e) {
7124 // ignore
7125 }
7126 } else {
7127 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007128 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007129 if (info != null) {
7130 ai = info.activityInfo;
7131 }
7132 }
7133
7134 return ai;
7135 }
7136
7137 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007138 * Special function for use by the system to resolve service
7139 * intents to system apps. Throws an exception if there are
7140 * multiple potential matches to the Intent. Returns null if
7141 * there are no matches.
7142 * @hide
7143 */
7144 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7145 if (mComponent != null) {
7146 return mComponent;
7147 }
7148
7149 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7150 if (results == null) {
7151 return null;
7152 }
7153 ComponentName comp = null;
7154 for (int i=0; i<results.size(); i++) {
7155 ResolveInfo ri = results.get(i);
7156 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7157 continue;
7158 }
7159 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7160 ri.serviceInfo.name);
7161 if (comp != null) {
7162 throw new IllegalStateException("Multiple system services handle " + this
7163 + ": " + comp + ", " + foundComp);
7164 }
7165 comp = foundComp;
7166 }
7167 return comp;
7168 }
7169
7170 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007171 * Set the general action to be performed.
7172 *
7173 * @param action An action name, such as ACTION_VIEW. Application-specific
7174 * actions should be prefixed with the vendor's package name.
7175 *
7176 * @return Returns the same Intent object, for chaining multiple calls
7177 * into a single statement.
7178 *
7179 * @see #getAction
7180 */
7181 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007182 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007183 return this;
7184 }
7185
7186 /**
7187 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007188 * clears any type that was previously set by {@link #setType} or
7189 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007190 *
Nick Pellyccae4122012-01-09 14:12:58 -08007191 * <p><em>Note: scheme matching in the Android framework is
7192 * case-sensitive, unlike the formal RFC. As a result,
7193 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007194 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007195 * {@link #setDataAndNormalize}
7196 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007197 *
Nick Pellyccae4122012-01-09 14:12:58 -08007198 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007199 *
7200 * @return Returns the same Intent object, for chaining multiple calls
7201 * into a single statement.
7202 *
7203 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007204 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007205 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007206 */
7207 public Intent setData(Uri data) {
7208 mData = data;
7209 mType = null;
7210 return this;
7211 }
7212
7213 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007214 * Normalize and set the data this intent is operating on.
7215 *
7216 * <p>This method automatically clears any type that was
7217 * previously set (for example, by {@link #setType}).
7218 *
7219 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007220 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007221 * so really this is just a convenience method for
7222 * <pre>
7223 * setData(data.normalize())
7224 * </pre>
7225 *
7226 * @param data The Uri of the data this intent is now targeting.
7227 *
7228 * @return Returns the same Intent object, for chaining multiple calls
7229 * into a single statement.
7230 *
7231 * @see #getData
7232 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007233 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007234 */
7235 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007236 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007237 }
7238
7239 /**
7240 * Set an explicit MIME data type.
7241 *
7242 * <p>This is used to create intents that only specify a type and not data,
7243 * for example to indicate the type of data to return.
7244 *
7245 * <p>This method automatically clears any data that was
7246 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007247 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007248 * <p><em>Note: MIME type matching in the Android framework is
7249 * case-sensitive, unlike formal RFC MIME types. As a result,
7250 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007251 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7252 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007253 *
7254 * @param type The MIME type of the data being handled by this intent.
7255 *
7256 * @return Returns the same Intent object, for chaining multiple calls
7257 * into a single statement.
7258 *
7259 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007260 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007261 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007262 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007263 */
7264 public Intent setType(String type) {
7265 mData = null;
7266 mType = type;
7267 return this;
7268 }
7269
7270 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007271 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007272 *
Nick Pellyccae4122012-01-09 14:12:58 -08007273 * <p>This is used to create intents that only specify a type and not data,
7274 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007275 *
Nick Pellyccae4122012-01-09 14:12:58 -08007276 * <p>This method automatically clears any data that was
7277 * previously set (for example by {@link #setData}).
7278 *
7279 * <p>The MIME type is normalized using
7280 * {@link #normalizeMimeType} before it is set,
7281 * so really this is just a convenience method for
7282 * <pre>
7283 * setType(Intent.normalizeMimeType(type))
7284 * </pre>
7285 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007286 * @param type The MIME type of the data being handled by this intent.
7287 *
7288 * @return Returns the same Intent object, for chaining multiple calls
7289 * into a single statement.
7290 *
Nick Pellyccae4122012-01-09 14:12:58 -08007291 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007292 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007293 * @see #normalizeMimeType
7294 */
7295 public Intent setTypeAndNormalize(String type) {
7296 return setType(normalizeMimeType(type));
7297 }
7298
7299 /**
7300 * (Usually optional) Set the data for the intent along with an explicit
7301 * MIME data type. This method should very rarely be used -- it allows you
7302 * to override the MIME type that would ordinarily be inferred from the
7303 * data with your own type given here.
7304 *
7305 * <p><em>Note: MIME type and Uri scheme matching in the
7306 * Android framework is case-sensitive, unlike the formal RFC definitions.
7307 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007308 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007309 * {@link #setDataAndTypeAndNormalize}
7310 * to ensure that they are converted to lower case.</em>
7311 *
7312 * @param data The Uri of the data this intent is now targeting.
7313 * @param type The MIME type of the data being handled by this intent.
7314 *
7315 * @return Returns the same Intent object, for chaining multiple calls
7316 * into a single statement.
7317 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007319 * @see #setData
7320 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007321 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007322 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007323 */
7324 public Intent setDataAndType(Uri data, String type) {
7325 mData = data;
7326 mType = type;
7327 return this;
7328 }
7329
7330 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007331 * (Usually optional) Normalize and set both the data Uri and an explicit
7332 * MIME data type. This method should very rarely be used -- it allows you
7333 * to override the MIME type that would ordinarily be inferred from the
7334 * data with your own type given here.
7335 *
7336 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007337 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007338 * before they are set, so really this is just a convenience method for
7339 * <pre>
7340 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7341 * </pre>
7342 *
7343 * @param data The Uri of the data this intent is now targeting.
7344 * @param type The MIME type of the data being handled by this intent.
7345 *
7346 * @return Returns the same Intent object, for chaining multiple calls
7347 * into a single statement.
7348 *
7349 * @see #setType
7350 * @see #setData
7351 * @see #setDataAndType
7352 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007353 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007354 */
7355 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007356 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007357 }
7358
7359 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007360 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007361 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007362 * activities that provide <em>all</em> of the requested categories will be
7363 * used.
7364 *
7365 * @param category The desired category. This can be either one of the
7366 * predefined Intent categories, or a custom category in your own
7367 * namespace.
7368 *
7369 * @return Returns the same Intent object, for chaining multiple calls
7370 * into a single statement.
7371 *
7372 * @see #hasCategory
7373 * @see #removeCategory
7374 */
7375 public Intent addCategory(String category) {
7376 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007377 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007378 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007379 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007380 return this;
7381 }
7382
7383 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007384 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007385 *
7386 * @param category The category to remove.
7387 *
7388 * @see #addCategory
7389 */
7390 public void removeCategory(String category) {
7391 if (mCategories != null) {
7392 mCategories.remove(category);
7393 if (mCategories.size() == 0) {
7394 mCategories = null;
7395 }
7396 }
7397 }
7398
7399 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007400 * Set a selector for this Intent. This is a modification to the kinds of
7401 * things the Intent will match. If the selector is set, it will be used
7402 * when trying to find entities that can handle the Intent, instead of the
7403 * main contents of the Intent. This allows you build an Intent containing
7404 * a generic protocol while targeting it more specifically.
7405 *
7406 * <p>An example of where this may be used is with things like
7407 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7408 * Intent that will launch the Browser application. However, the correct
7409 * main entry point of an application is actually {@link #ACTION_MAIN}
7410 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7411 * used to specify the actual Activity to launch. If you launch the browser
7412 * with something different, undesired behavior may happen if the user has
7413 * previously or later launches it the normal way, since they do not match.
7414 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7415 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7416 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7417 *
7418 * <p>Setting a selector does not impact the behavior of
7419 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7420 * desired behavior of a selector -- it does not impact the base meaning
7421 * of the Intent, just what kinds of things will be matched against it
7422 * when determining who can handle it.</p>
7423 *
7424 * <p>You can not use both a selector and {@link #setPackage(String)} on
7425 * the same base Intent.</p>
7426 *
7427 * @param selector The desired selector Intent; set to null to not use
7428 * a special selector.
7429 */
7430 public void setSelector(Intent selector) {
7431 if (selector == this) {
7432 throw new IllegalArgumentException(
7433 "Intent being set as a selector of itself");
7434 }
7435 if (selector != null && mPackage != null) {
7436 throw new IllegalArgumentException(
7437 "Can't set selector when package name is already set");
7438 }
7439 mSelector = selector;
7440 }
7441
7442 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007443 * Set a {@link ClipData} associated with this Intent. This replaces any
7444 * previously set ClipData.
7445 *
7446 * <p>The ClipData in an intent is not used for Intent matching or other
7447 * such operations. Semantically it is like extras, used to transmit
7448 * additional data with the Intent. The main feature of using this over
7449 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7450 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7451 * items included in the clip data. This is useful, in particular, if
7452 * you want to transmit an Intent containing multiple <code>content:</code>
7453 * URIs for which the recipient may not have global permission to access the
7454 * content provider.
7455 *
7456 * <p>If the ClipData contains items that are themselves Intents, any
7457 * grant flags in those Intents will be ignored. Only the top-level flags
7458 * of the main Intent are respected, and will be applied to all Uri or
7459 * Intent items in the clip (or sub-items of the clip).
7460 *
7461 * <p>The MIME type, label, and icon in the ClipData object are not
7462 * directly used by Intent. Applications should generally rely on the
7463 * MIME type of the Intent itself, not what it may find in the ClipData.
7464 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007465 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007466 *
7467 * @param clip The new clip to set. May be null to clear the current clip.
7468 */
7469 public void setClipData(ClipData clip) {
7470 mClipData = clip;
7471 }
7472
7473 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007474 * This is NOT a secure mechanism to identify the user who sent the intent.
7475 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7476 * who sent the intent.
7477 * @hide
7478 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007479 public void prepareToLeaveUser(int userId) {
7480 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7481 // We want mContentUserHint to refer to the original user, so don't do anything.
7482 if (mContentUserHint == UserHandle.USER_CURRENT) {
7483 mContentUserHint = userId;
7484 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007485 }
7486
7487 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007488 * Add extended data to the intent. The name must include a package
7489 * prefix, for example the app com.android.contacts would use names
7490 * like "com.android.contacts.ShowAll".
7491 *
7492 * @param name The name of the extra data, with package prefix.
7493 * @param value The boolean data value.
7494 *
7495 * @return Returns the same Intent object, for chaining multiple calls
7496 * into a single statement.
7497 *
7498 * @see #putExtras
7499 * @see #removeExtra
7500 * @see #getBooleanExtra(String, boolean)
7501 */
7502 public Intent putExtra(String name, boolean value) {
7503 if (mExtras == null) {
7504 mExtras = new Bundle();
7505 }
7506 mExtras.putBoolean(name, value);
7507 return this;
7508 }
7509
7510 /**
7511 * Add extended data to the intent. The name must include a package
7512 * prefix, for example the app com.android.contacts would use names
7513 * like "com.android.contacts.ShowAll".
7514 *
7515 * @param name The name of the extra data, with package prefix.
7516 * @param value The byte data value.
7517 *
7518 * @return Returns the same Intent object, for chaining multiple calls
7519 * into a single statement.
7520 *
7521 * @see #putExtras
7522 * @see #removeExtra
7523 * @see #getByteExtra(String, byte)
7524 */
7525 public Intent putExtra(String name, byte value) {
7526 if (mExtras == null) {
7527 mExtras = new Bundle();
7528 }
7529 mExtras.putByte(name, value);
7530 return this;
7531 }
7532
7533 /**
7534 * Add extended data to the intent. The name must include a package
7535 * prefix, for example the app com.android.contacts would use names
7536 * like "com.android.contacts.ShowAll".
7537 *
7538 * @param name The name of the extra data, with package prefix.
7539 * @param value The char data value.
7540 *
7541 * @return Returns the same Intent object, for chaining multiple calls
7542 * into a single statement.
7543 *
7544 * @see #putExtras
7545 * @see #removeExtra
7546 * @see #getCharExtra(String, char)
7547 */
7548 public Intent putExtra(String name, char value) {
7549 if (mExtras == null) {
7550 mExtras = new Bundle();
7551 }
7552 mExtras.putChar(name, value);
7553 return this;
7554 }
7555
7556 /**
7557 * Add extended data to the intent. The name must include a package
7558 * prefix, for example the app com.android.contacts would use names
7559 * like "com.android.contacts.ShowAll".
7560 *
7561 * @param name The name of the extra data, with package prefix.
7562 * @param value The short data value.
7563 *
7564 * @return Returns the same Intent object, for chaining multiple calls
7565 * into a single statement.
7566 *
7567 * @see #putExtras
7568 * @see #removeExtra
7569 * @see #getShortExtra(String, short)
7570 */
7571 public Intent putExtra(String name, short value) {
7572 if (mExtras == null) {
7573 mExtras = new Bundle();
7574 }
7575 mExtras.putShort(name, value);
7576 return this;
7577 }
7578
7579 /**
7580 * Add extended data to the intent. The name must include a package
7581 * prefix, for example the app com.android.contacts would use names
7582 * like "com.android.contacts.ShowAll".
7583 *
7584 * @param name The name of the extra data, with package prefix.
7585 * @param value The integer data value.
7586 *
7587 * @return Returns the same Intent object, for chaining multiple calls
7588 * into a single statement.
7589 *
7590 * @see #putExtras
7591 * @see #removeExtra
7592 * @see #getIntExtra(String, int)
7593 */
7594 public Intent putExtra(String name, int value) {
7595 if (mExtras == null) {
7596 mExtras = new Bundle();
7597 }
7598 mExtras.putInt(name, value);
7599 return this;
7600 }
7601
7602 /**
7603 * Add extended data to the intent. The name must include a package
7604 * prefix, for example the app com.android.contacts would use names
7605 * like "com.android.contacts.ShowAll".
7606 *
7607 * @param name The name of the extra data, with package prefix.
7608 * @param value The long data value.
7609 *
7610 * @return Returns the same Intent object, for chaining multiple calls
7611 * into a single statement.
7612 *
7613 * @see #putExtras
7614 * @see #removeExtra
7615 * @see #getLongExtra(String, long)
7616 */
7617 public Intent putExtra(String name, long value) {
7618 if (mExtras == null) {
7619 mExtras = new Bundle();
7620 }
7621 mExtras.putLong(name, value);
7622 return this;
7623 }
7624
7625 /**
7626 * Add extended data to the intent. The name must include a package
7627 * prefix, for example the app com.android.contacts would use names
7628 * like "com.android.contacts.ShowAll".
7629 *
7630 * @param name The name of the extra data, with package prefix.
7631 * @param value The float data value.
7632 *
7633 * @return Returns the same Intent object, for chaining multiple calls
7634 * into a single statement.
7635 *
7636 * @see #putExtras
7637 * @see #removeExtra
7638 * @see #getFloatExtra(String, float)
7639 */
7640 public Intent putExtra(String name, float value) {
7641 if (mExtras == null) {
7642 mExtras = new Bundle();
7643 }
7644 mExtras.putFloat(name, value);
7645 return this;
7646 }
7647
7648 /**
7649 * Add extended data to the intent. The name must include a package
7650 * prefix, for example the app com.android.contacts would use names
7651 * like "com.android.contacts.ShowAll".
7652 *
7653 * @param name The name of the extra data, with package prefix.
7654 * @param value The double data value.
7655 *
7656 * @return Returns the same Intent object, for chaining multiple calls
7657 * into a single statement.
7658 *
7659 * @see #putExtras
7660 * @see #removeExtra
7661 * @see #getDoubleExtra(String, double)
7662 */
7663 public Intent putExtra(String name, double value) {
7664 if (mExtras == null) {
7665 mExtras = new Bundle();
7666 }
7667 mExtras.putDouble(name, value);
7668 return this;
7669 }
7670
7671 /**
7672 * Add extended data to the intent. The name must include a package
7673 * prefix, for example the app com.android.contacts would use names
7674 * like "com.android.contacts.ShowAll".
7675 *
7676 * @param name The name of the extra data, with package prefix.
7677 * @param value The String data value.
7678 *
7679 * @return Returns the same Intent object, for chaining multiple calls
7680 * into a single statement.
7681 *
7682 * @see #putExtras
7683 * @see #removeExtra
7684 * @see #getStringExtra(String)
7685 */
7686 public Intent putExtra(String name, String value) {
7687 if (mExtras == null) {
7688 mExtras = new Bundle();
7689 }
7690 mExtras.putString(name, value);
7691 return this;
7692 }
7693
7694 /**
7695 * Add extended data to the intent. The name must include a package
7696 * prefix, for example the app com.android.contacts would use names
7697 * like "com.android.contacts.ShowAll".
7698 *
7699 * @param name The name of the extra data, with package prefix.
7700 * @param value The CharSequence data value.
7701 *
7702 * @return Returns the same Intent object, for chaining multiple calls
7703 * into a single statement.
7704 *
7705 * @see #putExtras
7706 * @see #removeExtra
7707 * @see #getCharSequenceExtra(String)
7708 */
7709 public Intent putExtra(String name, CharSequence value) {
7710 if (mExtras == null) {
7711 mExtras = new Bundle();
7712 }
7713 mExtras.putCharSequence(name, value);
7714 return this;
7715 }
7716
7717 /**
7718 * Add extended data to the intent. The name must include a package
7719 * prefix, for example the app com.android.contacts would use names
7720 * like "com.android.contacts.ShowAll".
7721 *
7722 * @param name The name of the extra data, with package prefix.
7723 * @param value The Parcelable data value.
7724 *
7725 * @return Returns the same Intent object, for chaining multiple calls
7726 * into a single statement.
7727 *
7728 * @see #putExtras
7729 * @see #removeExtra
7730 * @see #getParcelableExtra(String)
7731 */
7732 public Intent putExtra(String name, Parcelable value) {
7733 if (mExtras == null) {
7734 mExtras = new Bundle();
7735 }
7736 mExtras.putParcelable(name, value);
7737 return this;
7738 }
7739
7740 /**
7741 * Add extended data to the intent. The name must include a package
7742 * prefix, for example the app com.android.contacts would use names
7743 * like "com.android.contacts.ShowAll".
7744 *
7745 * @param name The name of the extra data, with package prefix.
7746 * @param value The Parcelable[] data value.
7747 *
7748 * @return Returns the same Intent object, for chaining multiple calls
7749 * into a single statement.
7750 *
7751 * @see #putExtras
7752 * @see #removeExtra
7753 * @see #getParcelableArrayExtra(String)
7754 */
7755 public Intent putExtra(String name, Parcelable[] value) {
7756 if (mExtras == null) {
7757 mExtras = new Bundle();
7758 }
7759 mExtras.putParcelableArray(name, value);
7760 return this;
7761 }
7762
7763 /**
7764 * Add extended data to the intent. The name must include a package
7765 * prefix, for example the app com.android.contacts would use names
7766 * like "com.android.contacts.ShowAll".
7767 *
7768 * @param name The name of the extra data, with package prefix.
7769 * @param value The ArrayList<Parcelable> data value.
7770 *
7771 * @return Returns the same Intent object, for chaining multiple calls
7772 * into a single statement.
7773 *
7774 * @see #putExtras
7775 * @see #removeExtra
7776 * @see #getParcelableArrayListExtra(String)
7777 */
7778 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7779 if (mExtras == null) {
7780 mExtras = new Bundle();
7781 }
7782 mExtras.putParcelableArrayList(name, value);
7783 return this;
7784 }
7785
7786 /**
7787 * Add extended data to the intent. The name must include a package
7788 * prefix, for example the app com.android.contacts would use names
7789 * like "com.android.contacts.ShowAll".
7790 *
7791 * @param name The name of the extra data, with package prefix.
7792 * @param value The ArrayList<Integer> data value.
7793 *
7794 * @return Returns the same Intent object, for chaining multiple calls
7795 * into a single statement.
7796 *
7797 * @see #putExtras
7798 * @see #removeExtra
7799 * @see #getIntegerArrayListExtra(String)
7800 */
7801 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7802 if (mExtras == null) {
7803 mExtras = new Bundle();
7804 }
7805 mExtras.putIntegerArrayList(name, value);
7806 return this;
7807 }
7808
7809 /**
7810 * Add extended data to the intent. The name must include a package
7811 * prefix, for example the app com.android.contacts would use names
7812 * like "com.android.contacts.ShowAll".
7813 *
7814 * @param name The name of the extra data, with package prefix.
7815 * @param value The ArrayList<String> data value.
7816 *
7817 * @return Returns the same Intent object, for chaining multiple calls
7818 * into a single statement.
7819 *
7820 * @see #putExtras
7821 * @see #removeExtra
7822 * @see #getStringArrayListExtra(String)
7823 */
7824 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7825 if (mExtras == null) {
7826 mExtras = new Bundle();
7827 }
7828 mExtras.putStringArrayList(name, value);
7829 return this;
7830 }
7831
7832 /**
7833 * Add extended data to the intent. The name must include a package
7834 * prefix, for example the app com.android.contacts would use names
7835 * like "com.android.contacts.ShowAll".
7836 *
7837 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007838 * @param value The ArrayList<CharSequence> data value.
7839 *
7840 * @return Returns the same Intent object, for chaining multiple calls
7841 * into a single statement.
7842 *
7843 * @see #putExtras
7844 * @see #removeExtra
7845 * @see #getCharSequenceArrayListExtra(String)
7846 */
7847 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7848 if (mExtras == null) {
7849 mExtras = new Bundle();
7850 }
7851 mExtras.putCharSequenceArrayList(name, value);
7852 return this;
7853 }
7854
7855 /**
7856 * Add extended data to the intent. The name must include a package
7857 * prefix, for example the app com.android.contacts would use names
7858 * like "com.android.contacts.ShowAll".
7859 *
7860 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007861 * @param value The Serializable data value.
7862 *
7863 * @return Returns the same Intent object, for chaining multiple calls
7864 * into a single statement.
7865 *
7866 * @see #putExtras
7867 * @see #removeExtra
7868 * @see #getSerializableExtra(String)
7869 */
7870 public Intent putExtra(String name, Serializable value) {
7871 if (mExtras == null) {
7872 mExtras = new Bundle();
7873 }
7874 mExtras.putSerializable(name, value);
7875 return this;
7876 }
7877
7878 /**
7879 * Add extended data to the intent. The name must include a package
7880 * prefix, for example the app com.android.contacts would use names
7881 * like "com.android.contacts.ShowAll".
7882 *
7883 * @param name The name of the extra data, with package prefix.
7884 * @param value The boolean array data value.
7885 *
7886 * @return Returns the same Intent object, for chaining multiple calls
7887 * into a single statement.
7888 *
7889 * @see #putExtras
7890 * @see #removeExtra
7891 * @see #getBooleanArrayExtra(String)
7892 */
7893 public Intent putExtra(String name, boolean[] value) {
7894 if (mExtras == null) {
7895 mExtras = new Bundle();
7896 }
7897 mExtras.putBooleanArray(name, value);
7898 return this;
7899 }
7900
7901 /**
7902 * Add extended data to the intent. The name must include a package
7903 * prefix, for example the app com.android.contacts would use names
7904 * like "com.android.contacts.ShowAll".
7905 *
7906 * @param name The name of the extra data, with package prefix.
7907 * @param value The byte array data value.
7908 *
7909 * @return Returns the same Intent object, for chaining multiple calls
7910 * into a single statement.
7911 *
7912 * @see #putExtras
7913 * @see #removeExtra
7914 * @see #getByteArrayExtra(String)
7915 */
7916 public Intent putExtra(String name, byte[] value) {
7917 if (mExtras == null) {
7918 mExtras = new Bundle();
7919 }
7920 mExtras.putByteArray(name, value);
7921 return this;
7922 }
7923
7924 /**
7925 * Add extended data to the intent. The name must include a package
7926 * prefix, for example the app com.android.contacts would use names
7927 * like "com.android.contacts.ShowAll".
7928 *
7929 * @param name The name of the extra data, with package prefix.
7930 * @param value The short array data value.
7931 *
7932 * @return Returns the same Intent object, for chaining multiple calls
7933 * into a single statement.
7934 *
7935 * @see #putExtras
7936 * @see #removeExtra
7937 * @see #getShortArrayExtra(String)
7938 */
7939 public Intent putExtra(String name, short[] value) {
7940 if (mExtras == null) {
7941 mExtras = new Bundle();
7942 }
7943 mExtras.putShortArray(name, value);
7944 return this;
7945 }
7946
7947 /**
7948 * Add extended data to the intent. The name must include a package
7949 * prefix, for example the app com.android.contacts would use names
7950 * like "com.android.contacts.ShowAll".
7951 *
7952 * @param name The name of the extra data, with package prefix.
7953 * @param value The char array data value.
7954 *
7955 * @return Returns the same Intent object, for chaining multiple calls
7956 * into a single statement.
7957 *
7958 * @see #putExtras
7959 * @see #removeExtra
7960 * @see #getCharArrayExtra(String)
7961 */
7962 public Intent putExtra(String name, char[] value) {
7963 if (mExtras == null) {
7964 mExtras = new Bundle();
7965 }
7966 mExtras.putCharArray(name, value);
7967 return this;
7968 }
7969
7970 /**
7971 * Add extended data to the intent. The name must include a package
7972 * prefix, for example the app com.android.contacts would use names
7973 * like "com.android.contacts.ShowAll".
7974 *
7975 * @param name The name of the extra data, with package prefix.
7976 * @param value The int array data value.
7977 *
7978 * @return Returns the same Intent object, for chaining multiple calls
7979 * into a single statement.
7980 *
7981 * @see #putExtras
7982 * @see #removeExtra
7983 * @see #getIntArrayExtra(String)
7984 */
7985 public Intent putExtra(String name, int[] value) {
7986 if (mExtras == null) {
7987 mExtras = new Bundle();
7988 }
7989 mExtras.putIntArray(name, value);
7990 return this;
7991 }
7992
7993 /**
7994 * Add extended data to the intent. The name must include a package
7995 * prefix, for example the app com.android.contacts would use names
7996 * like "com.android.contacts.ShowAll".
7997 *
7998 * @param name The name of the extra data, with package prefix.
7999 * @param value The byte array data value.
8000 *
8001 * @return Returns the same Intent object, for chaining multiple calls
8002 * into a single statement.
8003 *
8004 * @see #putExtras
8005 * @see #removeExtra
8006 * @see #getLongArrayExtra(String)
8007 */
8008 public Intent putExtra(String name, long[] value) {
8009 if (mExtras == null) {
8010 mExtras = new Bundle();
8011 }
8012 mExtras.putLongArray(name, value);
8013 return this;
8014 }
8015
8016 /**
8017 * Add extended data to the intent. The name must include a package
8018 * prefix, for example the app com.android.contacts would use names
8019 * like "com.android.contacts.ShowAll".
8020 *
8021 * @param name The name of the extra data, with package prefix.
8022 * @param value The float array data value.
8023 *
8024 * @return Returns the same Intent object, for chaining multiple calls
8025 * into a single statement.
8026 *
8027 * @see #putExtras
8028 * @see #removeExtra
8029 * @see #getFloatArrayExtra(String)
8030 */
8031 public Intent putExtra(String name, float[] value) {
8032 if (mExtras == null) {
8033 mExtras = new Bundle();
8034 }
8035 mExtras.putFloatArray(name, value);
8036 return this;
8037 }
8038
8039 /**
8040 * Add extended data to the intent. The name must include a package
8041 * prefix, for example the app com.android.contacts would use names
8042 * like "com.android.contacts.ShowAll".
8043 *
8044 * @param name The name of the extra data, with package prefix.
8045 * @param value The double array data value.
8046 *
8047 * @return Returns the same Intent object, for chaining multiple calls
8048 * into a single statement.
8049 *
8050 * @see #putExtras
8051 * @see #removeExtra
8052 * @see #getDoubleArrayExtra(String)
8053 */
8054 public Intent putExtra(String name, double[] value) {
8055 if (mExtras == null) {
8056 mExtras = new Bundle();
8057 }
8058 mExtras.putDoubleArray(name, value);
8059 return this;
8060 }
8061
8062 /**
8063 * Add extended data to the intent. The name must include a package
8064 * prefix, for example the app com.android.contacts would use names
8065 * like "com.android.contacts.ShowAll".
8066 *
8067 * @param name The name of the extra data, with package prefix.
8068 * @param value The String array data value.
8069 *
8070 * @return Returns the same Intent object, for chaining multiple calls
8071 * into a single statement.
8072 *
8073 * @see #putExtras
8074 * @see #removeExtra
8075 * @see #getStringArrayExtra(String)
8076 */
8077 public Intent putExtra(String name, String[] value) {
8078 if (mExtras == null) {
8079 mExtras = new Bundle();
8080 }
8081 mExtras.putStringArray(name, value);
8082 return this;
8083 }
8084
8085 /**
8086 * Add extended data to the intent. The name must include a package
8087 * prefix, for example the app com.android.contacts would use names
8088 * like "com.android.contacts.ShowAll".
8089 *
8090 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008091 * @param value The CharSequence array data value.
8092 *
8093 * @return Returns the same Intent object, for chaining multiple calls
8094 * into a single statement.
8095 *
8096 * @see #putExtras
8097 * @see #removeExtra
8098 * @see #getCharSequenceArrayExtra(String)
8099 */
8100 public Intent putExtra(String name, CharSequence[] value) {
8101 if (mExtras == null) {
8102 mExtras = new Bundle();
8103 }
8104 mExtras.putCharSequenceArray(name, value);
8105 return this;
8106 }
8107
8108 /**
8109 * Add extended data to the intent. The name must include a package
8110 * prefix, for example the app com.android.contacts would use names
8111 * like "com.android.contacts.ShowAll".
8112 *
8113 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008114 * @param value The Bundle data value.
8115 *
8116 * @return Returns the same Intent object, for chaining multiple calls
8117 * into a single statement.
8118 *
8119 * @see #putExtras
8120 * @see #removeExtra
8121 * @see #getBundleExtra(String)
8122 */
8123 public Intent putExtra(String name, Bundle value) {
8124 if (mExtras == null) {
8125 mExtras = new Bundle();
8126 }
8127 mExtras.putBundle(name, value);
8128 return this;
8129 }
8130
8131 /**
8132 * Add extended data to the intent. The name must include a package
8133 * prefix, for example the app com.android.contacts would use names
8134 * like "com.android.contacts.ShowAll".
8135 *
8136 * @param name The name of the extra data, with package prefix.
8137 * @param value The IBinder data value.
8138 *
8139 * @return Returns the same Intent object, for chaining multiple calls
8140 * into a single statement.
8141 *
8142 * @see #putExtras
8143 * @see #removeExtra
8144 * @see #getIBinderExtra(String)
8145 *
8146 * @deprecated
8147 * @hide
8148 */
8149 @Deprecated
8150 public Intent putExtra(String name, IBinder value) {
8151 if (mExtras == null) {
8152 mExtras = new Bundle();
8153 }
8154 mExtras.putIBinder(name, value);
8155 return this;
8156 }
8157
8158 /**
8159 * Copy all extras in 'src' in to this intent.
8160 *
8161 * @param src Contains the extras to copy.
8162 *
8163 * @see #putExtra
8164 */
8165 public Intent putExtras(Intent src) {
8166 if (src.mExtras != null) {
8167 if (mExtras == null) {
8168 mExtras = new Bundle(src.mExtras);
8169 } else {
8170 mExtras.putAll(src.mExtras);
8171 }
8172 }
8173 return this;
8174 }
8175
8176 /**
8177 * Add a set of extended data to the intent. The keys must include a package
8178 * prefix, for example the app com.android.contacts would use names
8179 * like "com.android.contacts.ShowAll".
8180 *
8181 * @param extras The Bundle of extras to add to this intent.
8182 *
8183 * @see #putExtra
8184 * @see #removeExtra
8185 */
8186 public Intent putExtras(Bundle extras) {
8187 if (mExtras == null) {
8188 mExtras = new Bundle();
8189 }
8190 mExtras.putAll(extras);
8191 return this;
8192 }
8193
8194 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008195 * Completely replace the extras in the Intent with the extras in the
8196 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008197 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008198 * @param src The exact extras contained in this Intent are copied
8199 * into the target intent, replacing any that were previously there.
8200 */
8201 public Intent replaceExtras(Intent src) {
8202 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8203 return this;
8204 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008205
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008206 /**
8207 * Completely replace the extras in the Intent with the given Bundle of
8208 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008209 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008210 * @param extras The new set of extras in the Intent, or null to erase
8211 * all extras.
8212 */
8213 public Intent replaceExtras(Bundle extras) {
8214 mExtras = extras != null ? new Bundle(extras) : null;
8215 return this;
8216 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008217
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008218 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008219 * Remove extended data from the intent.
8220 *
8221 * @see #putExtra
8222 */
8223 public void removeExtra(String name) {
8224 if (mExtras != null) {
8225 mExtras.remove(name);
8226 if (mExtras.size() == 0) {
8227 mExtras = null;
8228 }
8229 }
8230 }
8231
8232 /**
8233 * Set special flags controlling how this intent is handled. Most values
8234 * here depend on the type of component being executed by the Intent,
8235 * specifically the FLAG_ACTIVITY_* flags are all for use with
8236 * {@link Context#startActivity Context.startActivity()} and the
8237 * FLAG_RECEIVER_* flags are all for use with
8238 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8239 *
Scott Main7aee61f2011-02-08 11:25:01 -08008240 * <p>See the
8241 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8242 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008243 * the behavior of your application.
8244 *
8245 * @param flags The desired flags.
8246 *
8247 * @return Returns the same Intent object, for chaining multiple calls
8248 * into a single statement.
8249 *
8250 * @see #getFlags
8251 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008252 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008253 *
8254 * @see #FLAG_GRANT_READ_URI_PERMISSION
8255 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008256 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8257 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258 * @see #FLAG_DEBUG_LOG_RESOLUTION
8259 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008260 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008261 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008262 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008263 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008264 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8265 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008266 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008267 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008268 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008269 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008270 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008271 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008272 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008273 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8274 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008275 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008276 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008277 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008278 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8279 */
8280 public Intent setFlags(int flags) {
8281 mFlags = flags;
8282 return this;
8283 }
8284
8285 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008286 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008287 *
8288 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008289 * @return Returns the same Intent object, for chaining multiple calls into
8290 * a single statement.
8291 * @see #setFlags(int)
8292 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008293 */
8294 public Intent addFlags(int flags) {
8295 mFlags |= flags;
8296 return this;
8297 }
8298
8299 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008300 * Remove these flags from the intent.
8301 *
8302 * @param flags The flags to remove.
8303 * @see #setFlags(int)
8304 * @see #addFlags(int)
8305 */
8306 public void removeFlags(int flags) {
8307 mFlags &= ~flags;
8308 }
8309
8310 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008311 * (Usually optional) Set an explicit application package name that limits
8312 * the components this Intent will resolve to. If left to the default
8313 * value of null, all components in all applications will considered.
8314 * If non-null, the Intent can only match the components in the given
8315 * application package.
8316 *
8317 * @param packageName The name of the application package to handle the
8318 * intent, or null to allow any application package.
8319 *
8320 * @return Returns the same Intent object, for chaining multiple calls
8321 * into a single statement.
8322 *
8323 * @see #getPackage
8324 * @see #resolveActivity
8325 */
8326 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008327 if (packageName != null && mSelector != null) {
8328 throw new IllegalArgumentException(
8329 "Can't set package name when selector is already set");
8330 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008331 mPackage = packageName;
8332 return this;
8333 }
8334
8335 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008336 * (Usually optional) Explicitly set the component to handle the intent.
8337 * If left with the default value of null, the system will determine the
8338 * appropriate class to use based on the other fields (action, data,
8339 * type, categories) in the Intent. If this class is defined, the
8340 * specified class will always be used regardless of the other fields. You
8341 * should only set this value when you know you absolutely want a specific
8342 * class to be used; otherwise it is better to let the system find the
8343 * appropriate class so that you will respect the installed applications
8344 * and user preferences.
8345 *
8346 * @param component The name of the application component to handle the
8347 * intent, or null to let the system find one for you.
8348 *
8349 * @return Returns the same Intent object, for chaining multiple calls
8350 * into a single statement.
8351 *
8352 * @see #setClass
8353 * @see #setClassName(Context, String)
8354 * @see #setClassName(String, String)
8355 * @see #getComponent
8356 * @see #resolveActivity
8357 */
8358 public Intent setComponent(ComponentName component) {
8359 mComponent = component;
8360 return this;
8361 }
8362
8363 /**
8364 * Convenience for calling {@link #setComponent} with an
8365 * explicit class name.
8366 *
8367 * @param packageContext A Context of the application package implementing
8368 * this class.
8369 * @param className The name of a class inside of the application package
8370 * that will be used as the component for this Intent.
8371 *
8372 * @return Returns the same Intent object, for chaining multiple calls
8373 * into a single statement.
8374 *
8375 * @see #setComponent
8376 * @see #setClass
8377 */
8378 public Intent setClassName(Context packageContext, String className) {
8379 mComponent = new ComponentName(packageContext, className);
8380 return this;
8381 }
8382
8383 /**
8384 * Convenience for calling {@link #setComponent} with an
8385 * explicit application package name and class name.
8386 *
8387 * @param packageName The name of the package implementing the desired
8388 * component.
8389 * @param className The name of a class inside of the application package
8390 * that will be used as the component for this Intent.
8391 *
8392 * @return Returns the same Intent object, for chaining multiple calls
8393 * into a single statement.
8394 *
8395 * @see #setComponent
8396 * @see #setClass
8397 */
8398 public Intent setClassName(String packageName, String className) {
8399 mComponent = new ComponentName(packageName, className);
8400 return this;
8401 }
8402
8403 /**
8404 * Convenience for calling {@link #setComponent(ComponentName)} with the
8405 * name returned by a {@link Class} object.
8406 *
8407 * @param packageContext A Context of the application package implementing
8408 * this class.
8409 * @param cls The class name to set, equivalent to
8410 * <code>setClassName(context, cls.getName())</code>.
8411 *
8412 * @return Returns the same Intent object, for chaining multiple calls
8413 * into a single statement.
8414 *
8415 * @see #setComponent
8416 */
8417 public Intent setClass(Context packageContext, Class<?> cls) {
8418 mComponent = new ComponentName(packageContext, cls);
8419 return this;
8420 }
8421
8422 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008423 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8424 * used as a hint to the receiver for animations and the like. Null means that there
8425 * is no source bounds.
8426 */
8427 public void setSourceBounds(Rect r) {
8428 if (r != null) {
8429 mSourceBounds = new Rect(r);
8430 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008431 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008432 }
8433 }
8434
Tor Norbyed9273d62013-05-30 15:59:53 -07008435 /** @hide */
8436 @IntDef(flag = true,
8437 value = {
8438 FILL_IN_ACTION,
8439 FILL_IN_DATA,
8440 FILL_IN_CATEGORIES,
8441 FILL_IN_COMPONENT,
8442 FILL_IN_PACKAGE,
8443 FILL_IN_SOURCE_BOUNDS,
8444 FILL_IN_SELECTOR,
8445 FILL_IN_CLIP_DATA
8446 })
8447 @Retention(RetentionPolicy.SOURCE)
8448 public @interface FillInFlags {}
8449
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008450 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008451 * Use with {@link #fillIn} to allow the current action value to be
8452 * overwritten, even if it is already set.
8453 */
8454 public static final int FILL_IN_ACTION = 1<<0;
8455
8456 /**
8457 * Use with {@link #fillIn} to allow the current data or type value
8458 * overwritten, even if it is already set.
8459 */
8460 public static final int FILL_IN_DATA = 1<<1;
8461
8462 /**
8463 * Use with {@link #fillIn} to allow the current categories to be
8464 * overwritten, even if they are already set.
8465 */
8466 public static final int FILL_IN_CATEGORIES = 1<<2;
8467
8468 /**
8469 * Use with {@link #fillIn} to allow the current component value to be
8470 * overwritten, even if it is already set.
8471 */
8472 public static final int FILL_IN_COMPONENT = 1<<3;
8473
8474 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008475 * Use with {@link #fillIn} to allow the current package value to be
8476 * overwritten, even if it is already set.
8477 */
8478 public static final int FILL_IN_PACKAGE = 1<<4;
8479
8480 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008481 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008482 * overwritten, even if it is already set.
8483 */
8484 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8485
8486 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008487 * Use with {@link #fillIn} to allow the current selector to be
8488 * overwritten, even if it is already set.
8489 */
8490 public static final int FILL_IN_SELECTOR = 1<<6;
8491
8492 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008493 * Use with {@link #fillIn} to allow the current ClipData to be
8494 * overwritten, even if it is already set.
8495 */
8496 public static final int FILL_IN_CLIP_DATA = 1<<7;
8497
8498 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008499 * Copy the contents of <var>other</var> in to this object, but only
8500 * where fields are not defined by this object. For purposes of a field
8501 * being defined, the following pieces of data in the Intent are
8502 * considered to be separate fields:
8503 *
8504 * <ul>
8505 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008506 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008507 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8508 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008509 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008510 * <li> component, as set by {@link #setComponent(ComponentName)} or
8511 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008512 * <li> source bounds, as set by {@link #setSourceBounds}.
8513 * <li> selector, as set by {@link #setSelector(Intent)}.
8514 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008515 * <li> each top-level name in the associated extras.
8516 * </ul>
8517 *
8518 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008519 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008520 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8521 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8522 * the restriction where the corresponding field will not be replaced if
8523 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008525 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8526 * is explicitly specified. The selector will only be copied if
8527 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008528 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008529 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8530 * and Intent B with {action="gotit", data-type="some/thing",
8531 * categories="one","two"}.
8532 *
8533 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8534 * containing: {action="gotit", data-type="some/thing",
8535 * categories="bar"}.
8536 *
8537 * @param other Another Intent whose values are to be used to fill in
8538 * the current one.
8539 * @param flags Options to control which fields can be filled in.
8540 *
8541 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008542 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008543 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008544 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008545 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008546 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008547 @FillInFlags
8548 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008549 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008550 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008551 if (other.mAction != null
8552 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008553 mAction = other.mAction;
8554 changes |= FILL_IN_ACTION;
8555 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008556 if ((other.mData != null || other.mType != null)
8557 && ((mData == null && mType == null)
8558 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008559 mData = other.mData;
8560 mType = other.mType;
8561 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008562 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008563 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008564 if (other.mCategories != null
8565 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008566 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008567 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 }
8569 changes |= FILL_IN_CATEGORIES;
8570 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008571 if (other.mPackage != null
8572 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008573 // Only do this if mSelector is not set.
8574 if (mSelector == null) {
8575 mPackage = other.mPackage;
8576 changes |= FILL_IN_PACKAGE;
8577 }
8578 }
8579 // Selector is special: it can only be set if explicitly allowed,
8580 // for the same reason as the component name.
8581 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8582 if (mPackage == null) {
8583 mSelector = new Intent(other.mSelector);
8584 mPackage = null;
8585 changes |= FILL_IN_SELECTOR;
8586 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008587 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008588 if (other.mClipData != null
8589 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8590 mClipData = other.mClipData;
8591 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008592 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008593 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008594 // Component is special: it can -only- be set if explicitly allowed,
8595 // since otherwise the sender could force the intent somewhere the
8596 // originator didn't intend.
8597 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 mComponent = other.mComponent;
8599 changes |= FILL_IN_COMPONENT;
8600 }
8601 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008602 if (other.mSourceBounds != null
8603 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8604 mSourceBounds = new Rect(other.mSourceBounds);
8605 changes |= FILL_IN_SOURCE_BOUNDS;
8606 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008607 if (mExtras == null) {
8608 if (other.mExtras != null) {
8609 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008610 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008611 }
8612 } else if (other.mExtras != null) {
8613 try {
8614 Bundle newb = new Bundle(other.mExtras);
8615 newb.putAll(mExtras);
8616 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008617 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008618 } catch (RuntimeException e) {
8619 // Modifying the extras can cause us to unparcel the contents
8620 // of the bundle, and if we do this in the system process that
8621 // may fail. We really should handle this (i.e., the Bundle
8622 // impl shouldn't be on top of a plain map), but for now just
8623 // ignore it and keep the original contents. :(
8624 Log.w("Intent", "Failure filling in extras", e);
8625 }
8626 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008627 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8628 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8629 mContentUserHint = other.mContentUserHint;
8630 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008631 return changes;
8632 }
8633
8634 /**
8635 * Wrapper class holding an Intent and implementing comparisons on it for
8636 * the purpose of filtering. The class implements its
8637 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8638 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8639 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8640 * on the wrapped Intent.
8641 */
8642 public static final class FilterComparison {
8643 private final Intent mIntent;
8644 private final int mHashCode;
8645
8646 public FilterComparison(Intent intent) {
8647 mIntent = intent;
8648 mHashCode = intent.filterHashCode();
8649 }
8650
8651 /**
8652 * Return the Intent that this FilterComparison represents.
8653 * @return Returns the Intent held by the FilterComparison. Do
8654 * not modify!
8655 */
8656 public Intent getIntent() {
8657 return mIntent;
8658 }
8659
8660 @Override
8661 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008662 if (obj instanceof FilterComparison) {
8663 Intent other = ((FilterComparison)obj).mIntent;
8664 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008665 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008666 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008667 }
8668
8669 @Override
8670 public int hashCode() {
8671 return mHashCode;
8672 }
8673 }
8674
8675 /**
8676 * Determine if two intents are the same for the purposes of intent
8677 * resolution (filtering). That is, if their action, data, type,
8678 * class, and categories are the same. This does <em>not</em> compare
8679 * any extra data included in the intents.
8680 *
8681 * @param other The other Intent to compare against.
8682 *
8683 * @return Returns true if action, data, type, class, and categories
8684 * are the same.
8685 */
8686 public boolean filterEquals(Intent other) {
8687 if (other == null) {
8688 return false;
8689 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008690 if (!Objects.equals(this.mAction, other.mAction)) return false;
8691 if (!Objects.equals(this.mData, other.mData)) return false;
8692 if (!Objects.equals(this.mType, other.mType)) return false;
8693 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8694 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8695 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008696
8697 return true;
8698 }
8699
8700 /**
8701 * Generate hash code that matches semantics of filterEquals().
8702 *
8703 * @return Returns the hash value of the action, data, type, class, and
8704 * categories.
8705 *
8706 * @see #filterEquals
8707 */
8708 public int filterHashCode() {
8709 int code = 0;
8710 if (mAction != null) {
8711 code += mAction.hashCode();
8712 }
8713 if (mData != null) {
8714 code += mData.hashCode();
8715 }
8716 if (mType != null) {
8717 code += mType.hashCode();
8718 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008719 if (mPackage != null) {
8720 code += mPackage.hashCode();
8721 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008722 if (mComponent != null) {
8723 code += mComponent.hashCode();
8724 }
8725 if (mCategories != null) {
8726 code += mCategories.hashCode();
8727 }
8728 return code;
8729 }
8730
8731 @Override
8732 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008733 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008734
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008735 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008736 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008737 b.append(" }");
8738
8739 return b.toString();
8740 }
8741
8742 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008743 public String toInsecureString() {
8744 StringBuilder b = new StringBuilder(128);
8745
8746 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008747 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008748 b.append(" }");
8749
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008750 return b.toString();
8751 }
Romain Guy4969af72009-06-17 10:53:19 -07008752
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008753 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008754 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008755 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008756
8757 b.append("Intent { ");
8758 toShortString(b, false, true, true, true);
8759 b.append(" }");
8760
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008761 return b.toString();
8762 }
8763
8764 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008765 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8766 StringBuilder b = new StringBuilder(128);
8767 toShortString(b, secure, comp, extras, clip);
8768 return b.toString();
8769 }
8770
8771 /** @hide */
8772 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8773 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008774 boolean first = true;
8775 if (mAction != null) {
8776 b.append("act=").append(mAction);
8777 first = false;
8778 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008779 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008780 if (!first) {
8781 b.append(' ');
8782 }
8783 first = false;
8784 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008785 for (int i=0; i<mCategories.size(); i++) {
8786 if (i > 0) b.append(',');
8787 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008788 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008789 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008790 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008791 if (mData != null) {
8792 if (!first) {
8793 b.append(' ');
8794 }
8795 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008796 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008797 if (secure) {
8798 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008799 } else {
8800 b.append(mData);
8801 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008802 }
8803 if (mType != null) {
8804 if (!first) {
8805 b.append(' ');
8806 }
8807 first = false;
8808 b.append("typ=").append(mType);
8809 }
8810 if (mFlags != 0) {
8811 if (!first) {
8812 b.append(' ');
8813 }
8814 first = false;
8815 b.append("flg=0x").append(Integer.toHexString(mFlags));
8816 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008817 if (mPackage != null) {
8818 if (!first) {
8819 b.append(' ');
8820 }
8821 first = false;
8822 b.append("pkg=").append(mPackage);
8823 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008824 if (comp && mComponent != null) {
8825 if (!first) {
8826 b.append(' ');
8827 }
8828 first = false;
8829 b.append("cmp=").append(mComponent.flattenToShortString());
8830 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008831 if (mSourceBounds != null) {
8832 if (!first) {
8833 b.append(' ');
8834 }
8835 first = false;
8836 b.append("bnds=").append(mSourceBounds.toShortString());
8837 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008838 if (mClipData != null) {
8839 if (!first) {
8840 b.append(' ');
8841 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008842 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008843 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008844 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008845 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008846 if (mClipData.getDescription() != null) {
8847 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8848 } else {
8849 first = true;
8850 }
8851 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008852 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008853 first = false;
8854 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008855 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008856 if (extras && mExtras != null) {
8857 if (!first) {
8858 b.append(' ');
8859 }
8860 first = false;
8861 b.append("(has extras)");
8862 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008863 if (mContentUserHint != UserHandle.USER_CURRENT) {
8864 if (!first) {
8865 b.append(' ');
8866 }
8867 first = false;
8868 b.append("u=").append(mContentUserHint);
8869 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008870 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008871 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008872 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008873 b.append("}");
8874 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008875 }
8876
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008877 /**
8878 * Call {@link #toUri} with 0 flags.
8879 * @deprecated Use {@link #toUri} instead.
8880 */
8881 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008882 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008883 return toUri(0);
8884 }
8885
8886 /**
8887 * Convert this Intent into a String holding a URI representation of it.
8888 * The returned URI string has been properly URI encoded, so it can be
8889 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8890 * Intent's data as the base URI, with an additional fragment describing
8891 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008892 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008893 * <p>You can convert the returned string back to an Intent with
8894 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008895 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008896 * @param flags Additional operating flags. Either 0,
8897 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008898 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008899 * @return Returns a URI encoding URI string describing the entire contents
8900 * of the Intent.
8901 */
8902 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008903 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008904 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8905 if (mPackage == null) {
8906 throw new IllegalArgumentException(
8907 "Intent must include an explicit package name to build an android-app: "
8908 + this);
8909 }
8910 uri.append("android-app://");
8911 uri.append(mPackage);
8912 String scheme = null;
8913 if (mData != null) {
8914 scheme = mData.getScheme();
8915 if (scheme != null) {
8916 uri.append('/');
8917 uri.append(scheme);
8918 String authority = mData.getEncodedAuthority();
8919 if (authority != null) {
8920 uri.append('/');
8921 uri.append(authority);
8922 String path = mData.getEncodedPath();
8923 if (path != null) {
8924 uri.append(path);
8925 }
8926 String queryParams = mData.getEncodedQuery();
8927 if (queryParams != null) {
8928 uri.append('?');
8929 uri.append(queryParams);
8930 }
8931 String fragment = mData.getEncodedFragment();
8932 if (fragment != null) {
8933 uri.append('#');
8934 uri.append(fragment);
8935 }
8936 }
8937 }
8938 }
8939 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8940 mPackage, flags);
8941 return uri.toString();
8942 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008943 String scheme = null;
8944 if (mData != null) {
8945 String data = mData.toString();
8946 if ((flags&URI_INTENT_SCHEME) != 0) {
8947 final int N = data.length();
8948 for (int i=0; i<N; i++) {
8949 char c = data.charAt(i);
8950 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8951 || c == '.' || c == '-') {
8952 continue;
8953 }
8954 if (c == ':' && i > 0) {
8955 // Valid scheme.
8956 scheme = data.substring(0, i);
8957 uri.append("intent:");
8958 data = data.substring(i+1);
8959 break;
8960 }
Tom Taylord4a47292009-12-21 13:59:18 -08008961
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008962 // No scheme.
8963 break;
8964 }
8965 }
8966 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008967
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008968 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8969 uri.append("intent:");
8970 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008971
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008972 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008973
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008974 return uri.toString();
8975 }
8976
8977 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8978 String defPackage, int flags) {
8979 StringBuilder frag = new StringBuilder(128);
8980
8981 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008982 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008983 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008984 // Note that for now we are not going to try to handle the
8985 // data part; not clear how to represent this as a URI, and
8986 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008987 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8988 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008989 }
8990
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008991 if (frag.length() > 0) {
8992 uri.append("#Intent;");
8993 uri.append(frag);
8994 uri.append("end");
8995 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008996 }
8997
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008998 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8999 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009000 if (scheme != null) {
9001 uri.append("scheme=").append(scheme).append(';');
9002 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009003 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009004 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009005 }
9006 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009007 for (int i=0; i<mCategories.size(); i++) {
9008 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009009 }
9010 }
9011 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009012 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009013 }
9014 if (mFlags != 0) {
9015 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9016 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009017 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009018 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9019 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009020 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009021 uri.append("component=").append(Uri.encode(
9022 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009023 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009024 if (mSourceBounds != null) {
9025 uri.append("sourceBounds=")
9026 .append(Uri.encode(mSourceBounds.flattenToString()))
9027 .append(';');
9028 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009029 if (mExtras != null) {
9030 for (String key : mExtras.keySet()) {
9031 final Object value = mExtras.get(key);
9032 char entryType =
9033 value instanceof String ? 'S' :
9034 value instanceof Boolean ? 'B' :
9035 value instanceof Byte ? 'b' :
9036 value instanceof Character ? 'c' :
9037 value instanceof Double ? 'd' :
9038 value instanceof Float ? 'f' :
9039 value instanceof Integer ? 'i' :
9040 value instanceof Long ? 'l' :
9041 value instanceof Short ? 's' :
9042 '\0';
9043
9044 if (entryType != '\0') {
9045 uri.append(entryType);
9046 uri.append('.');
9047 uri.append(Uri.encode(key));
9048 uri.append('=');
9049 uri.append(Uri.encode(value.toString()));
9050 uri.append(';');
9051 }
9052 }
9053 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009054 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009055
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009056 public int describeContents() {
9057 return (mExtras != null) ? mExtras.describeContents() : 0;
9058 }
9059
9060 public void writeToParcel(Parcel out, int flags) {
9061 out.writeString(mAction);
9062 Uri.writeToParcel(out, mData);
9063 out.writeString(mType);
9064 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009065 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009066 ComponentName.writeToParcel(mComponent, out);
9067
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009068 if (mSourceBounds != null) {
9069 out.writeInt(1);
9070 mSourceBounds.writeToParcel(out, flags);
9071 } else {
9072 out.writeInt(0);
9073 }
9074
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009075 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009076 final int N = mCategories.size();
9077 out.writeInt(N);
9078 for (int i=0; i<N; i++) {
9079 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009080 }
9081 } else {
9082 out.writeInt(0);
9083 }
9084
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009085 if (mSelector != null) {
9086 out.writeInt(1);
9087 mSelector.writeToParcel(out, flags);
9088 } else {
9089 out.writeInt(0);
9090 }
9091
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009092 if (mClipData != null) {
9093 out.writeInt(1);
9094 mClipData.writeToParcel(out, flags);
9095 } else {
9096 out.writeInt(0);
9097 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009098 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009099 out.writeBundle(mExtras);
9100 }
9101
9102 public static final Parcelable.Creator<Intent> CREATOR
9103 = new Parcelable.Creator<Intent>() {
9104 public Intent createFromParcel(Parcel in) {
9105 return new Intent(in);
9106 }
9107 public Intent[] newArray(int size) {
9108 return new Intent[size];
9109 }
9110 };
9111
Dianne Hackborneb034652009-09-07 00:49:58 -07009112 /** @hide */
9113 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 readFromParcel(in);
9115 }
9116
9117 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009118 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 mData = Uri.CREATOR.createFromParcel(in);
9120 mType = in.readString();
9121 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009122 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009123 mComponent = ComponentName.readFromParcel(in);
9124
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009125 if (in.readInt() != 0) {
9126 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9127 }
9128
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009129 int N = in.readInt();
9130 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009131 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132 int i;
9133 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009134 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009135 }
9136 } else {
9137 mCategories = null;
9138 }
9139
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009140 if (in.readInt() != 0) {
9141 mSelector = new Intent(in);
9142 }
9143
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009144 if (in.readInt() != 0) {
9145 mClipData = new ClipData(in);
9146 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009147 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009148 mExtras = in.readBundle();
9149 }
9150
9151 /**
9152 * Parses the "intent" element (and its children) from XML and instantiates
9153 * an Intent object. The given XML parser should be located at the tag
9154 * where parsing should start (often named "intent"), from which the
9155 * basic action, data, type, and package and class name will be
9156 * retrieved. The function will then parse in to any child elements,
9157 * looking for <category android:name="xxx"> tags to add categories and
9158 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9159 * to the intent.
9160 *
9161 * @param resources The Resources to use when inflating resources.
9162 * @param parser The XML parser pointing at an "intent" tag.
9163 * @param attrs The AttributeSet interface for retrieving extended
9164 * attribute data at the current <var>parser</var> location.
9165 * @return An Intent object matching the XML data.
9166 * @throws XmlPullParserException If there was an XML parsing error.
9167 * @throws IOException If there was an I/O error.
9168 */
9169 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9170 throws XmlPullParserException, IOException {
9171 Intent intent = new Intent();
9172
9173 TypedArray sa = resources.obtainAttributes(attrs,
9174 com.android.internal.R.styleable.Intent);
9175
9176 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9177
9178 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9179 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9180 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9181
9182 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9183 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9184 if (packageName != null && className != null) {
9185 intent.setComponent(new ComponentName(packageName, className));
9186 }
9187
9188 sa.recycle();
9189
9190 int outerDepth = parser.getDepth();
9191 int type;
9192 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9193 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9194 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9195 continue;
9196 }
9197
9198 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009199 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009200 sa = resources.obtainAttributes(attrs,
9201 com.android.internal.R.styleable.IntentCategory);
9202 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9203 sa.recycle();
9204
9205 if (cat != null) {
9206 intent.addCategory(cat);
9207 }
9208 XmlUtils.skipCurrentTag(parser);
9209
Craig Mautner21d24a22014-04-23 11:45:37 -07009210 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009211 if (intent.mExtras == null) {
9212 intent.mExtras = new Bundle();
9213 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009214 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009215 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009216
9217 } else {
9218 XmlUtils.skipCurrentTag(parser);
9219 }
9220 }
9221
9222 return intent;
9223 }
Nick Pellyccae4122012-01-09 14:12:58 -08009224
Craig Mautner21d24a22014-04-23 11:45:37 -07009225 /** @hide */
9226 public void saveToXml(XmlSerializer out) throws IOException {
9227 if (mAction != null) {
9228 out.attribute(null, ATTR_ACTION, mAction);
9229 }
9230 if (mData != null) {
9231 out.attribute(null, ATTR_DATA, mData.toString());
9232 }
9233 if (mType != null) {
9234 out.attribute(null, ATTR_TYPE, mType);
9235 }
9236 if (mComponent != null) {
9237 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9238 }
9239 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9240
9241 if (mCategories != null) {
9242 out.startTag(null, TAG_CATEGORIES);
9243 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9244 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9245 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009246 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009247 }
9248 }
9249
9250 /** @hide */
9251 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9252 XmlPullParserException {
9253 Intent intent = new Intent();
9254 final int outerDepth = in.getDepth();
9255
9256 int attrCount = in.getAttributeCount();
9257 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9258 final String attrName = in.getAttributeName(attrNdx);
9259 final String attrValue = in.getAttributeValue(attrNdx);
9260 if (ATTR_ACTION.equals(attrName)) {
9261 intent.setAction(attrValue);
9262 } else if (ATTR_DATA.equals(attrName)) {
9263 intent.setData(Uri.parse(attrValue));
9264 } else if (ATTR_TYPE.equals(attrName)) {
9265 intent.setType(attrValue);
9266 } else if (ATTR_COMPONENT.equals(attrName)) {
9267 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9268 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009269 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009270 } else {
9271 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9272 }
9273 }
9274
9275 int event;
9276 String name;
9277 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9278 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9279 if (event == XmlPullParser.START_TAG) {
9280 name = in.getName();
9281 if (TAG_CATEGORIES.equals(name)) {
9282 attrCount = in.getAttributeCount();
9283 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9284 intent.addCategory(in.getAttributeValue(attrNdx));
9285 }
9286 } else {
9287 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9288 XmlUtils.skipCurrentTag(in);
9289 }
9290 }
9291 }
9292
9293 return intent;
9294 }
9295
Nick Pellyccae4122012-01-09 14:12:58 -08009296 /**
9297 * Normalize a MIME data type.
9298 *
9299 * <p>A normalized MIME type has white-space trimmed,
9300 * content-type parameters removed, and is lower-case.
9301 * This aligns the type with Android best practices for
9302 * intent filtering.
9303 *
9304 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9305 * "text/x-vCard" becomes "text/x-vcard".
9306 *
9307 * <p>All MIME types received from outside Android (such as user input,
9308 * or external sources like Bluetooth, NFC, or the Internet) should
9309 * be normalized before they are used to create an Intent.
9310 *
9311 * @param type MIME data type to normalize
9312 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009313 * @see #setType
9314 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009315 */
9316 public static String normalizeMimeType(String type) {
9317 if (type == null) {
9318 return null;
9319 }
9320
Elliott Hughescb64d432013-08-02 10:00:44 -07009321 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009322
9323 final int semicolonIndex = type.indexOf(';');
9324 if (semicolonIndex != -1) {
9325 type = type.substring(0, semicolonIndex);
9326 }
9327 return type;
9328 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009329
9330 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009331 * Prepare this {@link Intent} to leave an app process.
9332 *
9333 * @hide
9334 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009335 public void prepareToLeaveProcess(Context context) {
9336 final boolean leavingPackage = (mComponent == null)
9337 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9338 prepareToLeaveProcess(leavingPackage);
9339 }
9340
9341 /**
9342 * Prepare this {@link Intent} to leave an app process.
9343 *
9344 * @hide
9345 */
9346 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009347 setAllowFds(false);
9348
9349 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009350 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009351 }
9352 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009353 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009354 }
9355
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009356 if (mExtras != null && !mExtras.isParcelled()) {
9357 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9358 if (intent instanceof Intent) {
9359 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9360 }
9361 }
9362
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009363 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9364 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009365 switch (mAction) {
9366 case ACTION_MEDIA_REMOVED:
9367 case ACTION_MEDIA_UNMOUNTED:
9368 case ACTION_MEDIA_CHECKING:
9369 case ACTION_MEDIA_NOFS:
9370 case ACTION_MEDIA_MOUNTED:
9371 case ACTION_MEDIA_SHARED:
9372 case ACTION_MEDIA_UNSHARED:
9373 case ACTION_MEDIA_BAD_REMOVAL:
9374 case ACTION_MEDIA_UNMOUNTABLE:
9375 case ACTION_MEDIA_EJECT:
9376 case ACTION_MEDIA_SCANNER_STARTED:
9377 case ACTION_MEDIA_SCANNER_FINISHED:
9378 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009379 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9380 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009381 // Ignore legacy actions
9382 break;
9383 default:
9384 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009385 }
9386 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009387
9388 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9389 && leavingPackage) {
9390 switch (mAction) {
9391 case ACTION_PROVIDER_CHANGED:
9392 // Ignore actions that don't need to grant
9393 break;
9394 default:
9395 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9396 }
9397 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009398 }
9399
9400 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009401 * @hide
9402 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009403 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009404 // We just entered destination process, so we should be able to read all
9405 // parcelables inside.
9406 setDefusable(true);
9407
9408 if (mSelector != null) {
9409 mSelector.prepareToEnterProcess();
9410 }
9411 if (mClipData != null) {
9412 mClipData.prepareToEnterProcess();
9413 }
9414
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009415 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009416 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9417 fixUris(mContentUserHint);
9418 mContentUserHint = UserHandle.USER_CURRENT;
9419 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009420 }
9421 }
9422
9423 /**
9424 * @hide
9425 */
9426 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009427 Uri data = getData();
9428 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009429 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009430 }
9431 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009432 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009433 }
9434 String action = getAction();
9435 if (ACTION_SEND.equals(action)) {
9436 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9437 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009438 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009439 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009440 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009441 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9442 if (streams != null) {
9443 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9444 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009445 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009446 }
9447 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9448 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009449 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9450 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9451 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9452 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9453 if (output != null) {
9454 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9455 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009456 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009457 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009458
9459 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009460 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009461 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9462 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009463 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009464 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009465 * @hide
9466 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009467 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009468 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009469 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009470
9471 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009472 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009473
9474 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009475 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009476 // Inspect contained intents to see if we need to migrate extras. We
9477 // don't promote ClipData to the parent, since ChooserActivity will
9478 // already start the picked item as the caller, and we can't combine
9479 // the flags in a safe way.
9480
9481 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009482 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009483 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9484 if (intent != null) {
9485 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009486 }
9487 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009488 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009489 try {
9490 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9491 if (intents != null) {
9492 for (int i = 0; i < intents.length; i++) {
9493 final Intent intent = (Intent) intents[i];
9494 if (intent != null) {
9495 migrated |= intent.migrateExtraStreamToClipData();
9496 }
9497 }
9498 }
9499 } catch (ClassCastException e) {
9500 }
9501 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009502
9503 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009504 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009505 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9506 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9507 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9508 if (stream != null || text != null || htmlText != null) {
9509 final ClipData clipData = new ClipData(
9510 null, new String[] { getType() },
9511 new ClipData.Item(text, htmlText, null, stream));
9512 setClipData(clipData);
9513 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009514 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009515 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009516 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009517 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009518
9519 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009520 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009521 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9522 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9523 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9524 int num = -1;
9525 if (streams != null) {
9526 num = streams.size();
9527 }
9528 if (texts != null) {
9529 if (num >= 0 && num != texts.size()) {
9530 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009531 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009532 }
9533 num = texts.size();
9534 }
9535 if (htmlTexts != null) {
9536 if (num >= 0 && num != htmlTexts.size()) {
9537 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009538 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009539 }
9540 num = htmlTexts.size();
9541 }
9542 if (num > 0) {
9543 final ClipData clipData = new ClipData(
9544 null, new String[] { getType() },
9545 makeClipItem(streams, texts, htmlTexts, 0));
9546
9547 for (int i = 1; i < num; i++) {
9548 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9549 }
9550
9551 setClipData(clipData);
9552 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009553 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009554 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009555 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009556 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009557 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9558 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9559 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9560 final Uri output;
9561 try {
9562 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9563 } catch (ClassCastException e) {
9564 return false;
9565 }
9566 if (output != null) {
9567 setClipData(ClipData.newRawUri("", output));
9568 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9569 return true;
9570 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009571 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009572
9573 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009574 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009575
9576 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9577 ArrayList<String> htmlTexts, int which) {
9578 Uri uri = streams != null ? streams.get(which) : null;
9579 CharSequence text = texts != null ? texts.get(which) : null;
9580 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9581 return new ClipData.Item(text, htmlText, null, uri);
9582 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009583
9584 /** @hide */
9585 public boolean isDocument() {
9586 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9587 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009588}