blob: b6f9ac97e7275b1126aa28fc202bcf5c13d534d8 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070022import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050024import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060027import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30import android.content.res.Resources;
31import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080032import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060034import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.os.Bundle;
36import android.os.IBinder;
37import android.os.Parcel;
38import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000039import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050040import android.os.ResultReceiver;
41import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070042import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010043import android.os.UserHandle;
Jeff Sharkey81aebe72017-04-03 20:14:10 +000044import android.os.storage.StorageManager;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070045import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070048import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070050import android.util.AttributeSet;
51import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080052import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import org.xmlpull.v1.XmlPullParser;
54import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070055import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070056
57import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080058import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070060import java.lang.annotation.Retention;
61import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.net.URISyntaxException;
63import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080064import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070065import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080066import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070067import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.util.Set;
69
Jeff Sharkey81aebe72017-04-03 20:14:10 +000070import static android.content.ContentProvider.maybeAddUserId;
71
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072/**
73 * An intent is an abstract description of an operation to be performed. It
74 * can be used with {@link Context#startActivity(Intent) startActivity} to
75 * launch an {@link android.app.Activity},
76 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
77 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
78 * and {@link android.content.Context#startService} or
79 * {@link android.content.Context#bindService} to communicate with a
80 * background {@link android.app.Service}.
81 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 * <p>An Intent provides a facility for performing late runtime binding between the code in
83 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070084 * can be thought of as the glue between activities. It is basically a passive data structure
85 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 *
87 * <div class="special reference">
88 * <h3>Developer Guides</h3>
89 * <p>For information about how to create and resolve intents, read the
90 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
91 * developer guide.</p>
92 * </div>
93 *
94 * <a name="IntentStructure"></a>
95 * <h3>Intent Structure</h3>
96 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 *
98 * <ul>
99 * <li> <p><b>action</b> -- The general action to be performed, such as
100 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
101 * etc.</p>
102 * </li>
103 * <li> <p><b>data</b> -- The data to operate on, such as a person record
104 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
105 * </li>
106 * </ul>
107 *
108 *
109 * <p>Some examples of action/data pairs are:</p>
110 *
111 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700112 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700113 * information about the person whose identifier is "1".</p>
114 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700115 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700116 * the phone dialer with the person filled in.</p>
117 * </li>
118 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
119 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700120 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * a particular URI.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in.</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * information about the person whose identifier is "1".</p>
128 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a list of people, which the user can browse through. This example is a
131 * typical top-level entry into the Contacts application, showing you the
132 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700133 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * being used to start an activity to display that person.</p>
135 * </li>
136 * </ul>
137 *
138 * <p>In addition to these primary attributes, there are a number of secondary
139 * attributes that you can also include with an intent:</p>
140 *
141 * <ul>
142 * <li> <p><b>category</b> -- Gives additional information about the action
143 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
144 * appear in the Launcher as a top-level application, while
145 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
146 * of alternative actions the user can perform on a piece of data.</p>
147 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
148 * intent data. Normally the type is inferred from the data itself.
149 * By setting this attribute, you disable that evaluation and force
150 * an explicit type.</p>
151 * <li> <p><b>component</b> -- Specifies an explicit name of a component
152 * class to use for the intent. Normally this is determined by looking
153 * at the other information in the intent (the action, data/type, and
154 * categories) and matching that with a component that can handle it.
155 * If this attribute is set then none of the evaluation is performed,
156 * and this component is used exactly as is. By specifying this attribute,
157 * all of the other Intent attributes become optional.</p>
158 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
159 * This can be used to provide extended information to the component.
160 * For example, if we have a action to send an e-mail message, we could
161 * also include extra pieces of data here to supply a subject, body,
162 * etc.</p>
163 * </ul>
164 *
165 * <p>Here are some examples of other operations you can specify as intents
166 * using these additional parameters:</p>
167 *
168 * <ul>
169 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
170 * Launch the home screen.</p>
171 * </li>
172 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
173 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
174 * vnd.android.cursor.item/phone}</i></b>
175 * -- Display the list of people's phone numbers, allowing the user to
176 * browse through them and pick one and return it to the parent activity.</p>
177 * </li>
178 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
180 * -- Display all pickers for data that can be opened with
181 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
182 * allowing the user to pick one of them and then some data inside of it
183 * and returning the resulting URI to the caller. This can be used,
184 * for example, in an e-mail application to allow the user to pick some
185 * data to include as an attachment.</p>
186 * </li>
187 * </ul>
188 *
189 * <p>There are a variety of standard Intent action and category constants
190 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700191 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700193 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700194 *
195 * <p>Put together, the set of actions, data types, categories, and extra data
196 * defines a language for the system allowing for the expression of phrases
197 * such as "call john smith's cell". As applications are added to the system,
198 * they can extend this language by adding new actions, types, and categories, or
199 * they can modify the behavior of existing phrases by supplying their own
200 * activities that handle them.</p>
201 *
202 * <a name="IntentResolution"></a>
203 * <h3>Intent Resolution</h3>
204 *
205 * <p>There are two primary forms of intents you will use.
206 *
207 * <ul>
208 * <li> <p><b>Explicit Intents</b> have specified a component (via
209 * {@link #setComponent} or {@link #setClass}), which provides the exact
210 * class to be run. Often these will not include any other information,
211 * simply being a way for an application to launch various internal
212 * activities it has as the user interacts with the application.
213 *
214 * <li> <p><b>Implicit Intents</b> have not specified a component;
215 * instead, they must include enough information for the system to
216 * determine which of the available components is best to run for that
217 * intent.
218 * </ul>
219 *
220 * <p>When using implicit intents, given such an arbitrary intent we need to
221 * know what to do with it. This is handled by the process of <em>Intent
222 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
223 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
224 * more activities/receivers) that can handle it.</p>
225 *
226 * <p>The intent resolution mechanism basically revolves around matching an
227 * Intent against all of the &lt;intent-filter&gt; descriptions in the
228 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
229 * objects explicitly registered with {@link Context#registerReceiver}.) More
230 * details on this can be found in the documentation on the {@link
231 * IntentFilter} class.</p>
232 *
233 * <p>There are three pieces of information in the Intent that are used for
234 * resolution: the action, type, and category. Using this information, a query
235 * is done on the {@link PackageManager} for a component that can handle the
236 * intent. The appropriate component is determined based on the intent
237 * information supplied in the <code>AndroidManifest.xml</code> file as
238 * follows:</p>
239 *
240 * <ul>
241 * <li> <p>The <b>action</b>, if given, must be listed by the component as
242 * one it handles.</p>
243 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
244 * already supplied in the Intent. Like the action, if a type is
245 * included in the intent (either explicitly or implicitly in its
246 * data), then this must be listed by the component as one it handles.</p>
247 * <li> For data that is not a <code>content:</code> URI and where no explicit
248 * type is included in the Intent, instead the <b>scheme</b> of the
249 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
250 * considered. Again like the action, if we are matching a scheme it
251 * must be listed by the component as one it can handle.
252 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
253 * by the activity as categories it handles. That is, if you include
254 * the categories {@link #CATEGORY_LAUNCHER} and
255 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
256 * with an intent that lists <em>both</em> of those categories.
257 * Activities will very often need to support the
258 * {@link #CATEGORY_DEFAULT} so that they can be found by
259 * {@link Context#startActivity Context.startActivity()}.</p>
260 * </ul>
261 *
262 * <p>For example, consider the Note Pad sample application that
263 * allows user to browse through a list of notes data and view details about
264 * individual items. Text in italics indicate places were you would replace a
265 * name with one specific to your own package.</p>
266 *
267 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
268 * package="<i>com.android.notepad</i>"&gt;
269 * &lt;application android:icon="@drawable/app_notes"
270 * android:label="@string/app_name"&gt;
271 *
272 * &lt;provider class=".NotePadProvider"
273 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
274 *
275 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.MAIN" /&gt;
278 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700279 * &lt;/intent-filter&gt;
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.VIEW" /&gt;
282 * &lt;action android:name="android.intent.action.EDIT" /&gt;
283 * &lt;action android:name="android.intent.action.PICK" /&gt;
284 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;/activity&gt;
293 *
294 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
295 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.VIEW" /&gt;
297 * &lt;action android:name="android.intent.action.EDIT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 *
302 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700303 * &lt;action android:name="android.intent.action.INSERT" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700306 * &lt;/intent-filter&gt;
307 *
308 * &lt;/activity&gt;
309 *
310 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
311 * android:theme="@android:style/Theme.Dialog"&gt;
312 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
314 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
316 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
317 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700318 * &lt;/intent-filter&gt;
319 * &lt;/activity&gt;
320 *
321 * &lt;/application&gt;
322 * &lt;/manifest&gt;</pre>
323 *
324 * <p>The first activity,
325 * <code>com.android.notepad.NotesList</code>, serves as our main
326 * entry into the app. It can do three things as described by its three intent
327 * templates:
328 * <ol>
329 * <li><pre>
330 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700331 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
332 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700333 * &lt;/intent-filter&gt;</pre>
334 * <p>This provides a top-level entry into the NotePad application: the standard
335 * MAIN action is a main entry point (not requiring any other information in
336 * the Intent), and the LAUNCHER category says that this entry point should be
337 * listed in the application launcher.</p>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
341 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
342 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
343 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700344 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700345 * &lt;/intent-filter&gt;</pre>
346 * <p>This declares the things that the activity can do on a directory of
347 * notes. The type being supported is given with the &lt;type&gt; tag, where
348 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
349 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
350 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
351 * The activity allows the user to view or edit the directory of data (via
352 * the VIEW and EDIT actions), or to pick a particular note and return it
353 * to the caller (via the PICK action). Note also the DEFAULT category
354 * supplied here: this is <em>required</em> for the
355 * {@link Context#startActivity Context.startActivity} method to resolve your
356 * activity when its component name is not explicitly specified.</p>
357 * <li><pre>
358 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700359 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
360 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700363 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700364 * the user without needing to know where it came from. The data type
365 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
366 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
367 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
368 * The GET_CONTENT action is similar to the PICK action, where the activity
369 * will return to its caller a piece of data selected by the user. Here,
370 * however, the caller specifies the type of data they desire instead of
371 * the type of data the user will be picking from.</p>
372 * </ol>
373 *
374 * <p>Given these capabilities, the following intents will resolve to the
375 * NotesList activity:</p>
376 *
377 * <ul>
378 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
379 * activities that can be used as top-level entry points into an
380 * application.</p>
381 * <li> <p><b>{ action=android.app.action.MAIN,
382 * category=android.app.category.LAUNCHER }</b> is the actual intent
383 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700384 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700385 * data=content://com.google.provider.NotePad/notes }</b>
386 * displays a list of all the notes under
387 * "content://com.google.provider.NotePad/notes", which
388 * the user can browse through and see the details on.</p>
389 * <li> <p><b>{ action=android.app.action.PICK
390 * data=content://com.google.provider.NotePad/notes }</b>
391 * provides a list of the notes under
392 * "content://com.google.provider.NotePad/notes", from which
393 * the user can pick a note whose data URL is returned back to the caller.</p>
394 * <li> <p><b>{ action=android.app.action.GET_CONTENT
395 * type=vnd.android.cursor.item/vnd.google.note }</b>
396 * is similar to the pick action, but allows the caller to specify the
397 * kind of data they want back so that the system can find the appropriate
398 * activity to pick something of that data type.</p>
399 * </ul>
400 *
401 * <p>The second activity,
402 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
403 * note entry and allows them to edit it. It can do two things as described
404 * by its two intent templates:
405 * <ol>
406 * <li><pre>
407 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700408 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
409 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
410 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
411 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700412 * &lt;/intent-filter&gt;</pre>
413 * <p>The first, primary, purpose of this activity is to let the user interact
414 * with a single note, as decribed by the MIME type
415 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
416 * either VIEW a note or allow the user to EDIT it. Again we support the
417 * DEFAULT category to allow the activity to be launched without explicitly
418 * specifying its component.</p>
419 * <li><pre>
420 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700421 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
422 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
423 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700424 * &lt;/intent-filter&gt;</pre>
425 * <p>The secondary use of this activity is to insert a new note entry into
426 * an existing directory of notes. This is used when the user creates a new
427 * note: the INSERT action is executed on the directory of notes, causing
428 * this activity to run and have the user create the new note data which
429 * it then adds to the content provider.</p>
430 * </ol>
431 *
432 * <p>Given these capabilities, the following intents will resolve to the
433 * NoteEditor activity:</p>
434 *
435 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700436 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700437 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 * shows the user the content of note <var>{ID}</var>.</p>
439 * <li> <p><b>{ action=android.app.action.EDIT
440 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
441 * allows the user to edit the content of note <var>{ID}</var>.</p>
442 * <li> <p><b>{ action=android.app.action.INSERT
443 * data=content://com.google.provider.NotePad/notes }</b>
444 * creates a new, empty note in the notes list at
445 * "content://com.google.provider.NotePad/notes"
446 * and allows the user to edit it. If they keep their changes, the URI
447 * of the newly created note is returned to the caller.</p>
448 * </ul>
449 *
450 * <p>The last activity,
451 * <code>com.android.notepad.TitleEditor</code>, allows the user to
452 * edit the title of a note. This could be implemented as a class that the
453 * application directly invokes (by explicitly setting its component in
454 * the Intent), but here we show a way you can publish alternative
455 * operations on existing data:</p>
456 *
457 * <pre>
458 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700459 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
463 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700464 * &lt;/intent-filter&gt;</pre>
465 *
466 * <p>In the single intent template here, we
467 * have created our own private action called
468 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
469 * edit the title of a note. It must be invoked on a specific note
470 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
471 * view and edit actions, but here displays and edits the title contained
472 * in the note data.
473 *
474 * <p>In addition to supporting the default category as usual, our title editor
475 * also supports two other standard categories: ALTERNATIVE and
476 * SELECTED_ALTERNATIVE. Implementing
477 * these categories allows others to find the special action it provides
478 * without directly knowing about it, through the
479 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
480 * more often to build dynamic menu items with
481 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
482 * template here was also supply an explicit name for the template
483 * (via <code>android:label="@string/resolve_title"</code>) to better control
484 * what the user sees when presented with this activity as an alternative
485 * action to the data they are viewing.
486 *
487 * <p>Given these capabilities, the following intent will resolve to the
488 * TitleEditor activity:</p>
489 *
490 * <ul>
491 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
492 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
493 * displays and allows the user to edit the title associated
494 * with note <var>{ID}</var>.</p>
495 * </ul>
496 *
497 * <h3>Standard Activity Actions</h3>
498 *
499 * <p>These are the current standard actions that Intent defines for launching
500 * activities (usually through {@link Context#startActivity}. The most
501 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
502 * {@link #ACTION_EDIT}.
503 *
504 * <ul>
505 * <li> {@link #ACTION_MAIN}
506 * <li> {@link #ACTION_VIEW}
507 * <li> {@link #ACTION_ATTACH_DATA}
508 * <li> {@link #ACTION_EDIT}
509 * <li> {@link #ACTION_PICK}
510 * <li> {@link #ACTION_CHOOSER}
511 * <li> {@link #ACTION_GET_CONTENT}
512 * <li> {@link #ACTION_DIAL}
513 * <li> {@link #ACTION_CALL}
514 * <li> {@link #ACTION_SEND}
515 * <li> {@link #ACTION_SENDTO}
516 * <li> {@link #ACTION_ANSWER}
517 * <li> {@link #ACTION_INSERT}
518 * <li> {@link #ACTION_DELETE}
519 * <li> {@link #ACTION_RUN}
520 * <li> {@link #ACTION_SYNC}
521 * <li> {@link #ACTION_PICK_ACTIVITY}
522 * <li> {@link #ACTION_SEARCH}
523 * <li> {@link #ACTION_WEB_SEARCH}
524 * <li> {@link #ACTION_FACTORY_TEST}
525 * </ul>
526 *
527 * <h3>Standard Broadcast Actions</h3>
528 *
529 * <p>These are the current standard actions that Intent defines for receiving
530 * broadcasts (usually through {@link Context#registerReceiver} or a
531 * &lt;receiver&gt; tag in a manifest).
532 *
533 * <ul>
534 * <li> {@link #ACTION_TIME_TICK}
535 * <li> {@link #ACTION_TIME_CHANGED}
536 * <li> {@link #ACTION_TIMEZONE_CHANGED}
537 * <li> {@link #ACTION_BOOT_COMPLETED}
538 * <li> {@link #ACTION_PACKAGE_ADDED}
539 * <li> {@link #ACTION_PACKAGE_CHANGED}
540 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 * <li> {@link #ACTION_PACKAGE_RESTARTED}
542 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000543 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
544 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * <li> {@link #ACTION_UID_REMOVED}
546 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700547 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700548 * <li> {@link #ACTION_POWER_DISCONNECTED}
549 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * </ul>
551 *
552 * <h3>Standard Categories</h3>
553 *
554 * <p>These are the current standard categories that can be used to further
555 * clarify an Intent via {@link #addCategory}.
556 *
557 * <ul>
558 * <li> {@link #CATEGORY_DEFAULT}
559 * <li> {@link #CATEGORY_BROWSABLE}
560 * <li> {@link #CATEGORY_TAB}
561 * <li> {@link #CATEGORY_ALTERNATIVE}
562 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
563 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_HOME}
566 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400568 * <li> {@link #CATEGORY_CAR_DOCK}
569 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500570 * <li> {@link #CATEGORY_LE_DESK_DOCK}
571 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200572 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700573 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800574 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700660 * Extra that can be included on activity intents coming from the storage UI
661 * when it launches sub-activities to manage various types of storage. For example,
662 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
663 * the images on the device, and in that case also include this extra to tell the
664 * app it is coming from the storage UI so should help the user manage storage of
665 * this type.
666 */
667 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
668
669 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
671 * performed on a piece of data.
672 */
673 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800674
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900676 * Activity Action: Quick view the data. Launches a quick viewer for
677 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900678 * <p>Activities handling this intent action should handle the vast majority of
679 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700680 * <p>Quick viewers must render the quick view image locally, and must not send
681 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900682 * <p>Input: {@link #getData} is a mandatory content URI of the item to
683 * preview. {@link #getClipData} contains an optional list of content URIs
684 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
685 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700686 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
687 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700688 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900689 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700690 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700691 */
692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
693 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
694
695 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 * Used to indicate that some piece of data should be attached to some other
697 * place. For example, image data could be attached to a contact. It is up
698 * to the recipient to decide where the data should be attached; the intent
699 * does not specify the ultimate destination.
700 * <p>Input: {@link #getData} is URI of data to be attached.
701 * <p>Output: nothing.
702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 /**
707 * Activity Action: Provide explicit editable access to the given data.
708 * <p>Input: {@link #getData} is URI of data to be edited.
709 * <p>Output: nothing.
710 */
711 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
712 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 /**
715 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
716 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
717 * The extras can contain type specific data to pass through to the editing/creating
718 * activity.
719 * <p>Output: The URI of the item that was picked. This must be a content:
720 * URI so that any receiver can access it.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Pick an item from the data, returning what was selected.
727 * <p>Input: {@link #getData} is URI containing a directory of data
728 * (vnd.android.cursor.dir/*) from which to pick an item.
729 * <p>Output: The URI of the item that was picked.
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 /**
735 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800736 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800737 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
738 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700739 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
740 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741 * (value: ShortcutIconResource).</p>
742 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800743 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 * @see #EXTRA_SHORTCUT_INTENT
745 * @see #EXTRA_SHORTCUT_NAME
746 * @see #EXTRA_SHORTCUT_ICON
747 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
748 * @see android.content.Intent.ShortcutIconResource
749 */
750 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
751 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
752
753 /**
754 * The name of the extra used to define the Intent of a shortcut.
755 *
756 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800759 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700760 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
761 /**
762 * The name of the extra used to define the name of a shortcut.
763 *
764 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
769 /**
770 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
771 *
772 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
777 /**
778 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
779 *
780 * @see #ACTION_CREATE_SHORTCUT
781 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800782 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
786 "android.intent.extra.shortcut.ICON_RESOURCE";
787
788 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500789 * An activity that provides a user interface for adjusting application preferences.
790 * Optional but recommended settings for all applications which have settings.
791 */
792 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
793 public static final String ACTION_APPLICATION_PREFERENCES
794 = "android.intent.action.APPLICATION_PREFERENCES";
795
796 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700797 * Activity Action: Launch an activity showing the app information.
798 * For applications which install other applications (such as app stores), it is recommended
799 * to handle this action for providing the app information to the user.
800 *
801 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
802 * to be displayed.
803 * <p>Output: Nothing.
804 */
805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
806 public static final String ACTION_SHOW_APP_INFO
807 = "android.intent.action.SHOW_APP_INFO";
808
809 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800810 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700811 *
812 * @see Intent#ACTION_CREATE_SHORTCUT
813 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800814 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
815 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700816 */
817 public static class ShortcutIconResource implements Parcelable {
818 /**
819 * The package name of the application containing the icon.
820 */
821 public String packageName;
822
823 /**
824 * The resource name of the icon, including package, name and type.
825 */
826 public String resourceName;
827
828 /**
829 * Creates a new ShortcutIconResource for the specified context and resource
830 * identifier.
831 *
832 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700833 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700834 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700835 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700836 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700837 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700838 ShortcutIconResource icon = new ShortcutIconResource();
839 icon.packageName = context.getPackageName();
840 icon.resourceName = context.getResources().getResourceName(resourceId);
841 return icon;
842 }
843
844 /**
845 * Used to read a ShortcutIconResource from a Parcel.
846 */
847 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
848 new Parcelable.Creator<ShortcutIconResource>() {
849
850 public ShortcutIconResource createFromParcel(Parcel source) {
851 ShortcutIconResource icon = new ShortcutIconResource();
852 icon.packageName = source.readString();
853 icon.resourceName = source.readString();
854 return icon;
855 }
856
857 public ShortcutIconResource[] newArray(int size) {
858 return new ShortcutIconResource[size];
859 }
860 };
861
862 /**
863 * No special parcel contents.
864 */
865 public int describeContents() {
866 return 0;
867 }
868
869 public void writeToParcel(Parcel dest, int flags) {
870 dest.writeString(packageName);
871 dest.writeString(resourceName);
872 }
873
874 @Override
875 public String toString() {
876 return resourceName;
877 }
878 }
879
880 /**
881 * Activity Action: Display an activity chooser, allowing the user to pick
882 * what they want to before proceeding. This can be used as an alternative
883 * to the standard activity picker that is displayed by the system when
884 * you try to start an activity with multiple possible matches, with these
885 * differences in behavior:
886 * <ul>
887 * <li>You can specify the title that will appear in the activity chooser.
888 * <li>The user does not have the option to make one of the matching
889 * activities a preferred activity, and all possible activities will
890 * always be shown even if one of them is currently marked as the
891 * preferred activity.
892 * </ul>
893 * <p>
894 * This action should be used when the user will naturally expect to
895 * select an activity in order to proceed. An example if when not to use
896 * it is when the user clicks on a "mailto:" link. They would naturally
897 * expect to go directly to their mail app, so startActivity() should be
898 * called directly: it will
899 * either launch the current preferred app, or put up a dialog allowing the
900 * user to pick an app to use and optionally marking that as preferred.
901 * <p>
902 * In contrast, if the user is selecting a menu item to send a picture
903 * they are viewing to someone else, there are many different things they
904 * may want to do at this point: send it through e-mail, upload it to a
905 * web service, etc. In this case the CHOOSER action should be used, to
906 * always present to the user a list of the things they can do, with a
907 * nice title given by the caller such as "Send this photo with:".
908 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700909 * If you need to grant URI permissions through a chooser, you must specify
910 * the permissions to be granted on the ACTION_CHOOSER Intent
911 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
912 * {@link #setClipData} to specify the URIs to be granted as well as
913 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
914 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
915 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700916 * As a convenience, an Intent of this form can be created with the
917 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700918 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700919 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700920 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
921 * and can optionally have a {@link #EXTRA_TITLE} field containing the
922 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700923 * <p>
924 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 */
926 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
927 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
928
929 /**
930 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
931 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700932 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
933 * target intent, also optionally supplying a title. If the target
934 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
935 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
936 * set in the returned chooser intent, with its ClipData set appropriately:
937 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500938 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700939 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700940 * @param target The Intent that the user will be selecting an activity
941 * to perform.
942 * @param title Optional title that will be displayed in the chooser.
943 * @return Return a new Intent object that you can hand to
944 * {@link Context#startActivity(Intent) Context.startActivity()} and
945 * related methods.
946 */
947 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700948 return createChooser(target, title, null);
949 }
950
951 /**
952 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
953 *
954 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
955 * target intent, also optionally supplying a title. If the target
956 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
957 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
958 * set in the returned chooser intent, with its ClipData set appropriately:
959 * either a direct reflection of {@link #getClipData()} if that is non-null,
960 * or a new ClipData built from {@link #getData()}.</p>
961 *
962 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
963 * when the user makes a choice. This can be useful if the calling application wants
964 * to remember the last chosen target and surface it as a more prominent or one-touch
965 * affordance elsewhere in the UI for next time.</p>
966 *
967 * @param target The Intent that the user will be selecting an activity
968 * to perform.
969 * @param title Optional title that will be displayed in the chooser.
970 * @param sender Optional IntentSender to be called when a choice is made.
971 * @return Return a new Intent object that you can hand to
972 * {@link Context#startActivity(Intent) Context.startActivity()} and
973 * related methods.
974 */
975 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700976 Intent intent = new Intent(ACTION_CHOOSER);
977 intent.putExtra(EXTRA_INTENT, target);
978 if (title != null) {
979 intent.putExtra(EXTRA_TITLE, title);
980 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700981
Adam Powell0b3c1122014-10-09 12:50:14 -0700982 if (sender != null) {
983 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
984 }
985
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700986 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700987 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
988 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
989 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700990 if (permFlags != 0) {
991 ClipData targetClipData = target.getClipData();
992 if (targetClipData == null && target.getData() != null) {
993 ClipData.Item item = new ClipData.Item(target.getData());
994 String[] mimeTypes;
995 if (target.getType() != null) {
996 mimeTypes = new String[] { target.getType() };
997 } else {
998 mimeTypes = new String[] { };
999 }
1000 targetClipData = new ClipData(null, mimeTypes, item);
1001 }
1002 if (targetClipData != null) {
1003 intent.setClipData(targetClipData);
1004 intent.addFlags(permFlags);
1005 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001006 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001007
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 return intent;
1009 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001010
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 /**
1012 * Activity Action: Allow the user to select a particular kind of data and
1013 * return it. This is different than {@link #ACTION_PICK} in that here we
1014 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001015 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001017 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 * etc.
1019 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001020 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001021 * of data, such as a person contact, you set the MIME type to the kind of
1022 * data you want and launch it with {@link Context#startActivity(Intent)}.
1023 * The system will then launch the best application to select that kind
1024 * of data for you.
1025 * <p>
1026 * You may also be interested in any of a set of types of content the user
1027 * can pick. For example, an e-mail application that wants to allow the
1028 * user to add an attachment to an e-mail message can use this action to
1029 * bring up a list of all of the types of content the user can attach.
1030 * <p>
1031 * In this case, you should wrap the GET_CONTENT intent with a chooser
1032 * (through {@link #createChooser}), which will give the proper interface
1033 * for the user to pick how to send your data and allow you to specify
1034 * a prompt indicating what they are doing. You will usually specify a
1035 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1036 * broad range of content types the user can select from.
1037 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001038 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001039 * only pick from data that can be represented as a stream. This is
1040 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1041 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001042 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001043 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001044 * is locally available on the device. For example, if this extra is set
1045 * to true then an image picker should not show any pictures that are available
1046 * from a remote server but not already on the local device (thus requiring
1047 * they be downloaded when opened).
1048 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001049 * If the caller can handle multiple returned items (the user performing
1050 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1051 * to indicate this.
1052 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001053 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1054 * that no URI is supplied in the intent, as there are no constraints on
1055 * where the returned data originally comes from. You may also include the
1056 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001057 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001058 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1059 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001060 * <p>
1061 * Output: The URI of the item that was picked. This must be a content:
1062 * URI so that any receiver can access it.
1063 */
1064 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1065 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1066 /**
1067 * Activity Action: Dial a number as specified by the data. This shows a
1068 * UI with the number being dialed, allowing the user to explicitly
1069 * initiate the call.
1070 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1071 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1072 * number.
1073 * <p>Output: nothing.
1074 */
1075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1076 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1077 /**
1078 * Activity Action: Perform a call to someone specified by the data.
1079 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1080 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1081 * number.
1082 * <p>Output: nothing.
1083 *
1084 * <p>Note: there will be restrictions on which applications can initiate a
1085 * call; most applications should use the {@link #ACTION_DIAL}.
1086 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1087 * numbers. Applications can <strong>dial</strong> emergency numbers using
1088 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001089 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001090 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001091 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001092 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001093 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001094 */
1095 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1096 public static final String ACTION_CALL = "android.intent.action.CALL";
1097 /**
1098 * Activity Action: Perform a call to an emergency number specified by the
1099 * data.
1100 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1101 * tel: URI of an explicit phone number.
1102 * <p>Output: nothing.
1103 * @hide
1104 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001105 @SystemApi
1106 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001107 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1108 /**
1109 * Activity action: Perform a call to any number (emergency or not)
1110 * specified by the data.
1111 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1112 * tel: URI of an explicit phone number.
1113 * <p>Output: nothing.
1114 * @hide
1115 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001116 @SystemApi
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001118 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001119
Santos Cordon15a13782015-03-31 18:32:31 -07001120 /**
fionaxuadfe7002017-02-17 17:20:46 -08001121 * Activity Action: Main entry point for carrier setup apps.
1122 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1123 * carrier service and typically require
1124 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1125 * fulfill their duties.
1126 */
1127 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1128 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1129 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001130 * Activity Action: Send a message to someone specified by the data.
1131 * <p>Input: {@link #getData} is URI describing the target.
1132 * <p>Output: nothing.
1133 */
1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1135 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1136 /**
1137 * Activity Action: Deliver some data to someone else. Who the data is
1138 * being delivered to is not specified; it is up to the receiver of this
1139 * action to ask the user where the data should be sent.
1140 * <p>
1141 * When launching a SEND intent, you should usually wrap it in a chooser
1142 * (through {@link #createChooser}), which will give the proper interface
1143 * for the user to pick how to send your data and allow you to specify
1144 * a prompt indicating what they are doing.
1145 * <p>
1146 * Input: {@link #getType} is the MIME type of the data being sent.
1147 * get*Extra can have either a {@link #EXTRA_TEXT}
1148 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1149 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1150 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1151 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001152 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1153 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1154 * your text with HTML formatting.
1155 * <p>
1156 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1157 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1158 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1159 * content: URIs and other advanced features of {@link ClipData}. If
1160 * using this approach, you still must supply the same data through the
1161 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1162 * for compatibility with old applications. If you don't set a ClipData,
1163 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001164 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001165 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1166 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1167 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1168 * be openable only as asset typed files using
1169 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1170 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001171 * Optional standard extras, which may be interpreted by some recipients as
1172 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1173 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1174 * <p>
1175 * Output: nothing.
1176 */
1177 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1178 public static final String ACTION_SEND = "android.intent.action.SEND";
1179 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001180 * Activity Action: Deliver multiple data to someone else.
1181 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001182 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001183 * <p>
1184 * Input: {@link #getType} is the MIME type of the data being sent.
1185 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001186 * #EXTRA_STREAM} field, containing the data to be sent. If using
1187 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1188 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001189 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001190 * Multiple types are supported, and receivers should handle mixed types
1191 * whenever possible. The right way for the receiver to check them is to
1192 * use the content resolver on each URI. The intent sender should try to
1193 * put the most concrete mime type in the intent type, but it can fall
1194 * back to {@literal <type>/*} or {@literal *}/* as needed.
1195 * <p>
1196 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1197 * be image/jpg, but if you are sending image/jpg and image/png, then the
1198 * intent's type should be image/*.
1199 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001200 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1201 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1202 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1203 * content: URIs and other advanced features of {@link ClipData}. If
1204 * using this approach, you still must supply the same data through the
1205 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1206 * for compatibility with old applications. If you don't set a ClipData,
1207 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1208 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001209 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1210 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1211 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1212 * be openable only as asset typed files using
1213 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1214 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001215 * Optional standard extras, which may be interpreted by some recipients as
1216 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1217 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1218 * <p>
1219 * Output: nothing.
1220 */
1221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1222 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1223 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001224 * Activity Action: Handle an incoming phone call.
1225 * <p>Input: nothing.
1226 * <p>Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1230 /**
1231 * Activity Action: Insert an empty item into the given container.
1232 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1233 * in which to place the data.
1234 * <p>Output: URI of the new data that was created.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1238 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001239 * Activity Action: Create a new item in the given container, initializing it
1240 * from the current contents of the clipboard.
1241 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1242 * in which to place the data.
1243 * <p>Output: URI of the new data that was created.
1244 */
1245 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1246 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1247 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001248 * Activity Action: Delete the given data from its container.
1249 * <p>Input: {@link #getData} is URI of data to be deleted.
1250 * <p>Output: nothing.
1251 */
1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1253 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1254 /**
1255 * Activity Action: Run the data, whatever that means.
1256 * <p>Input: ? (Note: this is currently specific to the test harness.)
1257 * <p>Output: nothing.
1258 */
1259 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1260 public static final String ACTION_RUN = "android.intent.action.RUN";
1261 /**
1262 * Activity Action: Perform a data synchronization.
1263 * <p>Input: ?
1264 * <p>Output: ?
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1268 /**
1269 * Activity Action: Pick an activity given an intent, returning the class
1270 * selected.
1271 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1272 * used with {@link PackageManager#queryIntentActivities} to determine the
1273 * set of activities from which to pick.
1274 * <p>Output: Class name of the activity that was selected.
1275 */
1276 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1277 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1278 /**
1279 * Activity Action: Perform a search.
1280 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1281 * is the text to search for. If empty, simply
1282 * enter your search results Activity with the search UI activated.
1283 * <p>Output: nothing.
1284 */
1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1286 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1287 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001288 * Activity Action: Start the platform-defined tutorial
1289 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1290 * is the text to search for. If empty, simply
1291 * enter your search results Activity with the search UI activated.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1296 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001297 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001298 * <p>
1299 * Input: {@link android.app.SearchManager#QUERY
1300 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1301 * a url starts with http or https, the site will be opened. If it is plain
1302 * text, Google search will be applied.
1303 * <p>
1304 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001308
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001309 /**
Jim Miller07994402012-05-02 14:22:27 -07001310 * Activity Action: Perform assist action.
1311 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001312 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1313 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001314 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1315 * information.
Jim Miller07994402012-05-02 14:22:27 -07001316 * Output: nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001320
1321 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001322 * Activity Action: Perform voice assist action.
1323 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001324 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1325 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001326 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001327 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001328 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001329 */
Amith Yamasani16452032017-03-03 10:15:57 -08001330 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1333
1334 /**
Adam Skory7140a252013-09-11 12:04:58 +01001335 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1336 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001337 */
1338 public static final String EXTRA_ASSIST_PACKAGE
1339 = "android.intent.extra.ASSIST_PACKAGE";
1340
1341 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001342 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1343 * application package at the time the assist was invoked.
1344 */
1345 public static final String EXTRA_ASSIST_UID
1346 = "android.intent.extra.ASSIST_UID";
1347
1348 /**
Adam Skory7140a252013-09-11 12:04:58 +01001349 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1350 * information supplied by the current foreground app at the time of the assist request.
1351 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001352 */
1353 public static final String EXTRA_ASSIST_CONTEXT
1354 = "android.intent.extra.ASSIST_CONTEXT";
1355
Jim Miller07994402012-05-02 14:22:27 -07001356 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001357 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1358 * keyboard as the primary input device for assistance.
1359 */
1360 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1361 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1362
1363 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001364 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1365 * that was used to invoke the assist.
1366 */
1367 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1368 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1369
1370 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001371 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001372 * <p>Input: Nothing.
1373 * <p>Output: nothing.
1374 */
1375 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1376 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1377 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001378 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001379 * <p>Input: Nothing.
1380 * <p>Output: Nothing.
1381 */
1382 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1383 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1384
1385 /**
1386 * Activity Action: Show activity for reporting a bug.
1387 * <p>Input: Nothing.
1388 * <p>Output: Nothing.
1389 */
1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1392
1393 /**
1394 * Activity Action: Main entry point for factory tests. Only used when
1395 * the device is booting in factory test node. The implementing package
1396 * must be installed in the system image.
1397 * <p>Input: nothing
1398 * <p>Output: nothing
1399 */
1400 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1401
1402 /**
1403 * Activity Action: The user pressed the "call" button to go to the dialer
1404 * or other appropriate UI for placing a call.
1405 * <p>Input: Nothing.
1406 * <p>Output: Nothing.
1407 */
1408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1409 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1410
1411 /**
1412 * Activity Action: Start Voice Command.
1413 * <p>Input: Nothing.
1414 * <p>Output: Nothing.
1415 */
1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1417 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001418
1419 /**
1420 * Activity Action: Start action associated with long pressing on the
1421 * search key.
1422 * <p>Input: Nothing.
1423 * <p>Output: Nothing.
1424 */
1425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1426 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001427
Jacek Surazski86b6c532009-05-13 14:38:28 +02001428 /**
1429 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1430 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001431 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001432 * <p>Input: No data is specified. The bug report is passed in using
1433 * an {@link #EXTRA_BUG_REPORT} field.
1434 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001435 *
1436 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001437 */
1438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1439 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001440
1441 /**
1442 * Activity Action: Show power usage information to the user.
1443 * <p>Input: Nothing.
1444 * <p>Output: Nothing.
1445 */
1446 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1447 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001448
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001449 /**
Russell Brenner880994d2017-02-24 11:11:47 -08001450 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1451 * to run.
1452 * <p>Input: Nothing.
1453 * <p>Output: Nothing.
1454 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1455 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1456 * @hide
1457 */
1458 @Deprecated
1459 @SystemApi
1460 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1461 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1462
1463 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001464 * Activity Action: Setup wizard to launch after a platform update. This
1465 * activity should have a string meta-data field associated with it,
1466 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1467 * the platform for setup. The activity will be launched only if
1468 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1469 * same value.
1470 * <p>Input: Nothing.
1471 * <p>Output: Nothing.
1472 * @hide
1473 */
Russell Brenner880994d2017-02-24 11:11:47 -08001474 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001475 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1476 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001477
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001478 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001479 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1480 * <p>Input: Nothing.
1481 * <p>Output: Nothing.
1482 * @hide
1483 */
1484 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1485 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001486 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001487
1488 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001489 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1490 * <p>Input: Nothing.
1491 * <p>Output: Nothing.
1492 * @hide
1493 */
1494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1495 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001496 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001497
1498 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001499 * Activity Action: Show settings for managing network data usage of a
1500 * specific application. Applications should define an activity that offers
1501 * options to control data usage.
1502 */
1503 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1504 public static final String ACTION_MANAGE_NETWORK_USAGE =
1505 "android.intent.action.MANAGE_NETWORK_USAGE";
1506
1507 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001508 * Activity Action: Launch application installer.
1509 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001510 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001511 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1512 * you can also use "package:<package-name>" to install an application for the
1513 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001514 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1515 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1516 * <p>
1517 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1518 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001519 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001520 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001521 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1522 * in order to launch the application installer.
1523 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001524 *
1525 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1526 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1527 * @see #EXTRA_RETURN_RESULT
1528 */
1529 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1530 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1531
1532 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001533 * @hide
1534 * @deprecated Do not use. This will go away.
1535 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1536 */
1537 @SystemApi
1538 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1539 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1540 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1541 /**
1542 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001543 * <p class="note">
1544 * This is a protected intent that can only be sent by the system.
1545 * </p>
1546 *
1547 * @hide
1548 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001549 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001551 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1552 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001553
1554 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001555 * @hide
1556 * @deprecated Do not use. This will go away.
1557 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1558 */
1559 @SystemApi
1560 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1561 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1562 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1563 /**
1564 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001565 * <p>
1566 * The system will have a persistent connection to this service.
1567 * This is a protected intent that can only be sent by the system.
1568 * </p>
1569 *
1570 * @hide
1571 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1575 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576
1577 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 * @hide
1579 * @deprecated Do not use. This will go away.
1580 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1581 */
1582 @SystemApi
1583 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1584 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1585 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1586 /**
1587 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001588 *
1589 * <p class="note">
1590 * This is a protected intent that can only be sent by the system.
1591 * </p>
1592 *
1593 * @hide
1594 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001595 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001596 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1598 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001599
1600 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001601 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1602 * package. Specifies the installer package name; this package will receive the
1603 * {@link #ACTION_APP_ERROR} intent.
1604 */
1605 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1606 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1607
1608 /**
1609 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1610 * package. Specifies that the application being installed should not be
1611 * treated as coming from an unknown source, but as coming from the app
1612 * invoking the Intent. For this to work you must start the installer with
1613 * startActivityForResult().
1614 */
1615 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1616 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1617
1618 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001619 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1620 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001621 * data field originated from.
1622 */
rich cannings706e8ba2012-08-20 13:20:14 -07001623 public static final String EXTRA_ORIGINATING_URI
1624 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001625
1626 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001627 * This extra can be used with any Intent used to launch an activity, supplying information
1628 * about who is launching that activity. This field contains a {@link android.net.Uri}
1629 * object, typically an http: or https: URI of the web site that the referral came from;
1630 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1631 * a native application that it came from.
1632 *
1633 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1634 * instead of directly retrieving the extra. It is also valid for applications to
1635 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1636 * a string, not a Uri; the field here, if supplied, will always take precedence,
1637 * however.</p>
1638 *
1639 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001640 */
1641 public static final String EXTRA_REFERRER
1642 = "android.intent.extra.REFERRER";
1643
1644 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001645 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1646 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1647 * not be created, in particular when Intent extras are supplied through the
1648 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1649 * schemes.
1650 *
1651 * @see #EXTRA_REFERRER
1652 */
1653 public static final String EXTRA_REFERRER_NAME
1654 = "android.intent.extra.REFERRER_NAME";
1655
1656 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001657 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001658 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001659 * Currently only a system app that hosts the provider authority "downloads" or holds the
1660 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001661 * @hide
1662 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001663 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001664 public static final String EXTRA_ORIGINATING_UID
1665 = "android.intent.extra.ORIGINATING_UID";
1666
1667 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001668 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1669 * package. Tells the installer UI to skip the confirmation with the user
1670 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001671 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1672 * will no longer show an interstitial message about updating existing
1673 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001674 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001675 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001676 public static final String EXTRA_ALLOW_REPLACE
1677 = "android.intent.extra.ALLOW_REPLACE";
1678
1679 /**
1680 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1681 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1682 * return to the application the result code of the install/uninstall. The returned result
1683 * code will be {@link android.app.Activity#RESULT_OK} on success or
1684 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1685 */
1686 public static final String EXTRA_RETURN_RESULT
1687 = "android.intent.extra.RETURN_RESULT";
1688
1689 /**
1690 * Package manager install result code. @hide because result codes are not
1691 * yet ready to be exposed.
1692 */
1693 public static final String EXTRA_INSTALL_RESULT
1694 = "android.intent.extra.INSTALL_RESULT";
1695
1696 /**
1697 * Activity Action: Launch application uninstaller.
1698 * <p>
1699 * Input: The data must be a package: URI whose scheme specific part is
1700 * the package name of the current installed package to be uninstalled.
1701 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1702 * <p>
1703 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1704 * succeeded.
1705 */
1706 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1707 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1708
1709 /**
msnider3c191b82017-01-23 14:23:16 -08001710 * Activity Action: Launch application uninstaller.
1711 * <p>
1712 * Input: The data must be a package: URI whose scheme specific part is
1713 * the package name of the current installed package to be uninstalled.
1714 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1715 * <p>
1716 * Output: Nothing.
1717 * </p>
1718 */
1719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1720 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1721
1722 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001723 * Specify whether the package should be uninstalled for all users.
1724 * @hide because these should not be part of normal application flow.
1725 */
1726 public static final String EXTRA_UNINSTALL_ALL_USERS
1727 = "android.intent.extra.UNINSTALL_ALL_USERS";
1728
1729 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001730 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1731 * describing the last run version of the platform that was setup.
1732 * @hide
1733 */
1734 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1735
Svet Ganov3695b8a2015-03-24 16:30:25 -07001736 /**
1737 * Activity action: Launch UI to manage the permissions of an app.
1738 * <p>
1739 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1740 * will be managed by the launched UI.
1741 * </p>
1742 * <p>
1743 * Output: Nothing.
1744 * </p>
1745 *
1746 * @see #EXTRA_PACKAGE_NAME
1747 *
1748 * @hide
1749 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001750 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001751 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1752 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1753 "android.intent.action.MANAGE_APP_PERMISSIONS";
1754
1755 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001756 * Activity action: Launch UI to manage permissions.
1757 * <p>
1758 * Input: Nothing.
1759 * </p>
1760 * <p>
1761 * Output: Nothing.
1762 * </p>
1763 *
1764 * @hide
1765 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001766 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001767 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1768 public static final String ACTION_MANAGE_PERMISSIONS =
1769 "android.intent.action.MANAGE_PERMISSIONS";
1770
1771 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001772 * Activity action: Launch UI to review permissions for an app.
1773 * The system uses this intent if permission review for apps not
1774 * supporting the new runtime permissions model is enabled. In
1775 * this mode a permission review is required before any of the
1776 * app components can run.
1777 * <p>
1778 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1779 * permissions will be reviewed (mandatory).
1780 * </p>
1781 * <p>
1782 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1783 * be fired after the permission review (optional).
1784 * </p>
1785 * <p>
1786 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1787 * be invoked after the permission review (optional).
1788 * </p>
1789 * <p>
1790 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1791 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1792 * </p>
1793 * <p>
1794 * Output: Nothing.
1795 * </p>
1796 *
1797 * @see #EXTRA_PACKAGE_NAME
1798 * @see #EXTRA_INTENT
1799 * @see #EXTRA_REMOTE_CALLBACK
1800 * @see #EXTRA_RESULT_NEEDED
1801 *
1802 * @hide
1803 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001804 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1806 public static final String ACTION_REVIEW_PERMISSIONS =
1807 "android.intent.action.REVIEW_PERMISSIONS";
1808
1809 /**
1810 * Intent extra: A callback for reporting remote result as a bundle.
1811 * <p>
1812 * Type: IRemoteCallback
1813 * </p>
1814 *
1815 * @hide
1816 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001817 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001818 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1819
1820 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001821 * Intent extra: An app package name.
1822 * <p>
1823 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001824 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001825 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001826 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001827 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1828
1829 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001830 * Intent extra: An app split name.
1831 * <p>
1832 * Type: String
1833 * </p>
1834 * @hide
1835 */
1836 @SystemApi
1837 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1838
1839 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001840 * Intent extra: An extra for specifying whether a result is needed.
1841 * <p>
1842 * Type: boolean
1843 * </p>
1844 *
1845 * @hide
1846 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001847 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001848 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1849
1850 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001851 * Activity action: Launch UI to manage which apps have a given permission.
1852 * <p>
1853 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1854 * to which will be managed by the launched UI.
1855 * </p>
1856 * <p>
1857 * Output: Nothing.
1858 * </p>
1859 *
1860 * @see #EXTRA_PERMISSION_NAME
1861 *
1862 * @hide
1863 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001864 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001865 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1866 public static final String ACTION_MANAGE_PERMISSION_APPS =
1867 "android.intent.action.MANAGE_PERMISSION_APPS";
1868
1869 /**
1870 * Intent extra: The name of a permission.
1871 * <p>
1872 * Type: String
1873 * </p>
1874 *
1875 * @hide
1876 */
1877 @SystemApi
1878 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1879
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001880 // ---------------------------------------------------------------------
1881 // ---------------------------------------------------------------------
1882 // Standard intent broadcast actions (see action variable).
1883
1884 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001885 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1886 * <p>
1887 * For historical reasons, the name of this broadcast action refers to the power
1888 * state of the screen but it is actually sent in response to changes in the
1889 * overall interactive state of the device.
1890 * </p><p>
1891 * This broadcast is sent when the device becomes non-interactive which may have
1892 * nothing to do with the screen turning off. To determine the
1893 * actual state of the screen, use {@link android.view.Display#getState}.
1894 * </p><p>
1895 * See {@link android.os.PowerManager#isInteractive} for details.
1896 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001897 * You <em>cannot</em> receive this through components declared in
1898 * manifests, only by explicitly registering for it with
1899 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1900 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001901 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001902 * <p class="note">This is a protected intent that can only be sent
1903 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001904 */
1905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1906 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001907
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001908 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001909 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1910 * <p>
1911 * For historical reasons, the name of this broadcast action refers to the power
1912 * state of the screen but it is actually sent in response to changes in the
1913 * overall interactive state of the device.
1914 * </p><p>
1915 * This broadcast is sent when the device becomes interactive which may have
1916 * nothing to do with the screen turning on. To determine the
1917 * actual state of the screen, use {@link android.view.Display#getState}.
1918 * </p><p>
1919 * See {@link android.os.PowerManager#isInteractive} for details.
1920 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001921 * You <em>cannot</em> receive this through components declared in
1922 * manifests, only by explicitly registering for it with
1923 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1924 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001925 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001926 * <p class="note">This is a protected intent that can only be sent
1927 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001928 */
1929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1930 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001931
1932 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001933 * Broadcast Action: Sent after the system stops dreaming.
1934 *
1935 * <p class="note">This is a protected intent that can only be sent by the system.
1936 * It is only sent to registered receivers.</p>
1937 */
1938 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1939 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1940
1941 /**
1942 * Broadcast Action: Sent after the system starts dreaming.
1943 *
1944 * <p class="note">This is a protected intent that can only be sent by the system.
1945 * It is only sent to registered receivers.</p>
1946 */
1947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1948 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1949
1950 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001951 * 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 -07001952 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001953 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001954 * <p class="note">This is a protected intent that can only be sent
1955 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001956 */
1957 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001958 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001959
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001960 /**
1961 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001962 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001963 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1965 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001966 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001967 * <p class="note">This is a protected intent that can only be sent
1968 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001969 */
1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1971 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1972 /**
1973 * Broadcast Action: The time was set.
1974 */
1975 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1976 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1977 /**
1978 * Broadcast Action: The date has changed.
1979 */
1980 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1981 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1982 /**
1983 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1984 * <ul>
1985 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1986 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001987 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001988 * <p class="note">This is a protected intent that can only be sent
1989 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001990 */
1991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1993 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001994 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1995 * DNS entries should be tossed.
1996 * @hide
1997 */
1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1999 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2000 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002001 * Alarm Changed Action: This is broadcast when the AlarmClock
2002 * application's alarm is set or unset. It is used by the
2003 * AlarmClock application and the StatusBar service.
2004 * @hide
2005 */
2006 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2007 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002008
2009 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002010 * Broadcast Action: This is broadcast once, after the user has finished
2011 * booting, but while still in the "locked" state. It can be used to perform
2012 * application-specific initialization, such as installing alarms. You must
2013 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2014 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002015 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002016 * This broadcast is sent immediately at boot by all devices (regardless of
2017 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2018 * higher. Upon receipt of this broadcast, the user is still locked and only
2019 * device-protected storage can be accessed safely. If you want to access
2020 * credential-protected storage, you need to wait for the user to be
2021 * unlocked (typically by entering their lock pattern or PIN for the first
2022 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2023 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2024 * <p>
2025 * To receive this broadcast, your receiver component must be marked as
2026 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002027 * <p class="note">
2028 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002029 *
2030 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002031 */
2032 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2033 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2034
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002036 * Broadcast Action: This is broadcast once, after the user has finished
2037 * booting. It can be used to perform application-specific initialization,
2038 * such as installing alarms. You must hold the
2039 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2040 * order to receive this broadcast.
2041 * <p>
2042 * This broadcast is sent at boot by all devices (both with and without
2043 * direct boot support). Upon receipt of this broadcast, the user is
2044 * unlocked and both device-protected and credential-protected storage can
2045 * accessed safely.
2046 * <p>
2047 * If you need to run while the user is still locked (before they've entered
2048 * their lock pattern or PIN for the first time), you can listen for the
2049 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2050 * <p class="note">
2051 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002054 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002055 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002056
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 /**
2058 * Broadcast Action: This is broadcast when a user action should request a
2059 * temporary system dialog to dismiss. Some examples of temporary system
2060 * dialogs are the notification window-shade and the recent tasks dialog.
2061 */
2062 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2063 /**
2064 * Broadcast Action: Trigger the download and eventual installation
2065 * of a package.
2066 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002067 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002068 * <p class="note">This is a protected intent that can only be sent
2069 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002070 *
2071 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002073 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2075 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2076 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002077 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002078 * device. The data contains the name of the package. Note that the
2079 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002080 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002081 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002082 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2083 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002084 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2085 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002086 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002087 * <p class="note">This is a protected intent that can only be sent
2088 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002089 */
2090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2091 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2092 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002093 * Broadcast Action: A new version of an application package has been
2094 * installed, replacing an existing version that was previously installed.
2095 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002096 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002097 * <ul>
2098 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2099 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002100 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002101 * <p class="note">This is a protected intent that can only be sent
2102 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002103 */
2104 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2105 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2106 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002107 * Broadcast Action: A new version of your application has been installed
2108 * over an existing one. This is only sent to the application that was
2109 * replaced. It does not contain any additional data; to receive it, just
2110 * use an intent filter for this action.
2111 *
2112 * <p class="note">This is a protected intent that can only be sent
2113 * by the system.
2114 */
2115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2116 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2117 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002118 * Broadcast Action: An existing application package has been removed from
2119 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002120 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002121 * <ul>
2122 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2123 * to the package.
2124 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2125 * application -- data and code -- is being removed.
2126 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2127 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2128 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002129 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002130 * <p class="note">This is a protected intent that can only be sent
2131 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002132 */
2133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2134 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2135 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002136 * Broadcast Action: An existing application package has been completely
2137 * removed from the device. The data contains the name of the package.
2138 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2139 * {@link #EXTRA_DATA_REMOVED} is true and
2140 * {@link #EXTRA_REPLACING} is false of that broadcast.
2141 *
2142 * <ul>
2143 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2144 * to the package.
2145 * </ul>
2146 *
2147 * <p class="note">This is a protected intent that can only be sent
2148 * by the system.
2149 */
2150 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2151 public static final String ACTION_PACKAGE_FULLY_REMOVED
2152 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2153 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002154 * Broadcast Action: An existing application package has been changed (for
2155 * example, a component has been enabled or disabled). The data contains
2156 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002157 * <ul>
2158 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002159 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002160 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002161 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2162 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002163 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002164 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002165 * <p class="note">This is a protected intent that can only be sent
2166 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002167 */
2168 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2169 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2170 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002171 * @hide
2172 * Broadcast Action: Ask system services if there is any reason to
2173 * restart the given package. The data contains the name of the
2174 * package.
2175 * <ul>
2176 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2177 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2178 * </ul>
2179 *
2180 * <p class="note">This is a protected intent that can only be sent
2181 * by the system.
2182 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002183 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002184 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2185 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2186 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002187 * Broadcast Action: The user has restarted a package, and all of its
2188 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002189 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002190 * be removed. Note that the restarted package does <em>not</em>
2191 * receive this broadcast.
2192 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002193 * <ul>
2194 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2195 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002196 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002197 * <p class="note">This is a protected intent that can only be sent
2198 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002199 */
2200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2202 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002203 * Broadcast Action: The user has cleared the data of a package. This should
2204 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002205 * its persistent data is erased and this broadcast sent.
2206 * Note that the cleared package does <em>not</em>
2207 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002208 * <ul>
2209 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2210 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002211 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002212 * <p class="note">This is a protected intent that can only be sent
2213 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2216 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2217 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002218 * Broadcast Action: Packages have been suspended.
2219 * <p>Includes the following extras:
2220 * <ul>
2221 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2222 * </ul>
2223 *
2224 * <p class="note">This is a protected intent that can only be sent
2225 * by the system. It is only sent to registered receivers.
2226 */
2227 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2228 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2229 /**
2230 * Broadcast Action: Packages have been unsuspended.
2231 * <p>Includes the following extras:
2232 * <ul>
2233 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2234 * </ul>
2235 *
2236 * <p class="note">This is a protected intent that can only be sent
2237 * by the system. It is only sent to registered receivers.
2238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2241 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002242 * Broadcast Action: A user ID has been removed from the system. The user
2243 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002244 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002245 * <p class="note">This is a protected intent that can only be sent
2246 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002247 */
2248 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2249 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002250
2251 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002252 * Broadcast Action: Sent to the installer package of an application when
2253 * that application is first launched (that is the first time it is moved
2254 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002255 *
2256 * <p class="note">This is a protected intent that can only be sent
2257 * by the system.
2258 */
2259 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2260 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2261
2262 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002263 * Broadcast Action: Sent to the system package verifier when a package
2264 * needs to be verified. The data contains the package URI.
2265 * <p class="note">
2266 * This is a protected intent that can only be sent by the system.
2267 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002268 */
2269 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2270 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2271
2272 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002273 * Broadcast Action: Sent to the system package verifier when a package is
2274 * verified. The data contains the package URI.
2275 * <p class="note">
2276 * This is a protected intent that can only be sent by the system.
2277 */
2278 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2279 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2280
2281 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002282 * Broadcast Action: Sent to the system intent filter verifier when an
2283 * intent filter needs to be verified. The data contains the filter data
2284 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002285 * <p class="note">
2286 * This is a protected intent that can only be sent by the system.
2287 * </p>
2288 *
2289 * @hide
2290 */
2291 @SystemApi
2292 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2293 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2294
2295 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002296 * Broadcast Action: Resources for a set of packages (which were
2297 * previously unavailable) are currently
2298 * available since the media on which they exist is available.
2299 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2300 * list of packages whose availability changed.
2301 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2302 * list of uids of packages whose availability changed.
2303 * Note that the
2304 * packages in this list do <em>not</em> receive this broadcast.
2305 * The specified set of packages are now available on the system.
2306 * <p>Includes the following extras:
2307 * <ul>
2308 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2309 * whose resources(were previously unavailable) are currently available.
2310 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2311 * packages whose resources(were previously unavailable)
2312 * are currently available.
2313 * </ul>
2314 *
2315 * <p class="note">This is a protected intent that can only be sent
2316 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002319 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2320 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002321
2322 /**
2323 * Broadcast Action: Resources for a set of packages are currently
2324 * unavailable since the media on which they exist is unavailable.
2325 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2326 * list of packages whose availability changed.
2327 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2328 * list of uids of packages whose availability changed.
2329 * The specified set of packages can no longer be
2330 * launched and are practically unavailable on the system.
2331 * <p>Inclues the following extras:
2332 * <ul>
2333 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2334 * whose resources are no longer available.
2335 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2336 * whose resources are no longer available.
2337 * </ul>
2338 *
2339 * <p class="note">This is a protected intent that can only be sent
2340 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002341 */
2342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002343 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002344 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002345
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002346 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002347 * Broadcast Action: preferred activities have changed *explicitly*.
2348 *
2349 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2350 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2351 * be sent.
2352 *
2353 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2354 *
2355 * @hide
2356 */
2357 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2358 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2359 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2360
2361
2362 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002363 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002364 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002365 * This should <em>only</em> be used to determine when the wallpaper
2366 * has changed to show the new wallpaper to the user. You should certainly
2367 * never, in response to this, change the wallpaper or other attributes of
2368 * it such as the suggested size. That would be crazy, right? You'd cause
2369 * all kinds of loops, especially if other apps are doing similar things,
2370 * right? Of course. So please don't do this.
2371 *
2372 * @deprecated Modern applications should use
2373 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2374 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2375 * shown behind their UI, rather than watching for this broadcast and
2376 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002377 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002378 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002379 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2380 /**
2381 * Broadcast Action: The current device {@link android.content.res.Configuration}
2382 * (orientation, locale, etc) has changed. When such a change happens, the
2383 * UIs (view hierarchy) will need to be rebuilt based on this new
2384 * information; for the most part, applications don't need to worry about
2385 * this, because the system will take care of stopping and restarting the
2386 * application to make sure it sees the new changes. Some system code that
2387 * can not be restarted will need to watch for this action and handle it
2388 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002389 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002390 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002391 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002392 * in manifests, only by explicitly registering for it with
2393 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2394 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002395 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002396 * <p class="note">This is a protected intent that can only be sent
2397 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002398 *
2399 * @see android.content.res.Configuration
2400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2402 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2403 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002404 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002405 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002406 * <p class="note">This is a protected intent that can only be sent
2407 * by the system.
2408 */
2409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2410 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2411 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002412 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2413 * charging state, level, and other information about the battery.
2414 * See {@link android.os.BatteryManager} for documentation on the
2415 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002416 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002417 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002418 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002419 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002420 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002421 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2422 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2423 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2424 * broadcasts that are sent and can be received through manifest
2425 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002426 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002427 * <p class="note">This is a protected intent that can only be sent
2428 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002429 */
2430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2431 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2432 /**
2433 * Broadcast Action: Indicates low battery condition on the device.
2434 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002435 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002436 * <p class="note">This is a protected intent that can only be sent
2437 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002438 */
2439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2440 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2441 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002442 * Broadcast Action: Indicates the battery is now okay after being low.
2443 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2444 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002445 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002446 * <p class="note">This is a protected intent that can only be sent
2447 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2450 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2451 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002452 * Broadcast Action: External power has been connected to the device.
2453 * This is intended for applications that wish to register specifically to this notification.
2454 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2455 * stay active to receive this notification. This action can be used to implement actions
2456 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002457 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002458 * <p class="note">This is a protected intent that can only be sent
2459 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002460 */
2461 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002462 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002463 /**
2464 * Broadcast Action: External power has been removed from the device.
2465 * This is intended for applications that wish to register specifically to this notification.
2466 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2467 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002468 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002469 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002470 * <p class="note">This is a protected intent that can only be sent
2471 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002472 */
2473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002474 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002475 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002476 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002477 * Broadcast Action: Device is shutting down.
2478 * This is broadcast when the device is being shut down (completely turned
2479 * off, not sleeping). Once the broadcast is complete, the final shutdown
2480 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002481 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002482 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002483 * <p class="note">This is a protected intent that can only be sent
2484 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002485 * <p>May include the following extras:
2486 * <ul>
2487 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2488 * shutdown is only for userspace processes. If not set, assumed to be false.
2489 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002490 */
2491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002492 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002493 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002494 * Activity Action: Start this activity to request system shutdown.
2495 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002496 * to request confirmation from the user before shutting down. The optional boolean
2497 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2498 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002499 *
2500 * <p class="note">This is a protected intent that can only be sent
2501 * by the system.
2502 *
2503 * {@hide}
2504 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002505 public static final String ACTION_REQUEST_SHUTDOWN
2506 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002507 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002508 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002509 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002510 * <p class="note">
2511 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002512 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002513 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2514 * or above, this broadcast will no longer be delivered to any
2515 * {@link BroadcastReceiver} defined in your manifest. Instead,
2516 * apps are strongly encouraged to use the improved
2517 * {@link Context#getCacheDir()} behavior so the system can
2518 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002521 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002522 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2523 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002524 * Broadcast Action: Indicates low storage space condition on the device no
2525 * longer exists
2526 * <p class="note">
2527 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002528 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002529 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2530 * or above, this broadcast will no longer be delivered to any
2531 * {@link BroadcastReceiver} defined in your manifest. Instead,
2532 * apps are strongly encouraged to use the improved
2533 * {@link Context#getCacheDir()} behavior so the system can
2534 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002535 */
2536 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002537 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002538 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2539 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002540 * Broadcast Action: A sticky broadcast that indicates a storage space full
2541 * condition on the device. This is intended for activities that want to be
2542 * able to fill the data partition completely, leaving only enough free
2543 * space to prevent system-wide SQLite failures.
2544 * <p class="note">
2545 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002546 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002547 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2548 * or above, this broadcast will no longer be delivered to any
2549 * {@link BroadcastReceiver} defined in your manifest. Instead,
2550 * apps are strongly encouraged to use the improved
2551 * {@link Context#getCacheDir()} behavior so the system can
2552 * automatically free up storage when needed.
2553 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002554 */
2555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002556 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002557 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2558 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002559 * Broadcast Action: Indicates storage space full condition on the device no
2560 * longer exists.
2561 * <p class="note">
2562 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002563 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002564 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2565 * or above, this broadcast will no longer be delivered to any
2566 * {@link BroadcastReceiver} defined in your manifest. Instead,
2567 * apps are strongly encouraged to use the improved
2568 * {@link Context#getCacheDir()} behavior so the system can
2569 * automatically free up storage when needed.
2570 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002573 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002574 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2575 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002576 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2577 * and package management should be started.
2578 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2579 * notification.
2580 */
2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2582 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2583 /**
2584 * Broadcast Action: The device has entered USB Mass Storage mode.
2585 * This is used mainly for the USB Settings panel.
2586 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2587 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002588 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002590 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002591 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2592
2593 /**
2594 * Broadcast Action: The device has exited USB Mass Storage mode.
2595 * This is used mainly for the USB Settings panel.
2596 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2597 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002598 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002599 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002600 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002601 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2602
2603 /**
2604 * Broadcast Action: External media has been removed.
2605 * The path to the mount point for the removed media is contained in the Intent.mData field.
2606 */
2607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2608 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2609
2610 /**
2611 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002612 * 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 -07002613 */
2614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2615 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2616
2617 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002618 * Broadcast Action: External media is present, and being disk-checked
2619 * 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 -08002620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2623
2624 /**
2625 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2626 * 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 -08002627 */
2628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2629 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2630
2631 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002632 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002633 * 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 -07002634 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2635 * media was mounted read only.
2636 */
2637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2638 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2639
2640 /**
2641 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002642 * 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 -07002643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2646
2647 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002648 * Broadcast Action: External media is no longer being shared via USB mass storage.
2649 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2650 *
2651 * @hide
2652 */
2653 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2654
2655 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002656 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2657 * The path to the mount point for the removed media is contained in the Intent.mData field.
2658 */
2659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2660 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2661
2662 /**
2663 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002664 * 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 -07002665 */
2666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2667 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2668
2669 /**
2670 * Broadcast Action: User has expressed the desire to remove the external storage media.
2671 * Applications should close all files they have open within the mount point when they receive this intent.
2672 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2673 */
2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2676
2677 /**
2678 * Broadcast Action: The media scanner has started scanning a directory.
2679 * The path to the directory being scanned is contained in the Intent.mData field.
2680 */
2681 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2682 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2683
2684 /**
2685 * Broadcast Action: The media scanner has finished scanning a directory.
2686 * The path to the scanned directory is contained in the Intent.mData field.
2687 */
2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2689 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2690
2691 /**
2692 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2693 * The path to the file is contained in the Intent.mData field.
2694 */
2695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2696 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2697
2698 /**
2699 * Broadcast Action: The "Media Button" was pressed. Includes a single
2700 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2701 * caused the broadcast.
2702 */
2703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2704 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2705
2706 /**
2707 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2708 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2709 * caused the broadcast.
2710 */
2711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2712 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2713
2714 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2715 // location; they are not general-purpose actions.
2716
2717 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002718 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2721 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2722 "android.intent.action.GTALK_CONNECTED";
2723
2724 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002725 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002726 */
2727 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2728 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2729 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002730
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002731 /**
2732 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002733 */
2734 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2735 public static final String ACTION_INPUT_METHOD_CHANGED =
2736 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002737
2738 /**
2739 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2740 * more radios have been turned off or on. The intent will have the following extra value:</p>
2741 * <ul>
2742 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2743 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2744 * turned off</li>
2745 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002746 *
Peng Xua35b5532016-01-20 00:05:45 -08002747 * <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 -07002748 */
2749 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2750 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2751
2752 /**
2753 * Broadcast Action: Some content providers have parts of their namespace
2754 * where they publish new events or items that the user may be especially
2755 * interested in. For these things, they may broadcast this action when the
2756 * set of interesting items change.
2757 *
2758 * For example, GmailProvider sends this notification when the set of unread
2759 * mail in the inbox changes.
2760 *
2761 * <p>The data of the intent identifies which part of which provider
2762 * changed. When queried through the content resolver, the data URI will
2763 * return the data set in question.
2764 *
2765 * <p>The intent will have the following extra values:
2766 * <ul>
2767 * <li><em>count</em> - The number of items in the data set. This is the
2768 * same as the number of items in the cursor returned by querying the
2769 * data URI. </li>
2770 * </ul>
2771 *
2772 * This intent will be sent at boot (if the count is non-zero) and when the
2773 * data set changes. It is possible for the data set to change without the
2774 * count changing (for example, if a new unread message arrives in the same
2775 * sync operation in which a message is archived). The phone should still
2776 * ring/vibrate/etc as normal in this case.
2777 */
2778 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2779 public static final String ACTION_PROVIDER_CHANGED =
2780 "android.intent.action.PROVIDER_CHANGED";
2781
2782 /**
2783 * Broadcast Action: Wired Headset plugged in or unplugged.
2784 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002785 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2786 * and documentation.
2787 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002788 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002789 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002790 */
2791 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002792 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002793
2794 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002795 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2796 * <ul>
2797 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2798 * </ul>
2799 *
2800 * <p class="note">This is a protected intent that can only be sent
2801 * by the system.
2802 *
2803 * @hide
2804 */
2805 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2806 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2807 = "android.intent.action.ADVANCED_SETTINGS";
2808
2809 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002810 * Broadcast Action: Sent after application restrictions are changed.
2811 *
2812 * <p class="note">This is a protected intent that can only be sent
2813 * by the system.</p>
2814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2817 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2818
2819 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002820 * Broadcast Action: An outgoing call is about to be placed.
2821 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002822 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002823 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002824 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002825 * the phone number originally intended to be dialed.</li>
2826 * </ul>
2827 * <p>Once the broadcast is finished, the resultData is used as the actual
2828 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002829 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002830 * outgoing call in turn: for example, a parental control application
2831 * might verify that the user is authorized to place the call at that
2832 * time, then a number-rewriting application might add an area code if
2833 * one was not specified.</p>
2834 * <p>For consistency, any receiver whose purpose is to prohibit phone
2835 * calls should have a priority of 0, to ensure it will see the final
2836 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002837 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002838 * should have a positive priority.
2839 * Negative priorities are reserved for the system for this broadcast;
2840 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002841 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2842 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002843 * <p>Emergency calls cannot be intercepted using this mechanism, and
2844 * other calls cannot be modified to call emergency numbers using this
2845 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002846 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2847 * call to use their own service instead. Those apps should first prevent
2848 * the call from being placed by setting resultData to <code>null</code>
2849 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002850 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002851 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2852 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002853 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002854 * <p class="note">This is a protected intent that can only be sent
2855 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_NEW_OUTGOING_CALL =
2859 "android.intent.action.NEW_OUTGOING_CALL";
2860
2861 /**
2862 * Broadcast Action: Have the device reboot. This is only for use by
2863 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002864 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002865 * <p class="note">This is a protected intent that can only be sent
2866 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002867 */
2868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2869 public static final String ACTION_REBOOT =
2870 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002871
Wei Huang97ecc9c2009-05-11 17:44:20 -07002872 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002873 * Broadcast Action: A sticky broadcast for changes in the physical
2874 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002875 *
2876 * <p>The intent will have the following extra values:
2877 * <ul>
2878 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002879 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002880 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002881 * <p>This is intended for monitoring the current physical dock state.
2882 * See {@link android.app.UiModeManager} for the normal API dealing with
2883 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002884 */
2885 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2886 public static final String ACTION_DOCK_EVENT =
2887 "android.intent.action.DOCK_EVENT";
2888
2889 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002890 * Broadcast Action: A broadcast when idle maintenance can be started.
2891 * This means that the user is not interacting with the device and is
2892 * not expected to do so soon. Typical use of the idle maintenance is
2893 * to perform somehow expensive tasks that can be postponed at a moment
2894 * when they will not degrade user experience.
2895 * <p>
2896 * <p class="note">In order to keep the device responsive in case of an
2897 * unexpected user interaction, implementations of a maintenance task
2898 * should be interruptible. In such a scenario a broadcast with action
2899 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2900 * should not do the maintenance work in
2901 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2902 * maintenance service by {@link Context#startService(Intent)}. Also
2903 * you should hold a wake lock while your maintenance service is running
2904 * to prevent the device going to sleep.
2905 * </p>
2906 * <p>
2907 * <p class="note">This is a protected intent that can only be sent by
2908 * the system.
2909 * </p>
2910 *
2911 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002912 *
2913 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002914 */
2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2916 public static final String ACTION_IDLE_MAINTENANCE_START =
2917 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2918
2919 /**
2920 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2921 * This means that the user was not interacting with the device as a result
2922 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2923 * was sent and now the user started interacting with the device. Typical
2924 * use of the idle maintenance is to perform somehow expensive tasks that
2925 * can be postponed at a moment when they will not degrade user experience.
2926 * <p>
2927 * <p class="note">In order to keep the device responsive in case of an
2928 * unexpected user interaction, implementations of a maintenance task
2929 * should be interruptible. Hence, on receiving a broadcast with this
2930 * action, the maintenance task should be interrupted as soon as possible.
2931 * In other words, you should not do the maintenance work in
2932 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2933 * maintenance service that was started on receiving of
2934 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2935 * lock you acquired when your maintenance service started.
2936 * </p>
2937 * <p class="note">This is a protected intent that can only be sent
2938 * by the system.
2939 *
2940 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002941 *
2942 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002943 */
2944 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2945 public static final String ACTION_IDLE_MAINTENANCE_END =
2946 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2947
2948 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002949 * Broadcast Action: a remote intent is to be broadcasted.
2950 *
2951 * A remote intent is used for remote RPC between devices. The remote intent
2952 * is serialized and sent from one device to another device. The receiving
2953 * device parses the remote intent and broadcasts it. Note that anyone can
2954 * broadcast a remote intent. However, if the intent receiver of the remote intent
2955 * does not trust intent broadcasts from arbitrary intent senders, it should require
2956 * the sender to hold certain permissions so only trusted sender's broadcast will be
2957 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002958 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002959 */
2960 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002961 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002962
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002963 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002964 * Broadcast Action: This is broadcast once when the user is booting after a
2965 * system update. It can be used to perform cleanup or upgrades after a
2966 * system update.
2967 * <p>
2968 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2969 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2970 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2971 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002972 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002973 * @hide
2974 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002975 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002976 public static final String ACTION_PRE_BOOT_COMPLETED =
2977 "android.intent.action.PRE_BOOT_COMPLETED";
2978
Amith Yamasani13593602012-03-22 16:16:17 -07002979 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002980 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002981 * on restricted users. The broadcast intent contains an extra
2982 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2983 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2984 * String[] depending on the restriction type.<p/>
2985 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002986 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2987 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2988 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002989 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2990 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002991 * @see RestrictionEntry
2992 */
2993 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2994 "android.intent.action.GET_RESTRICTION_ENTRIES";
2995
2996 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002997 * Sent the first time a user is starting, to allow system apps to
2998 * perform one time initialization. (This will not be seen by third
2999 * party applications because a newly initialized user does not have any
3000 * third party applications installed for it.) This is sent early in
3001 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003002 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3003 * broadcast, since it is part of a visible user interaction; be as quick
3004 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003005 */
3006 public static final String ACTION_USER_INITIALIZE =
3007 "android.intent.action.USER_INITIALIZE";
3008
3009 /**
3010 * Sent when a user switch is happening, causing the process's user to be
3011 * brought to the foreground. This is only sent to receivers registered
3012 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3013 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003014 * foreground. This is sent as a foreground
3015 * broadcast, since it is part of a visible user interaction; be as quick
3016 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003017 */
3018 public static final String ACTION_USER_FOREGROUND =
3019 "android.intent.action.USER_FOREGROUND";
3020
3021 /**
3022 * Sent when a user switch is happening, causing the process's user to be
3023 * sent to the background. This is only sent to receivers registered
3024 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3025 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003026 * background. This is sent as a foreground
3027 * broadcast, since it is part of a visible user interaction; be as quick
3028 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003029 */
3030 public static final String ACTION_USER_BACKGROUND =
3031 "android.intent.action.USER_BACKGROUND";
3032
3033 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003034 * Broadcast sent to the system when a user is added. Carries an extra
3035 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3036 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003037 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003038 * @hide
3039 */
3040 public static final String ACTION_USER_ADDED =
3041 "android.intent.action.USER_ADDED";
3042
3043 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003044 * Broadcast sent by the system when a user is started. Carries an extra
3045 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003046 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003047 * that has been started. This is sent as a foreground
3048 * broadcast, since it is part of a visible user interaction; be as quick
3049 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003050 * @hide
3051 */
3052 public static final String ACTION_USER_STARTED =
3053 "android.intent.action.USER_STARTED";
3054
3055 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003056 * Broadcast sent when a user is in the process of starting. Carries an extra
3057 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3058 * sent to registered receivers, not manifest receivers. It is sent to all
3059 * users (including the one that is being started). You must hold
3060 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3061 * this broadcast. This is sent as a background broadcast, since
3062 * its result is not part of the primary UX flow; to safely keep track of
3063 * started/stopped state of a user you can use this in conjunction with
3064 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3065 * other user state broadcasts since those are foreground broadcasts so can
3066 * execute in a different order.
3067 * @hide
3068 */
3069 public static final String ACTION_USER_STARTING =
3070 "android.intent.action.USER_STARTING";
3071
3072 /**
3073 * Broadcast sent when a user is going to be stopped. Carries an extra
3074 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3075 * sent to registered receivers, not manifest receivers. It is sent to all
3076 * users (including the one that is being stopped). You must hold
3077 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3078 * this broadcast. The user will not stop until all receivers have
3079 * handled the broadcast. This is sent as a background broadcast, since
3080 * its result is not part of the primary UX flow; to safely keep track of
3081 * started/stopped state of a user you can use this in conjunction with
3082 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3083 * other user state broadcasts since those are foreground broadcasts so can
3084 * execute in a different order.
3085 * @hide
3086 */
3087 public static final String ACTION_USER_STOPPING =
3088 "android.intent.action.USER_STOPPING";
3089
3090 /**
3091 * Broadcast sent to the system when a user is stopped. Carries an extra
3092 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3093 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3094 * specific package. This is only sent to registered receivers, not manifest
3095 * receivers. It is sent to all running users <em>except</em> the one that
3096 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003097 * @hide
3098 */
3099 public static final String ACTION_USER_STOPPED =
3100 "android.intent.action.USER_STOPPED";
3101
3102 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003103 * 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 -07003104 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003105 * one that has been removed. The user will not be completely removed until all receivers have
3106 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003107 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003108 * @hide
3109 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003110 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003111 public static final String ACTION_USER_REMOVED =
3112 "android.intent.action.USER_REMOVED";
3113
3114 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003115 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003116 * the userHandle of the user to become the current one. This is only sent to
3117 * registered receivers, not manifest receivers. It is sent to all running users.
3118 * You must hold
3119 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003120 * @hide
3121 */
3122 public static final String ACTION_USER_SWITCHED =
3123 "android.intent.action.USER_SWITCHED";
3124
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003125 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003126 * Broadcast Action: Sent when the credential-encrypted private storage has
3127 * become unlocked for the target user. This is only sent to registered
3128 * receivers, not manifest receivers.
3129 */
3130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3131 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3132
3133 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003134 * Broadcast sent to the system when a user's information changes. Carries an extra
3135 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003136 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003137 * @hide
3138 */
3139 public static final String ACTION_USER_INFO_CHANGED =
3140 "android.intent.action.USER_INFO_CHANGED";
3141
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003142 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003143 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3144 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003145 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3146 * that need to display merged content across both primary and managed profiles need to
3147 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003148 * not manifest receivers.
3149 */
3150 public static final String ACTION_MANAGED_PROFILE_ADDED =
3151 "android.intent.action.MANAGED_PROFILE_ADDED";
3152
3153 /**
3154 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003155 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3156 * Only applications (for example Launchers) that need to display merged content across both
3157 * primary and managed profiles need to worry about this broadcast. This is only sent to
3158 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003159 */
3160 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3161 "android.intent.action.MANAGED_PROFILE_REMOVED";
3162
3163 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003164 * Broadcast sent to the primary user when the credential-encrypted private storage for
3165 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3166 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3167 * Launchers) that need to display merged content across both primary and managed profiles
3168 * need to worry about this broadcast. This is only sent to registered receivers,
3169 * not manifest receivers.
3170 */
3171 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3172 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3173
3174 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003175 * Broadcast sent to the primary user when an associated managed profile has become available.
3176 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003177 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3178 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3179 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003180 */
Rubin Xue95057a2016-04-01 16:49:25 +01003181 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3182 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3183
3184 /**
3185 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3186 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3187 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3188 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3189 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3190 */
3191 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3192 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003193
3194 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003195 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3196 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3197 * the device was locked or unlocked.
3198 *
3199 * This is only sent to registered receivers.
3200 *
3201 * @hide
3202 */
3203 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3204 "android.intent.action.DEVICE_LOCKED_CHANGED";
3205
3206 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003207 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3208 */
3209 public static final String ACTION_QUICK_CLOCK =
3210 "android.intent.action.QUICK_CLOCK";
3211
Michael Wright0087a142013-02-05 16:29:39 -08003212 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003213 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003214 * @hide
3215 */
3216 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003217 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003218
Justin Kohd378ad72013-04-01 12:18:26 -07003219 /**
3220 * Broadcast Action: A global button was pressed. Includes a single
3221 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3222 * caused the broadcast.
3223 * @hide
3224 */
3225 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3226
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003227 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003228 * Broadcast Action: Sent when media resource is granted.
3229 * <p>
3230 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3231 * granted.
3232 * </p>
3233 * <p class="note">
3234 * This is a protected intent that can only be sent by the system.
3235 * </p>
3236 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003237 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003238 * </p>
3239 *
3240 * @hide
3241 */
3242 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3243 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3244
3245 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003246 * Broadcast Action: An overlay package has changed. The data contains the
3247 * name of the overlay package which has changed. This is broadcast on all
3248 * changes to the OverlayInfo returned by {@link
3249 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3250 * most common change is a state change that will change whether the
3251 * overlay is enabled or not.
3252 * @hide
3253 */
3254 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3255
3256 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003257 * Activity Action: Allow the user to select and return one or more existing
3258 * documents. When invoked, the system will display the various
3259 * {@link DocumentsProvider} instances installed on the device, letting the
3260 * user interactively navigate through them. These documents include local
3261 * media, such as photos and video, and documents provided by installed
3262 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003263 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003264 * Each document is represented as a {@code content://} URI backed by a
3265 * {@link DocumentsProvider}, which can be opened as a stream with
3266 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3267 * {@link android.provider.DocumentsContract.Document} metadata.
3268 * <p>
3269 * All selected documents are returned to the calling application with
3270 * persistable read and write permission grants. If you want to maintain
3271 * access to the documents across device reboots, you need to explicitly
3272 * take the persistable permissions using
3273 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3274 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003275 * Callers must indicate the acceptable document MIME types through
3276 * {@link #setType(String)}. For example, to select photos, use
3277 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3278 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3279 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003280 * <p>
3281 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003282 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3283 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003284 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003285 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3286 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003287 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003288 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003289 * Callers can set a document URI through
3290 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3291 * location of documents navigator. System will do its best to launch the
3292 * navigator in the specified document if it's a folder, or the folder that
3293 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003294 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003295 * Output: The URI of the item that was picked, returned in
3296 * {@link #getData()}. This must be a {@code content://} URI so that any
3297 * receiver can access it. If multiple documents were selected, they are
3298 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003299 *
3300 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003301 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003302 * @see #ACTION_CREATE_DOCUMENT
3303 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003304 */
3305 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3306 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3307
3308 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003309 * Activity Action: Allow the user to create a new document. When invoked,
3310 * the system will display the various {@link DocumentsProvider} instances
3311 * installed on the device, letting the user navigate through them. The
3312 * returned document may be a newly created document with no content, or it
3313 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003314 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003315 * Each document is represented as a {@code content://} URI backed by a
3316 * {@link DocumentsProvider}, which can be opened as a stream with
3317 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3318 * {@link android.provider.DocumentsContract.Document} metadata.
3319 * <p>
3320 * Callers must indicate the concrete MIME type of the document being
3321 * created by setting {@link #setType(String)}. This MIME type cannot be
3322 * changed after the document is created.
3323 * <p>
3324 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3325 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003326 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003327 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3328 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003329 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003330 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003331 * Callers can set a document URI through
3332 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3333 * location of documents navigator. System will do its best to launch the
3334 * navigator in the specified document if it's a folder, or the folder that
3335 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003336 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003337 * Output: The URI of the item that was created. This must be a
3338 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003339 *
3340 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003341 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003342 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003343 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003344 */
3345 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3346 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3347
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003348 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003349 * Activity Action: Allow the user to pick a directory subtree. When
3350 * invoked, the system will display the various {@link DocumentsProvider}
3351 * instances installed on the device, letting the user navigate through
3352 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003353 * <p>
3354 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003355 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3356 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3357 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003358 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003359 * Callers can set a document URI through
3360 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3361 * location of documents navigator. System will do its best to launch the
3362 * navigator in the specified document if it's a folder, or the folder that
3363 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003364 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003365 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003366 *
3367 * @see DocumentsContract
3368 */
3369 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003370 public static final String
3371 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003372
Felipe Lemec7b1f892016-01-15 15:02:31 -08003373 /**
Peng Xua35b5532016-01-20 00:05:45 -08003374 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3375 * exisiting sensor being disconnected.
3376 *
3377 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3378 *
3379 * {@hide}
3380 */
3381 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3382 public static final String
3383 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3384
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003385 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003386 * Broadcast Action: The default subscription has changed. This has the following
3387 * extra values:</p>
3388 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3389 */
3390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3391 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3392 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3393
3394 /**
3395 * Broadcast Action: The default sms subscription has changed. This has the following
3396 * extra values:</p>
3397 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3398 * subscription index
3399 */
3400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3401 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3402 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3403
3404 /**
3405 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3406 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3407 * which has changed.
3408 */
3409 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3410
3411 /**
Sam Line707f832017-04-13 17:00:55 -07003412 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003413 * @hide
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003414 */
3415 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003416 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003417 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3418
Christopher Tate6597e342015-02-17 12:15:25 -08003419 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003420 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3421 * is about to be performed.
3422 * @hide
3423 */
3424 @SystemApi
3425 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3426 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3427 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3428
3429 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003430 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3431 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3432 *
3433 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3434 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003435 * @hide
3436 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003437 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003438 public static final String EXTRA_FORCE_MASTER_CLEAR =
3439 "android.intent.extra.FORCE_MASTER_CLEAR";
3440
3441 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003442 * A broadcast action to trigger a factory reset.
3443 *
3444 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3445 *
3446 * <p>Not for use by third-party applications.
3447 *
3448 * @see #EXTRA_FORCE_MASTER_CLEAR
3449 *
3450 * {@hide}
3451 */
3452 @SystemApi
3453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3454 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3455
3456 /**
3457 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3458 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3459 *
3460 * <p>Not for use by third-party applications.
3461 *
3462 * @hide
3463 */
3464 @SystemApi
3465 public static final String EXTRA_FORCE_FACTORY_RESET =
3466 "android.intent.extra.FORCE_FACTORY_RESET";
3467
3468 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003469 * Broadcast action: report that a settings element is being restored from backup. The intent
3470 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3471 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3472 * is the value of that settings entry prior to the restore operation. All of these values are
3473 * represented as strings.
3474 *
3475 * <p>This broadcast is sent only for settings provider entries known to require special handling
3476 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3477 * the provider's backup agent implementation.
3478 *
3479 * @see #EXTRA_SETTING_NAME
3480 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3481 * @see #EXTRA_SETTING_NEW_VALUE
3482 * {@hide}
3483 */
3484 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3485
3486 /** {@hide} */
3487 public static final String EXTRA_SETTING_NAME = "setting_name";
3488 /** {@hide} */
3489 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3490 /** {@hide} */
3491 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3492
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003493 /**
3494 * Activity Action: Process a piece of text.
3495 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3496 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3497 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3498 */
3499 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3500 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003501
3502 /**
3503 * Broadcast Action: The sim card state has changed.
3504 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3505 * because TelephonyIntents is an internal class.
3506 * @hide
3507 */
3508 @SystemApi
3509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3510 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3511
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003512 /**
fionaxu90fee272017-03-31 12:45:12 -07003513 * Broadcast Action: indicate that the phone service state has changed.
3514 * The intent will have the following extra values:</p>
3515 * <p>
3516 * @see #EXTRA_VOICE_REG_STATE
3517 * @see #EXTRA_DATA_REG_STATE
3518 * @see #EXTRA_VOICE_ROAMING_TYPE
3519 * @see #EXTRA_DATA_ROAMING_TYPE
3520 * @see #EXTRA_OPERATOR_ALPHA_LONG
3521 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3522 * @see #EXTRA_OPERATOR_NUMERIC
3523 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3524 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3525 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3526 * @see #EXTRA_MANUAL
3527 * @see #EXTRA_VOICE_RADIO_TECH
3528 * @see #EXTRA_DATA_RADIO_TECH
3529 * @see #EXTRA_CSS_INDICATOR
3530 * @see #EXTRA_NETWORK_ID
3531 * @see #EXTRA_SYSTEM_ID
3532 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3533 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3534 * @see #EXTRA_EMERGENCY_ONLY
3535 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3536 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3537 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3538 *
3539 * <p class="note">
3540 * Requires the READ_PHONE_STATE permission.
3541 *
3542 * <p class="note">This is a protected intent that can only be sent by the system.
3543 * @hide
3544 */
3545 @Deprecated
3546 @SystemApi
3547 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3548 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3549
3550 /**
3551 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3552 * state.
3553 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3554 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3555 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3556 * @see android.telephony.ServiceState#STATE_POWER_OFF
3557 * @hide
3558 */
3559 @Deprecated
3560 @SystemApi
3561 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3562
3563 /**
3564 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3565 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3566 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3567 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3568 * @see android.telephony.ServiceState#STATE_POWER_OFF
3569 * @hide
3570 */
3571 @Deprecated
3572 @SystemApi
3573 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3574
3575 /**
3576 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3577 * type.
3578 * @hide
3579 */
3580 @Deprecated
3581 @SystemApi
3582 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3583
3584 /**
3585 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3586 * type.
3587 * @hide
3588 */
3589 @Deprecated
3590 @SystemApi
3591 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3592
3593 /**
3594 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3595 * registered voice operator name in long alphanumeric format.
3596 * {@code null} if the operator name is not known or unregistered.
3597 * @hide
3598 */
3599 @Deprecated
3600 @SystemApi
3601 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3602
3603 /**
3604 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3605 * registered voice operator name in short alphanumeric format.
3606 * {@code null} if the operator name is not known or unregistered.
3607 * @hide
3608 */
3609 @Deprecated
3610 @SystemApi
3611 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3612
3613 /**
3614 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3615 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3616 * network.
3617 * @hide
3618 */
3619 @Deprecated
3620 @SystemApi
3621 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3622
3623 /**
3624 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3625 * registered data operator name in long alphanumeric format.
3626 * {@code null} if the operator name is not known or unregistered.
3627 * @hide
3628 */
3629 @Deprecated
3630 @SystemApi
3631 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3632
3633 /**
3634 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3635 * registered data operator name in short alphanumeric format.
3636 * {@code null} if the operator name is not known or unregistered.
3637 * @hide
3638 */
3639 @Deprecated
3640 @SystemApi
3641 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3642
3643 /**
3644 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3645 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3646 * data operator.
3647 * @hide
3648 */
3649 @Deprecated
3650 @SystemApi
3651 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3652
3653 /**
3654 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3655 * network selection mode is manual.
3656 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3657 * @hide
3658 */
3659 @Deprecated
3660 @SystemApi
3661 public static final String EXTRA_MANUAL = "manual";
3662
3663 /**
3664 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3665 * radio technology.
3666 * @hide
3667 */
3668 @Deprecated
3669 @SystemApi
3670 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3671
3672 /**
3673 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3674 * radio technology.
3675 * @hide
3676 */
3677 @Deprecated
3678 @SystemApi
3679 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3680
3681 /**
3682 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3683 * support on CDMA network.
3684 * Will be {@code true} if support, {@code false} otherwise.
3685 * @hide
3686 */
3687 @Deprecated
3688 @SystemApi
3689 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3690
3691 /**
3692 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3693 * id. {@code Integer.MAX_VALUE} if unknown.
3694 * @hide
3695 */
3696 @Deprecated
3697 @SystemApi
3698 public static final String EXTRA_NETWORK_ID = "networkId";
3699
3700 /**
3701 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3702 * {@code Integer.MAX_VALUE} if unknown.
3703 * @hide
3704 */
3705 @Deprecated
3706 @SystemApi
3707 public static final String EXTRA_SYSTEM_ID = "systemId";
3708
3709 /**
3710 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3711 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3712 * @hide
3713 */
3714 @Deprecated
3715 @SystemApi
3716 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3717
3718 /**
3719 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3720 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3721 * @hide
3722 */
3723 @Deprecated
3724 @SystemApi
3725 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3726
3727 /**
3728 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3729 * only mode.
3730 * {@code true} if in emergency only mode, {@code false} otherwise.
3731 * @hide
3732 */
3733 @Deprecated
3734 @SystemApi
3735 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3736
3737 /**
3738 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3739 * registration state is roaming.
3740 * {@code true} if registration indicates roaming, {@code false} otherwise
3741 * @hide
3742 */
3743 @Deprecated
3744 @SystemApi
3745 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3746 "isDataRoamingFromRegistration";
3747
3748 /**
3749 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3750 * aggregation is in use.
3751 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3752 * @hide
3753 */
3754 @Deprecated
3755 @SystemApi
3756 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3757
3758 /**
3759 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3760 * is reduced from the rsrp threshold while calculating signal strength level.
3761 * @hide
3762 */
3763 @Deprecated
3764 @SystemApi
3765 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3766
3767 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003768 * The name of the extra used to define the text to be processed, as a
3769 * CharSequence. Note that this may be a styled CharSequence, so you must use
3770 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003771 */
3772 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3773 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003774 * 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 +00003775 */
3776 public static final String EXTRA_PROCESS_TEXT_READONLY =
3777 "android.intent.extra.PROCESS_TEXT_READONLY";
3778
Bryce Leebc58f592015-09-25 16:43:01 -07003779 /**
3780 * Broadcast action: reports when a new thermal event has been reached. When the device
3781 * is reaching its maximum temperatue, the thermal level reported
3782 * {@hide}
3783 */
3784 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3785 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3786
3787 /** {@hide} */
3788 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3789
3790 /**
3791 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003792 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003793 * {@hide}
3794 */
3795 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3796
3797 /**
3798 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003799 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003800 * {@hide}
3801 */
3802 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3803
3804 /**
3805 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003806 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003807 * {@hide}
3808 */
3809 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3810
3811
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003812 // ---------------------------------------------------------------------
3813 // ---------------------------------------------------------------------
3814 // Standard intent categories (see addCategory()).
3815
3816 /**
3817 * Set if the activity should be an option for the default action
3818 * (center press) to perform on a piece of data. Setting this will
3819 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003820 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003821 * Intent when initiating an action -- it is for use in intent filters
3822 * specified in packages.
3823 */
3824 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3825 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3826 /**
3827 * Activities that can be safely invoked from a browser must support this
3828 * category. For example, if the user is viewing a web page or an e-mail
3829 * and clicks on a link in the text, the Intent generated execute that
3830 * link will require the BROWSABLE category, so that only activities
3831 * supporting this category will be considered as possible actions. By
3832 * supporting this category, you are promising that there is nothing
3833 * damaging (without user intervention) that can happen by invoking any
3834 * matching Intent.
3835 */
3836 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3837 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3838 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003839 * Categories for activities that can participate in voice interaction.
3840 * An activity that supports this category must be prepared to run with
3841 * no UI shown at all (though in some case it may have a UI shown), and
3842 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3843 */
3844 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3845 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3846 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003847 * Set if the activity should be considered as an alternative action to
3848 * the data the user is currently viewing. See also
3849 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3850 * applies to the selection in a list of items.
3851 *
3852 * <p>Supporting this category means that you would like your activity to be
3853 * displayed in the set of alternative things the user can do, usually as
3854 * part of the current activity's options menu. You will usually want to
3855 * include a specific label in the &lt;intent-filter&gt; of this action
3856 * describing to the user what it does.
3857 *
3858 * <p>The action of IntentFilter with this category is important in that it
3859 * describes the specific action the target will perform. This generally
3860 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3861 * a specific name such as "com.android.camera.action.CROP. Only one
3862 * alternative of any particular action will be shown to the user, so using
3863 * a specific action like this makes sure that your alternative will be
3864 * displayed while also allowing other applications to provide their own
3865 * overrides of that particular action.
3866 */
3867 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3868 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3869 /**
3870 * Set if the activity should be considered as an alternative selection
3871 * action to the data the user has currently selected. This is like
3872 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3873 * of items from which the user can select, giving them alternatives to the
3874 * default action that will be performed on it.
3875 */
3876 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3877 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3878 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003879 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003880 */
3881 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3882 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3883 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003884 * Should be displayed in the top-level launcher.
3885 */
3886 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3887 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3888 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003889 * Indicates an activity optimized for Leanback mode, and that should
3890 * be displayed in the Leanback launcher.
3891 */
3892 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3893 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3894 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003895 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3896 * @hide
3897 */
3898 @SystemApi
3899 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3900 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003901 * Provides information about the package it is in; typically used if
3902 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3903 * a front-door to the user without having to be shown in the all apps list.
3904 */
3905 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3906 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3907 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003908 * This is the home activity, that is the first activity that is displayed
3909 * when the device boots.
3910 */
3911 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3912 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3913 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003914 * This is the home activity that is displayed when the device is finished setting up and ready
3915 * for use.
3916 * @hide
3917 */
3918 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3919 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3920 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003921 * This is the setup wizard activity, that is the first activity that is displayed
3922 * when the user sets up the device for the first time.
3923 * @hide
3924 */
3925 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3926 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3927 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003928 * This activity is a preference panel.
3929 */
3930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3931 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3932 /**
3933 * This activity is a development preference panel.
3934 */
3935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3936 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3937 /**
3938 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003939 */
3940 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3941 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3942 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003943 * This activity allows the user to browse and download new applications.
3944 */
3945 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3946 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003948 * This activity may be exercised by the monkey or other automated test tools.
3949 */
3950 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3951 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3952 /**
3953 * To be used as a test (not part of the normal user experience).
3954 */
3955 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3956 /**
3957 * To be used as a unit test (run through the Test Harness).
3958 */
3959 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3960 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003961 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003962 * experience).
3963 */
3964 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003965
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003966 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003967 * Used to indicate that an intent only wants URIs that can be opened with
3968 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3969 * must support at least the columns defined in {@link OpenableColumns} when
3970 * queried.
3971 *
3972 * @see #ACTION_GET_CONTENT
3973 * @see #ACTION_OPEN_DOCUMENT
3974 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003975 */
3976 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3977 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3978
3979 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003980 * Used to indicate that an intent filter can accept files which are not necessarily
3981 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3982 * at least streamable via
3983 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3984 * using one of the stream types exposed via
3985 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3986 *
3987 * @see #ACTION_SEND
3988 * @see #ACTION_SEND_MULTIPLE
3989 */
3990 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3991 public static final String CATEGORY_TYPED_OPENABLE =
3992 "android.intent.category.TYPED_OPENABLE";
3993
3994 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003995 * To be used as code under test for framework instrumentation tests.
3996 */
3997 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3998 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003999 /**
4000 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004001 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4002 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004003 */
4004 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4005 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4006 /**
4007 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004008 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4009 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004010 */
4011 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4012 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004013 /**
4014 * An activity to run when device is inserted into a analog (low end) dock.
4015 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4016 * information, see {@link android.app.UiModeManager}.
4017 */
4018 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4019 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4020
4021 /**
4022 * An activity to run when device is inserted into a digital (high end) dock.
4023 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4024 * information, see {@link android.app.UiModeManager}.
4025 */
4026 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4027 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004028
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004029 /**
4030 * Used to indicate that the activity can be used in a car environment.
4031 */
4032 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4033 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4034
Zak Cohendb6ca492017-01-26 14:09:00 -08004035 /**
4036 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4037 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4038 * information, see {@link android.app.UiModeManager}.
4039 */
4040 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4041 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004042 // ---------------------------------------------------------------------
4043 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004044 // Application launch intent categories (see addCategory()).
4045
4046 /**
4047 * Used with {@link #ACTION_MAIN} to launch the browser application.
4048 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004049 * <p>NOTE: This should not be used as the primary key of an Intent,
4050 * since it will not result in the app launching with the correct
4051 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004052 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004053 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004054 */
4055 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4056 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4057
4058 /**
4059 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4060 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004061 * <p>NOTE: This should not be used as the primary key of an Intent,
4062 * since it will not result in the app launching with the correct
4063 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004064 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004065 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004066 */
4067 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4068 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4069
4070 /**
4071 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4072 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004073 * <p>NOTE: This should not be used as the primary key of an Intent,
4074 * since it will not result in the app launching with the correct
4075 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004076 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004077 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004078 */
4079 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4080 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4081
4082 /**
4083 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4084 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004085 * <p>NOTE: This should not be used as the primary key of an Intent,
4086 * since it will not result in the app launching with the correct
4087 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004088 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004089 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004090 */
4091 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4092 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4093
4094 /**
4095 * Used with {@link #ACTION_MAIN} to launch the email application.
4096 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004097 * <p>NOTE: This should not be used as the primary key of an Intent,
4098 * since it will not result in the app launching with the correct
4099 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004100 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004101 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004102 */
4103 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4104 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4105
4106 /**
4107 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4108 * The activity should be able to view and manipulate image and video files
4109 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004110 * <p>NOTE: This should not be used as the primary key of an Intent,
4111 * since it will not result in the app launching with the correct
4112 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004113 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004114 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004115 */
4116 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4117 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4118
4119 /**
4120 * Used with {@link #ACTION_MAIN} to launch the maps application.
4121 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004122 * <p>NOTE: This should not be used as the primary key of an Intent,
4123 * since it will not result in the app launching with the correct
4124 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004125 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004126 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004127 */
4128 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4129 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4130
4131 /**
4132 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4133 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004134 * <p>NOTE: This should not be used as the primary key of an Intent,
4135 * since it will not result in the app launching with the correct
4136 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004137 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004138 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004139 */
4140 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4141 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4142
4143 /**
4144 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004145 * The activity should be able to play, browse, or manipulate music files
4146 * stored on the device.
4147 * <p>NOTE: This should not be used as the primary key of an Intent,
4148 * since it will not result in the app launching with the correct
4149 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004150 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004151 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004152 */
4153 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4154 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4155
4156 // ---------------------------------------------------------------------
4157 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004158 // Standard extra data keys.
4159
4160 /**
4161 * The initial data to place in a newly created record. Use with
4162 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4163 * fields as would be given to the underlying ContentProvider.insert()
4164 * call.
4165 */
4166 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4167
4168 /**
4169 * A constant CharSequence that is associated with the Intent, used with
4170 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4171 * this may be a styled CharSequence, so you must use
4172 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4173 * retrieve it.
4174 */
4175 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4176
4177 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004178 * A constant String that is associated with the Intent, used with
4179 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4180 * as HTML formatted text. Note that you <em>must</em> also supply
4181 * {@link #EXTRA_TEXT}.
4182 */
4183 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4184
4185 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004186 * A content: URI holding a stream of data associated with the Intent,
4187 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004188 */
4189 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4190
4191 /**
4192 * A String[] holding e-mail addresses that should be delivered to.
4193 */
4194 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4195
4196 /**
4197 * A String[] holding e-mail addresses that should be carbon copied.
4198 */
4199 public static final String EXTRA_CC = "android.intent.extra.CC";
4200
4201 /**
4202 * A String[] holding e-mail addresses that should be blind carbon copied.
4203 */
4204 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4205
4206 /**
4207 * A constant string holding the desired subject line of a message.
4208 */
4209 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4210
4211 /**
4212 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004213 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004214 */
4215 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4216
4217 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004218 * An int representing the user id to be used.
4219 *
4220 * @hide
4221 */
4222 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4223
4224 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004225 * An int representing the task id to be retrieved. This is used when a launch from recents is
4226 * intercepted by another action such as credentials confirmation to remember which task should
4227 * be resumed when complete.
4228 *
4229 * @hide
4230 */
4231 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4232
4233 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004234 * An Intent[] describing additional, alternate choices you would like shown with
4235 * {@link #ACTION_CHOOSER}.
4236 *
4237 * <p>An app may be capable of providing several different payload types to complete a
4238 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4239 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4240 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4241 * photo data or a hosted link where the photos can be viewed.</p>
4242 *
4243 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4244 * first/primary/preferred intent in the set. Additional intents specified in
4245 * this extra are ordered; by default intents that appear earlier in the array will be
4246 * preferred over intents that appear later in the array as matches for the same
4247 * target component. To alter this preference, a calling app may also supply
4248 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4249 */
4250 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4251
4252 /**
Adam Powell52c39212016-04-07 15:14:18 -07004253 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4254 * and omitted from a list of components presented to the user.
4255 *
4256 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4257 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4258 * from your own package or other apps from your organization if the idea of sending to those
4259 * targets would be redundant with other app functionality. Filtered components will not
4260 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4261 */
4262 public static final String EXTRA_EXCLUDE_COMPONENTS
4263 = "android.intent.extra.EXCLUDE_COMPONENTS";
4264
4265 /**
4266 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4267 * describing additional high-priority deep-link targets for the chooser to present to the user.
4268 *
4269 * <p>Targets provided in this way will be presented inline with all other targets provided
4270 * by services from other apps. They will be prioritized before other service targets, but
4271 * after those targets provided by sources that the user has manually pinned to the front.</p>
4272 *
4273 * @see #ACTION_CHOOSER
4274 */
4275 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4276
4277 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004278 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4279 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4280 *
4281 * <p>An app preparing an action for another app to complete may wish to allow the user to
4282 * disambiguate between several options for completing the action based on the chosen target
4283 * or otherwise refine the action before it is invoked.
4284 * </p>
4285 *
4286 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4287 * <ul>
4288 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4289 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4290 * chosen target beyond the first</li>
4291 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4292 * should fill in and send once the disambiguation is complete</li>
4293 * </ul>
4294 */
4295 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4296 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4297
4298 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004299 * An {@code ArrayList} of {@code String} annotations describing content for
4300 * {@link #ACTION_CHOOSER}.
4301 *
4302 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4303 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4304 *
4305 * <p>Annotations should describe the major components or topics of the content. It is up to
4306 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4307 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4308 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4309 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
Kang Lifadc0162017-04-19 11:56:05 -07004310 * use the following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004311 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004312 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004313 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004314 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004315 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004316 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004317 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004318 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004319 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004320 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4321 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4322 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4323 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4324 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004325 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004326 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4327 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004328 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004329 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004330 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004331 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004332 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004333 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004334 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004335 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004336 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004337 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004338 * Christmas and Thanksgiving.</li>
4339 * </ul>
4340 */
4341 public static final String EXTRA_CONTENT_ANNOTATIONS
4342 = "android.intent.extra.CONTENT_ANNOTATIONS";
4343
4344 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004345 * A {@link ResultReceiver} used to return data back to the sender.
4346 *
4347 * <p>Used to complete an app-specific
4348 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4349 *
4350 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4351 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4352 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4353 * when the user selects a target component from the chooser. It is up to the recipient
4354 * to send a result to this ResultReceiver to signal that disambiguation is complete
4355 * and that the chooser should invoke the user's choice.</p>
4356 *
4357 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4358 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4359 * to match and fill in the final Intent or ChooserTarget before starting it.
4360 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4361 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4362 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4363 *
4364 * <p>The result code passed to the ResultReceiver should be
4365 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4366 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4367 * the chooser should finish without starting a target.</p>
4368 */
4369 public static final String EXTRA_RESULT_RECEIVER
4370 = "android.intent.extra.RESULT_RECEIVER";
4371
4372 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004373 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004374 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004375 */
4376 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4377
4378 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004379 * A Parcelable[] of {@link Intent} or
4380 * {@link android.content.pm.LabeledIntent} objects as set with
4381 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4382 * a the front of the list of choices, when shown to the user with a
4383 * {@link #ACTION_CHOOSER}.
4384 */
4385 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4386
4387 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004388 * A {@link IntentSender} to start after ephemeral installation success.
4389 * @hide
4390 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004391 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4392
4393 /**
4394 * A {@link IntentSender} to start after ephemeral installation failure.
4395 * @hide
4396 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004397 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4398
4399 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004400 * The host name that triggered an ephemeral resolution.
4401 * @hide
4402 */
4403 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4404
4405 /**
4406 * An opaque token to track ephemeral resolution.
4407 * @hide
4408 */
4409 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4410
4411 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004412 * The version code of the app to install components from.
4413 * @hide
4414 */
4415 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4416
4417 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004418 * A Bundle forming a mapping of potential target package names to different extras Bundles
4419 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4420 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4421 * be currently installed on the device.
4422 *
4423 * <p>An application may choose to provide alternate extras for the case where a user
4424 * selects an activity from a predetermined set of target packages. If the activity
4425 * the user selects from the chooser belongs to a package with its package name as
4426 * a key in this bundle, the corresponding extras for that package will be merged with
4427 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4428 * extra has the same key as an extra already present in the intent it will overwrite
4429 * the extra from the intent.</p>
4430 *
4431 * <p><em>Examples:</em>
4432 * <ul>
4433 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4434 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4435 * parameters for that target.</li>
4436 * <li>An application may offer additional metadata for known targets of a given intent
4437 * to pass along information only relevant to that target such as account or content
4438 * identifiers already known to that application.</li>
4439 * </ul></p>
4440 */
4441 public static final String EXTRA_REPLACEMENT_EXTRAS =
4442 "android.intent.extra.REPLACEMENT_EXTRAS";
4443
4444 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004445 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4446 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4447 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4448 * {@link ComponentName} of the chosen component.
4449 *
4450 * <p>In some situations this callback may never come, for example if the user abandons
4451 * the chooser, switches to another task or any number of other reasons. Apps should not
4452 * be written assuming that this callback will always occur.</p>
4453 */
4454 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4455 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4456
4457 /**
4458 * The {@link ComponentName} chosen by the user to complete an action.
4459 *
4460 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4461 */
4462 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4463
4464 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004465 * A {@link android.view.KeyEvent} object containing the event that
4466 * triggered the creation of the Intent it is in.
4467 */
4468 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4469
4470 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004471 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4472 * before shutting down.
4473 *
4474 * {@hide}
4475 */
4476 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4477
4478 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004479 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4480 * requested by the user.
4481 *
4482 * {@hide}
4483 */
4484 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4485 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4486
4487 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004488 * 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 -07004489 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4490 * of restarting the application.
4491 */
4492 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4493
4494 /**
4495 * A String holding the phone number originally entered in
4496 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4497 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4498 */
4499 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004500
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004501 /**
4502 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4503 * intents to supply the uid the package had been assigned. Also an optional
4504 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4505 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4506 * purpose.
4507 */
4508 public static final String EXTRA_UID = "android.intent.extra.UID";
4509
4510 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004511 * @hide String array of package names.
4512 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004513 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004514 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4515
4516 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004517 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4518 * intents to indicate whether this represents a full uninstall (removing
4519 * both the code and its data) or a partial uninstall (leaving its data,
4520 * implying that this is an update).
4521 */
4522 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004523
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004524 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004525 * @hide
4526 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4527 * intents to indicate that at this point the package has been removed for
4528 * all users on the device.
4529 */
4530 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4531 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4532
4533 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004534 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4535 * intents to indicate that this is a replacement of the package, so this
4536 * broadcast will immediately be followed by an add broadcast for a
4537 * different version of the same package.
4538 */
4539 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004540
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004541 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004542 * Used as an int extra field in {@link android.app.AlarmManager} intents
4543 * to tell the application being invoked how many pending alarms are being
4544 * delievered with the intent. For one-shot alarms this will always be 1.
4545 * For recurring alarms, this might be greater than 1 if the device was
4546 * asleep or powered off at the time an earlier alarm would have been
4547 * delivered.
4548 */
4549 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004550
Jacek Surazski86b6c532009-05-13 14:38:28 +02004551 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004552 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4553 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004554 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4555 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004556 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4557 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4558 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004559 */
4560 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4561
4562 /**
4563 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4564 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004565 */
4566 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4567
4568 /**
4569 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4570 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004571 */
4572 public static final int EXTRA_DOCK_STATE_DESK = 1;
4573
4574 /**
4575 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4576 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004577 */
4578 public static final int EXTRA_DOCK_STATE_CAR = 2;
4579
4580 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004581 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4582 * to represent that the phone is in a analog (low end) dock.
4583 */
4584 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4585
4586 /**
4587 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4588 * to represent that the phone is in a digital (high end) dock.
4589 */
4590 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4591
4592 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004593 * Boolean that can be supplied as meta-data with a dock activity, to
4594 * indicate that the dock should take over the home key when it is active.
4595 */
4596 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004597
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004598 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004599 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4600 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004601 */
4602 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4603
4604 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004605 * Used in the extra field in the remote intent. It's astring token passed with the
4606 * remote intent.
4607 */
4608 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4609 "android.intent.extra.remote_intent_token";
4610
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004611 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004612 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004613 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004614 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004615 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004616 "android.intent.extra.changed_component_name";
4617
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004618 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004619 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004620 * and contains a string array of all of the components that have changed. If
4621 * the state of the overall package has changed, then it will contain an entry
4622 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004623 */
4624 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4625 "android.intent.extra.changed_component_name_list";
4626
4627 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004628 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004629 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004630 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4631 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4632 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004633 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004634 */
4635 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4636 "android.intent.extra.changed_package_list";
4637
4638 /**
4639 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004640 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4641 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004642 * and contains an integer array of uids of all of the components
4643 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004644 */
4645 public static final String EXTRA_CHANGED_UID_LIST =
4646 "android.intent.extra.changed_uid_list";
4647
4648 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004649 * @hide
4650 * Magic extra system code can use when binding, to give a label for
4651 * who it is that has bound to a service. This is an integer giving
4652 * a framework string resource that can be displayed to the user.
4653 */
4654 public static final String EXTRA_CLIENT_LABEL =
4655 "android.intent.extra.client_label";
4656
4657 /**
4658 * @hide
4659 * Magic extra system code can use when binding, to give a PendingIntent object
4660 * that can be launched for the user to disable the system's use of this
4661 * service.
4662 */
4663 public static final String EXTRA_CLIENT_INTENT =
4664 "android.intent.extra.client_intent";
4665
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004666 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004667 * Extra used to indicate that an intent should only return data that is on
4668 * the local device. This is a boolean extra; the default is false. If true,
4669 * an implementation should only allow the user to select data that is
4670 * already on the device, not requiring it be downloaded from a remote
4671 * service when opened.
4672 *
4673 * @see #ACTION_GET_CONTENT
4674 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004675 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004676 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004677 */
4678 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004679 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004680
Amith Yamasani13593602012-03-22 16:16:17 -07004681 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004682 * Extra used to indicate that an intent can allow the user to select and
4683 * return multiple items. This is a boolean extra; the default is false. If
4684 * true, an implementation is allowed to present the user with a UI where
4685 * they can pick multiple items that are all returned to the caller. When
4686 * this happens, they should be returned as the {@link #getClipData()} part
4687 * of the result Intent.
4688 *
4689 * @see #ACTION_GET_CONTENT
4690 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004691 */
4692 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004693 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004694
4695 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004696 * The integer userHandle carried with broadcast intents related to addition, removal and
4697 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4698 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4699 *
Amith Yamasani13593602012-03-22 16:16:17 -07004700 * @hide
4701 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004702 public static final String EXTRA_USER_HANDLE =
4703 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004704
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004705 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004706 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4707 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4708 */
4709 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004710 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004711
4712 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004713 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004714 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4715 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004716 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004717 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4718
4719 /**
4720 * Extra sent in the intent to the BroadcastReceiver that handles
4721 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4722 * the restrictions as key/value pairs.
4723 */
4724 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4725 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004726
Amith Yamasani86118ba2013-03-28 14:33:16 -07004727 /**
4728 * Extra used in the response from a BroadcastReceiver that handles
4729 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4730 */
4731 public static final String EXTRA_RESTRICTIONS_INTENT =
4732 "android.intent.extra.restrictions_intent";
4733
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004734 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004735 * Extra used to communicate a set of acceptable MIME types. The type of the
4736 * extra is {@code String[]}. Values may be a combination of concrete MIME
4737 * types (such as "image/png") and/or partial MIME types (such as
4738 * "audio/*").
4739 *
4740 * @see #ACTION_GET_CONTENT
4741 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004742 */
4743 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4744
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004745 /**
4746 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4747 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004748 * When this is true, hardware devices can use this information to determine that
4749 * they shouldn't do a complete shutdown of their device since this is not a
4750 * complete shutdown down to the kernel, but only user space restarting.
4751 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004752 */
4753 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4754 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4755
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004756 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004757 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4758 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4759 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4760 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004761 *
4762 * @hide for internal use only.
4763 */
4764 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4765 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004766 /** @hide */
4767 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4768 /** @hide */
4769 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4770 /** @hide */
4771 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004772
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004773 /** {@hide} */
4774 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4775
Rubin Xue8490f12015-06-25 12:17:48 +01004776 /** {@hide} */
4777 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4778
Santos Cordon15a13782015-03-31 18:32:31 -07004779 /**
4780 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4781 * activation request.
4782 * TODO: Add information about the structure and response data used with the pending intent.
4783 * @hide
4784 */
4785 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4786 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4787
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004788 /**
4789 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004790 *
4791 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004792 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004793 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004794 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4795
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004796 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004797 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4798 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4799 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004800 *
4801 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004802 * @see #ACTION_QUICK_VIEW
4803 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004804 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004805 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004806 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4807 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004808
4809 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004810 * An optional extra of {@code String[]} indicating which quick view features should be made
4811 * available to the user in the quick view UI while handing a
4812 * {@link Intent#ACTION_QUICK_VIEW} intent.
4813 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4814 * Quick viewer can implement features not listed below.
4815 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4816 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4817 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4818 * <p>
4819 * Requirements:
4820 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4821 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4822 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4823 * internal policies.
4824 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4825 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4826 * disable or hide features.
4827 *
4828 * @see #ACTION_QUICK_VIEW
4829 */
4830 public static final String EXTRA_QUICK_VIEW_FEATURES =
4831 "android.intent.extra.QUICK_VIEW_FEATURES";
4832
4833 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004834 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004835 * When a profile goes into quiet mode, all apps in the profile are killed and the
4836 * profile user is stopped. Widgets originating from the profile are masked, and app
4837 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004838 */
4839 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004840
4841 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004842 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004843 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004844 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4845 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004846 *
4847 * @hide
4848 */
4849 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4850 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4851
4852 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004853 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4854 * whether to show the chooser or not when there is only one application available
4855 * to choose from.
4856 *
4857 * @hide
4858 */
4859 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4860 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4861
4862 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004863 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004864 * to represent that a video codec is allowed to use.
4865 *
4866 * @hide
4867 */
4868 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4869
4870 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004871 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004872 * to represent that a audio codec is allowed to use.
4873 *
4874 * @hide
4875 */
4876 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4877
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004878 // ---------------------------------------------------------------------
4879 // ---------------------------------------------------------------------
4880 // Intent flags (see mFlags variable).
4881
Tor Norbyed9273d62013-05-30 15:59:53 -07004882 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004883 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004884 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4885 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004886 @Retention(RetentionPolicy.SOURCE)
4887 public @interface GrantUriMode {}
4888
Jeff Sharkey846318a2014-04-04 12:12:41 -07004889 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004890 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004891 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4892 @Retention(RetentionPolicy.SOURCE)
4893 public @interface AccessUriMode {}
4894
4895 /**
4896 * Test if given mode flags specify an access mode, which must be at least
4897 * read and/or write.
4898 *
4899 * @hide
4900 */
4901 public static boolean isAccessUriMode(int modeFlags) {
4902 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4903 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4904 }
4905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004906 /**
4907 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004908 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004909 * specified in its ClipData. When applying to an Intent's ClipData,
4910 * all URIs as well as recursive traversals through data or other ClipData
4911 * in Intent items will be granted; only the grant flags of the top-level
4912 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004913 */
4914 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4915 /**
4916 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004917 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004918 * specified in its ClipData. When applying to an Intent's ClipData,
4919 * all URIs as well as recursive traversals through data or other ClipData
4920 * in Intent items will be granted; only the grant flags of the top-level
4921 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004922 */
4923 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4924 /**
4925 * Can be set by the caller to indicate that this Intent is coming from
4926 * a background operation, not from direct user interaction.
4927 */
4928 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4929 /**
4930 * A flag you can enable for debugging: when set, log messages will be
4931 * printed during the resolution of this intent to show you what has
4932 * been found to create the final resolved list.
4933 */
4934 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004935 /**
4936 * If set, this intent will not match any components in packages that
4937 * are currently stopped. If this is not set, then the default behavior
4938 * is to include such applications in the result.
4939 */
4940 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4941 /**
4942 * If set, this intent will always match any components in packages that
4943 * are currently stopped. This is the default behavior when
4944 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4945 * flags are set, this one wins (it allows overriding of exclude for
4946 * places where the framework may automatically set the exclude flag).
4947 */
4948 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004949
4950 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004951 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004952 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004953 * persisted across device reboots until explicitly revoked with
4954 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4955 * grant for possible persisting; the receiving application must call
4956 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4957 * actually persist.
4958 *
4959 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4960 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4961 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004962 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004963 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004964 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004965
4966 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004967 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4968 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4969 * applies to any URI that is a prefix match against the original granted
4970 * URI. (Without this flag, the URI must match exactly for access to be
4971 * granted.) Another URI is considered a prefix match only when scheme,
4972 * authority, and all path segments defined by the prefix are an exact
4973 * match.
4974 */
4975 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4976
4977 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004978 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004979 * homework and verified that they correctly handle packages and components
4980 * that come and go over time. In particular:
4981 * <ul>
4982 * <li>Apps installed on external storage, which will appear to be
4983 * uninstalled while the the device is ejected.
4984 * <li>Apps with encryption unaware components, which will appear to not
4985 * exist while the device is locked.
4986 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004987 *
4988 * @hide
4989 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004990 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004991
4992 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004993 * Internal flag used to indicate ephemeral applications should not be
4994 * considered when resolving the intent.
4995 *
4996 * @hide
4997 */
4998 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4999
5000 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005001 * If set, the new activity is not kept in the history stack. As soon as
5002 * the user navigates away from it, the activity is finished. This may also
5003 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5004 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005005 *
5006 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5007 * is never invoked when the current activity starts a new activity which
5008 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005009 */
5010 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5011 /**
5012 * If set, the activity will not be launched if it is already running
5013 * at the top of the history stack.
5014 */
5015 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5016 /**
5017 * If set, this activity will become the start of a new task on this
5018 * history stack. A task (from the activity that started it to the
5019 * next task activity) defines an atomic group of activities that the
5020 * user can move to. Tasks can be moved to the foreground and background;
5021 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005022 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005023 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5024 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005025 *
5026 * <p>This flag is generally used by activities that want
5027 * to present a "launcher" style behavior: they give the user a list of
5028 * separate things that can be done, which otherwise run completely
5029 * independently of the activity launching them.
5030 *
5031 * <p>When using this flag, if a task is already running for the activity
5032 * you are now starting, then a new activity will not be started; instead,
5033 * the current task will simply be brought to the front of the screen with
5034 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5035 * to disable this behavior.
5036 *
5037 * <p>This flag can not be used when the caller is requesting a result from
5038 * the activity being launched.
5039 */
5040 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5041 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005042 * This flag is used to create a new task and launch an activity into it.
5043 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5044 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5045 * search through existing tasks for ones matching this Intent. Only if no such
5046 * task is found would a new task be created. When paired with
5047 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5048 * the search for a matching task and unconditionally start a new task.
5049 *
5050 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5051 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005052 * top-level application launcher.</strong> Used in conjunction with
5053 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5054 * behavior of bringing an existing task to the foreground. When set,
5055 * a new task is <em>always</em> started to host the Activity for the
5056 * Intent, regardless of whether there is already an existing task running
5057 * the same thing.
5058 *
5059 * <p><strong>Because the default system does not include graphical task management,
5060 * you should not use this flag unless you provide some way for a user to
5061 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005062 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005063 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5064 * creating new document tasks.
5065 *
5066 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005067 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005068 *
Scott Main7aee61f2011-02-08 11:25:01 -08005069 * <p>See
5070 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5071 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005072 *
5073 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5074 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005075 */
5076 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5077 /**
5078 * If set, and the activity being launched is already running in the
5079 * current task, then instead of launching a new instance of that activity,
5080 * all of the other activities on top of it will be closed and this Intent
5081 * will be delivered to the (now on top) old activity as a new Intent.
5082 *
5083 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5084 * If D calls startActivity() with an Intent that resolves to the component
5085 * of activity B, then C and D will be finished and B receive the given
5086 * Intent, resulting in the stack now being: A, B.
5087 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005088 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005089 * either receive the new intent you are starting here in its
5090 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005091 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005092 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5093 * the same intent, then it will be finished and re-created; for all other
5094 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5095 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005096 *
5097 * <p>This launch mode can also be used to good effect in conjunction with
5098 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5099 * of a task, it will bring any currently running instance of that task
5100 * to the foreground, and then clear it to its root state. This is
5101 * especially useful, for example, when launching an activity from the
5102 * notification manager.
5103 *
Scott Main7aee61f2011-02-08 11:25:01 -08005104 * <p>See
5105 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5106 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005107 */
5108 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5109 /**
5110 * If set and this intent is being used to launch a new activity from an
5111 * existing one, then the reply target of the existing activity will be
5112 * transfered to the new activity. This way the new activity can call
5113 * {@link android.app.Activity#setResult} and have that result sent back to
5114 * the reply target of the original activity.
5115 */
5116 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5117 /**
5118 * If set and this intent is being used to launch a new activity from an
5119 * existing one, the current activity will not be counted as the top
5120 * activity for deciding whether the new intent should be delivered to
5121 * the top instead of starting a new one. The previous activity will
5122 * be used as the top, with the assumption being that the current activity
5123 * will finish itself immediately.
5124 */
5125 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5126 /**
5127 * If set, the new activity is not kept in the list of recently launched
5128 * activities.
5129 */
5130 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5131 /**
5132 * This flag is not normally set by application code, but set for you by
5133 * the system as described in the
5134 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5135 * launchMode} documentation for the singleTask mode.
5136 */
5137 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5138 /**
5139 * If set, and this activity is either being started in a new task or
5140 * bringing to the top an existing task, then it will be launched as
5141 * the front door of the task. This will result in the application of
5142 * any affinities needed to have that task in the proper state (either
5143 * moving activities to or from it), or simply resetting that task to
5144 * its initial state if needed.
5145 */
5146 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5147 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005148 * This flag is not normally set by application code, but set for you by
5149 * the system if this activity is being launched from history
5150 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005151 */
5152 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005153 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005154 * @deprecated As of API 21 this performs identically to
5155 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005156 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005157 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005158 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005159 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005160 * This flag is used to open a document into a new task rooted at the activity launched
5161 * by this Intent. Through the use of this flag, or its equivalent attribute,
5162 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005163 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005164 *
Craig Mautner026596b2014-05-21 15:35:44 -07005165 * <p>The use of the activity attribute form of this,
5166 * {@link android.R.attr#documentLaunchMode}, is
5167 * preferred over the Intent flag described here. The attribute form allows the
5168 * Activity to specify multiple document behavior for all launchers of the Activity
5169 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005170 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005171 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5172 * it is kept after the activity is finished is different than the use of
5173 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5174 * this flag is being used to create a new recents entry, then by default that entry
5175 * will be removed once the activity is finished. You can modify this behavior with
5176 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5177 *
Craig Mautner026596b2014-05-21 15:35:44 -07005178 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5179 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5180 * equivalent of the Activity manifest specifying {@link
5181 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5182 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5183 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005184 *
Craig Mautner026596b2014-05-21 15:35:44 -07005185 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005186 *
Craig Mautner026596b2014-05-21 15:35:44 -07005187 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005188 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5189 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005190 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005191 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005192 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005193 * callback from occurring on the current frontmost activity before it is
5194 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005195 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005196 * <p>Typically, an activity can rely on that callback to indicate that an
5197 * explicit user action has caused their activity to be moved out of the
5198 * foreground. The callback marks an appropriate point in the activity's
5199 * lifecycle for it to dismiss any notifications that it intends to display
5200 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005201 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005202 * <p>If an activity is ever started via any non-user-driven events such as
5203 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5204 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005205 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005206 */
5207 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005208 /**
5209 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5210 * this flag will cause the launched activity to be brought to the front of its
5211 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005212 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005213 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5214 * If D calls startActivity() with an Intent that resolves to the component
5215 * of activity B, then B will be brought to the front of the history stack,
5216 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005217 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005218 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005219 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005220 */
5221 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005222 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005223 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5224 * this flag will prevent the system from applying an activity transition
5225 * animation to go to the next activity state. This doesn't mean an
5226 * animation will never run -- if another activity change happens that doesn't
5227 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005228 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005229 * when you are going to do a series of activity operations but the
5230 * animation seen by the user shouldn't be driven by the first activity
5231 * change but rather a later one.
5232 */
5233 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5234 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005235 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5236 * this flag will cause any existing task that would be associated with the
5237 * activity to be cleared before the activity is started. That is, the activity
5238 * becomes the new root of an otherwise empty task, and any old activities
5239 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5240 */
5241 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5242 /**
5243 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5244 * this flag will cause a newly launching task to be placed on top of the current
5245 * home activity task (if there is one). That is, pressing back from the task
5246 * will always return the user to home even if that was not the last activity they
5247 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5248 */
5249 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5250 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005251 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5252 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005253 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005254 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005255 * this flag. When set and the task's activity is finished, the recents
5256 * entry will remain in the interface for the user to re-launch it, like a
5257 * recents entry for a top-level application.
5258 * <p>
5259 * The receiving activity can override this request with
5260 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5261 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005262 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005263 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005264 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005265
5266 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005267 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5268 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005269 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5270 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005271 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005272 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005273
5274 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005275 * If set, when sending a broadcast only registered receivers will be
5276 * called -- no BroadcastReceiver components will be launched.
5277 */
5278 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005279 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005280 * If set, when sending a broadcast the new broadcast will replace
5281 * any existing pending broadcast that matches it. Matching is defined
5282 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5283 * true for the intents of the two broadcasts. When a match is found,
5284 * the new broadcast (and receivers associated with it) will replace the
5285 * existing one in the pending broadcast list, remaining at the same
5286 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005287 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005288 * <p>This flag is most typically used with sticky broadcasts, which
5289 * only care about delivering the most recent values of the broadcast
5290 * to their receivers.
5291 */
5292 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5293 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005294 * If set, when sending a broadcast the recipient is allowed to run at
5295 * foreground priority, with a shorter timeout interval. During normal
5296 * broadcasts the receivers are not automatically hoisted out of the
5297 * background priority class.
5298 */
5299 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5300 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005301 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5302 * They can still propagate results through to later receivers, but they can not prevent
5303 * later receivers from seeing the broadcast.
5304 */
5305 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5306 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005307 * If set, when sending a broadcast <i>before boot has completed</i> only
5308 * registered receivers will be called -- no BroadcastReceiver components
5309 * will be launched. Sticky intent state will be recorded properly even
5310 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5311 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005312 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005313 * <p>This flag is only for use by system sevices as a convenience to
5314 * avoid having to implement a more complex mechanism around detection
5315 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005316 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005317 * @hide
5318 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005319 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005320 /**
5321 * Set when this broadcast is for a boot upgrade, a special mode that
5322 * allows the broadcast to be sent before the system is ready and launches
5323 * the app process with no providers running in it.
5324 * @hide
5325 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005326 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005327 /**
5328 * If set, the broadcast will always go to manifest receivers in background (cached
5329 * or not running) apps, regardless of whether that would be done by default. By
5330 * default they will only receive broadcasts if the broadcast has specified an
5331 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005332 *
5333 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5334 * the broadcast code there must also be changed to match.
5335 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005336 * @hide
5337 */
5338 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5339 /**
5340 * If set, the broadcast will never go to manifest receivers in background (cached
5341 * or not running) apps, regardless of whether that would be done by default. By
5342 * default they will receive broadcasts if the broadcast has specified an
5343 * explicit component or package name.
5344 * @hide
5345 */
5346 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005347 /**
5348 * If set, this broadcast is being sent from the shell.
5349 * @hide
5350 */
5351 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005352
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005353 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005354 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5355 * will not receive broadcasts.
5356 *
5357 * <em>This flag has no effect when used by an Instant App.</em>
5358 */
5359 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5360
5361 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005362 * @hide Flags that can't be changed with PendingIntent.
5363 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005364 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5365 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5366 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005367
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005368 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005369 // ---------------------------------------------------------------------
5370 // toUri() and parseUri() options.
5371
5372 /**
5373 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5374 * always has the "intent:" scheme. This syntax can be used when you want
5375 * to later disambiguate between URIs that are intended to describe an
5376 * Intent vs. all others that should be treated as raw URIs. When used
5377 * with {@link #parseUri}, any other scheme will result in a generic
5378 * VIEW action for that raw URI.
5379 */
5380 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005381
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005382 /**
5383 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5384 * always has the "android-app:" scheme. This is a variation of
5385 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5386 * http/https URI being delivered to a specific package name. The format
5387 * is:
5388 *
5389 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005390 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005391 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005392 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5393 * you must also include a scheme; including a path also requires both a host and a scheme.
5394 * The final #Intent; fragment can be used without a scheme, host, or path.
5395 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005396 * used with intents that have a {@link #setSelector}, since the base intent
5397 * will always have an explicit package name.</p>
5398 *
5399 * <p>Some examples of how this scheme maps to Intent objects:</p>
5400 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5401 * <colgroup align="left" />
5402 * <colgroup align="left" />
5403 * <thead>
5404 * <tr><th>URI</th> <th>Intent</th></tr>
5405 * </thead>
5406 *
5407 * <tbody>
5408 * <tr><td><code>android-app://com.example.app</code></td>
5409 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5410 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5411 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5412 * </table></td>
5413 * </tr>
5414 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5415 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5416 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5417 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5418 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5419 * </table></td>
5420 * </tr>
5421 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5422 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5423 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5424 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5425 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5426 * </table></td>
5427 * </tr>
5428 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5429 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5430 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5431 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5432 * </table></td>
5433 * </tr>
5434 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5435 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5436 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5437 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5438 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5439 * </table></td>
5440 * </tr>
5441 * <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>
5442 * <td><table border="" style="margin:0" >
5443 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5444 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5445 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5446 * </table></td>
5447 * </tr>
5448 * </tbody>
5449 * </table>
5450 */
5451 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5452
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005453 /**
5454 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5455 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5456 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5457 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5458 * generated Intent can not cause unexpected data access to happen.
5459 *
5460 * <p>If you do not trust the source of the URI being parsed, you should still do further
5461 * processing to protect yourself from it. In particular, when using it to start an
5462 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5463 * that can handle it.</p>
5464 */
5465 public static final int URI_ALLOW_UNSAFE = 1<<2;
5466
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005467 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468
5469 private String mAction;
5470 private Uri mData;
5471 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005472 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005473 private ComponentName mComponent;
5474 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005475 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005476 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005477 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005478 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005479 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005480 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005481 /** Token to track instant app launches. Local only; do not copy cross-process. */
5482 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005483
5484 // ---------------------------------------------------------------------
5485
5486 /**
5487 * Create an empty intent.
5488 */
5489 public Intent() {
5490 }
5491
5492 /**
5493 * Copy constructor.
5494 */
5495 public Intent(Intent o) {
5496 this.mAction = o.mAction;
5497 this.mData = o.mData;
5498 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005499 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005500 this.mComponent = o.mComponent;
5501 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005502 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005503 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005504 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005505 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005506 }
5507 if (o.mExtras != null) {
5508 this.mExtras = new Bundle(o.mExtras);
5509 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005510 if (o.mSourceBounds != null) {
5511 this.mSourceBounds = new Rect(o.mSourceBounds);
5512 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005513 if (o.mSelector != null) {
5514 this.mSelector = new Intent(o.mSelector);
5515 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005516 if (o.mClipData != null) {
5517 this.mClipData = new ClipData(o.mClipData);
5518 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005519 }
5520
5521 @Override
5522 public Object clone() {
5523 return new Intent(this);
5524 }
5525
5526 private Intent(Intent o, boolean all) {
5527 this.mAction = o.mAction;
5528 this.mData = o.mData;
5529 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005530 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005531 this.mComponent = o.mComponent;
5532 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005533 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005534 }
5535 }
5536
5537 /**
5538 * Make a clone of only the parts of the Intent that are relevant for
5539 * filter matching: the action, data, type, component, and categories.
5540 */
5541 public Intent cloneFilter() {
5542 return new Intent(this, false);
5543 }
5544
5545 /**
5546 * Create an intent with a given action. All other fields (data, type,
5547 * class) are null. Note that the action <em>must</em> be in a
5548 * namespace because Intents are used globally in the system -- for
5549 * example the system VIEW action is android.intent.action.VIEW; an
5550 * application's custom action would be something like
5551 * com.google.app.myapp.CUSTOM_ACTION.
5552 *
5553 * @param action The Intent action, such as ACTION_VIEW.
5554 */
5555 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005556 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005557 }
5558
5559 /**
5560 * Create an intent with a given action and for a given data url. Note
5561 * that the action <em>must</em> be in a namespace because Intents are
5562 * used globally in the system -- for example the system VIEW action is
5563 * android.intent.action.VIEW; an application's custom action would be
5564 * something like com.google.app.myapp.CUSTOM_ACTION.
5565 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005566 * <p><em>Note: scheme and host name matching in the Android framework is
5567 * case-sensitive, unlike the formal RFC. As a result,
5568 * you should always ensure that you write your Uri with these elements
5569 * using lower case letters, and normalize any Uris you receive from
5570 * outside of Android to ensure the scheme and host is lower case.</em></p>
5571 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005572 * @param action The Intent action, such as ACTION_VIEW.
5573 * @param uri The Intent data URI.
5574 */
5575 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005576 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 mData = uri;
5578 }
5579
5580 /**
5581 * Create an intent for a specific component. All other fields (action, data,
5582 * type, class) are null, though they can be modified later with explicit
5583 * calls. This provides a convenient way to create an intent that is
5584 * intended to execute a hard-coded class name, rather than relying on the
5585 * system to find an appropriate class for you; see {@link #setComponent}
5586 * for more information on the repercussions of this.
5587 *
5588 * @param packageContext A Context of the application package implementing
5589 * this class.
5590 * @param cls The component class that is to be used for the intent.
5591 *
5592 * @see #setClass
5593 * @see #setComponent
5594 * @see #Intent(String, android.net.Uri , Context, Class)
5595 */
5596 public Intent(Context packageContext, Class<?> cls) {
5597 mComponent = new ComponentName(packageContext, cls);
5598 }
5599
5600 /**
5601 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005602 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005603 * construct the Intent and then calling {@link #setClass} to set its
5604 * class.
5605 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005606 * <p><em>Note: scheme and host name matching in the Android framework is
5607 * case-sensitive, unlike the formal RFC. As a result,
5608 * you should always ensure that you write your Uri with these elements
5609 * using lower case letters, and normalize any Uris you receive from
5610 * outside of Android to ensure the scheme and host is lower case.</em></p>
5611 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005612 * @param action The Intent action, such as ACTION_VIEW.
5613 * @param uri The Intent data URI.
5614 * @param packageContext A Context of the application package implementing
5615 * this class.
5616 * @param cls The component class that is to be used for the intent.
5617 *
5618 * @see #Intent(String, android.net.Uri)
5619 * @see #Intent(Context, Class)
5620 * @see #setClass
5621 * @see #setComponent
5622 */
5623 public Intent(String action, Uri uri,
5624 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005625 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005626 mData = uri;
5627 mComponent = new ComponentName(packageContext, cls);
5628 }
5629
5630 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005631 * Create an intent to launch the main (root) activity of a task. This
5632 * is the Intent that is started when the application's is launched from
5633 * Home. For anything else that wants to launch an application in the
5634 * same way, it is important that they use an Intent structured the same
5635 * way, and can use this function to ensure this is the case.
5636 *
5637 * <p>The returned Intent has the given Activity component as its explicit
5638 * component, {@link #ACTION_MAIN} as its action, and includes the
5639 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5640 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5641 * to do that through {@link #addFlags(int)} on the returned Intent.
5642 *
5643 * @param mainActivity The main activity component that this Intent will
5644 * launch.
5645 * @return Returns a newly created Intent that can be used to launch the
5646 * activity as a main application entry.
5647 *
5648 * @see #setClass
5649 * @see #setComponent
5650 */
5651 public static Intent makeMainActivity(ComponentName mainActivity) {
5652 Intent intent = new Intent(ACTION_MAIN);
5653 intent.setComponent(mainActivity);
5654 intent.addCategory(CATEGORY_LAUNCHER);
5655 return intent;
5656 }
5657
5658 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005659 * Make an Intent for the main activity of an application, without
5660 * specifying a specific activity to run but giving a selector to find
5661 * the activity. This results in a final Intent that is structured
5662 * the same as when the application is launched from
5663 * Home. For anything else that wants to launch an application in the
5664 * same way, it is important that they use an Intent structured the same
5665 * way, and can use this function to ensure this is the case.
5666 *
5667 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5668 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5669 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5670 * to do that through {@link #addFlags(int)} on the returned Intent.
5671 *
5672 * @param selectorAction The action name of the Intent's selector.
5673 * @param selectorCategory The name of a category to add to the Intent's
5674 * selector.
5675 * @return Returns a newly created Intent that can be used to launch the
5676 * activity as a main application entry.
5677 *
5678 * @see #setSelector(Intent)
5679 */
5680 public static Intent makeMainSelectorActivity(String selectorAction,
5681 String selectorCategory) {
5682 Intent intent = new Intent(ACTION_MAIN);
5683 intent.addCategory(CATEGORY_LAUNCHER);
5684 Intent selector = new Intent();
5685 selector.setAction(selectorAction);
5686 selector.addCategory(selectorCategory);
5687 intent.setSelector(selector);
5688 return intent;
5689 }
5690
5691 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005692 * Make an Intent that can be used to re-launch an application's task
5693 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5694 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5695 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5696 *
5697 * @param mainActivity The activity component that is the root of the
5698 * task; this is the activity that has been published in the application's
5699 * manifest as the main launcher icon.
5700 *
5701 * @return Returns a newly created Intent that can be used to relaunch the
5702 * activity's task in its root state.
5703 */
5704 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5705 Intent intent = makeMainActivity(mainActivity);
5706 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5707 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5708 return intent;
5709 }
5710
5711 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005712 * Call {@link #parseUri} with 0 flags.
5713 * @deprecated Use {@link #parseUri} instead.
5714 */
5715 @Deprecated
5716 public static Intent getIntent(String uri) throws URISyntaxException {
5717 return parseUri(uri, 0);
5718 }
Tom Taylord4a47292009-12-21 13:59:18 -08005719
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005720 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005721 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005722 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005723 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005724 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005725 *
5726 * <p>The URI given here must not be relative -- that is, it must include
5727 * the scheme and full path.
5728 *
5729 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005730 * @param flags Additional processing flags. Either 0,
5731 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 *
5733 * @return Intent The newly created Intent object.
5734 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005735 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5736 * it bad (as parsed by the Uri class) or the Intent data within the
5737 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005738 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005739 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005740 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005741 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005742 int i = 0;
5743 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005744 final boolean androidApp = uri.startsWith("android-app:");
5745
5746 // Validate intent scheme if requested.
5747 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5748 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005749 Intent intent = new Intent(ACTION_VIEW);
5750 try {
5751 intent.setData(Uri.parse(uri));
5752 } catch (IllegalArgumentException e) {
5753 throw new URISyntaxException(uri, e.getMessage());
5754 }
5755 return intent;
5756 }
5757 }
Tom Taylord4a47292009-12-21 13:59:18 -08005758
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005759 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005760 // simple case
5761 if (i == -1) {
5762 if (!androidApp) {
5763 return new Intent(ACTION_VIEW, Uri.parse(uri));
5764 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005765
5766 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005767 } else if (!uri.startsWith("#Intent;", i)) {
5768 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005769 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005770 } else {
5771 i = -1;
5772 }
5773 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005774
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005775 // new format
5776 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005777 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005778 boolean explicitAction = false;
5779 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005780
5781 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005782 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005783 String data;
5784 if (i >= 0) {
5785 data = uri.substring(0, i);
5786 i += 8; // length of "#Intent;"
5787 } else {
5788 data = uri;
5789 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005790
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005791 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005792 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005793 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005794 if (eq < 0) eq = i-1;
5795 int semi = uri.indexOf(';', i);
5796 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005797
5798 // action
5799 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005800 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005801 if (!inSelector) {
5802 explicitAction = true;
5803 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005804 }
5805
5806 // categories
5807 else if (uri.startsWith("category=", i)) {
5808 intent.addCategory(value);
5809 }
5810
5811 // type
5812 else if (uri.startsWith("type=", i)) {
5813 intent.mType = value;
5814 }
5815
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005816 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005817 else if (uri.startsWith("launchFlags=", i)) {
5818 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005819 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5820 intent.mFlags &= ~IMMUTABLE_FLAGS;
5821 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 }
5823
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005824 // package
5825 else if (uri.startsWith("package=", i)) {
5826 intent.mPackage = value;
5827 }
5828
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005829 // component
5830 else if (uri.startsWith("component=", i)) {
5831 intent.mComponent = ComponentName.unflattenFromString(value);
5832 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005833
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005834 // scheme
5835 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005836 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005837 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005838 } else {
5839 scheme = value;
5840 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005841 }
5842
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005843 // source bounds
5844 else if (uri.startsWith("sourceBounds=", i)) {
5845 intent.mSourceBounds = Rect.unflattenFromString(value);
5846 }
5847
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005848 // selector
5849 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5850 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005851 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005852 }
5853
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005854 // extra
5855 else {
5856 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005857 // create Bundle if it doesn't already exist
5858 if (intent.mExtras == null) intent.mExtras = new Bundle();
5859 Bundle b = intent.mExtras;
5860 // add EXTRA
5861 if (uri.startsWith("S.", i)) b.putString(key, value);
5862 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5863 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5864 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5865 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5866 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5867 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5868 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5869 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5870 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5871 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005872
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005873 // move to the next item
5874 i = semi + 1;
5875 }
5876
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005877 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005878 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005879 if (baseIntent.mPackage == null) {
5880 baseIntent.setSelector(intent);
5881 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005882 intent = baseIntent;
5883 }
5884
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005885 if (data != null) {
5886 if (data.startsWith("intent:")) {
5887 data = data.substring(7);
5888 if (scheme != null) {
5889 data = scheme + ':' + data;
5890 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005891 } else if (data.startsWith("android-app:")) {
5892 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5893 // Correctly formed android-app, first part is package name.
5894 int end = data.indexOf('/', 14);
5895 if (end < 0) {
5896 // All we have is a package name.
5897 intent.mPackage = data.substring(14);
5898 if (!explicitAction) {
5899 intent.setAction(ACTION_MAIN);
5900 }
5901 data = "";
5902 } else {
5903 // Target the Intent at the given package name always.
5904 String authority = null;
5905 intent.mPackage = data.substring(14, end);
5906 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005907 if ((end+1) < data.length()) {
5908 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5909 // Found a scheme, remember it.
5910 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005911 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005912 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5913 // Found a authority, remember it.
5914 authority = data.substring(end+1, newEnd);
5915 end = newEnd;
5916 }
5917 } else {
5918 // All we have is a scheme.
5919 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005920 }
5921 }
5922 if (scheme == null) {
5923 // If there was no scheme, then this just targets the package.
5924 if (!explicitAction) {
5925 intent.setAction(ACTION_MAIN);
5926 }
5927 data = "";
5928 } else if (authority == null) {
5929 data = scheme + ":";
5930 } else {
5931 data = scheme + "://" + authority + data.substring(end);
5932 }
5933 }
5934 } else {
5935 data = "";
5936 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005937 }
Tom Taylord4a47292009-12-21 13:59:18 -08005938
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005939 if (data.length() > 0) {
5940 try {
5941 intent.mData = Uri.parse(data);
5942 } catch (IllegalArgumentException e) {
5943 throw new URISyntaxException(uri, e.getMessage());
5944 }
5945 }
5946 }
Tom Taylord4a47292009-12-21 13:59:18 -08005947
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005949
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005950 } catch (IndexOutOfBoundsException e) {
5951 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5952 }
5953 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005954
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005955 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005956 return getIntentOld(uri, 0);
5957 }
5958
5959 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005960 Intent intent;
5961
5962 int i = uri.lastIndexOf('#');
5963 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005964 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005965 final int intentFragmentStart = i;
5966 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005967
5968 i++;
5969
5970 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005971 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005972 i += 7;
5973 int j = uri.indexOf(')', i);
5974 action = uri.substring(i, j);
5975 i = j + 1;
5976 }
5977
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005978 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005979
5980 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005981 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005982 i += 11;
5983 int j = uri.indexOf(')', i);
5984 while (i < j) {
5985 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005986 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005987 if (i < sep) {
5988 intent.addCategory(uri.substring(i, sep));
5989 }
5990 i = sep + 1;
5991 }
5992 i = j + 1;
5993 }
5994
5995 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005996 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005997 i += 5;
5998 int j = uri.indexOf(')', i);
5999 intent.mType = uri.substring(i, j);
6000 i = j + 1;
6001 }
6002
6003 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006004 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 i += 12;
6006 int j = uri.indexOf(')', i);
6007 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006008 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6009 intent.mFlags &= ~IMMUTABLE_FLAGS;
6010 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006011 i = j + 1;
6012 }
6013
6014 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006015 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006016 i += 10;
6017 int j = uri.indexOf(')', i);
6018 int sep = uri.indexOf('!', i);
6019 if (sep >= 0 && sep < j) {
6020 String pkg = uri.substring(i, sep);
6021 String cls = uri.substring(sep + 1, j);
6022 intent.mComponent = new ComponentName(pkg, cls);
6023 }
6024 i = j + 1;
6025 }
6026
6027 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006028 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006029 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006030
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006031 final int closeParen = uri.indexOf(')', i);
6032 if (closeParen == -1) throw new URISyntaxException(uri,
6033 "EXTRA missing trailing ')'", i);
6034
6035 while (i < closeParen) {
6036 // fetch the key value
6037 int j = uri.indexOf('=', i);
6038 if (j <= i + 1 || i >= closeParen) {
6039 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6040 }
6041 char type = uri.charAt(i);
6042 i++;
6043 String key = uri.substring(i, j);
6044 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006045
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006046 // get type-value
6047 j = uri.indexOf('!', i);
6048 if (j == -1 || j >= closeParen) j = closeParen;
6049 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6050 String value = uri.substring(i, j);
6051 i = j;
6052
6053 // create Bundle if it doesn't already exist
6054 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006055
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006056 // add item to bundle
6057 try {
6058 switch (type) {
6059 case 'S':
6060 intent.mExtras.putString(key, Uri.decode(value));
6061 break;
6062 case 'B':
6063 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6064 break;
6065 case 'b':
6066 intent.mExtras.putByte(key, Byte.parseByte(value));
6067 break;
6068 case 'c':
6069 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6070 break;
6071 case 'd':
6072 intent.mExtras.putDouble(key, Double.parseDouble(value));
6073 break;
6074 case 'f':
6075 intent.mExtras.putFloat(key, Float.parseFloat(value));
6076 break;
6077 case 'i':
6078 intent.mExtras.putInt(key, Integer.parseInt(value));
6079 break;
6080 case 'l':
6081 intent.mExtras.putLong(key, Long.parseLong(value));
6082 break;
6083 case 's':
6084 intent.mExtras.putShort(key, Short.parseShort(value));
6085 break;
6086 default:
6087 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6088 }
6089 } catch (NumberFormatException e) {
6090 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6091 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006092
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006093 char ch = uri.charAt(i);
6094 if (ch == ')') break;
6095 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6096 i++;
6097 }
6098 }
6099
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006100 if (isIntentFragment) {
6101 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6102 } else {
6103 intent.mData = Uri.parse(uri);
6104 }
Tom Taylord4a47292009-12-21 13:59:18 -08006105
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006106 if (intent.mAction == null) {
6107 // By default, if no action is specified, then use VIEW.
6108 intent.mAction = ACTION_VIEW;
6109 }
6110
6111 } else {
6112 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6113 }
6114
6115 return intent;
6116 }
6117
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006118 /** @hide */
6119 public interface CommandOptionHandler {
6120 boolean handleOption(String opt, ShellCommand cmd);
6121 }
6122
6123 /** @hide */
6124 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6125 throws URISyntaxException {
6126 Intent intent = new Intent();
6127 Intent baseIntent = intent;
6128 boolean hasIntentInfo = false;
6129
6130 Uri data = null;
6131 String type = null;
6132
6133 String opt;
6134 while ((opt=cmd.getNextOption()) != null) {
6135 switch (opt) {
6136 case "-a":
6137 intent.setAction(cmd.getNextArgRequired());
6138 if (intent == baseIntent) {
6139 hasIntentInfo = true;
6140 }
6141 break;
6142 case "-d":
6143 data = Uri.parse(cmd.getNextArgRequired());
6144 if (intent == baseIntent) {
6145 hasIntentInfo = true;
6146 }
6147 break;
6148 case "-t":
6149 type = cmd.getNextArgRequired();
6150 if (intent == baseIntent) {
6151 hasIntentInfo = true;
6152 }
6153 break;
6154 case "-c":
6155 intent.addCategory(cmd.getNextArgRequired());
6156 if (intent == baseIntent) {
6157 hasIntentInfo = true;
6158 }
6159 break;
6160 case "-e":
6161 case "--es": {
6162 String key = cmd.getNextArgRequired();
6163 String value = cmd.getNextArgRequired();
6164 intent.putExtra(key, value);
6165 }
6166 break;
6167 case "--esn": {
6168 String key = cmd.getNextArgRequired();
6169 intent.putExtra(key, (String) null);
6170 }
6171 break;
6172 case "--ei": {
6173 String key = cmd.getNextArgRequired();
6174 String value = cmd.getNextArgRequired();
6175 intent.putExtra(key, Integer.decode(value));
6176 }
6177 break;
6178 case "--eu": {
6179 String key = cmd.getNextArgRequired();
6180 String value = cmd.getNextArgRequired();
6181 intent.putExtra(key, Uri.parse(value));
6182 }
6183 break;
6184 case "--ecn": {
6185 String key = cmd.getNextArgRequired();
6186 String value = cmd.getNextArgRequired();
6187 ComponentName cn = ComponentName.unflattenFromString(value);
6188 if (cn == null)
6189 throw new IllegalArgumentException("Bad component name: " + value);
6190 intent.putExtra(key, cn);
6191 }
6192 break;
6193 case "--eia": {
6194 String key = cmd.getNextArgRequired();
6195 String value = cmd.getNextArgRequired();
6196 String[] strings = value.split(",");
6197 int[] list = new int[strings.length];
6198 for (int i = 0; i < strings.length; i++) {
6199 list[i] = Integer.decode(strings[i]);
6200 }
6201 intent.putExtra(key, list);
6202 }
6203 break;
6204 case "--eial": {
6205 String key = cmd.getNextArgRequired();
6206 String value = cmd.getNextArgRequired();
6207 String[] strings = value.split(",");
6208 ArrayList<Integer> list = new ArrayList<>(strings.length);
6209 for (int i = 0; i < strings.length; i++) {
6210 list.add(Integer.decode(strings[i]));
6211 }
6212 intent.putExtra(key, list);
6213 }
6214 break;
6215 case "--el": {
6216 String key = cmd.getNextArgRequired();
6217 String value = cmd.getNextArgRequired();
6218 intent.putExtra(key, Long.valueOf(value));
6219 }
6220 break;
6221 case "--ela": {
6222 String key = cmd.getNextArgRequired();
6223 String value = cmd.getNextArgRequired();
6224 String[] strings = value.split(",");
6225 long[] list = new long[strings.length];
6226 for (int i = 0; i < strings.length; i++) {
6227 list[i] = Long.valueOf(strings[i]);
6228 }
6229 intent.putExtra(key, list);
6230 hasIntentInfo = true;
6231 }
6232 break;
6233 case "--elal": {
6234 String key = cmd.getNextArgRequired();
6235 String value = cmd.getNextArgRequired();
6236 String[] strings = value.split(",");
6237 ArrayList<Long> list = new ArrayList<>(strings.length);
6238 for (int i = 0; i < strings.length; i++) {
6239 list.add(Long.valueOf(strings[i]));
6240 }
6241 intent.putExtra(key, list);
6242 hasIntentInfo = true;
6243 }
6244 break;
6245 case "--ef": {
6246 String key = cmd.getNextArgRequired();
6247 String value = cmd.getNextArgRequired();
6248 intent.putExtra(key, Float.valueOf(value));
6249 hasIntentInfo = true;
6250 }
6251 break;
6252 case "--efa": {
6253 String key = cmd.getNextArgRequired();
6254 String value = cmd.getNextArgRequired();
6255 String[] strings = value.split(",");
6256 float[] list = new float[strings.length];
6257 for (int i = 0; i < strings.length; i++) {
6258 list[i] = Float.valueOf(strings[i]);
6259 }
6260 intent.putExtra(key, list);
6261 hasIntentInfo = true;
6262 }
6263 break;
6264 case "--efal": {
6265 String key = cmd.getNextArgRequired();
6266 String value = cmd.getNextArgRequired();
6267 String[] strings = value.split(",");
6268 ArrayList<Float> list = new ArrayList<>(strings.length);
6269 for (int i = 0; i < strings.length; i++) {
6270 list.add(Float.valueOf(strings[i]));
6271 }
6272 intent.putExtra(key, list);
6273 hasIntentInfo = true;
6274 }
6275 break;
6276 case "--esa": {
6277 String key = cmd.getNextArgRequired();
6278 String value = cmd.getNextArgRequired();
6279 // Split on commas unless they are preceeded by an escape.
6280 // The escape character must be escaped for the string and
6281 // again for the regex, thus four escape characters become one.
6282 String[] strings = value.split("(?<!\\\\),");
6283 intent.putExtra(key, strings);
6284 hasIntentInfo = true;
6285 }
6286 break;
6287 case "--esal": {
6288 String key = cmd.getNextArgRequired();
6289 String value = cmd.getNextArgRequired();
6290 // Split on commas unless they are preceeded by an escape.
6291 // The escape character must be escaped for the string and
6292 // again for the regex, thus four escape characters become one.
6293 String[] strings = value.split("(?<!\\\\),");
6294 ArrayList<String> list = new ArrayList<>(strings.length);
6295 for (int i = 0; i < strings.length; i++) {
6296 list.add(strings[i]);
6297 }
6298 intent.putExtra(key, list);
6299 hasIntentInfo = true;
6300 }
6301 break;
6302 case "--ez": {
6303 String key = cmd.getNextArgRequired();
6304 String value = cmd.getNextArgRequired().toLowerCase();
6305 // Boolean.valueOf() results in false for anything that is not "true", which is
6306 // error-prone in shell commands
6307 boolean arg;
6308 if ("true".equals(value) || "t".equals(value)) {
6309 arg = true;
6310 } else if ("false".equals(value) || "f".equals(value)) {
6311 arg = false;
6312 } else {
6313 try {
6314 arg = Integer.decode(value) != 0;
6315 } catch (NumberFormatException ex) {
6316 throw new IllegalArgumentException("Invalid boolean value: " + value);
6317 }
6318 }
6319
6320 intent.putExtra(key, arg);
6321 }
6322 break;
6323 case "-n": {
6324 String str = cmd.getNextArgRequired();
6325 ComponentName cn = ComponentName.unflattenFromString(str);
6326 if (cn == null)
6327 throw new IllegalArgumentException("Bad component name: " + str);
6328 intent.setComponent(cn);
6329 if (intent == baseIntent) {
6330 hasIntentInfo = true;
6331 }
6332 }
6333 break;
6334 case "-p": {
6335 String str = cmd.getNextArgRequired();
6336 intent.setPackage(str);
6337 if (intent == baseIntent) {
6338 hasIntentInfo = true;
6339 }
6340 }
6341 break;
6342 case "-f":
6343 String str = cmd.getNextArgRequired();
6344 intent.setFlags(Integer.decode(str).intValue());
6345 break;
6346 case "--grant-read-uri-permission":
6347 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6348 break;
6349 case "--grant-write-uri-permission":
6350 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6351 break;
6352 case "--grant-persistable-uri-permission":
6353 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6354 break;
6355 case "--grant-prefix-uri-permission":
6356 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6357 break;
6358 case "--exclude-stopped-packages":
6359 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6360 break;
6361 case "--include-stopped-packages":
6362 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6363 break;
6364 case "--debug-log-resolution":
6365 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6366 break;
6367 case "--activity-brought-to-front":
6368 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6369 break;
6370 case "--activity-clear-top":
6371 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6372 break;
6373 case "--activity-clear-when-task-reset":
6374 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6375 break;
6376 case "--activity-exclude-from-recents":
6377 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6378 break;
6379 case "--activity-launched-from-history":
6380 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6381 break;
6382 case "--activity-multiple-task":
6383 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6384 break;
6385 case "--activity-no-animation":
6386 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6387 break;
6388 case "--activity-no-history":
6389 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6390 break;
6391 case "--activity-no-user-action":
6392 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6393 break;
6394 case "--activity-previous-is-top":
6395 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6396 break;
6397 case "--activity-reorder-to-front":
6398 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6399 break;
6400 case "--activity-reset-task-if-needed":
6401 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6402 break;
6403 case "--activity-single-top":
6404 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6405 break;
6406 case "--activity-clear-task":
6407 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6408 break;
6409 case "--activity-task-on-home":
6410 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6411 break;
6412 case "--receiver-registered-only":
6413 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6414 break;
6415 case "--receiver-replace-pending":
6416 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6417 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006418 case "--receiver-foreground":
6419 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6420 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006421 case "--receiver-no-abort":
6422 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6423 break;
6424 case "--receiver-include-background":
6425 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6426 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006427 case "--selector":
6428 intent.setDataAndType(data, type);
6429 intent = new Intent();
6430 break;
6431 default:
6432 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6433 // Okay, caller handled this option.
6434 } else {
6435 throw new IllegalArgumentException("Unknown option: " + opt);
6436 }
6437 break;
6438 }
6439 }
6440 intent.setDataAndType(data, type);
6441
6442 final boolean hasSelector = intent != baseIntent;
6443 if (hasSelector) {
6444 // A selector was specified; fix up.
6445 baseIntent.setSelector(intent);
6446 intent = baseIntent;
6447 }
6448
6449 String arg = cmd.getNextArg();
6450 baseIntent = null;
6451 if (arg == null) {
6452 if (hasSelector) {
6453 // If a selector has been specified, and no arguments
6454 // have been supplied for the main Intent, then we can
6455 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6456 // need to have a component name specified yet, the
6457 // selector will take care of that.
6458 baseIntent = new Intent(Intent.ACTION_MAIN);
6459 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6460 }
6461 } else if (arg.indexOf(':') >= 0) {
6462 // The argument is a URI. Fully parse it, and use that result
6463 // to fill in any data not specified so far.
6464 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6465 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6466 } else if (arg.indexOf('/') >= 0) {
6467 // The argument is a component name. Build an Intent to launch
6468 // it.
6469 baseIntent = new Intent(Intent.ACTION_MAIN);
6470 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6471 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6472 } else {
6473 // Assume the argument is a package name.
6474 baseIntent = new Intent(Intent.ACTION_MAIN);
6475 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6476 baseIntent.setPackage(arg);
6477 }
6478 if (baseIntent != null) {
6479 Bundle extras = intent.getExtras();
6480 intent.replaceExtras((Bundle)null);
6481 Bundle uriExtras = baseIntent.getExtras();
6482 baseIntent.replaceExtras((Bundle)null);
6483 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6484 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6485 for (String c : cats) {
6486 baseIntent.removeCategory(c);
6487 }
6488 }
6489 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6490 if (extras == null) {
6491 extras = uriExtras;
6492 } else if (uriExtras != null) {
6493 uriExtras.putAll(extras);
6494 extras = uriExtras;
6495 }
6496 intent.replaceExtras(extras);
6497 hasIntentInfo = true;
6498 }
6499
6500 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6501 return intent;
6502 }
6503
6504 /** @hide */
6505 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6506 final String[] lines = new String[] {
6507 "<INTENT> specifications include these flags and arguments:",
6508 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6509 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6510 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6511 " [--esn <EXTRA_KEY> ...]",
6512 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6513 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6514 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6515 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6516 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6517 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6518 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6519 " (mutiple extras passed as Integer[])",
6520 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6521 " (mutiple extras passed as List<Integer>)",
6522 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6523 " (mutiple extras passed as Long[])",
6524 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6525 " (mutiple extras passed as List<Long>)",
6526 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6527 " (mutiple extras passed as Float[])",
6528 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6529 " (mutiple extras passed as List<Float>)",
6530 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6531 " (mutiple extras passed as String[]; to embed a comma into a string,",
6532 " escape it using \"\\,\")",
6533 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6534 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6535 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006536 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006537 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6538 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6539 " [--debug-log-resolution] [--exclude-stopped-packages]",
6540 " [--include-stopped-packages]",
6541 " [--activity-brought-to-front] [--activity-clear-top]",
6542 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6543 " [--activity-launched-from-history] [--activity-multiple-task]",
6544 " [--activity-no-animation] [--activity-no-history]",
6545 " [--activity-no-user-action] [--activity-previous-is-top]",
6546 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6547 " [--activity-single-top] [--activity-clear-task]",
6548 " [--activity-task-on-home]",
6549 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006550 " [--receiver-foreground] [--receiver-no-abort]",
6551 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006552 " [--selector]",
6553 " [<URI> | <PACKAGE> | <COMPONENT>]"
6554 };
6555 for (String line : lines) {
6556 pw.print(prefix);
6557 pw.println(line);
6558 }
6559 }
6560
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006561 /**
6562 * Retrieve the general action to be performed, such as
6563 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6564 * the information in the intent should be interpreted -- most importantly,
6565 * what to do with the data returned by {@link #getData}.
6566 *
6567 * @return The action of this intent or null if none is specified.
6568 *
6569 * @see #setAction
6570 */
6571 public String getAction() {
6572 return mAction;
6573 }
6574
6575 /**
6576 * Retrieve data this intent is operating on. This URI specifies the name
6577 * of the data; often it uses the content: scheme, specifying data in a
6578 * content provider. Other schemes may be handled by specific activities,
6579 * such as http: by the web browser.
6580 *
6581 * @return The URI of the data this intent is targeting or null.
6582 *
6583 * @see #getScheme
6584 * @see #setData
6585 */
6586 public Uri getData() {
6587 return mData;
6588 }
6589
6590 /**
6591 * The same as {@link #getData()}, but returns the URI as an encoded
6592 * String.
6593 */
6594 public String getDataString() {
6595 return mData != null ? mData.toString() : null;
6596 }
6597
6598 /**
6599 * Return the scheme portion of the intent's data. If the data is null or
6600 * does not include a scheme, null is returned. Otherwise, the scheme
6601 * prefix without the final ':' is returned, i.e. "http".
6602 *
6603 * <p>This is the same as calling getData().getScheme() (and checking for
6604 * null data).
6605 *
6606 * @return The scheme of this intent.
6607 *
6608 * @see #getData
6609 */
6610 public String getScheme() {
6611 return mData != null ? mData.getScheme() : null;
6612 }
6613
6614 /**
6615 * Retrieve any explicit MIME type included in the intent. This is usually
6616 * null, as the type is determined by the intent data.
6617 *
6618 * @return If a type was manually set, it is returned; else null is
6619 * returned.
6620 *
6621 * @see #resolveType(ContentResolver)
6622 * @see #setType
6623 */
6624 public String getType() {
6625 return mType;
6626 }
6627
6628 /**
6629 * Return the MIME data type of this intent. If the type field is
6630 * explicitly set, that is simply returned. Otherwise, if the data is set,
6631 * the type of that data is returned. If neither fields are set, a null is
6632 * returned.
6633 *
6634 * @return The MIME type of this intent.
6635 *
6636 * @see #getType
6637 * @see #resolveType(ContentResolver)
6638 */
6639 public String resolveType(Context context) {
6640 return resolveType(context.getContentResolver());
6641 }
6642
6643 /**
6644 * Return the MIME data type of this intent. If the type field is
6645 * explicitly set, that is simply returned. Otherwise, if the data is set,
6646 * the type of that data is returned. If neither fields are set, a null is
6647 * returned.
6648 *
6649 * @param resolver A ContentResolver that can be used to determine the MIME
6650 * type of the intent's data.
6651 *
6652 * @return The MIME type of this intent.
6653 *
6654 * @see #getType
6655 * @see #resolveType(Context)
6656 */
6657 public String resolveType(ContentResolver resolver) {
6658 if (mType != null) {
6659 return mType;
6660 }
6661 if (mData != null) {
6662 if ("content".equals(mData.getScheme())) {
6663 return resolver.getType(mData);
6664 }
6665 }
6666 return null;
6667 }
6668
6669 /**
6670 * Return the MIME data type of this intent, only if it will be needed for
6671 * intent resolution. This is not generally useful for application code;
6672 * it is used by the frameworks for communicating with back-end system
6673 * services.
6674 *
6675 * @param resolver A ContentResolver that can be used to determine the MIME
6676 * type of the intent's data.
6677 *
6678 * @return The MIME type of this intent, or null if it is unknown or not
6679 * needed.
6680 */
6681 public String resolveTypeIfNeeded(ContentResolver resolver) {
6682 if (mComponent != null) {
6683 return mType;
6684 }
6685 return resolveType(resolver);
6686 }
6687
6688 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006689 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006690 *
6691 * @param category The category to check.
6692 *
6693 * @return boolean True if the intent contains the category, else false.
6694 *
6695 * @see #getCategories
6696 * @see #addCategory
6697 */
6698 public boolean hasCategory(String category) {
6699 return mCategories != null && mCategories.contains(category);
6700 }
6701
6702 /**
6703 * Return the set of all categories in the intent. If there are no categories,
6704 * returns NULL.
6705 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006706 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006707 *
6708 * @see #hasCategory
6709 * @see #addCategory
6710 */
6711 public Set<String> getCategories() {
6712 return mCategories;
6713 }
6714
6715 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006716 * Return the specific selector associated with this Intent. If there is
6717 * none, returns null. See {@link #setSelector} for more information.
6718 *
6719 * @see #setSelector
6720 */
6721 public Intent getSelector() {
6722 return mSelector;
6723 }
6724
6725 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006726 * Return the {@link ClipData} associated with this Intent. If there is
6727 * none, returns null. See {@link #setClipData} for more information.
6728 *
John Spurlock125d1332013-11-25 11:58:37 -05006729 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006730 */
6731 public ClipData getClipData() {
6732 return mClipData;
6733 }
6734
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006735 /** @hide */
6736 public int getContentUserHint() {
6737 return mContentUserHint;
6738 }
6739
Todd Kennedyb3b431302017-03-20 16:05:48 -07006740 /** @hide */
6741 public String getLaunchToken() {
6742 return mLaunchToken;
6743 }
6744
6745 /** @hide */
6746 public void setLaunchToken(String launchToken) {
6747 mLaunchToken = launchToken;
6748 }
6749
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006751 * Sets the ClassLoader that will be used when unmarshalling
6752 * any Parcelable values from the extras of this Intent.
6753 *
6754 * @param loader a ClassLoader, or null to use the default loader
6755 * at the time of unmarshalling.
6756 */
6757 public void setExtrasClassLoader(ClassLoader loader) {
6758 if (mExtras != null) {
6759 mExtras.setClassLoader(loader);
6760 }
6761 }
6762
6763 /**
6764 * Returns true if an extra value is associated with the given name.
6765 * @param name the extra's name
6766 * @return true if the given extra is present.
6767 */
6768 public boolean hasExtra(String name) {
6769 return mExtras != null && mExtras.containsKey(name);
6770 }
6771
6772 /**
6773 * Returns true if the Intent's extras contain a parcelled file descriptor.
6774 * @return true if the Intent contains a parcelled file descriptor.
6775 */
6776 public boolean hasFileDescriptors() {
6777 return mExtras != null && mExtras.hasFileDescriptors();
6778 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006779
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006780 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006781 public void setAllowFds(boolean allowFds) {
6782 if (mExtras != null) {
6783 mExtras.setAllowFds(allowFds);
6784 }
6785 }
6786
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006787 /** {@hide} */
6788 public void setDefusable(boolean defusable) {
6789 if (mExtras != null) {
6790 mExtras.setDefusable(defusable);
6791 }
6792 }
6793
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006794 /**
6795 * Retrieve extended data from the intent.
6796 *
6797 * @param name The name of the desired item.
6798 *
6799 * @return the value of an item that previously added with putExtra()
6800 * or null if none was found.
6801 *
6802 * @deprecated
6803 * @hide
6804 */
6805 @Deprecated
6806 public Object getExtra(String name) {
6807 return getExtra(name, null);
6808 }
6809
6810 /**
6811 * Retrieve extended data from the intent.
6812 *
6813 * @param name The name of the desired item.
6814 * @param defaultValue the value to be returned if no value of the desired
6815 * type is stored with the given name.
6816 *
6817 * @return the value of an item that previously added with putExtra()
6818 * or the default value if none was found.
6819 *
6820 * @see #putExtra(String, boolean)
6821 */
6822 public boolean getBooleanExtra(String name, boolean defaultValue) {
6823 return mExtras == null ? defaultValue :
6824 mExtras.getBoolean(name, defaultValue);
6825 }
6826
6827 /**
6828 * Retrieve extended data from the intent.
6829 *
6830 * @param name The name of the desired item.
6831 * @param defaultValue the value to be returned if no value of the desired
6832 * type is stored with the given name.
6833 *
6834 * @return the value of an item that previously added with putExtra()
6835 * or the default value if none was found.
6836 *
6837 * @see #putExtra(String, byte)
6838 */
6839 public byte getByteExtra(String name, byte defaultValue) {
6840 return mExtras == null ? defaultValue :
6841 mExtras.getByte(name, defaultValue);
6842 }
6843
6844 /**
6845 * Retrieve extended data from the intent.
6846 *
6847 * @param name The name of the desired item.
6848 * @param defaultValue the value to be returned if no value of the desired
6849 * type is stored with the given name.
6850 *
6851 * @return the value of an item that previously added with putExtra()
6852 * or the default value if none was found.
6853 *
6854 * @see #putExtra(String, short)
6855 */
6856 public short getShortExtra(String name, short defaultValue) {
6857 return mExtras == null ? defaultValue :
6858 mExtras.getShort(name, defaultValue);
6859 }
6860
6861 /**
6862 * Retrieve extended data from the intent.
6863 *
6864 * @param name The name of the desired item.
6865 * @param defaultValue the value to be returned if no value of the desired
6866 * type is stored with the given name.
6867 *
6868 * @return the value of an item that previously added with putExtra()
6869 * or the default value if none was found.
6870 *
6871 * @see #putExtra(String, char)
6872 */
6873 public char getCharExtra(String name, char defaultValue) {
6874 return mExtras == null ? defaultValue :
6875 mExtras.getChar(name, defaultValue);
6876 }
6877
6878 /**
6879 * Retrieve extended data from the intent.
6880 *
6881 * @param name The name of the desired item.
6882 * @param defaultValue the value to be returned if no value of the desired
6883 * type is stored with the given name.
6884 *
6885 * @return the value of an item that previously added with putExtra()
6886 * or the default value if none was found.
6887 *
6888 * @see #putExtra(String, int)
6889 */
6890 public int getIntExtra(String name, int defaultValue) {
6891 return mExtras == null ? defaultValue :
6892 mExtras.getInt(name, defaultValue);
6893 }
6894
6895 /**
6896 * Retrieve extended data from the intent.
6897 *
6898 * @param name The name of the desired item.
6899 * @param defaultValue the value to be returned if no value of the desired
6900 * type is stored with the given name.
6901 *
6902 * @return the value of an item that previously added with putExtra()
6903 * or the default value if none was found.
6904 *
6905 * @see #putExtra(String, long)
6906 */
6907 public long getLongExtra(String name, long defaultValue) {
6908 return mExtras == null ? defaultValue :
6909 mExtras.getLong(name, defaultValue);
6910 }
6911
6912 /**
6913 * Retrieve extended data from the intent.
6914 *
6915 * @param name The name of the desired item.
6916 * @param defaultValue the value to be returned if no value of the desired
6917 * type is stored with the given name.
6918 *
6919 * @return the value of an item that previously added with putExtra(),
6920 * or the default value if no such item is present
6921 *
6922 * @see #putExtra(String, float)
6923 */
6924 public float getFloatExtra(String name, float defaultValue) {
6925 return mExtras == null ? defaultValue :
6926 mExtras.getFloat(name, defaultValue);
6927 }
6928
6929 /**
6930 * Retrieve extended data from the intent.
6931 *
6932 * @param name The name of the desired item.
6933 * @param defaultValue the value to be returned if no value of the desired
6934 * type is stored with the given name.
6935 *
6936 * @return the value of an item that previously added with putExtra()
6937 * or the default value if none was found.
6938 *
6939 * @see #putExtra(String, double)
6940 */
6941 public double getDoubleExtra(String name, double defaultValue) {
6942 return mExtras == null ? defaultValue :
6943 mExtras.getDouble(name, defaultValue);
6944 }
6945
6946 /**
6947 * Retrieve extended data from the intent.
6948 *
6949 * @param name The name of the desired item.
6950 *
6951 * @return the value of an item that previously added with putExtra()
6952 * or null if no String value was found.
6953 *
6954 * @see #putExtra(String, String)
6955 */
6956 public String getStringExtra(String name) {
6957 return mExtras == null ? null : mExtras.getString(name);
6958 }
6959
6960 /**
6961 * Retrieve extended data from the intent.
6962 *
6963 * @param name The name of the desired item.
6964 *
6965 * @return the value of an item that previously added with putExtra()
6966 * or null if no CharSequence value was found.
6967 *
6968 * @see #putExtra(String, CharSequence)
6969 */
6970 public CharSequence getCharSequenceExtra(String name) {
6971 return mExtras == null ? null : mExtras.getCharSequence(name);
6972 }
6973
6974 /**
6975 * Retrieve extended data from the intent.
6976 *
6977 * @param name The name of the desired item.
6978 *
6979 * @return the value of an item that previously added with putExtra()
6980 * or null if no Parcelable value was found.
6981 *
6982 * @see #putExtra(String, Parcelable)
6983 */
6984 public <T extends Parcelable> T getParcelableExtra(String name) {
6985 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6986 }
6987
6988 /**
6989 * Retrieve extended data from the intent.
6990 *
6991 * @param name The name of the desired item.
6992 *
6993 * @return the value of an item that previously added with putExtra()
6994 * or null if no Parcelable[] value was found.
6995 *
6996 * @see #putExtra(String, Parcelable[])
6997 */
6998 public Parcelable[] getParcelableArrayExtra(String name) {
6999 return mExtras == null ? null : mExtras.getParcelableArray(name);
7000 }
7001
7002 /**
7003 * Retrieve extended data from the intent.
7004 *
7005 * @param name The name of the desired item.
7006 *
7007 * @return the value of an item that previously added with putExtra()
7008 * or null if no ArrayList<Parcelable> value was found.
7009 *
7010 * @see #putParcelableArrayListExtra(String, ArrayList)
7011 */
7012 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7013 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7014 }
7015
7016 /**
7017 * Retrieve extended data from the intent.
7018 *
7019 * @param name The name of the desired item.
7020 *
7021 * @return the value of an item that previously added with putExtra()
7022 * or null if no Serializable value was found.
7023 *
7024 * @see #putExtra(String, Serializable)
7025 */
7026 public Serializable getSerializableExtra(String name) {
7027 return mExtras == null ? null : mExtras.getSerializable(name);
7028 }
7029
7030 /**
7031 * Retrieve extended data from the intent.
7032 *
7033 * @param name The name of the desired item.
7034 *
7035 * @return the value of an item that previously added with putExtra()
7036 * or null if no ArrayList<Integer> value was found.
7037 *
7038 * @see #putIntegerArrayListExtra(String, ArrayList)
7039 */
7040 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7041 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7042 }
7043
7044 /**
7045 * Retrieve extended data from the intent.
7046 *
7047 * @param name The name of the desired item.
7048 *
7049 * @return the value of an item that previously added with putExtra()
7050 * or null if no ArrayList<String> value was found.
7051 *
7052 * @see #putStringArrayListExtra(String, ArrayList)
7053 */
7054 public ArrayList<String> getStringArrayListExtra(String name) {
7055 return mExtras == null ? null : mExtras.getStringArrayList(name);
7056 }
7057
7058 /**
7059 * Retrieve extended data from the intent.
7060 *
7061 * @param name The name of the desired item.
7062 *
7063 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007064 * or null if no ArrayList<CharSequence> value was found.
7065 *
7066 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7067 */
7068 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7069 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7070 }
7071
7072 /**
7073 * Retrieve extended data from the intent.
7074 *
7075 * @param name The name of the desired item.
7076 *
7077 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007078 * or null if no boolean array value was found.
7079 *
7080 * @see #putExtra(String, boolean[])
7081 */
7082 public boolean[] getBooleanArrayExtra(String name) {
7083 return mExtras == null ? null : mExtras.getBooleanArray(name);
7084 }
7085
7086 /**
7087 * Retrieve extended data from the intent.
7088 *
7089 * @param name The name of the desired item.
7090 *
7091 * @return the value of an item that previously added with putExtra()
7092 * or null if no byte array value was found.
7093 *
7094 * @see #putExtra(String, byte[])
7095 */
7096 public byte[] getByteArrayExtra(String name) {
7097 return mExtras == null ? null : mExtras.getByteArray(name);
7098 }
7099
7100 /**
7101 * Retrieve extended data from the intent.
7102 *
7103 * @param name The name of the desired item.
7104 *
7105 * @return the value of an item that previously added with putExtra()
7106 * or null if no short array value was found.
7107 *
7108 * @see #putExtra(String, short[])
7109 */
7110 public short[] getShortArrayExtra(String name) {
7111 return mExtras == null ? null : mExtras.getShortArray(name);
7112 }
7113
7114 /**
7115 * Retrieve extended data from the intent.
7116 *
7117 * @param name The name of the desired item.
7118 *
7119 * @return the value of an item that previously added with putExtra()
7120 * or null if no char array value was found.
7121 *
7122 * @see #putExtra(String, char[])
7123 */
7124 public char[] getCharArrayExtra(String name) {
7125 return mExtras == null ? null : mExtras.getCharArray(name);
7126 }
7127
7128 /**
7129 * Retrieve extended data from the intent.
7130 *
7131 * @param name The name of the desired item.
7132 *
7133 * @return the value of an item that previously added with putExtra()
7134 * or null if no int array value was found.
7135 *
7136 * @see #putExtra(String, int[])
7137 */
7138 public int[] getIntArrayExtra(String name) {
7139 return mExtras == null ? null : mExtras.getIntArray(name);
7140 }
7141
7142 /**
7143 * Retrieve extended data from the intent.
7144 *
7145 * @param name The name of the desired item.
7146 *
7147 * @return the value of an item that previously added with putExtra()
7148 * or null if no long array value was found.
7149 *
7150 * @see #putExtra(String, long[])
7151 */
7152 public long[] getLongArrayExtra(String name) {
7153 return mExtras == null ? null : mExtras.getLongArray(name);
7154 }
7155
7156 /**
7157 * Retrieve extended data from the intent.
7158 *
7159 * @param name The name of the desired item.
7160 *
7161 * @return the value of an item that previously added with putExtra()
7162 * or null if no float array value was found.
7163 *
7164 * @see #putExtra(String, float[])
7165 */
7166 public float[] getFloatArrayExtra(String name) {
7167 return mExtras == null ? null : mExtras.getFloatArray(name);
7168 }
7169
7170 /**
7171 * Retrieve extended data from the intent.
7172 *
7173 * @param name The name of the desired item.
7174 *
7175 * @return the value of an item that previously added with putExtra()
7176 * or null if no double array value was found.
7177 *
7178 * @see #putExtra(String, double[])
7179 */
7180 public double[] getDoubleArrayExtra(String name) {
7181 return mExtras == null ? null : mExtras.getDoubleArray(name);
7182 }
7183
7184 /**
7185 * Retrieve extended data from the intent.
7186 *
7187 * @param name The name of the desired item.
7188 *
7189 * @return the value of an item that previously added with putExtra()
7190 * or null if no String array value was found.
7191 *
7192 * @see #putExtra(String, String[])
7193 */
7194 public String[] getStringArrayExtra(String name) {
7195 return mExtras == null ? null : mExtras.getStringArray(name);
7196 }
7197
7198 /**
7199 * Retrieve extended data from the intent.
7200 *
7201 * @param name The name of the desired item.
7202 *
7203 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007204 * or null if no CharSequence array value was found.
7205 *
7206 * @see #putExtra(String, CharSequence[])
7207 */
7208 public CharSequence[] getCharSequenceArrayExtra(String name) {
7209 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7210 }
7211
7212 /**
7213 * Retrieve extended data from the intent.
7214 *
7215 * @param name The name of the desired item.
7216 *
7217 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007218 * or null if no Bundle value was found.
7219 *
7220 * @see #putExtra(String, Bundle)
7221 */
7222 public Bundle getBundleExtra(String name) {
7223 return mExtras == null ? null : mExtras.getBundle(name);
7224 }
7225
7226 /**
7227 * Retrieve extended data from the intent.
7228 *
7229 * @param name The name of the desired item.
7230 *
7231 * @return the value of an item that previously added with putExtra()
7232 * or null if no IBinder value was found.
7233 *
7234 * @see #putExtra(String, IBinder)
7235 *
7236 * @deprecated
7237 * @hide
7238 */
7239 @Deprecated
7240 public IBinder getIBinderExtra(String name) {
7241 return mExtras == null ? null : mExtras.getIBinder(name);
7242 }
7243
7244 /**
7245 * Retrieve extended data from the intent.
7246 *
7247 * @param name The name of the desired item.
7248 * @param defaultValue The default value to return in case no item is
7249 * associated with the key 'name'
7250 *
7251 * @return the value of an item that previously added with putExtra()
7252 * or defaultValue if none was found.
7253 *
7254 * @see #putExtra
7255 *
7256 * @deprecated
7257 * @hide
7258 */
7259 @Deprecated
7260 public Object getExtra(String name, Object defaultValue) {
7261 Object result = defaultValue;
7262 if (mExtras != null) {
7263 Object result2 = mExtras.get(name);
7264 if (result2 != null) {
7265 result = result2;
7266 }
7267 }
7268
7269 return result;
7270 }
7271
7272 /**
7273 * Retrieves a map of extended data from the intent.
7274 *
7275 * @return the map of all extras previously added with putExtra(),
7276 * or null if none have been added.
7277 */
7278 public Bundle getExtras() {
7279 return (mExtras != null)
7280 ? new Bundle(mExtras)
7281 : null;
7282 }
7283
7284 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007285 * Filter extras to only basic types.
7286 * @hide
7287 */
7288 public void removeUnsafeExtras() {
7289 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007290 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007291 }
7292 }
7293
7294 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007295 * Retrieve any special flags associated with this intent. You will
7296 * normally just set them with {@link #setFlags} and let the system
7297 * take the appropriate action with them.
7298 *
7299 * @return int The currently set flags.
7300 *
7301 * @see #setFlags
7302 */
7303 public int getFlags() {
7304 return mFlags;
7305 }
7306
Dianne Hackborne7f97212011-02-24 14:40:20 -08007307 /** @hide */
7308 public boolean isExcludingStopped() {
7309 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7310 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7311 }
7312
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007313 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007314 * Retrieve the application package name this Intent is limited to. When
7315 * resolving an Intent, if non-null this limits the resolution to only
7316 * components in the given application package.
7317 *
7318 * @return The name of the application package for the Intent.
7319 *
7320 * @see #resolveActivity
7321 * @see #setPackage
7322 */
7323 public String getPackage() {
7324 return mPackage;
7325 }
7326
7327 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007328 * Retrieve the concrete component associated with the intent. When receiving
7329 * an intent, this is the component that was found to best handle it (that is,
7330 * yourself) and will always be non-null; in all other cases it will be
7331 * null unless explicitly set.
7332 *
7333 * @return The name of the application component to handle the intent.
7334 *
7335 * @see #resolveActivity
7336 * @see #setComponent
7337 */
7338 public ComponentName getComponent() {
7339 return mComponent;
7340 }
7341
7342 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007343 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7344 * used as a hint to the receiver for animations and the like. Null means that there
7345 * is no source bounds.
7346 */
7347 public Rect getSourceBounds() {
7348 return mSourceBounds;
7349 }
7350
7351 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007352 * Return the Activity component that should be used to handle this intent.
7353 * The appropriate component is determined based on the information in the
7354 * intent, evaluated as follows:
7355 *
7356 * <p>If {@link #getComponent} returns an explicit class, that is returned
7357 * without any further consideration.
7358 *
7359 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7360 * category to be considered.
7361 *
7362 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7363 * action.
7364 *
7365 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7366 * this type.
7367 *
7368 * <p>If {@link #addCategory} has added any categories, the activity must
7369 * handle ALL of the categories specified.
7370 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007371 * <p>If {@link #getPackage} is non-NULL, only activity components in
7372 * that application package will be considered.
7373 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007374 * <p>If there are no activities that satisfy all of these conditions, a
7375 * null string is returned.
7376 *
7377 * <p>If multiple activities are found to satisfy the intent, the one with
7378 * the highest priority will be used. If there are multiple activities
7379 * with the same priority, the system will either pick the best activity
7380 * based on user preference, or resolve to a system class that will allow
7381 * the user to pick an activity and forward from there.
7382 *
7383 * <p>This method is implemented simply by calling
7384 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7385 * true.</p>
7386 * <p> This API is called for you as part of starting an activity from an
7387 * intent. You do not normally need to call it yourself.</p>
7388 *
7389 * @param pm The package manager with which to resolve the Intent.
7390 *
7391 * @return Name of the component implementing an activity that can
7392 * display the intent.
7393 *
7394 * @see #setComponent
7395 * @see #getComponent
7396 * @see #resolveActivityInfo
7397 */
7398 public ComponentName resolveActivity(PackageManager pm) {
7399 if (mComponent != null) {
7400 return mComponent;
7401 }
7402
7403 ResolveInfo info = pm.resolveActivity(
7404 this, PackageManager.MATCH_DEFAULT_ONLY);
7405 if (info != null) {
7406 return new ComponentName(
7407 info.activityInfo.applicationInfo.packageName,
7408 info.activityInfo.name);
7409 }
7410
7411 return null;
7412 }
7413
7414 /**
7415 * Resolve the Intent into an {@link ActivityInfo}
7416 * describing the activity that should execute the intent. Resolution
7417 * follows the same rules as described for {@link #resolveActivity}, but
7418 * you get back the completely information about the resolved activity
7419 * instead of just its class name.
7420 *
7421 * @param pm The package manager with which to resolve the Intent.
7422 * @param flags Addition information to retrieve as per
7423 * {@link PackageManager#getActivityInfo(ComponentName, int)
7424 * PackageManager.getActivityInfo()}.
7425 *
7426 * @return PackageManager.ActivityInfo
7427 *
7428 * @see #resolveActivity
7429 */
7430 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7431 ActivityInfo ai = null;
7432 if (mComponent != null) {
7433 try {
7434 ai = pm.getActivityInfo(mComponent, flags);
7435 } catch (PackageManager.NameNotFoundException e) {
7436 // ignore
7437 }
7438 } else {
7439 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007440 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007441 if (info != null) {
7442 ai = info.activityInfo;
7443 }
7444 }
7445
7446 return ai;
7447 }
7448
7449 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007450 * Special function for use by the system to resolve service
7451 * intents to system apps. Throws an exception if there are
7452 * multiple potential matches to the Intent. Returns null if
7453 * there are no matches.
7454 * @hide
7455 */
7456 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7457 if (mComponent != null) {
7458 return mComponent;
7459 }
7460
7461 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7462 if (results == null) {
7463 return null;
7464 }
7465 ComponentName comp = null;
7466 for (int i=0; i<results.size(); i++) {
7467 ResolveInfo ri = results.get(i);
7468 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7469 continue;
7470 }
7471 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7472 ri.serviceInfo.name);
7473 if (comp != null) {
7474 throw new IllegalStateException("Multiple system services handle " + this
7475 + ": " + comp + ", " + foundComp);
7476 }
7477 comp = foundComp;
7478 }
7479 return comp;
7480 }
7481
7482 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007483 * Set the general action to be performed.
7484 *
7485 * @param action An action name, such as ACTION_VIEW. Application-specific
7486 * actions should be prefixed with the vendor's package name.
7487 *
7488 * @return Returns the same Intent object, for chaining multiple calls
7489 * into a single statement.
7490 *
7491 * @see #getAction
7492 */
7493 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007494 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007495 return this;
7496 }
7497
7498 /**
7499 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007500 * clears any type that was previously set by {@link #setType} or
7501 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007502 *
Nick Pellyccae4122012-01-09 14:12:58 -08007503 * <p><em>Note: scheme matching in the Android framework is
7504 * case-sensitive, unlike the formal RFC. As a result,
7505 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007506 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007507 * {@link #setDataAndNormalize}
7508 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007509 *
Nick Pellyccae4122012-01-09 14:12:58 -08007510 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007511 *
7512 * @return Returns the same Intent object, for chaining multiple calls
7513 * into a single statement.
7514 *
7515 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007516 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007517 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007518 */
7519 public Intent setData(Uri data) {
7520 mData = data;
7521 mType = null;
7522 return this;
7523 }
7524
7525 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007526 * Normalize and set the data this intent is operating on.
7527 *
7528 * <p>This method automatically clears any type that was
7529 * previously set (for example, by {@link #setType}).
7530 *
7531 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007532 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007533 * so really this is just a convenience method for
7534 * <pre>
7535 * setData(data.normalize())
7536 * </pre>
7537 *
7538 * @param data The Uri of the data this intent is now targeting.
7539 *
7540 * @return Returns the same Intent object, for chaining multiple calls
7541 * into a single statement.
7542 *
7543 * @see #getData
7544 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007545 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007546 */
7547 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007548 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007549 }
7550
7551 /**
7552 * Set an explicit MIME data type.
7553 *
7554 * <p>This is used to create intents that only specify a type and not data,
7555 * for example to indicate the type of data to return.
7556 *
7557 * <p>This method automatically clears any data that was
7558 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007559 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007560 * <p><em>Note: MIME type matching in the Android framework is
7561 * case-sensitive, unlike formal RFC MIME types. As a result,
7562 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007563 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7564 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007565 *
7566 * @param type The MIME type of the data being handled by this intent.
7567 *
7568 * @return Returns the same Intent object, for chaining multiple calls
7569 * into a single statement.
7570 *
7571 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007572 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007573 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007574 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007575 */
7576 public Intent setType(String type) {
7577 mData = null;
7578 mType = type;
7579 return this;
7580 }
7581
7582 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007583 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007584 *
Nick Pellyccae4122012-01-09 14:12:58 -08007585 * <p>This is used to create intents that only specify a type and not data,
7586 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007587 *
Nick Pellyccae4122012-01-09 14:12:58 -08007588 * <p>This method automatically clears any data that was
7589 * previously set (for example by {@link #setData}).
7590 *
7591 * <p>The MIME type is normalized using
7592 * {@link #normalizeMimeType} before it is set,
7593 * so really this is just a convenience method for
7594 * <pre>
7595 * setType(Intent.normalizeMimeType(type))
7596 * </pre>
7597 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007598 * @param type The MIME type of the data being handled by this intent.
7599 *
7600 * @return Returns the same Intent object, for chaining multiple calls
7601 * into a single statement.
7602 *
Nick Pellyccae4122012-01-09 14:12:58 -08007603 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007604 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007605 * @see #normalizeMimeType
7606 */
7607 public Intent setTypeAndNormalize(String type) {
7608 return setType(normalizeMimeType(type));
7609 }
7610
7611 /**
7612 * (Usually optional) Set the data for the intent along with an explicit
7613 * MIME data type. This method should very rarely be used -- it allows you
7614 * to override the MIME type that would ordinarily be inferred from the
7615 * data with your own type given here.
7616 *
7617 * <p><em>Note: MIME type and Uri scheme matching in the
7618 * Android framework is case-sensitive, unlike the formal RFC definitions.
7619 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007620 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007621 * {@link #setDataAndTypeAndNormalize}
7622 * to ensure that they are converted to lower case.</em>
7623 *
7624 * @param data The Uri of the data this intent is now targeting.
7625 * @param type The MIME type of the data being handled by this intent.
7626 *
7627 * @return Returns the same Intent object, for chaining multiple calls
7628 * into a single statement.
7629 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007630 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007631 * @see #setData
7632 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007633 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007634 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007635 */
7636 public Intent setDataAndType(Uri data, String type) {
7637 mData = data;
7638 mType = type;
7639 return this;
7640 }
7641
7642 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007643 * (Usually optional) Normalize and set both the data Uri and an explicit
7644 * MIME data type. This method should very rarely be used -- it allows you
7645 * to override the MIME type that would ordinarily be inferred from the
7646 * data with your own type given here.
7647 *
7648 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007649 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007650 * before they are set, so really this is just a convenience method for
7651 * <pre>
7652 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7653 * </pre>
7654 *
7655 * @param data The Uri of the data this intent is now targeting.
7656 * @param type The MIME type of the data being handled by this intent.
7657 *
7658 * @return Returns the same Intent object, for chaining multiple calls
7659 * into a single statement.
7660 *
7661 * @see #setType
7662 * @see #setData
7663 * @see #setDataAndType
7664 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007665 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007666 */
7667 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007668 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007669 }
7670
7671 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007672 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007673 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007674 * activities that provide <em>all</em> of the requested categories will be
7675 * used.
7676 *
7677 * @param category The desired category. This can be either one of the
7678 * predefined Intent categories, or a custom category in your own
7679 * namespace.
7680 *
7681 * @return Returns the same Intent object, for chaining multiple calls
7682 * into a single statement.
7683 *
7684 * @see #hasCategory
7685 * @see #removeCategory
7686 */
7687 public Intent addCategory(String category) {
7688 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007689 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007690 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007691 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007692 return this;
7693 }
7694
7695 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007696 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007697 *
7698 * @param category The category to remove.
7699 *
7700 * @see #addCategory
7701 */
7702 public void removeCategory(String category) {
7703 if (mCategories != null) {
7704 mCategories.remove(category);
7705 if (mCategories.size() == 0) {
7706 mCategories = null;
7707 }
7708 }
7709 }
7710
7711 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007712 * Set a selector for this Intent. This is a modification to the kinds of
7713 * things the Intent will match. If the selector is set, it will be used
7714 * when trying to find entities that can handle the Intent, instead of the
7715 * main contents of the Intent. This allows you build an Intent containing
7716 * a generic protocol while targeting it more specifically.
7717 *
7718 * <p>An example of where this may be used is with things like
7719 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7720 * Intent that will launch the Browser application. However, the correct
7721 * main entry point of an application is actually {@link #ACTION_MAIN}
7722 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7723 * used to specify the actual Activity to launch. If you launch the browser
7724 * with something different, undesired behavior may happen if the user has
7725 * previously or later launches it the normal way, since they do not match.
7726 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7727 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7728 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7729 *
7730 * <p>Setting a selector does not impact the behavior of
7731 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7732 * desired behavior of a selector -- it does not impact the base meaning
7733 * of the Intent, just what kinds of things will be matched against it
7734 * when determining who can handle it.</p>
7735 *
7736 * <p>You can not use both a selector and {@link #setPackage(String)} on
7737 * the same base Intent.</p>
7738 *
7739 * @param selector The desired selector Intent; set to null to not use
7740 * a special selector.
7741 */
7742 public void setSelector(Intent selector) {
7743 if (selector == this) {
7744 throw new IllegalArgumentException(
7745 "Intent being set as a selector of itself");
7746 }
7747 if (selector != null && mPackage != null) {
7748 throw new IllegalArgumentException(
7749 "Can't set selector when package name is already set");
7750 }
7751 mSelector = selector;
7752 }
7753
7754 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007755 * Set a {@link ClipData} associated with this Intent. This replaces any
7756 * previously set ClipData.
7757 *
7758 * <p>The ClipData in an intent is not used for Intent matching or other
7759 * such operations. Semantically it is like extras, used to transmit
7760 * additional data with the Intent. The main feature of using this over
7761 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7762 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7763 * items included in the clip data. This is useful, in particular, if
7764 * you want to transmit an Intent containing multiple <code>content:</code>
7765 * URIs for which the recipient may not have global permission to access the
7766 * content provider.
7767 *
7768 * <p>If the ClipData contains items that are themselves Intents, any
7769 * grant flags in those Intents will be ignored. Only the top-level flags
7770 * of the main Intent are respected, and will be applied to all Uri or
7771 * Intent items in the clip (or sub-items of the clip).
7772 *
7773 * <p>The MIME type, label, and icon in the ClipData object are not
7774 * directly used by Intent. Applications should generally rely on the
7775 * MIME type of the Intent itself, not what it may find in the ClipData.
7776 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007777 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007778 *
7779 * @param clip The new clip to set. May be null to clear the current clip.
7780 */
7781 public void setClipData(ClipData clip) {
7782 mClipData = clip;
7783 }
7784
7785 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007786 * This is NOT a secure mechanism to identify the user who sent the intent.
7787 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7788 * who sent the intent.
7789 * @hide
7790 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007791 public void prepareToLeaveUser(int userId) {
7792 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7793 // We want mContentUserHint to refer to the original user, so don't do anything.
7794 if (mContentUserHint == UserHandle.USER_CURRENT) {
7795 mContentUserHint = userId;
7796 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007797 }
7798
7799 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007800 * Add extended data to the intent. The name must include a package
7801 * prefix, for example the app com.android.contacts would use names
7802 * like "com.android.contacts.ShowAll".
7803 *
7804 * @param name The name of the extra data, with package prefix.
7805 * @param value The boolean data value.
7806 *
7807 * @return Returns the same Intent object, for chaining multiple calls
7808 * into a single statement.
7809 *
7810 * @see #putExtras
7811 * @see #removeExtra
7812 * @see #getBooleanExtra(String, boolean)
7813 */
7814 public Intent putExtra(String name, boolean value) {
7815 if (mExtras == null) {
7816 mExtras = new Bundle();
7817 }
7818 mExtras.putBoolean(name, value);
7819 return this;
7820 }
7821
7822 /**
7823 * Add extended data to the intent. The name must include a package
7824 * prefix, for example the app com.android.contacts would use names
7825 * like "com.android.contacts.ShowAll".
7826 *
7827 * @param name The name of the extra data, with package prefix.
7828 * @param value The byte data value.
7829 *
7830 * @return Returns the same Intent object, for chaining multiple calls
7831 * into a single statement.
7832 *
7833 * @see #putExtras
7834 * @see #removeExtra
7835 * @see #getByteExtra(String, byte)
7836 */
7837 public Intent putExtra(String name, byte value) {
7838 if (mExtras == null) {
7839 mExtras = new Bundle();
7840 }
7841 mExtras.putByte(name, value);
7842 return this;
7843 }
7844
7845 /**
7846 * Add extended data to the intent. The name must include a package
7847 * prefix, for example the app com.android.contacts would use names
7848 * like "com.android.contacts.ShowAll".
7849 *
7850 * @param name The name of the extra data, with package prefix.
7851 * @param value The char data value.
7852 *
7853 * @return Returns the same Intent object, for chaining multiple calls
7854 * into a single statement.
7855 *
7856 * @see #putExtras
7857 * @see #removeExtra
7858 * @see #getCharExtra(String, char)
7859 */
7860 public Intent putExtra(String name, char value) {
7861 if (mExtras == null) {
7862 mExtras = new Bundle();
7863 }
7864 mExtras.putChar(name, value);
7865 return this;
7866 }
7867
7868 /**
7869 * Add extended data to the intent. The name must include a package
7870 * prefix, for example the app com.android.contacts would use names
7871 * like "com.android.contacts.ShowAll".
7872 *
7873 * @param name The name of the extra data, with package prefix.
7874 * @param value The short data value.
7875 *
7876 * @return Returns the same Intent object, for chaining multiple calls
7877 * into a single statement.
7878 *
7879 * @see #putExtras
7880 * @see #removeExtra
7881 * @see #getShortExtra(String, short)
7882 */
7883 public Intent putExtra(String name, short value) {
7884 if (mExtras == null) {
7885 mExtras = new Bundle();
7886 }
7887 mExtras.putShort(name, value);
7888 return this;
7889 }
7890
7891 /**
7892 * Add extended data to the intent. The name must include a package
7893 * prefix, for example the app com.android.contacts would use names
7894 * like "com.android.contacts.ShowAll".
7895 *
7896 * @param name The name of the extra data, with package prefix.
7897 * @param value The integer data value.
7898 *
7899 * @return Returns the same Intent object, for chaining multiple calls
7900 * into a single statement.
7901 *
7902 * @see #putExtras
7903 * @see #removeExtra
7904 * @see #getIntExtra(String, int)
7905 */
7906 public Intent putExtra(String name, int value) {
7907 if (mExtras == null) {
7908 mExtras = new Bundle();
7909 }
7910 mExtras.putInt(name, value);
7911 return this;
7912 }
7913
7914 /**
7915 * Add extended data to the intent. The name must include a package
7916 * prefix, for example the app com.android.contacts would use names
7917 * like "com.android.contacts.ShowAll".
7918 *
7919 * @param name The name of the extra data, with package prefix.
7920 * @param value The long data value.
7921 *
7922 * @return Returns the same Intent object, for chaining multiple calls
7923 * into a single statement.
7924 *
7925 * @see #putExtras
7926 * @see #removeExtra
7927 * @see #getLongExtra(String, long)
7928 */
7929 public Intent putExtra(String name, long value) {
7930 if (mExtras == null) {
7931 mExtras = new Bundle();
7932 }
7933 mExtras.putLong(name, value);
7934 return this;
7935 }
7936
7937 /**
7938 * Add extended data to the intent. The name must include a package
7939 * prefix, for example the app com.android.contacts would use names
7940 * like "com.android.contacts.ShowAll".
7941 *
7942 * @param name The name of the extra data, with package prefix.
7943 * @param value The float data value.
7944 *
7945 * @return Returns the same Intent object, for chaining multiple calls
7946 * into a single statement.
7947 *
7948 * @see #putExtras
7949 * @see #removeExtra
7950 * @see #getFloatExtra(String, float)
7951 */
7952 public Intent putExtra(String name, float value) {
7953 if (mExtras == null) {
7954 mExtras = new Bundle();
7955 }
7956 mExtras.putFloat(name, value);
7957 return this;
7958 }
7959
7960 /**
7961 * Add extended data to the intent. The name must include a package
7962 * prefix, for example the app com.android.contacts would use names
7963 * like "com.android.contacts.ShowAll".
7964 *
7965 * @param name The name of the extra data, with package prefix.
7966 * @param value The double data value.
7967 *
7968 * @return Returns the same Intent object, for chaining multiple calls
7969 * into a single statement.
7970 *
7971 * @see #putExtras
7972 * @see #removeExtra
7973 * @see #getDoubleExtra(String, double)
7974 */
7975 public Intent putExtra(String name, double value) {
7976 if (mExtras == null) {
7977 mExtras = new Bundle();
7978 }
7979 mExtras.putDouble(name, value);
7980 return this;
7981 }
7982
7983 /**
7984 * Add extended data to the intent. The name must include a package
7985 * prefix, for example the app com.android.contacts would use names
7986 * like "com.android.contacts.ShowAll".
7987 *
7988 * @param name The name of the extra data, with package prefix.
7989 * @param value The String data value.
7990 *
7991 * @return Returns the same Intent object, for chaining multiple calls
7992 * into a single statement.
7993 *
7994 * @see #putExtras
7995 * @see #removeExtra
7996 * @see #getStringExtra(String)
7997 */
7998 public Intent putExtra(String name, String value) {
7999 if (mExtras == null) {
8000 mExtras = new Bundle();
8001 }
8002 mExtras.putString(name, value);
8003 return this;
8004 }
8005
8006 /**
8007 * Add extended data to the intent. The name must include a package
8008 * prefix, for example the app com.android.contacts would use names
8009 * like "com.android.contacts.ShowAll".
8010 *
8011 * @param name The name of the extra data, with package prefix.
8012 * @param value The CharSequence data value.
8013 *
8014 * @return Returns the same Intent object, for chaining multiple calls
8015 * into a single statement.
8016 *
8017 * @see #putExtras
8018 * @see #removeExtra
8019 * @see #getCharSequenceExtra(String)
8020 */
8021 public Intent putExtra(String name, CharSequence value) {
8022 if (mExtras == null) {
8023 mExtras = new Bundle();
8024 }
8025 mExtras.putCharSequence(name, value);
8026 return this;
8027 }
8028
8029 /**
8030 * Add extended data to the intent. The name must include a package
8031 * prefix, for example the app com.android.contacts would use names
8032 * like "com.android.contacts.ShowAll".
8033 *
8034 * @param name The name of the extra data, with package prefix.
8035 * @param value The Parcelable data value.
8036 *
8037 * @return Returns the same Intent object, for chaining multiple calls
8038 * into a single statement.
8039 *
8040 * @see #putExtras
8041 * @see #removeExtra
8042 * @see #getParcelableExtra(String)
8043 */
8044 public Intent putExtra(String name, Parcelable value) {
8045 if (mExtras == null) {
8046 mExtras = new Bundle();
8047 }
8048 mExtras.putParcelable(name, value);
8049 return this;
8050 }
8051
8052 /**
8053 * Add extended data to the intent. The name must include a package
8054 * prefix, for example the app com.android.contacts would use names
8055 * like "com.android.contacts.ShowAll".
8056 *
8057 * @param name The name of the extra data, with package prefix.
8058 * @param value The Parcelable[] data value.
8059 *
8060 * @return Returns the same Intent object, for chaining multiple calls
8061 * into a single statement.
8062 *
8063 * @see #putExtras
8064 * @see #removeExtra
8065 * @see #getParcelableArrayExtra(String)
8066 */
8067 public Intent putExtra(String name, Parcelable[] value) {
8068 if (mExtras == null) {
8069 mExtras = new Bundle();
8070 }
8071 mExtras.putParcelableArray(name, value);
8072 return this;
8073 }
8074
8075 /**
8076 * Add extended data to the intent. The name must include a package
8077 * prefix, for example the app com.android.contacts would use names
8078 * like "com.android.contacts.ShowAll".
8079 *
8080 * @param name The name of the extra data, with package prefix.
8081 * @param value The ArrayList<Parcelable> data value.
8082 *
8083 * @return Returns the same Intent object, for chaining multiple calls
8084 * into a single statement.
8085 *
8086 * @see #putExtras
8087 * @see #removeExtra
8088 * @see #getParcelableArrayListExtra(String)
8089 */
8090 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
8091 if (mExtras == null) {
8092 mExtras = new Bundle();
8093 }
8094 mExtras.putParcelableArrayList(name, value);
8095 return this;
8096 }
8097
8098 /**
8099 * Add extended data to the intent. The name must include a package
8100 * prefix, for example the app com.android.contacts would use names
8101 * like "com.android.contacts.ShowAll".
8102 *
8103 * @param name The name of the extra data, with package prefix.
8104 * @param value The ArrayList<Integer> data value.
8105 *
8106 * @return Returns the same Intent object, for chaining multiple calls
8107 * into a single statement.
8108 *
8109 * @see #putExtras
8110 * @see #removeExtra
8111 * @see #getIntegerArrayListExtra(String)
8112 */
8113 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
8114 if (mExtras == null) {
8115 mExtras = new Bundle();
8116 }
8117 mExtras.putIntegerArrayList(name, value);
8118 return this;
8119 }
8120
8121 /**
8122 * Add extended data to the intent. The name must include a package
8123 * prefix, for example the app com.android.contacts would use names
8124 * like "com.android.contacts.ShowAll".
8125 *
8126 * @param name The name of the extra data, with package prefix.
8127 * @param value The ArrayList<String> data value.
8128 *
8129 * @return Returns the same Intent object, for chaining multiple calls
8130 * into a single statement.
8131 *
8132 * @see #putExtras
8133 * @see #removeExtra
8134 * @see #getStringArrayListExtra(String)
8135 */
8136 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
8137 if (mExtras == null) {
8138 mExtras = new Bundle();
8139 }
8140 mExtras.putStringArrayList(name, value);
8141 return this;
8142 }
8143
8144 /**
8145 * Add extended data to the intent. The name must include a package
8146 * prefix, for example the app com.android.contacts would use names
8147 * like "com.android.contacts.ShowAll".
8148 *
8149 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008150 * @param value The ArrayList<CharSequence> data value.
8151 *
8152 * @return Returns the same Intent object, for chaining multiple calls
8153 * into a single statement.
8154 *
8155 * @see #putExtras
8156 * @see #removeExtra
8157 * @see #getCharSequenceArrayListExtra(String)
8158 */
8159 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
8160 if (mExtras == null) {
8161 mExtras = new Bundle();
8162 }
8163 mExtras.putCharSequenceArrayList(name, value);
8164 return this;
8165 }
8166
8167 /**
8168 * Add extended data to the intent. The name must include a package
8169 * prefix, for example the app com.android.contacts would use names
8170 * like "com.android.contacts.ShowAll".
8171 *
8172 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008173 * @param value The Serializable data value.
8174 *
8175 * @return Returns the same Intent object, for chaining multiple calls
8176 * into a single statement.
8177 *
8178 * @see #putExtras
8179 * @see #removeExtra
8180 * @see #getSerializableExtra(String)
8181 */
8182 public Intent putExtra(String name, Serializable value) {
8183 if (mExtras == null) {
8184 mExtras = new Bundle();
8185 }
8186 mExtras.putSerializable(name, value);
8187 return this;
8188 }
8189
8190 /**
8191 * Add extended data to the intent. The name must include a package
8192 * prefix, for example the app com.android.contacts would use names
8193 * like "com.android.contacts.ShowAll".
8194 *
8195 * @param name The name of the extra data, with package prefix.
8196 * @param value The boolean array data value.
8197 *
8198 * @return Returns the same Intent object, for chaining multiple calls
8199 * into a single statement.
8200 *
8201 * @see #putExtras
8202 * @see #removeExtra
8203 * @see #getBooleanArrayExtra(String)
8204 */
8205 public Intent putExtra(String name, boolean[] value) {
8206 if (mExtras == null) {
8207 mExtras = new Bundle();
8208 }
8209 mExtras.putBooleanArray(name, value);
8210 return this;
8211 }
8212
8213 /**
8214 * Add extended data to the intent. The name must include a package
8215 * prefix, for example the app com.android.contacts would use names
8216 * like "com.android.contacts.ShowAll".
8217 *
8218 * @param name The name of the extra data, with package prefix.
8219 * @param value The byte array data value.
8220 *
8221 * @return Returns the same Intent object, for chaining multiple calls
8222 * into a single statement.
8223 *
8224 * @see #putExtras
8225 * @see #removeExtra
8226 * @see #getByteArrayExtra(String)
8227 */
8228 public Intent putExtra(String name, byte[] value) {
8229 if (mExtras == null) {
8230 mExtras = new Bundle();
8231 }
8232 mExtras.putByteArray(name, value);
8233 return this;
8234 }
8235
8236 /**
8237 * Add extended data to the intent. The name must include a package
8238 * prefix, for example the app com.android.contacts would use names
8239 * like "com.android.contacts.ShowAll".
8240 *
8241 * @param name The name of the extra data, with package prefix.
8242 * @param value The short array data value.
8243 *
8244 * @return Returns the same Intent object, for chaining multiple calls
8245 * into a single statement.
8246 *
8247 * @see #putExtras
8248 * @see #removeExtra
8249 * @see #getShortArrayExtra(String)
8250 */
8251 public Intent putExtra(String name, short[] value) {
8252 if (mExtras == null) {
8253 mExtras = new Bundle();
8254 }
8255 mExtras.putShortArray(name, value);
8256 return this;
8257 }
8258
8259 /**
8260 * Add extended data to the intent. The name must include a package
8261 * prefix, for example the app com.android.contacts would use names
8262 * like "com.android.contacts.ShowAll".
8263 *
8264 * @param name The name of the extra data, with package prefix.
8265 * @param value The char array data value.
8266 *
8267 * @return Returns the same Intent object, for chaining multiple calls
8268 * into a single statement.
8269 *
8270 * @see #putExtras
8271 * @see #removeExtra
8272 * @see #getCharArrayExtra(String)
8273 */
8274 public Intent putExtra(String name, char[] value) {
8275 if (mExtras == null) {
8276 mExtras = new Bundle();
8277 }
8278 mExtras.putCharArray(name, value);
8279 return this;
8280 }
8281
8282 /**
8283 * Add extended data to the intent. The name must include a package
8284 * prefix, for example the app com.android.contacts would use names
8285 * like "com.android.contacts.ShowAll".
8286 *
8287 * @param name The name of the extra data, with package prefix.
8288 * @param value The int array data value.
8289 *
8290 * @return Returns the same Intent object, for chaining multiple calls
8291 * into a single statement.
8292 *
8293 * @see #putExtras
8294 * @see #removeExtra
8295 * @see #getIntArrayExtra(String)
8296 */
8297 public Intent putExtra(String name, int[] value) {
8298 if (mExtras == null) {
8299 mExtras = new Bundle();
8300 }
8301 mExtras.putIntArray(name, value);
8302 return this;
8303 }
8304
8305 /**
8306 * Add extended data to the intent. The name must include a package
8307 * prefix, for example the app com.android.contacts would use names
8308 * like "com.android.contacts.ShowAll".
8309 *
8310 * @param name The name of the extra data, with package prefix.
8311 * @param value The byte array data value.
8312 *
8313 * @return Returns the same Intent object, for chaining multiple calls
8314 * into a single statement.
8315 *
8316 * @see #putExtras
8317 * @see #removeExtra
8318 * @see #getLongArrayExtra(String)
8319 */
8320 public Intent putExtra(String name, long[] value) {
8321 if (mExtras == null) {
8322 mExtras = new Bundle();
8323 }
8324 mExtras.putLongArray(name, value);
8325 return this;
8326 }
8327
8328 /**
8329 * Add extended data to the intent. The name must include a package
8330 * prefix, for example the app com.android.contacts would use names
8331 * like "com.android.contacts.ShowAll".
8332 *
8333 * @param name The name of the extra data, with package prefix.
8334 * @param value The float array data value.
8335 *
8336 * @return Returns the same Intent object, for chaining multiple calls
8337 * into a single statement.
8338 *
8339 * @see #putExtras
8340 * @see #removeExtra
8341 * @see #getFloatArrayExtra(String)
8342 */
8343 public Intent putExtra(String name, float[] value) {
8344 if (mExtras == null) {
8345 mExtras = new Bundle();
8346 }
8347 mExtras.putFloatArray(name, value);
8348 return this;
8349 }
8350
8351 /**
8352 * Add extended data to the intent. The name must include a package
8353 * prefix, for example the app com.android.contacts would use names
8354 * like "com.android.contacts.ShowAll".
8355 *
8356 * @param name The name of the extra data, with package prefix.
8357 * @param value The double array data value.
8358 *
8359 * @return Returns the same Intent object, for chaining multiple calls
8360 * into a single statement.
8361 *
8362 * @see #putExtras
8363 * @see #removeExtra
8364 * @see #getDoubleArrayExtra(String)
8365 */
8366 public Intent putExtra(String name, double[] value) {
8367 if (mExtras == null) {
8368 mExtras = new Bundle();
8369 }
8370 mExtras.putDoubleArray(name, value);
8371 return this;
8372 }
8373
8374 /**
8375 * Add extended data to the intent. The name must include a package
8376 * prefix, for example the app com.android.contacts would use names
8377 * like "com.android.contacts.ShowAll".
8378 *
8379 * @param name The name of the extra data, with package prefix.
8380 * @param value The String array data value.
8381 *
8382 * @return Returns the same Intent object, for chaining multiple calls
8383 * into a single statement.
8384 *
8385 * @see #putExtras
8386 * @see #removeExtra
8387 * @see #getStringArrayExtra(String)
8388 */
8389 public Intent putExtra(String name, String[] value) {
8390 if (mExtras == null) {
8391 mExtras = new Bundle();
8392 }
8393 mExtras.putStringArray(name, value);
8394 return this;
8395 }
8396
8397 /**
8398 * Add extended data to the intent. The name must include a package
8399 * prefix, for example the app com.android.contacts would use names
8400 * like "com.android.contacts.ShowAll".
8401 *
8402 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008403 * @param value The CharSequence array data value.
8404 *
8405 * @return Returns the same Intent object, for chaining multiple calls
8406 * into a single statement.
8407 *
8408 * @see #putExtras
8409 * @see #removeExtra
8410 * @see #getCharSequenceArrayExtra(String)
8411 */
8412 public Intent putExtra(String name, CharSequence[] value) {
8413 if (mExtras == null) {
8414 mExtras = new Bundle();
8415 }
8416 mExtras.putCharSequenceArray(name, value);
8417 return this;
8418 }
8419
8420 /**
8421 * Add extended data to the intent. The name must include a package
8422 * prefix, for example the app com.android.contacts would use names
8423 * like "com.android.contacts.ShowAll".
8424 *
8425 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008426 * @param value The Bundle data value.
8427 *
8428 * @return Returns the same Intent object, for chaining multiple calls
8429 * into a single statement.
8430 *
8431 * @see #putExtras
8432 * @see #removeExtra
8433 * @see #getBundleExtra(String)
8434 */
8435 public Intent putExtra(String name, Bundle value) {
8436 if (mExtras == null) {
8437 mExtras = new Bundle();
8438 }
8439 mExtras.putBundle(name, value);
8440 return this;
8441 }
8442
8443 /**
8444 * Add extended data to the intent. The name must include a package
8445 * prefix, for example the app com.android.contacts would use names
8446 * like "com.android.contacts.ShowAll".
8447 *
8448 * @param name The name of the extra data, with package prefix.
8449 * @param value The IBinder data value.
8450 *
8451 * @return Returns the same Intent object, for chaining multiple calls
8452 * into a single statement.
8453 *
8454 * @see #putExtras
8455 * @see #removeExtra
8456 * @see #getIBinderExtra(String)
8457 *
8458 * @deprecated
8459 * @hide
8460 */
8461 @Deprecated
8462 public Intent putExtra(String name, IBinder value) {
8463 if (mExtras == null) {
8464 mExtras = new Bundle();
8465 }
8466 mExtras.putIBinder(name, value);
8467 return this;
8468 }
8469
8470 /**
8471 * Copy all extras in 'src' in to this intent.
8472 *
8473 * @param src Contains the extras to copy.
8474 *
8475 * @see #putExtra
8476 */
8477 public Intent putExtras(Intent src) {
8478 if (src.mExtras != null) {
8479 if (mExtras == null) {
8480 mExtras = new Bundle(src.mExtras);
8481 } else {
8482 mExtras.putAll(src.mExtras);
8483 }
8484 }
8485 return this;
8486 }
8487
8488 /**
8489 * Add a set of extended data to the intent. The keys must include a package
8490 * prefix, for example the app com.android.contacts would use names
8491 * like "com.android.contacts.ShowAll".
8492 *
8493 * @param extras The Bundle of extras to add to this intent.
8494 *
8495 * @see #putExtra
8496 * @see #removeExtra
8497 */
8498 public Intent putExtras(Bundle extras) {
8499 if (mExtras == null) {
8500 mExtras = new Bundle();
8501 }
8502 mExtras.putAll(extras);
8503 return this;
8504 }
8505
8506 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008507 * Completely replace the extras in the Intent with the extras in the
8508 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008509 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008510 * @param src The exact extras contained in this Intent are copied
8511 * into the target intent, replacing any that were previously there.
8512 */
8513 public Intent replaceExtras(Intent src) {
8514 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8515 return this;
8516 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008517
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008518 /**
8519 * Completely replace the extras in the Intent with the given Bundle of
8520 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008521 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008522 * @param extras The new set of extras in the Intent, or null to erase
8523 * all extras.
8524 */
8525 public Intent replaceExtras(Bundle extras) {
8526 mExtras = extras != null ? new Bundle(extras) : null;
8527 return this;
8528 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008529
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008530 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008531 * Remove extended data from the intent.
8532 *
8533 * @see #putExtra
8534 */
8535 public void removeExtra(String name) {
8536 if (mExtras != null) {
8537 mExtras.remove(name);
8538 if (mExtras.size() == 0) {
8539 mExtras = null;
8540 }
8541 }
8542 }
8543
8544 /**
8545 * Set special flags controlling how this intent is handled. Most values
8546 * here depend on the type of component being executed by the Intent,
8547 * specifically the FLAG_ACTIVITY_* flags are all for use with
8548 * {@link Context#startActivity Context.startActivity()} and the
8549 * FLAG_RECEIVER_* flags are all for use with
8550 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8551 *
Scott Main7aee61f2011-02-08 11:25:01 -08008552 * <p>See the
8553 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8554 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 * the behavior of your application.
8556 *
8557 * @param flags The desired flags.
8558 *
8559 * @return Returns the same Intent object, for chaining multiple calls
8560 * into a single statement.
8561 *
8562 * @see #getFlags
8563 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008564 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008565 *
8566 * @see #FLAG_GRANT_READ_URI_PERMISSION
8567 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008568 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8569 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008570 * @see #FLAG_DEBUG_LOG_RESOLUTION
8571 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008572 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008573 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008574 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008575 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008576 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8577 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008578 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008579 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008580 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008582 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008584 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008585 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8586 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008587 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008588 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008589 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008590 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8591 */
8592 public Intent setFlags(int flags) {
8593 mFlags = flags;
8594 return this;
8595 }
8596
8597 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008598 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008599 *
8600 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008601 * @return Returns the same Intent object, for chaining multiple calls into
8602 * a single statement.
8603 * @see #setFlags(int)
8604 * @see #removeFlags(int)
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06008605 *
8606 * @see #FLAG_GRANT_READ_URI_PERMISSION
8607 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
8608 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8609 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
8610 * @see #FLAG_DEBUG_LOG_RESOLUTION
8611 * @see #FLAG_FROM_BACKGROUND
8612 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
8613 * @see #FLAG_ACTIVITY_CLEAR_TASK
8614 * @see #FLAG_ACTIVITY_CLEAR_TOP
8615 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
8616 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8617 * @see #FLAG_ACTIVITY_FORWARD_RESULT
8618 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
8619 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
8620 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
8621 * @see #FLAG_ACTIVITY_NEW_TASK
8622 * @see #FLAG_ACTIVITY_NO_ANIMATION
8623 * @see #FLAG_ACTIVITY_NO_HISTORY
8624 * @see #FLAG_ACTIVITY_NO_USER_ACTION
8625 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8626 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8627 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
8628 * @see #FLAG_ACTIVITY_SINGLE_TOP
8629 * @see #FLAG_ACTIVITY_TASK_ON_HOME
8630 * @see #FLAG_RECEIVER_REGISTERED_ONLY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008631 */
8632 public Intent addFlags(int flags) {
8633 mFlags |= flags;
8634 return this;
8635 }
8636
8637 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008638 * Remove these flags from the intent.
8639 *
8640 * @param flags The flags to remove.
8641 * @see #setFlags(int)
8642 * @see #addFlags(int)
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06008643 *
8644 * @see #FLAG_GRANT_READ_URI_PERMISSION
8645 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
8646 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8647 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
8648 * @see #FLAG_DEBUG_LOG_RESOLUTION
8649 * @see #FLAG_FROM_BACKGROUND
8650 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
8651 * @see #FLAG_ACTIVITY_CLEAR_TASK
8652 * @see #FLAG_ACTIVITY_CLEAR_TOP
8653 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
8654 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8655 * @see #FLAG_ACTIVITY_FORWARD_RESULT
8656 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
8657 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
8658 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
8659 * @see #FLAG_ACTIVITY_NEW_TASK
8660 * @see #FLAG_ACTIVITY_NO_ANIMATION
8661 * @see #FLAG_ACTIVITY_NO_HISTORY
8662 * @see #FLAG_ACTIVITY_NO_USER_ACTION
8663 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8664 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8665 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
8666 * @see #FLAG_ACTIVITY_SINGLE_TOP
8667 * @see #FLAG_ACTIVITY_TASK_ON_HOME
8668 * @see #FLAG_RECEIVER_REGISTERED_ONLY
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008669 */
8670 public void removeFlags(int flags) {
8671 mFlags &= ~flags;
8672 }
8673
8674 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008675 * (Usually optional) Set an explicit application package name that limits
8676 * the components this Intent will resolve to. If left to the default
8677 * value of null, all components in all applications will considered.
8678 * If non-null, the Intent can only match the components in the given
8679 * application package.
8680 *
8681 * @param packageName The name of the application package to handle the
8682 * intent, or null to allow any application package.
8683 *
8684 * @return Returns the same Intent object, for chaining multiple calls
8685 * into a single statement.
8686 *
8687 * @see #getPackage
8688 * @see #resolveActivity
8689 */
8690 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008691 if (packageName != null && mSelector != null) {
8692 throw new IllegalArgumentException(
8693 "Can't set package name when selector is already set");
8694 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008695 mPackage = packageName;
8696 return this;
8697 }
8698
8699 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008700 * (Usually optional) Explicitly set the component to handle the intent.
8701 * If left with the default value of null, the system will determine the
8702 * appropriate class to use based on the other fields (action, data,
8703 * type, categories) in the Intent. If this class is defined, the
8704 * specified class will always be used regardless of the other fields. You
8705 * should only set this value when you know you absolutely want a specific
8706 * class to be used; otherwise it is better to let the system find the
8707 * appropriate class so that you will respect the installed applications
8708 * and user preferences.
8709 *
8710 * @param component The name of the application component to handle the
8711 * intent, or null to let the system find one for you.
8712 *
8713 * @return Returns the same Intent object, for chaining multiple calls
8714 * into a single statement.
8715 *
8716 * @see #setClass
8717 * @see #setClassName(Context, String)
8718 * @see #setClassName(String, String)
8719 * @see #getComponent
8720 * @see #resolveActivity
8721 */
8722 public Intent setComponent(ComponentName component) {
8723 mComponent = component;
8724 return this;
8725 }
8726
8727 /**
8728 * Convenience for calling {@link #setComponent} with an
8729 * explicit class name.
8730 *
8731 * @param packageContext A Context of the application package implementing
8732 * this class.
8733 * @param className The name of a class inside of the application package
8734 * that will be used as the component for this Intent.
8735 *
8736 * @return Returns the same Intent object, for chaining multiple calls
8737 * into a single statement.
8738 *
8739 * @see #setComponent
8740 * @see #setClass
8741 */
8742 public Intent setClassName(Context packageContext, String className) {
8743 mComponent = new ComponentName(packageContext, className);
8744 return this;
8745 }
8746
8747 /**
8748 * Convenience for calling {@link #setComponent} with an
8749 * explicit application package name and class name.
8750 *
8751 * @param packageName The name of the package implementing the desired
8752 * component.
8753 * @param className The name of a class inside of the application package
8754 * that will be used as the component for this Intent.
8755 *
8756 * @return Returns the same Intent object, for chaining multiple calls
8757 * into a single statement.
8758 *
8759 * @see #setComponent
8760 * @see #setClass
8761 */
8762 public Intent setClassName(String packageName, String className) {
8763 mComponent = new ComponentName(packageName, className);
8764 return this;
8765 }
8766
8767 /**
8768 * Convenience for calling {@link #setComponent(ComponentName)} with the
8769 * name returned by a {@link Class} object.
8770 *
8771 * @param packageContext A Context of the application package implementing
8772 * this class.
8773 * @param cls The class name to set, equivalent to
8774 * <code>setClassName(context, cls.getName())</code>.
8775 *
8776 * @return Returns the same Intent object, for chaining multiple calls
8777 * into a single statement.
8778 *
8779 * @see #setComponent
8780 */
8781 public Intent setClass(Context packageContext, Class<?> cls) {
8782 mComponent = new ComponentName(packageContext, cls);
8783 return this;
8784 }
8785
8786 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008787 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8788 * used as a hint to the receiver for animations and the like. Null means that there
8789 * is no source bounds.
8790 */
8791 public void setSourceBounds(Rect r) {
8792 if (r != null) {
8793 mSourceBounds = new Rect(r);
8794 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008795 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008796 }
8797 }
8798
Tor Norbyed9273d62013-05-30 15:59:53 -07008799 /** @hide */
8800 @IntDef(flag = true,
8801 value = {
8802 FILL_IN_ACTION,
8803 FILL_IN_DATA,
8804 FILL_IN_CATEGORIES,
8805 FILL_IN_COMPONENT,
8806 FILL_IN_PACKAGE,
8807 FILL_IN_SOURCE_BOUNDS,
8808 FILL_IN_SELECTOR,
8809 FILL_IN_CLIP_DATA
8810 })
8811 @Retention(RetentionPolicy.SOURCE)
8812 public @interface FillInFlags {}
8813
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008814 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008815 * Use with {@link #fillIn} to allow the current action value to be
8816 * overwritten, even if it is already set.
8817 */
8818 public static final int FILL_IN_ACTION = 1<<0;
8819
8820 /**
8821 * Use with {@link #fillIn} to allow the current data or type value
8822 * overwritten, even if it is already set.
8823 */
8824 public static final int FILL_IN_DATA = 1<<1;
8825
8826 /**
8827 * Use with {@link #fillIn} to allow the current categories to be
8828 * overwritten, even if they are already set.
8829 */
8830 public static final int FILL_IN_CATEGORIES = 1<<2;
8831
8832 /**
8833 * Use with {@link #fillIn} to allow the current component value to be
8834 * overwritten, even if it is already set.
8835 */
8836 public static final int FILL_IN_COMPONENT = 1<<3;
8837
8838 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008839 * Use with {@link #fillIn} to allow the current package value to be
8840 * overwritten, even if it is already set.
8841 */
8842 public static final int FILL_IN_PACKAGE = 1<<4;
8843
8844 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008845 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008846 * overwritten, even if it is already set.
8847 */
8848 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8849
8850 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008851 * Use with {@link #fillIn} to allow the current selector to be
8852 * overwritten, even if it is already set.
8853 */
8854 public static final int FILL_IN_SELECTOR = 1<<6;
8855
8856 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008857 * Use with {@link #fillIn} to allow the current ClipData to be
8858 * overwritten, even if it is already set.
8859 */
8860 public static final int FILL_IN_CLIP_DATA = 1<<7;
8861
8862 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008863 * Copy the contents of <var>other</var> in to this object, but only
8864 * where fields are not defined by this object. For purposes of a field
8865 * being defined, the following pieces of data in the Intent are
8866 * considered to be separate fields:
8867 *
8868 * <ul>
8869 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008870 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008871 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8872 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008873 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008874 * <li> component, as set by {@link #setComponent(ComponentName)} or
8875 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008876 * <li> source bounds, as set by {@link #setSourceBounds}.
8877 * <li> selector, as set by {@link #setSelector(Intent)}.
8878 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008879 * <li> each top-level name in the associated extras.
8880 * </ul>
8881 *
8882 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008883 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008884 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8885 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8886 * the restriction where the corresponding field will not be replaced if
8887 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008888 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008889 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8890 * is explicitly specified. The selector will only be copied if
8891 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008892 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008893 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8894 * and Intent B with {action="gotit", data-type="some/thing",
8895 * categories="one","two"}.
8896 *
8897 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8898 * containing: {action="gotit", data-type="some/thing",
8899 * categories="bar"}.
8900 *
8901 * @param other Another Intent whose values are to be used to fill in
8902 * the current one.
8903 * @param flags Options to control which fields can be filled in.
8904 *
8905 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008906 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008907 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008908 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008909 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008910 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008911 @FillInFlags
8912 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008913 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008914 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008915 if (other.mAction != null
8916 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008917 mAction = other.mAction;
8918 changes |= FILL_IN_ACTION;
8919 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008920 if ((other.mData != null || other.mType != null)
8921 && ((mData == null && mType == null)
8922 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008923 mData = other.mData;
8924 mType = other.mType;
8925 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008926 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008927 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008928 if (other.mCategories != null
8929 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008930 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008931 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008932 }
8933 changes |= FILL_IN_CATEGORIES;
8934 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008935 if (other.mPackage != null
8936 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008937 // Only do this if mSelector is not set.
8938 if (mSelector == null) {
8939 mPackage = other.mPackage;
8940 changes |= FILL_IN_PACKAGE;
8941 }
8942 }
8943 // Selector is special: it can only be set if explicitly allowed,
8944 // for the same reason as the component name.
8945 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8946 if (mPackage == null) {
8947 mSelector = new Intent(other.mSelector);
8948 mPackage = null;
8949 changes |= FILL_IN_SELECTOR;
8950 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008951 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008952 if (other.mClipData != null
8953 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8954 mClipData = other.mClipData;
8955 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008956 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008957 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008958 // Component is special: it can -only- be set if explicitly allowed,
8959 // since otherwise the sender could force the intent somewhere the
8960 // originator didn't intend.
8961 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008962 mComponent = other.mComponent;
8963 changes |= FILL_IN_COMPONENT;
8964 }
8965 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008966 if (other.mSourceBounds != null
8967 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8968 mSourceBounds = new Rect(other.mSourceBounds);
8969 changes |= FILL_IN_SOURCE_BOUNDS;
8970 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008971 if (mExtras == null) {
8972 if (other.mExtras != null) {
8973 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008974 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008975 }
8976 } else if (other.mExtras != null) {
8977 try {
8978 Bundle newb = new Bundle(other.mExtras);
8979 newb.putAll(mExtras);
8980 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008981 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008982 } catch (RuntimeException e) {
8983 // Modifying the extras can cause us to unparcel the contents
8984 // of the bundle, and if we do this in the system process that
8985 // may fail. We really should handle this (i.e., the Bundle
8986 // impl shouldn't be on top of a plain map), but for now just
8987 // ignore it and keep the original contents. :(
8988 Log.w("Intent", "Failure filling in extras", e);
8989 }
8990 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008991 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8992 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8993 mContentUserHint = other.mContentUserHint;
8994 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008995 return changes;
8996 }
8997
8998 /**
8999 * Wrapper class holding an Intent and implementing comparisons on it for
9000 * the purpose of filtering. The class implements its
9001 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9002 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9003 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9004 * on the wrapped Intent.
9005 */
9006 public static final class FilterComparison {
9007 private final Intent mIntent;
9008 private final int mHashCode;
9009
9010 public FilterComparison(Intent intent) {
9011 mIntent = intent;
9012 mHashCode = intent.filterHashCode();
9013 }
9014
9015 /**
9016 * Return the Intent that this FilterComparison represents.
9017 * @return Returns the Intent held by the FilterComparison. Do
9018 * not modify!
9019 */
9020 public Intent getIntent() {
9021 return mIntent;
9022 }
9023
9024 @Override
9025 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009026 if (obj instanceof FilterComparison) {
9027 Intent other = ((FilterComparison)obj).mIntent;
9028 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009029 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009030 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009031 }
9032
9033 @Override
9034 public int hashCode() {
9035 return mHashCode;
9036 }
9037 }
9038
9039 /**
9040 * Determine if two intents are the same for the purposes of intent
9041 * resolution (filtering). That is, if their action, data, type,
9042 * class, and categories are the same. This does <em>not</em> compare
9043 * any extra data included in the intents.
9044 *
9045 * @param other The other Intent to compare against.
9046 *
9047 * @return Returns true if action, data, type, class, and categories
9048 * are the same.
9049 */
9050 public boolean filterEquals(Intent other) {
9051 if (other == null) {
9052 return false;
9053 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009054 if (!Objects.equals(this.mAction, other.mAction)) return false;
9055 if (!Objects.equals(this.mData, other.mData)) return false;
9056 if (!Objects.equals(this.mType, other.mType)) return false;
9057 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9058 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9059 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009060
9061 return true;
9062 }
9063
9064 /**
9065 * Generate hash code that matches semantics of filterEquals().
9066 *
9067 * @return Returns the hash value of the action, data, type, class, and
9068 * categories.
9069 *
9070 * @see #filterEquals
9071 */
9072 public int filterHashCode() {
9073 int code = 0;
9074 if (mAction != null) {
9075 code += mAction.hashCode();
9076 }
9077 if (mData != null) {
9078 code += mData.hashCode();
9079 }
9080 if (mType != null) {
9081 code += mType.hashCode();
9082 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009083 if (mPackage != null) {
9084 code += mPackage.hashCode();
9085 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009086 if (mComponent != null) {
9087 code += mComponent.hashCode();
9088 }
9089 if (mCategories != null) {
9090 code += mCategories.hashCode();
9091 }
9092 return code;
9093 }
9094
9095 @Override
9096 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009097 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009098
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009099 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009100 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009101 b.append(" }");
9102
9103 return b.toString();
9104 }
9105
9106 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009107 public String toInsecureString() {
9108 StringBuilder b = new StringBuilder(128);
9109
9110 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009111 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009112 b.append(" }");
9113
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009114 return b.toString();
9115 }
Romain Guy4969af72009-06-17 10:53:19 -07009116
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009117 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009118 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009119 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009120
9121 b.append("Intent { ");
9122 toShortString(b, false, true, true, true);
9123 b.append(" }");
9124
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009125 return b.toString();
9126 }
9127
9128 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009129 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9130 StringBuilder b = new StringBuilder(128);
9131 toShortString(b, secure, comp, extras, clip);
9132 return b.toString();
9133 }
9134
9135 /** @hide */
9136 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9137 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009138 boolean first = true;
9139 if (mAction != null) {
9140 b.append("act=").append(mAction);
9141 first = false;
9142 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009143 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009144 if (!first) {
9145 b.append(' ');
9146 }
9147 first = false;
9148 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009149 for (int i=0; i<mCategories.size(); i++) {
9150 if (i > 0) b.append(',');
9151 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009152 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009153 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009154 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009155 if (mData != null) {
9156 if (!first) {
9157 b.append(' ');
9158 }
9159 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009160 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009161 if (secure) {
9162 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009163 } else {
9164 b.append(mData);
9165 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009166 }
9167 if (mType != null) {
9168 if (!first) {
9169 b.append(' ');
9170 }
9171 first = false;
9172 b.append("typ=").append(mType);
9173 }
9174 if (mFlags != 0) {
9175 if (!first) {
9176 b.append(' ');
9177 }
9178 first = false;
9179 b.append("flg=0x").append(Integer.toHexString(mFlags));
9180 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009181 if (mPackage != null) {
9182 if (!first) {
9183 b.append(' ');
9184 }
9185 first = false;
9186 b.append("pkg=").append(mPackage);
9187 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009188 if (comp && mComponent != null) {
9189 if (!first) {
9190 b.append(' ');
9191 }
9192 first = false;
9193 b.append("cmp=").append(mComponent.flattenToShortString());
9194 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009195 if (mSourceBounds != null) {
9196 if (!first) {
9197 b.append(' ');
9198 }
9199 first = false;
9200 b.append("bnds=").append(mSourceBounds.toShortString());
9201 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009202 if (mClipData != null) {
9203 if (!first) {
9204 b.append(' ');
9205 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009206 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009207 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009208 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009209 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009210 if (mClipData.getDescription() != null) {
9211 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9212 } else {
9213 first = true;
9214 }
9215 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009216 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009217 first = false;
9218 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009219 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009220 if (extras && mExtras != null) {
9221 if (!first) {
9222 b.append(' ');
9223 }
9224 first = false;
9225 b.append("(has extras)");
9226 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009227 if (mContentUserHint != UserHandle.USER_CURRENT) {
9228 if (!first) {
9229 b.append(' ');
9230 }
9231 first = false;
9232 b.append("u=").append(mContentUserHint);
9233 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009234 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009235 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009236 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009237 b.append("}");
9238 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009239 }
9240
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009241 /**
9242 * Call {@link #toUri} with 0 flags.
9243 * @deprecated Use {@link #toUri} instead.
9244 */
9245 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009246 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009247 return toUri(0);
9248 }
9249
9250 /**
9251 * Convert this Intent into a String holding a URI representation of it.
9252 * The returned URI string has been properly URI encoded, so it can be
9253 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9254 * Intent's data as the base URI, with an additional fragment describing
9255 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009256 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009257 * <p>You can convert the returned string back to an Intent with
9258 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009259 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009260 * @param flags Additional operating flags. Either 0,
9261 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08009262 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009263 * @return Returns a URI encoding URI string describing the entire contents
9264 * of the Intent.
9265 */
9266 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009267 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009268 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9269 if (mPackage == null) {
9270 throw new IllegalArgumentException(
9271 "Intent must include an explicit package name to build an android-app: "
9272 + this);
9273 }
9274 uri.append("android-app://");
9275 uri.append(mPackage);
9276 String scheme = null;
9277 if (mData != null) {
9278 scheme = mData.getScheme();
9279 if (scheme != null) {
9280 uri.append('/');
9281 uri.append(scheme);
9282 String authority = mData.getEncodedAuthority();
9283 if (authority != null) {
9284 uri.append('/');
9285 uri.append(authority);
9286 String path = mData.getEncodedPath();
9287 if (path != null) {
9288 uri.append(path);
9289 }
9290 String queryParams = mData.getEncodedQuery();
9291 if (queryParams != null) {
9292 uri.append('?');
9293 uri.append(queryParams);
9294 }
9295 String fragment = mData.getEncodedFragment();
9296 if (fragment != null) {
9297 uri.append('#');
9298 uri.append(fragment);
9299 }
9300 }
9301 }
9302 }
9303 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9304 mPackage, flags);
9305 return uri.toString();
9306 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009307 String scheme = null;
9308 if (mData != null) {
9309 String data = mData.toString();
9310 if ((flags&URI_INTENT_SCHEME) != 0) {
9311 final int N = data.length();
9312 for (int i=0; i<N; i++) {
9313 char c = data.charAt(i);
9314 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9315 || c == '.' || c == '-') {
9316 continue;
9317 }
9318 if (c == ':' && i > 0) {
9319 // Valid scheme.
9320 scheme = data.substring(0, i);
9321 uri.append("intent:");
9322 data = data.substring(i+1);
9323 break;
9324 }
Tom Taylord4a47292009-12-21 13:59:18 -08009325
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009326 // No scheme.
9327 break;
9328 }
9329 }
9330 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009331
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009332 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9333 uri.append("intent:");
9334 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009335
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009336 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009337
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009338 return uri.toString();
9339 }
9340
9341 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9342 String defPackage, int flags) {
9343 StringBuilder frag = new StringBuilder(128);
9344
9345 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009346 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009347 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009348 // Note that for now we are not going to try to handle the
9349 // data part; not clear how to represent this as a URI, and
9350 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009351 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9352 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009353 }
9354
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009355 if (frag.length() > 0) {
9356 uri.append("#Intent;");
9357 uri.append(frag);
9358 uri.append("end");
9359 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009360 }
9361
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009362 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9363 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009364 if (scheme != null) {
9365 uri.append("scheme=").append(scheme).append(';');
9366 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009367 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009368 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009369 }
9370 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009371 for (int i=0; i<mCategories.size(); i++) {
9372 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009373 }
9374 }
9375 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009376 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009377 }
9378 if (mFlags != 0) {
9379 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9380 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009381 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009382 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9383 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009384 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009385 uri.append("component=").append(Uri.encode(
9386 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009387 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009388 if (mSourceBounds != null) {
9389 uri.append("sourceBounds=")
9390 .append(Uri.encode(mSourceBounds.flattenToString()))
9391 .append(';');
9392 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009393 if (mExtras != null) {
9394 for (String key : mExtras.keySet()) {
9395 final Object value = mExtras.get(key);
9396 char entryType =
9397 value instanceof String ? 'S' :
9398 value instanceof Boolean ? 'B' :
9399 value instanceof Byte ? 'b' :
9400 value instanceof Character ? 'c' :
9401 value instanceof Double ? 'd' :
9402 value instanceof Float ? 'f' :
9403 value instanceof Integer ? 'i' :
9404 value instanceof Long ? 'l' :
9405 value instanceof Short ? 's' :
9406 '\0';
9407
9408 if (entryType != '\0') {
9409 uri.append(entryType);
9410 uri.append('.');
9411 uri.append(Uri.encode(key));
9412 uri.append('=');
9413 uri.append(Uri.encode(value.toString()));
9414 uri.append(';');
9415 }
9416 }
9417 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009418 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009419
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009420 public int describeContents() {
9421 return (mExtras != null) ? mExtras.describeContents() : 0;
9422 }
9423
9424 public void writeToParcel(Parcel out, int flags) {
9425 out.writeString(mAction);
9426 Uri.writeToParcel(out, mData);
9427 out.writeString(mType);
9428 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009429 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009430 ComponentName.writeToParcel(mComponent, out);
9431
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009432 if (mSourceBounds != null) {
9433 out.writeInt(1);
9434 mSourceBounds.writeToParcel(out, flags);
9435 } else {
9436 out.writeInt(0);
9437 }
9438
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009439 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009440 final int N = mCategories.size();
9441 out.writeInt(N);
9442 for (int i=0; i<N; i++) {
9443 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009444 }
9445 } else {
9446 out.writeInt(0);
9447 }
9448
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009449 if (mSelector != null) {
9450 out.writeInt(1);
9451 mSelector.writeToParcel(out, flags);
9452 } else {
9453 out.writeInt(0);
9454 }
9455
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009456 if (mClipData != null) {
9457 out.writeInt(1);
9458 mClipData.writeToParcel(out, flags);
9459 } else {
9460 out.writeInt(0);
9461 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009462 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009463 out.writeBundle(mExtras);
9464 }
9465
9466 public static final Parcelable.Creator<Intent> CREATOR
9467 = new Parcelable.Creator<Intent>() {
9468 public Intent createFromParcel(Parcel in) {
9469 return new Intent(in);
9470 }
9471 public Intent[] newArray(int size) {
9472 return new Intent[size];
9473 }
9474 };
9475
Dianne Hackborneb034652009-09-07 00:49:58 -07009476 /** @hide */
9477 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009478 readFromParcel(in);
9479 }
9480
9481 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009482 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009483 mData = Uri.CREATOR.createFromParcel(in);
9484 mType = in.readString();
9485 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009486 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009487 mComponent = ComponentName.readFromParcel(in);
9488
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009489 if (in.readInt() != 0) {
9490 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9491 }
9492
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009493 int N = in.readInt();
9494 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009495 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009496 int i;
9497 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009498 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009499 }
9500 } else {
9501 mCategories = null;
9502 }
9503
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009504 if (in.readInt() != 0) {
9505 mSelector = new Intent(in);
9506 }
9507
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009508 if (in.readInt() != 0) {
9509 mClipData = new ClipData(in);
9510 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009511 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009512 mExtras = in.readBundle();
9513 }
9514
9515 /**
9516 * Parses the "intent" element (and its children) from XML and instantiates
9517 * an Intent object. The given XML parser should be located at the tag
9518 * where parsing should start (often named "intent"), from which the
9519 * basic action, data, type, and package and class name will be
9520 * retrieved. The function will then parse in to any child elements,
9521 * looking for <category android:name="xxx"> tags to add categories and
9522 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9523 * to the intent.
9524 *
9525 * @param resources The Resources to use when inflating resources.
9526 * @param parser The XML parser pointing at an "intent" tag.
9527 * @param attrs The AttributeSet interface for retrieving extended
9528 * attribute data at the current <var>parser</var> location.
9529 * @return An Intent object matching the XML data.
9530 * @throws XmlPullParserException If there was an XML parsing error.
9531 * @throws IOException If there was an I/O error.
9532 */
9533 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9534 throws XmlPullParserException, IOException {
9535 Intent intent = new Intent();
9536
9537 TypedArray sa = resources.obtainAttributes(attrs,
9538 com.android.internal.R.styleable.Intent);
9539
9540 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9541
9542 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9543 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9544 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9545
9546 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9547 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9548 if (packageName != null && className != null) {
9549 intent.setComponent(new ComponentName(packageName, className));
9550 }
9551
9552 sa.recycle();
9553
9554 int outerDepth = parser.getDepth();
9555 int type;
9556 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9557 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9558 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9559 continue;
9560 }
9561
9562 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009563 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009564 sa = resources.obtainAttributes(attrs,
9565 com.android.internal.R.styleable.IntentCategory);
9566 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9567 sa.recycle();
9568
9569 if (cat != null) {
9570 intent.addCategory(cat);
9571 }
9572 XmlUtils.skipCurrentTag(parser);
9573
Craig Mautner21d24a22014-04-23 11:45:37 -07009574 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009575 if (intent.mExtras == null) {
9576 intent.mExtras = new Bundle();
9577 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009578 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009579 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009580
9581 } else {
9582 XmlUtils.skipCurrentTag(parser);
9583 }
9584 }
9585
9586 return intent;
9587 }
Nick Pellyccae4122012-01-09 14:12:58 -08009588
Craig Mautner21d24a22014-04-23 11:45:37 -07009589 /** @hide */
9590 public void saveToXml(XmlSerializer out) throws IOException {
9591 if (mAction != null) {
9592 out.attribute(null, ATTR_ACTION, mAction);
9593 }
9594 if (mData != null) {
9595 out.attribute(null, ATTR_DATA, mData.toString());
9596 }
9597 if (mType != null) {
9598 out.attribute(null, ATTR_TYPE, mType);
9599 }
9600 if (mComponent != null) {
9601 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9602 }
9603 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9604
9605 if (mCategories != null) {
9606 out.startTag(null, TAG_CATEGORIES);
9607 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9608 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9609 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009610 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009611 }
9612 }
9613
9614 /** @hide */
9615 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9616 XmlPullParserException {
9617 Intent intent = new Intent();
9618 final int outerDepth = in.getDepth();
9619
9620 int attrCount = in.getAttributeCount();
9621 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9622 final String attrName = in.getAttributeName(attrNdx);
9623 final String attrValue = in.getAttributeValue(attrNdx);
9624 if (ATTR_ACTION.equals(attrName)) {
9625 intent.setAction(attrValue);
9626 } else if (ATTR_DATA.equals(attrName)) {
9627 intent.setData(Uri.parse(attrValue));
9628 } else if (ATTR_TYPE.equals(attrName)) {
9629 intent.setType(attrValue);
9630 } else if (ATTR_COMPONENT.equals(attrName)) {
9631 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9632 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009633 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009634 } else {
9635 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9636 }
9637 }
9638
9639 int event;
9640 String name;
9641 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9642 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9643 if (event == XmlPullParser.START_TAG) {
9644 name = in.getName();
9645 if (TAG_CATEGORIES.equals(name)) {
9646 attrCount = in.getAttributeCount();
9647 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9648 intent.addCategory(in.getAttributeValue(attrNdx));
9649 }
9650 } else {
9651 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9652 XmlUtils.skipCurrentTag(in);
9653 }
9654 }
9655 }
9656
9657 return intent;
9658 }
9659
Nick Pellyccae4122012-01-09 14:12:58 -08009660 /**
9661 * Normalize a MIME data type.
9662 *
9663 * <p>A normalized MIME type has white-space trimmed,
9664 * content-type parameters removed, and is lower-case.
9665 * This aligns the type with Android best practices for
9666 * intent filtering.
9667 *
9668 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9669 * "text/x-vCard" becomes "text/x-vcard".
9670 *
9671 * <p>All MIME types received from outside Android (such as user input,
9672 * or external sources like Bluetooth, NFC, or the Internet) should
9673 * be normalized before they are used to create an Intent.
9674 *
9675 * @param type MIME data type to normalize
9676 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009677 * @see #setType
9678 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009679 */
9680 public static String normalizeMimeType(String type) {
9681 if (type == null) {
9682 return null;
9683 }
9684
Elliott Hughescb64d432013-08-02 10:00:44 -07009685 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009686
9687 final int semicolonIndex = type.indexOf(';');
9688 if (semicolonIndex != -1) {
9689 type = type.substring(0, semicolonIndex);
9690 }
9691 return type;
9692 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009693
9694 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009695 * Prepare this {@link Intent} to leave an app process.
9696 *
9697 * @hide
9698 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009699 public void prepareToLeaveProcess(Context context) {
9700 final boolean leavingPackage = (mComponent == null)
9701 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9702 prepareToLeaveProcess(leavingPackage);
9703 }
9704
9705 /**
9706 * Prepare this {@link Intent} to leave an app process.
9707 *
9708 * @hide
9709 */
9710 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009711 setAllowFds(false);
9712
9713 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009714 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009715 }
9716 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009717 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009718 }
9719
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009720 if (mExtras != null && !mExtras.isParcelled()) {
9721 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9722 if (intent instanceof Intent) {
9723 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9724 }
9725 }
9726
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009727 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9728 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009729 switch (mAction) {
9730 case ACTION_MEDIA_REMOVED:
9731 case ACTION_MEDIA_UNMOUNTED:
9732 case ACTION_MEDIA_CHECKING:
9733 case ACTION_MEDIA_NOFS:
9734 case ACTION_MEDIA_MOUNTED:
9735 case ACTION_MEDIA_SHARED:
9736 case ACTION_MEDIA_UNSHARED:
9737 case ACTION_MEDIA_BAD_REMOVAL:
9738 case ACTION_MEDIA_UNMOUNTABLE:
9739 case ACTION_MEDIA_EJECT:
9740 case ACTION_MEDIA_SCANNER_STARTED:
9741 case ACTION_MEDIA_SCANNER_FINISHED:
9742 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009743 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9744 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009745 // Ignore legacy actions
9746 break;
9747 default:
9748 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009749 }
9750 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009751
9752 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9753 && leavingPackage) {
9754 switch (mAction) {
9755 case ACTION_PROVIDER_CHANGED:
9756 // Ignore actions that don't need to grant
9757 break;
9758 default:
9759 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9760 }
9761 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009762 }
9763
9764 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009765 * @hide
9766 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009767 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009768 // We just entered destination process, so we should be able to read all
9769 // parcelables inside.
9770 setDefusable(true);
9771
9772 if (mSelector != null) {
9773 mSelector.prepareToEnterProcess();
9774 }
9775 if (mClipData != null) {
9776 mClipData.prepareToEnterProcess();
9777 }
9778
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009779 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009780 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9781 fixUris(mContentUserHint);
9782 mContentUserHint = UserHandle.USER_CURRENT;
9783 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009784 }
9785 }
9786
9787 /**
9788 * @hide
9789 */
9790 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009791 Uri data = getData();
9792 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009793 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009794 }
9795 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009796 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009797 }
9798 String action = getAction();
9799 if (ACTION_SEND.equals(action)) {
9800 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9801 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009802 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009803 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009804 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009805 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9806 if (streams != null) {
9807 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9808 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009809 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009810 }
9811 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9812 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009813 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9814 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9815 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9816 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9817 if (output != null) {
9818 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9819 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009820 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009821 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009822
9823 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009824 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009825 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9826 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009827 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009828 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009829 * @hide
9830 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009831 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009832 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009833 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009834
9835 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009836 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009837
9838 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009839 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009840 // Inspect contained intents to see if we need to migrate extras. We
9841 // don't promote ClipData to the parent, since ChooserActivity will
9842 // already start the picked item as the caller, and we can't combine
9843 // the flags in a safe way.
9844
9845 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009846 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009847 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9848 if (intent != null) {
9849 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009850 }
9851 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009852 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009853 try {
9854 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9855 if (intents != null) {
9856 for (int i = 0; i < intents.length; i++) {
9857 final Intent intent = (Intent) intents[i];
9858 if (intent != null) {
9859 migrated |= intent.migrateExtraStreamToClipData();
9860 }
9861 }
9862 }
9863 } catch (ClassCastException e) {
9864 }
9865 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009866
9867 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009868 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009869 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9870 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9871 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9872 if (stream != null || text != null || htmlText != null) {
9873 final ClipData clipData = new ClipData(
9874 null, new String[] { getType() },
9875 new ClipData.Item(text, htmlText, null, stream));
9876 setClipData(clipData);
9877 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009878 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009879 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009880 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009881 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009882
9883 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009884 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009885 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9886 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9887 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9888 int num = -1;
9889 if (streams != null) {
9890 num = streams.size();
9891 }
9892 if (texts != null) {
9893 if (num >= 0 && num != texts.size()) {
9894 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009895 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009896 }
9897 num = texts.size();
9898 }
9899 if (htmlTexts != null) {
9900 if (num >= 0 && num != htmlTexts.size()) {
9901 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009902 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009903 }
9904 num = htmlTexts.size();
9905 }
9906 if (num > 0) {
9907 final ClipData clipData = new ClipData(
9908 null, new String[] { getType() },
9909 makeClipItem(streams, texts, htmlTexts, 0));
9910
9911 for (int i = 1; i < num; i++) {
9912 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9913 }
9914
9915 setClipData(clipData);
9916 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009917 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009918 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009919 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009920 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009921 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9922 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9923 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9924 final Uri output;
9925 try {
9926 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9927 } catch (ClassCastException e) {
9928 return false;
9929 }
9930 if (output != null) {
9931 setClipData(ClipData.newRawUri("", output));
9932 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9933 return true;
9934 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009935 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009936
9937 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009938 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009939
9940 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9941 ArrayList<String> htmlTexts, int which) {
9942 Uri uri = streams != null ? streams.get(which) : null;
9943 CharSequence text = texts != null ? texts.get(which) : null;
9944 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9945 return new ClipData.Item(text, htmlText, null, uri);
9946 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009947
9948 /** @hide */
9949 public boolean isDocument() {
9950 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9951 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009952}