blob: e7d306dc63ccdc5ddd62d1349514dd01fd217c31 [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 Sharkey179d6b32017-03-12 17:27:47 -060044import 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
Jason Monk2f68e8a2016-02-23 17:57:28 -050070import static android.content.ContentProvider.maybeAddUserId;
71
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072/**
73 * An intent is an abstract description of an operation to be performed. It
74 * can be used with {@link Context#startActivity(Intent) startActivity} to
75 * launch an {@link android.app.Activity},
76 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
77 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
78 * and {@link android.content.Context#startService} or
79 * {@link android.content.Context#bindService} to communicate with a
80 * background {@link android.app.Service}.
81 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 * <p>An Intent provides a facility for performing late runtime binding between the code in
83 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070084 * can be thought of as the glue between activities. It is basically a passive data structure
85 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 *
87 * <div class="special reference">
88 * <h3>Developer Guides</h3>
89 * <p>For information about how to create and resolve intents, read the
90 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
91 * developer guide.</p>
92 * </div>
93 *
94 * <a name="IntentStructure"></a>
95 * <h3>Intent Structure</h3>
96 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 *
98 * <ul>
99 * <li> <p><b>action</b> -- The general action to be performed, such as
100 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
101 * etc.</p>
102 * </li>
103 * <li> <p><b>data</b> -- The data to operate on, such as a person record
104 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
105 * </li>
106 * </ul>
107 *
108 *
109 * <p>Some examples of action/data pairs are:</p>
110 *
111 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700112 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700113 * information about the person whose identifier is "1".</p>
114 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700115 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700116 * the phone dialer with the person filled in.</p>
117 * </li>
118 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
119 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700120 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * a particular URI.</p>
122 * </li>
123 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
124 * the phone dialer with the given number filled in.</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * information about the person whose identifier is "1".</p>
128 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a list of people, which the user can browse through. This example is a
131 * typical top-level entry into the Contacts application, showing you the
132 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700133 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * being used to start an activity to display that person.</p>
135 * </li>
136 * </ul>
137 *
138 * <p>In addition to these primary attributes, there are a number of secondary
139 * attributes that you can also include with an intent:</p>
140 *
141 * <ul>
142 * <li> <p><b>category</b> -- Gives additional information about the action
143 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
144 * appear in the Launcher as a top-level application, while
145 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
146 * of alternative actions the user can perform on a piece of data.</p>
147 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
148 * intent data. Normally the type is inferred from the data itself.
149 * By setting this attribute, you disable that evaluation and force
150 * an explicit type.</p>
151 * <li> <p><b>component</b> -- Specifies an explicit name of a component
152 * class to use for the intent. Normally this is determined by looking
153 * at the other information in the intent (the action, data/type, and
154 * categories) and matching that with a component that can handle it.
155 * If this attribute is set then none of the evaluation is performed,
156 * and this component is used exactly as is. By specifying this attribute,
157 * all of the other Intent attributes become optional.</p>
158 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
159 * This can be used to provide extended information to the component.
160 * For example, if we have a action to send an e-mail message, we could
161 * also include extra pieces of data here to supply a subject, body,
162 * etc.</p>
163 * </ul>
164 *
165 * <p>Here are some examples of other operations you can specify as intents
166 * using these additional parameters:</p>
167 *
168 * <ul>
169 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
170 * Launch the home screen.</p>
171 * </li>
172 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
173 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
174 * vnd.android.cursor.item/phone}</i></b>
175 * -- Display the list of people's phone numbers, allowing the user to
176 * browse through them and pick one and return it to the parent activity.</p>
177 * </li>
178 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
180 * -- Display all pickers for data that can be opened with
181 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
182 * allowing the user to pick one of them and then some data inside of it
183 * and returning the resulting URI to the caller. This can be used,
184 * for example, in an e-mail application to allow the user to pick some
185 * data to include as an attachment.</p>
186 * </li>
187 * </ul>
188 *
189 * <p>There are a variety of standard Intent action and category constants
190 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700191 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700193 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700194 *
195 * <p>Put together, the set of actions, data types, categories, and extra data
196 * defines a language for the system allowing for the expression of phrases
197 * such as "call john smith's cell". As applications are added to the system,
198 * they can extend this language by adding new actions, types, and categories, or
199 * they can modify the behavior of existing phrases by supplying their own
200 * activities that handle them.</p>
201 *
202 * <a name="IntentResolution"></a>
203 * <h3>Intent Resolution</h3>
204 *
205 * <p>There are two primary forms of intents you will use.
206 *
207 * <ul>
208 * <li> <p><b>Explicit Intents</b> have specified a component (via
209 * {@link #setComponent} or {@link #setClass}), which provides the exact
210 * class to be run. Often these will not include any other information,
211 * simply being a way for an application to launch various internal
212 * activities it has as the user interacts with the application.
213 *
214 * <li> <p><b>Implicit Intents</b> have not specified a component;
215 * instead, they must include enough information for the system to
216 * determine which of the available components is best to run for that
217 * intent.
218 * </ul>
219 *
220 * <p>When using implicit intents, given such an arbitrary intent we need to
221 * know what to do with it. This is handled by the process of <em>Intent
222 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
223 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
224 * more activities/receivers) that can handle it.</p>
225 *
226 * <p>The intent resolution mechanism basically revolves around matching an
227 * Intent against all of the &lt;intent-filter&gt; descriptions in the
228 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
229 * objects explicitly registered with {@link Context#registerReceiver}.) More
230 * details on this can be found in the documentation on the {@link
231 * IntentFilter} class.</p>
232 *
233 * <p>There are three pieces of information in the Intent that are used for
234 * resolution: the action, type, and category. Using this information, a query
235 * is done on the {@link PackageManager} for a component that can handle the
236 * intent. The appropriate component is determined based on the intent
237 * information supplied in the <code>AndroidManifest.xml</code> file as
238 * follows:</p>
239 *
240 * <ul>
241 * <li> <p>The <b>action</b>, if given, must be listed by the component as
242 * one it handles.</p>
243 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
244 * already supplied in the Intent. Like the action, if a type is
245 * included in the intent (either explicitly or implicitly in its
246 * data), then this must be listed by the component as one it handles.</p>
247 * <li> For data that is not a <code>content:</code> URI and where no explicit
248 * type is included in the Intent, instead the <b>scheme</b> of the
249 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
250 * considered. Again like the action, if we are matching a scheme it
251 * must be listed by the component as one it can handle.
252 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
253 * by the activity as categories it handles. That is, if you include
254 * the categories {@link #CATEGORY_LAUNCHER} and
255 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
256 * with an intent that lists <em>both</em> of those categories.
257 * Activities will very often need to support the
258 * {@link #CATEGORY_DEFAULT} so that they can be found by
259 * {@link Context#startActivity Context.startActivity()}.</p>
260 * </ul>
261 *
262 * <p>For example, consider the Note Pad sample application that
263 * allows user to browse through a list of notes data and view details about
264 * individual items. Text in italics indicate places were you would replace a
265 * name with one specific to your own package.</p>
266 *
267 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
268 * package="<i>com.android.notepad</i>"&gt;
269 * &lt;application android:icon="@drawable/app_notes"
270 * android:label="@string/app_name"&gt;
271 *
272 * &lt;provider class=".NotePadProvider"
273 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
274 *
275 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.MAIN" /&gt;
278 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700279 * &lt;/intent-filter&gt;
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.VIEW" /&gt;
282 * &lt;action android:name="android.intent.action.EDIT" /&gt;
283 * &lt;action android:name="android.intent.action.PICK" /&gt;
284 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 * &lt;/activity&gt;
293 *
294 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
295 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.VIEW" /&gt;
297 * &lt;action android:name="android.intent.action.EDIT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 *
302 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700303 * &lt;action android:name="android.intent.action.INSERT" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700306 * &lt;/intent-filter&gt;
307 *
308 * &lt;/activity&gt;
309 *
310 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
311 * android:theme="@android:style/Theme.Dialog"&gt;
312 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
314 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
316 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
317 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700318 * &lt;/intent-filter&gt;
319 * &lt;/activity&gt;
320 *
321 * &lt;/application&gt;
322 * &lt;/manifest&gt;</pre>
323 *
324 * <p>The first activity,
325 * <code>com.android.notepad.NotesList</code>, serves as our main
326 * entry into the app. It can do three things as described by its three intent
327 * templates:
328 * <ol>
329 * <li><pre>
330 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700331 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
332 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700333 * &lt;/intent-filter&gt;</pre>
334 * <p>This provides a top-level entry into the NotePad application: the standard
335 * MAIN action is a main entry point (not requiring any other information in
336 * the Intent), and the LAUNCHER category says that this entry point should be
337 * listed in the application launcher.</p>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
341 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
342 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
343 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700344 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700345 * &lt;/intent-filter&gt;</pre>
346 * <p>This declares the things that the activity can do on a directory of
347 * notes. The type being supported is given with the &lt;type&gt; tag, where
348 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
349 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
350 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
351 * The activity allows the user to view or edit the directory of data (via
352 * the VIEW and EDIT actions), or to pick a particular note and return it
353 * to the caller (via the PICK action). Note also the DEFAULT category
354 * supplied here: this is <em>required</em> for the
355 * {@link Context#startActivity Context.startActivity} method to resolve your
356 * activity when its component name is not explicitly specified.</p>
357 * <li><pre>
358 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700359 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
360 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700363 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700364 * the user without needing to know where it came from. The data type
365 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
366 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
367 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
368 * The GET_CONTENT action is similar to the PICK action, where the activity
369 * will return to its caller a piece of data selected by the user. Here,
370 * however, the caller specifies the type of data they desire instead of
371 * the type of data the user will be picking from.</p>
372 * </ol>
373 *
374 * <p>Given these capabilities, the following intents will resolve to the
375 * NotesList activity:</p>
376 *
377 * <ul>
378 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
379 * activities that can be used as top-level entry points into an
380 * application.</p>
381 * <li> <p><b>{ action=android.app.action.MAIN,
382 * category=android.app.category.LAUNCHER }</b> is the actual intent
383 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700384 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700385 * data=content://com.google.provider.NotePad/notes }</b>
386 * displays a list of all the notes under
387 * "content://com.google.provider.NotePad/notes", which
388 * the user can browse through and see the details on.</p>
389 * <li> <p><b>{ action=android.app.action.PICK
390 * data=content://com.google.provider.NotePad/notes }</b>
391 * provides a list of the notes under
392 * "content://com.google.provider.NotePad/notes", from which
393 * the user can pick a note whose data URL is returned back to the caller.</p>
394 * <li> <p><b>{ action=android.app.action.GET_CONTENT
395 * type=vnd.android.cursor.item/vnd.google.note }</b>
396 * is similar to the pick action, but allows the caller to specify the
397 * kind of data they want back so that the system can find the appropriate
398 * activity to pick something of that data type.</p>
399 * </ul>
400 *
401 * <p>The second activity,
402 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
403 * note entry and allows them to edit it. It can do two things as described
404 * by its two intent templates:
405 * <ol>
406 * <li><pre>
407 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700408 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
409 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
410 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
411 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700412 * &lt;/intent-filter&gt;</pre>
413 * <p>The first, primary, purpose of this activity is to let the user interact
414 * with a single note, as decribed by the MIME type
415 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
416 * either VIEW a note or allow the user to EDIT it. Again we support the
417 * DEFAULT category to allow the activity to be launched without explicitly
418 * specifying its component.</p>
419 * <li><pre>
420 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700421 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
422 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
423 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700424 * &lt;/intent-filter&gt;</pre>
425 * <p>The secondary use of this activity is to insert a new note entry into
426 * an existing directory of notes. This is used when the user creates a new
427 * note: the INSERT action is executed on the directory of notes, causing
428 * this activity to run and have the user create the new note data which
429 * it then adds to the content provider.</p>
430 * </ol>
431 *
432 * <p>Given these capabilities, the following intents will resolve to the
433 * NoteEditor activity:</p>
434 *
435 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700436 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700437 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 * shows the user the content of note <var>{ID}</var>.</p>
439 * <li> <p><b>{ action=android.app.action.EDIT
440 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
441 * allows the user to edit the content of note <var>{ID}</var>.</p>
442 * <li> <p><b>{ action=android.app.action.INSERT
443 * data=content://com.google.provider.NotePad/notes }</b>
444 * creates a new, empty note in the notes list at
445 * "content://com.google.provider.NotePad/notes"
446 * and allows the user to edit it. If they keep their changes, the URI
447 * of the newly created note is returned to the caller.</p>
448 * </ul>
449 *
450 * <p>The last activity,
451 * <code>com.android.notepad.TitleEditor</code>, allows the user to
452 * edit the title of a note. This could be implemented as a class that the
453 * application directly invokes (by explicitly setting its component in
454 * the Intent), but here we show a way you can publish alternative
455 * operations on existing data:</p>
456 *
457 * <pre>
458 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700459 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
463 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700464 * &lt;/intent-filter&gt;</pre>
465 *
466 * <p>In the single intent template here, we
467 * have created our own private action called
468 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
469 * edit the title of a note. It must be invoked on a specific note
470 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
471 * view and edit actions, but here displays and edits the title contained
472 * in the note data.
473 *
474 * <p>In addition to supporting the default category as usual, our title editor
475 * also supports two other standard categories: ALTERNATIVE and
476 * SELECTED_ALTERNATIVE. Implementing
477 * these categories allows others to find the special action it provides
478 * without directly knowing about it, through the
479 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
480 * more often to build dynamic menu items with
481 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
482 * template here was also supply an explicit name for the template
483 * (via <code>android:label="@string/resolve_title"</code>) to better control
484 * what the user sees when presented with this activity as an alternative
485 * action to the data they are viewing.
486 *
487 * <p>Given these capabilities, the following intent will resolve to the
488 * TitleEditor activity:</p>
489 *
490 * <ul>
491 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
492 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
493 * displays and allows the user to edit the title associated
494 * with note <var>{ID}</var>.</p>
495 * </ul>
496 *
497 * <h3>Standard Activity Actions</h3>
498 *
499 * <p>These are the current standard actions that Intent defines for launching
500 * activities (usually through {@link Context#startActivity}. The most
501 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
502 * {@link #ACTION_EDIT}.
503 *
504 * <ul>
505 * <li> {@link #ACTION_MAIN}
506 * <li> {@link #ACTION_VIEW}
507 * <li> {@link #ACTION_ATTACH_DATA}
508 * <li> {@link #ACTION_EDIT}
509 * <li> {@link #ACTION_PICK}
510 * <li> {@link #ACTION_CHOOSER}
511 * <li> {@link #ACTION_GET_CONTENT}
512 * <li> {@link #ACTION_DIAL}
513 * <li> {@link #ACTION_CALL}
514 * <li> {@link #ACTION_SEND}
515 * <li> {@link #ACTION_SENDTO}
516 * <li> {@link #ACTION_ANSWER}
517 * <li> {@link #ACTION_INSERT}
518 * <li> {@link #ACTION_DELETE}
519 * <li> {@link #ACTION_RUN}
520 * <li> {@link #ACTION_SYNC}
521 * <li> {@link #ACTION_PICK_ACTIVITY}
522 * <li> {@link #ACTION_SEARCH}
523 * <li> {@link #ACTION_WEB_SEARCH}
524 * <li> {@link #ACTION_FACTORY_TEST}
525 * </ul>
526 *
527 * <h3>Standard Broadcast Actions</h3>
528 *
529 * <p>These are the current standard actions that Intent defines for receiving
530 * broadcasts (usually through {@link Context#registerReceiver} or a
531 * &lt;receiver&gt; tag in a manifest).
532 *
533 * <ul>
534 * <li> {@link #ACTION_TIME_TICK}
535 * <li> {@link #ACTION_TIME_CHANGED}
536 * <li> {@link #ACTION_TIMEZONE_CHANGED}
537 * <li> {@link #ACTION_BOOT_COMPLETED}
538 * <li> {@link #ACTION_PACKAGE_ADDED}
539 * <li> {@link #ACTION_PACKAGE_CHANGED}
540 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 * <li> {@link #ACTION_PACKAGE_RESTARTED}
542 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000543 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
544 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * <li> {@link #ACTION_UID_REMOVED}
546 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700547 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700548 * <li> {@link #ACTION_POWER_DISCONNECTED}
549 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * </ul>
551 *
552 * <h3>Standard Categories</h3>
553 *
554 * <p>These are the current standard categories that can be used to further
555 * clarify an Intent via {@link #addCategory}.
556 *
557 * <ul>
558 * <li> {@link #CATEGORY_DEFAULT}
559 * <li> {@link #CATEGORY_BROWSABLE}
560 * <li> {@link #CATEGORY_TAB}
561 * <li> {@link #CATEGORY_ALTERNATIVE}
562 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
563 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_HOME}
566 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400568 * <li> {@link #CATEGORY_CAR_DOCK}
569 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500570 * <li> {@link #CATEGORY_LE_DESK_DOCK}
571 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200572 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700573 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800574 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661 * performed on a piece of data.
662 */
663 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900666 * Activity Action: Quick view the data. Launches a quick viewer for
667 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900668 * <p>Activities handling this intent action should handle the vast majority of
669 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900670 * <p>Input: {@link #getData} is a mandatory content URI of the item to
671 * preview. {@link #getClipData} contains an optional list of content URIs
672 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
673 * optional index of the URI in the clip data to show first.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900674 * <p>By default quick viewers are supposed to be lightweight and focus on
675 * previewing the content only. They should not expose features such as printing,
676 * opening in an external app, deleting, rotating, casting, etc.
677 * However, if {@link #EXTRA_QUICK_VIEW_ADVANCED} is true, then the quick viewer
678 * may show advanced UI which includes convenience actions suitable for the passed
679 * Uris.
Steve McKayc78bcb82015-07-31 14:35:22 -0700680 * <p>Output: nothing.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900681 * @see #EXTRA_QUICK_VIEW_ADVANCED
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900682 * @see #EXTRA_INDEX
Steve McKayc78bcb82015-07-31 14:35:22 -0700683 */
684 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
685 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
686
687 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700688 * Used to indicate that some piece of data should be attached to some other
689 * place. For example, image data could be attached to a contact. It is up
690 * to the recipient to decide where the data should be attached; the intent
691 * does not specify the ultimate destination.
692 * <p>Input: {@link #getData} is URI of data to be attached.
693 * <p>Output: nothing.
694 */
695 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
696 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800697
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700698 /**
699 * Activity Action: Provide explicit editable access to the given data.
700 * <p>Input: {@link #getData} is URI of data to be edited.
701 * <p>Output: nothing.
702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_EDIT = "android.intent.action.EDIT";
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: Pick an existing item, or insert a new item, and then edit it.
708 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
709 * The extras can contain type specific data to pass through to the editing/creating
710 * activity.
711 * <p>Output: The URI of the item that was picked. This must be a content:
712 * URI so that any receiver can access it.
713 */
714 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
715 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800716
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700717 /**
718 * Activity Action: Pick an item from the data, returning what was selected.
719 * <p>Input: {@link #getData} is URI containing a directory of data
720 * (vnd.android.cursor.dir/*) from which to pick an item.
721 * <p>Output: The URI of the item that was picked.
722 */
723 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
724 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800725
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700726 /**
727 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800728 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800729 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
730 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700731 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
732 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733 * (value: ShortcutIconResource).</p>
734 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800735 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700736 * @see #EXTRA_SHORTCUT_INTENT
737 * @see #EXTRA_SHORTCUT_NAME
738 * @see #EXTRA_SHORTCUT_ICON
739 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
740 * @see android.content.Intent.ShortcutIconResource
741 */
742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
743 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
744
745 /**
746 * The name of the extra used to define the Intent of a shortcut.
747 *
748 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800751 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700752 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
753 /**
754 * The name of the extra used to define the name 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_NAME = "android.intent.extra.shortcut.NAME";
761 /**
762 * The name of the extra used to define the icon, as a Bitmap, 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_ICON = "android.intent.extra.shortcut.ICON";
769 /**
770 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
771 *
772 * @see #ACTION_CREATE_SHORTCUT
773 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800776 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700777 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
778 "android.intent.extra.shortcut.ICON_RESOURCE";
779
780 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500781 * An activity that provides a user interface for adjusting application preferences.
782 * Optional but recommended settings for all applications which have settings.
783 */
784 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
785 public static final String ACTION_APPLICATION_PREFERENCES
786 = "android.intent.action.APPLICATION_PREFERENCES";
787
788 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700789 * Activity Action: Launch an activity showing the app information.
790 * For applications which install other applications (such as app stores), it is recommended
791 * to handle this action for providing the app information to the user.
792 *
793 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
794 * to be displayed.
795 * <p>Output: Nothing.
796 */
797 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
798 public static final String ACTION_SHOW_APP_INFO
799 = "android.intent.action.SHOW_APP_INFO";
800
801 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800802 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700803 *
804 * @see Intent#ACTION_CREATE_SHORTCUT
805 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800806 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
807 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700808 */
809 public static class ShortcutIconResource implements Parcelable {
810 /**
811 * The package name of the application containing the icon.
812 */
813 public String packageName;
814
815 /**
816 * The resource name of the icon, including package, name and type.
817 */
818 public String resourceName;
819
820 /**
821 * Creates a new ShortcutIconResource for the specified context and resource
822 * identifier.
823 *
824 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700825 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700827 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700829 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700830 ShortcutIconResource icon = new ShortcutIconResource();
831 icon.packageName = context.getPackageName();
832 icon.resourceName = context.getResources().getResourceName(resourceId);
833 return icon;
834 }
835
836 /**
837 * Used to read a ShortcutIconResource from a Parcel.
838 */
839 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
840 new Parcelable.Creator<ShortcutIconResource>() {
841
842 public ShortcutIconResource createFromParcel(Parcel source) {
843 ShortcutIconResource icon = new ShortcutIconResource();
844 icon.packageName = source.readString();
845 icon.resourceName = source.readString();
846 return icon;
847 }
848
849 public ShortcutIconResource[] newArray(int size) {
850 return new ShortcutIconResource[size];
851 }
852 };
853
854 /**
855 * No special parcel contents.
856 */
857 public int describeContents() {
858 return 0;
859 }
860
861 public void writeToParcel(Parcel dest, int flags) {
862 dest.writeString(packageName);
863 dest.writeString(resourceName);
864 }
865
866 @Override
867 public String toString() {
868 return resourceName;
869 }
870 }
871
872 /**
873 * Activity Action: Display an activity chooser, allowing the user to pick
874 * what they want to before proceeding. This can be used as an alternative
875 * to the standard activity picker that is displayed by the system when
876 * you try to start an activity with multiple possible matches, with these
877 * differences in behavior:
878 * <ul>
879 * <li>You can specify the title that will appear in the activity chooser.
880 * <li>The user does not have the option to make one of the matching
881 * activities a preferred activity, and all possible activities will
882 * always be shown even if one of them is currently marked as the
883 * preferred activity.
884 * </ul>
885 * <p>
886 * This action should be used when the user will naturally expect to
887 * select an activity in order to proceed. An example if when not to use
888 * it is when the user clicks on a "mailto:" link. They would naturally
889 * expect to go directly to their mail app, so startActivity() should be
890 * called directly: it will
891 * either launch the current preferred app, or put up a dialog allowing the
892 * user to pick an app to use and optionally marking that as preferred.
893 * <p>
894 * In contrast, if the user is selecting a menu item to send a picture
895 * they are viewing to someone else, there are many different things they
896 * may want to do at this point: send it through e-mail, upload it to a
897 * web service, etc. In this case the CHOOSER action should be used, to
898 * always present to the user a list of the things they can do, with a
899 * nice title given by the caller such as "Send this photo with:".
900 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700901 * If you need to grant URI permissions through a chooser, you must specify
902 * the permissions to be granted on the ACTION_CHOOSER Intent
903 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
904 * {@link #setClipData} to specify the URIs to be granted as well as
905 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
906 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
907 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700908 * As a convenience, an Intent of this form can be created with the
909 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700910 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700911 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700912 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
913 * and can optionally have a {@link #EXTRA_TITLE} field containing the
914 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700915 * <p>
916 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700917 */
918 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
919 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
920
921 /**
922 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
923 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700924 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
925 * target intent, also optionally supplying a title. If the target
926 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
927 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
928 * set in the returned chooser intent, with its ClipData set appropriately:
929 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500930 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700931 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700932 * @param target The Intent that the user will be selecting an activity
933 * to perform.
934 * @param title Optional title that will be displayed in the chooser.
935 * @return Return a new Intent object that you can hand to
936 * {@link Context#startActivity(Intent) Context.startActivity()} and
937 * related methods.
938 */
939 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700940 return createChooser(target, title, null);
941 }
942
943 /**
944 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
945 *
946 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
947 * target intent, also optionally supplying a title. If the target
948 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
949 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
950 * set in the returned chooser intent, with its ClipData set appropriately:
951 * either a direct reflection of {@link #getClipData()} if that is non-null,
952 * or a new ClipData built from {@link #getData()}.</p>
953 *
954 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
955 * when the user makes a choice. This can be useful if the calling application wants
956 * to remember the last chosen target and surface it as a more prominent or one-touch
957 * affordance elsewhere in the UI for next time.</p>
958 *
959 * @param target The Intent that the user will be selecting an activity
960 * to perform.
961 * @param title Optional title that will be displayed in the chooser.
962 * @param sender Optional IntentSender to be called when a choice is made.
963 * @return Return a new Intent object that you can hand to
964 * {@link Context#startActivity(Intent) Context.startActivity()} and
965 * related methods.
966 */
967 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700968 Intent intent = new Intent(ACTION_CHOOSER);
969 intent.putExtra(EXTRA_INTENT, target);
970 if (title != null) {
971 intent.putExtra(EXTRA_TITLE, title);
972 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700973
Adam Powell0b3c1122014-10-09 12:50:14 -0700974 if (sender != null) {
975 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
976 }
977
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700978 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700979 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
980 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
981 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700982 if (permFlags != 0) {
983 ClipData targetClipData = target.getClipData();
984 if (targetClipData == null && target.getData() != null) {
985 ClipData.Item item = new ClipData.Item(target.getData());
986 String[] mimeTypes;
987 if (target.getType() != null) {
988 mimeTypes = new String[] { target.getType() };
989 } else {
990 mimeTypes = new String[] { };
991 }
992 targetClipData = new ClipData(null, mimeTypes, item);
993 }
994 if (targetClipData != null) {
995 intent.setClipData(targetClipData);
996 intent.addFlags(permFlags);
997 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700998 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700999
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001000 return intent;
1001 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001002
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001003 /**
1004 * Activity Action: Allow the user to select a particular kind of data and
1005 * return it. This is different than {@link #ACTION_PICK} in that here we
1006 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001007 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001009 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001010 * etc.
1011 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001012 * 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 -07001013 * of data, such as a person contact, you set the MIME type to the kind of
1014 * data you want and launch it with {@link Context#startActivity(Intent)}.
1015 * The system will then launch the best application to select that kind
1016 * of data for you.
1017 * <p>
1018 * You may also be interested in any of a set of types of content the user
1019 * can pick. For example, an e-mail application that wants to allow the
1020 * user to add an attachment to an e-mail message can use this action to
1021 * bring up a list of all of the types of content the user can attach.
1022 * <p>
1023 * In this case, you should wrap the GET_CONTENT intent with a chooser
1024 * (through {@link #createChooser}), which will give the proper interface
1025 * for the user to pick how to send your data and allow you to specify
1026 * a prompt indicating what they are doing. You will usually specify a
1027 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1028 * broad range of content types the user can select from.
1029 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001030 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001031 * only pick from data that can be represented as a stream. This is
1032 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1033 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001034 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001035 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001036 * is locally available on the device. For example, if this extra is set
1037 * to true then an image picker should not show any pictures that are available
1038 * from a remote server but not already on the local device (thus requiring
1039 * they be downloaded when opened).
1040 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001041 * If the caller can handle multiple returned items (the user performing
1042 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1043 * to indicate this.
1044 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001045 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1046 * that no URI is supplied in the intent, as there are no constraints on
1047 * where the returned data originally comes from. You may also include the
1048 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001049 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001050 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1051 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001052 * <p>
1053 * Output: The URI of the item that was picked. This must be a content:
1054 * URI so that any receiver can access it.
1055 */
1056 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1057 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1058 /**
1059 * Activity Action: Dial a number as specified by the data. This shows a
1060 * UI with the number being dialed, allowing the user to explicitly
1061 * initiate the call.
1062 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1063 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1064 * number.
1065 * <p>Output: nothing.
1066 */
1067 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1068 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1069 /**
1070 * Activity Action: Perform a call to someone specified by the data.
1071 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1072 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1073 * number.
1074 * <p>Output: nothing.
1075 *
1076 * <p>Note: there will be restrictions on which applications can initiate a
1077 * call; most applications should use the {@link #ACTION_DIAL}.
1078 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1079 * numbers. Applications can <strong>dial</strong> emergency numbers using
1080 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001081 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001082 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001083 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001084 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001085 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001086 */
1087 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1088 public static final String ACTION_CALL = "android.intent.action.CALL";
1089 /**
1090 * Activity Action: Perform a call to an emergency number specified by the
1091 * data.
1092 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1093 * tel: URI of an explicit phone number.
1094 * <p>Output: nothing.
1095 * @hide
1096 */
1097 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1098 /**
1099 * Activity action: Perform a call to any number (emergency or not)
1100 * specified by the data.
1101 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1102 * tel: URI of an explicit phone number.
1103 * <p>Output: nothing.
1104 * @hide
1105 */
1106 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001107
Santos Cordon15a13782015-03-31 18:32:31 -07001108 /**
fionaxuadfe7002017-02-17 17:20:46 -08001109 * Activity Action: Main entry point for carrier setup apps.
1110 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1111 * carrier service and typically require
1112 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1113 * fulfill their duties.
1114 */
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1116 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1117 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001118 * Activity Action: Send a message to someone specified by the data.
1119 * <p>Input: {@link #getData} is URI describing the target.
1120 * <p>Output: nothing.
1121 */
1122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1123 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1124 /**
1125 * Activity Action: Deliver some data to someone else. Who the data is
1126 * being delivered to is not specified; it is up to the receiver of this
1127 * action to ask the user where the data should be sent.
1128 * <p>
1129 * When launching a SEND intent, you should usually wrap it in a chooser
1130 * (through {@link #createChooser}), which will give the proper interface
1131 * for the user to pick how to send your data and allow you to specify
1132 * a prompt indicating what they are doing.
1133 * <p>
1134 * Input: {@link #getType} is the MIME type of the data being sent.
1135 * get*Extra can have either a {@link #EXTRA_TEXT}
1136 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1137 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1138 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1139 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001140 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1141 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1142 * your text with HTML formatting.
1143 * <p>
1144 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1145 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1146 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1147 * content: URIs and other advanced features of {@link ClipData}. If
1148 * using this approach, you still must supply the same data through the
1149 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1150 * for compatibility with old applications. If you don't set a ClipData,
1151 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001152 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001153 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1154 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1155 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1156 * be openable only as asset typed files using
1157 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1158 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001159 * Optional standard extras, which may be interpreted by some recipients as
1160 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1161 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1162 * <p>
1163 * Output: nothing.
1164 */
1165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166 public static final String ACTION_SEND = "android.intent.action.SEND";
1167 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001168 * Activity Action: Deliver multiple data to someone else.
1169 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001170 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001171 * <p>
1172 * Input: {@link #getType} is the MIME type of the data being sent.
1173 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001174 * #EXTRA_STREAM} field, containing the data to be sent. If using
1175 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1176 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001177 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001178 * Multiple types are supported, and receivers should handle mixed types
1179 * whenever possible. The right way for the receiver to check them is to
1180 * use the content resolver on each URI. The intent sender should try to
1181 * put the most concrete mime type in the intent type, but it can fall
1182 * back to {@literal <type>/*} or {@literal *}/* as needed.
1183 * <p>
1184 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1185 * be image/jpg, but if you are sending image/jpg and image/png, then the
1186 * intent's type should be image/*.
1187 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001188 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1189 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1190 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1191 * content: URIs and other advanced features of {@link ClipData}. If
1192 * using this approach, you still must supply the same data through the
1193 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1194 * for compatibility with old applications. If you don't set a ClipData,
1195 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1196 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001197 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1198 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1199 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1200 * be openable only as asset typed files using
1201 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1202 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001203 * Optional standard extras, which may be interpreted by some recipients as
1204 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1205 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1206 * <p>
1207 * Output: nothing.
1208 */
1209 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1210 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1211 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001212 * Activity Action: Handle an incoming phone call.
1213 * <p>Input: nothing.
1214 * <p>Output: nothing.
1215 */
1216 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1217 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1218 /**
1219 * Activity Action: Insert an empty item into the given container.
1220 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1221 * in which to place the data.
1222 * <p>Output: URI of the new data that was created.
1223 */
1224 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1225 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1226 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001227 * Activity Action: Create a new item in the given container, initializing it
1228 * from the current contents of the clipboard.
1229 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1230 * in which to place the data.
1231 * <p>Output: URI of the new data that was created.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1235 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001236 * Activity Action: Delete the given data from its container.
1237 * <p>Input: {@link #getData} is URI of data to be deleted.
1238 * <p>Output: nothing.
1239 */
1240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1241 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1242 /**
1243 * Activity Action: Run the data, whatever that means.
1244 * <p>Input: ? (Note: this is currently specific to the test harness.)
1245 * <p>Output: nothing.
1246 */
1247 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1248 public static final String ACTION_RUN = "android.intent.action.RUN";
1249 /**
1250 * Activity Action: Perform a data synchronization.
1251 * <p>Input: ?
1252 * <p>Output: ?
1253 */
1254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1256 /**
1257 * Activity Action: Pick an activity given an intent, returning the class
1258 * selected.
1259 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1260 * used with {@link PackageManager#queryIntentActivities} to determine the
1261 * set of activities from which to pick.
1262 * <p>Output: Class name of the activity that was selected.
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1266 /**
1267 * Activity Action: Perform a search.
1268 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1269 * is the text to search for. If empty, simply
1270 * enter your search results Activity with the search UI activated.
1271 * <p>Output: nothing.
1272 */
1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1275 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001276 * Activity Action: Start the platform-defined tutorial
1277 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1278 * is the text to search for. If empty, simply
1279 * enter your search results Activity with the search UI activated.
1280 * <p>Output: nothing.
1281 */
1282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1283 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1284 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001285 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001286 * <p>
1287 * Input: {@link android.app.SearchManager#QUERY
1288 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1289 * a url starts with http or https, the site will be opened. If it is plain
1290 * text, Google search will be applied.
1291 * <p>
1292 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001296
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001297 /**
Jim Miller07994402012-05-02 14:22:27 -07001298 * Activity Action: Perform assist action.
1299 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001300 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1301 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001302 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1303 * information.
Jim Miller07994402012-05-02 14:22:27 -07001304 * Output: nothing.
1305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001308
1309 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001310 * Activity Action: Perform voice 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
Adam Skorydfc7fd72013-08-05 19:23:41 -07001314 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001315 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001316 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001317 */
Amith Yamasani16452032017-03-03 10:15:57 -08001318 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001319 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1320 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1321
1322 /**
Adam Skory7140a252013-09-11 12:04:58 +01001323 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1324 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001325 */
1326 public static final String EXTRA_ASSIST_PACKAGE
1327 = "android.intent.extra.ASSIST_PACKAGE";
1328
1329 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001330 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1331 * application package at the time the assist was invoked.
1332 */
1333 public static final String EXTRA_ASSIST_UID
1334 = "android.intent.extra.ASSIST_UID";
1335
1336 /**
Adam Skory7140a252013-09-11 12:04:58 +01001337 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1338 * information supplied by the current foreground app at the time of the assist request.
1339 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001340 */
1341 public static final String EXTRA_ASSIST_CONTEXT
1342 = "android.intent.extra.ASSIST_CONTEXT";
1343
Jim Miller07994402012-05-02 14:22:27 -07001344 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001345 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1346 * keyboard as the primary input device for assistance.
1347 */
1348 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1349 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1350
1351 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001352 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1353 * that was used to invoke the assist.
1354 */
1355 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1356 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1357
1358 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001359 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001360 * <p>Input: Nothing.
1361 * <p>Output: nothing.
1362 */
1363 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1364 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1365 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001366 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001367 * <p>Input: Nothing.
1368 * <p>Output: Nothing.
1369 */
1370 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1371 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1372
1373 /**
1374 * Activity Action: Show activity for reporting a bug.
1375 * <p>Input: Nothing.
1376 * <p>Output: Nothing.
1377 */
1378 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1379 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1380
1381 /**
1382 * Activity Action: Main entry point for factory tests. Only used when
1383 * the device is booting in factory test node. The implementing package
1384 * must be installed in the system image.
1385 * <p>Input: nothing
1386 * <p>Output: nothing
1387 */
1388 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1389
1390 /**
1391 * Activity Action: The user pressed the "call" button to go to the dialer
1392 * or other appropriate UI for placing a call.
1393 * <p>Input: Nothing.
1394 * <p>Output: Nothing.
1395 */
1396 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1397 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1398
1399 /**
1400 * Activity Action: Start Voice Command.
1401 * <p>Input: Nothing.
1402 * <p>Output: Nothing.
1403 */
1404 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1405 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001406
1407 /**
1408 * Activity Action: Start action associated with long pressing on the
1409 * search key.
1410 * <p>Input: Nothing.
1411 * <p>Output: Nothing.
1412 */
1413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1414 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001415
Jacek Surazski86b6c532009-05-13 14:38:28 +02001416 /**
1417 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1418 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001419 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001420 * <p>Input: No data is specified. The bug report is passed in using
1421 * an {@link #EXTRA_BUG_REPORT} field.
1422 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001423 *
1424 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001425 */
1426 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1427 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001428
1429 /**
1430 * Activity Action: Show power usage information to the user.
1431 * <p>Input: Nothing.
1432 * <p>Output: Nothing.
1433 */
1434 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1435 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001436
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001437 /**
1438 * Activity Action: Setup wizard to launch after a platform update. This
1439 * activity should have a string meta-data field associated with it,
1440 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1441 * the platform for setup. The activity will be launched only if
1442 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1443 * same value.
1444 * <p>Input: Nothing.
1445 * <p>Output: Nothing.
1446 * @hide
1447 */
1448 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1449 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001450
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001451 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001452 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1453 * <p>Input: Nothing.
1454 * <p>Output: Nothing.
1455 * @hide
1456 */
1457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1458 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001459 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001460
1461 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001462 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1463 * <p>Input: Nothing.
1464 * <p>Output: Nothing.
1465 * @hide
1466 */
1467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1468 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001469 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001470
1471 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001472 * Activity Action: Show settings for managing network data usage of a
1473 * specific application. Applications should define an activity that offers
1474 * options to control data usage.
1475 */
1476 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1477 public static final String ACTION_MANAGE_NETWORK_USAGE =
1478 "android.intent.action.MANAGE_NETWORK_USAGE";
1479
1480 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001481 * Activity Action: Launch application installer.
1482 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001483 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001484 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1485 * you can also use "package:<package-name>" to install an application for the
1486 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001487 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1488 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1489 * <p>
1490 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1491 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001492 * <p>
1493 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1494 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1495 * in order to launch the application installer.
1496 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001497 *
1498 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1499 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1500 * @see #EXTRA_RETURN_RESULT
1501 */
1502 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1503 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1504
1505 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001506 * Activity Action: Launch ephemeral installer.
1507 * <p>
1508 * Input: The data must be a http: URI that the ephemeral application is registered
1509 * to handle.
1510 * <p class="note">
1511 * This is a protected intent that can only be sent by the system.
1512 * </p>
1513 *
1514 * @hide
1515 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001516 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1517 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1518 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1519
1520 /**
1521 * Service Action: Resolve ephemeral application.
1522 * <p>
1523 * The system will have a persistent connection to this service.
1524 * This is a protected intent that can only be sent by the system.
1525 * </p>
1526 *
1527 * @hide
1528 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001529 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1530 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1531 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1532
1533 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001534 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1535 * package. Specifies the installer package name; this package will receive the
1536 * {@link #ACTION_APP_ERROR} intent.
1537 */
1538 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1539 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1540
1541 /**
1542 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1543 * package. Specifies that the application being installed should not be
1544 * treated as coming from an unknown source, but as coming from the app
1545 * invoking the Intent. For this to work you must start the installer with
1546 * startActivityForResult().
1547 */
1548 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1549 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1550
1551 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001552 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1553 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001554 * data field originated from.
1555 */
rich cannings706e8ba2012-08-20 13:20:14 -07001556 public static final String EXTRA_ORIGINATING_URI
1557 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001558
1559 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001560 * This extra can be used with any Intent used to launch an activity, supplying information
1561 * about who is launching that activity. This field contains a {@link android.net.Uri}
1562 * object, typically an http: or https: URI of the web site that the referral came from;
1563 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1564 * a native application that it came from.
1565 *
1566 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1567 * instead of directly retrieving the extra. It is also valid for applications to
1568 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1569 * a string, not a Uri; the field here, if supplied, will always take precedence,
1570 * however.</p>
1571 *
1572 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001573 */
1574 public static final String EXTRA_REFERRER
1575 = "android.intent.extra.REFERRER";
1576
1577 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001578 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1579 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1580 * not be created, in particular when Intent extras are supplied through the
1581 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1582 * schemes.
1583 *
1584 * @see #EXTRA_REFERRER
1585 */
1586 public static final String EXTRA_REFERRER_NAME
1587 = "android.intent.extra.REFERRER_NAME";
1588
1589 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001590 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001591 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001592 * @hide
1593 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001594 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001595 public static final String EXTRA_ORIGINATING_UID
1596 = "android.intent.extra.ORIGINATING_UID";
1597
1598 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001599 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1600 * package. Tells the installer UI to skip the confirmation with the user
1601 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001602 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1603 * will no longer show an interstitial message about updating existing
1604 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001605 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001606 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001607 public static final String EXTRA_ALLOW_REPLACE
1608 = "android.intent.extra.ALLOW_REPLACE";
1609
1610 /**
1611 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1612 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1613 * return to the application the result code of the install/uninstall. The returned result
1614 * code will be {@link android.app.Activity#RESULT_OK} on success or
1615 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1616 */
1617 public static final String EXTRA_RETURN_RESULT
1618 = "android.intent.extra.RETURN_RESULT";
1619
1620 /**
1621 * Package manager install result code. @hide because result codes are not
1622 * yet ready to be exposed.
1623 */
1624 public static final String EXTRA_INSTALL_RESULT
1625 = "android.intent.extra.INSTALL_RESULT";
1626
1627 /**
1628 * Activity Action: Launch application uninstaller.
1629 * <p>
1630 * Input: The data must be a package: URI whose scheme specific part is
1631 * the package name of the current installed package to be uninstalled.
1632 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1633 * <p>
1634 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1635 * succeeded.
1636 */
1637 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1638 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1639
1640 /**
msnider3c191b82017-01-23 14:23:16 -08001641 * Activity Action: Launch application uninstaller.
1642 * <p>
1643 * Input: The data must be a package: URI whose scheme specific part is
1644 * the package name of the current installed package to be uninstalled.
1645 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1646 * <p>
1647 * Output: Nothing.
1648 * </p>
1649 */
1650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1651 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1652
1653 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001654 * Specify whether the package should be uninstalled for all users.
1655 * @hide because these should not be part of normal application flow.
1656 */
1657 public static final String EXTRA_UNINSTALL_ALL_USERS
1658 = "android.intent.extra.UNINSTALL_ALL_USERS";
1659
1660 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001661 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1662 * describing the last run version of the platform that was setup.
1663 * @hide
1664 */
1665 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1666
Svet Ganov3695b8a2015-03-24 16:30:25 -07001667 /**
1668 * Activity action: Launch UI to manage the permissions of an app.
1669 * <p>
1670 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1671 * will be managed by the launched UI.
1672 * </p>
1673 * <p>
1674 * Output: Nothing.
1675 * </p>
1676 *
1677 * @see #EXTRA_PACKAGE_NAME
1678 *
1679 * @hide
1680 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001681 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1683 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1684 "android.intent.action.MANAGE_APP_PERMISSIONS";
1685
1686 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001687 * Activity action: Launch UI to manage permissions.
1688 * <p>
1689 * Input: Nothing.
1690 * </p>
1691 * <p>
1692 * Output: Nothing.
1693 * </p>
1694 *
1695 * @hide
1696 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001697 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001698 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1699 public static final String ACTION_MANAGE_PERMISSIONS =
1700 "android.intent.action.MANAGE_PERMISSIONS";
1701
1702 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001703 * Activity action: Launch UI to review permissions for an app.
1704 * The system uses this intent if permission review for apps not
1705 * supporting the new runtime permissions model is enabled. In
1706 * this mode a permission review is required before any of the
1707 * app components can run.
1708 * <p>
1709 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1710 * permissions will be reviewed (mandatory).
1711 * </p>
1712 * <p>
1713 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1714 * be fired after the permission review (optional).
1715 * </p>
1716 * <p>
1717 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1718 * be invoked after the permission review (optional).
1719 * </p>
1720 * <p>
1721 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1722 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1723 * </p>
1724 * <p>
1725 * Output: Nothing.
1726 * </p>
1727 *
1728 * @see #EXTRA_PACKAGE_NAME
1729 * @see #EXTRA_INTENT
1730 * @see #EXTRA_REMOTE_CALLBACK
1731 * @see #EXTRA_RESULT_NEEDED
1732 *
1733 * @hide
1734 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001735 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001736 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1737 public static final String ACTION_REVIEW_PERMISSIONS =
1738 "android.intent.action.REVIEW_PERMISSIONS";
1739
1740 /**
1741 * Intent extra: A callback for reporting remote result as a bundle.
1742 * <p>
1743 * Type: IRemoteCallback
1744 * </p>
1745 *
1746 * @hide
1747 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001748 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001749 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1750
1751 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001752 * Intent extra: An app package name.
1753 * <p>
1754 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001755 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001756 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001757 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001758 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1759
1760 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001761 * Intent extra: An app split name.
1762 * <p>
1763 * Type: String
1764 * </p>
1765 * @hide
1766 */
1767 @SystemApi
1768 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1769
1770 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001771 * Intent extra: An extra for specifying whether a result is needed.
1772 * <p>
1773 * Type: boolean
1774 * </p>
1775 *
1776 * @hide
1777 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001778 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001779 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1780
1781 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001782 * Activity action: Launch UI to manage which apps have a given permission.
1783 * <p>
1784 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1785 * to which will be managed by the launched UI.
1786 * </p>
1787 * <p>
1788 * Output: Nothing.
1789 * </p>
1790 *
1791 * @see #EXTRA_PERMISSION_NAME
1792 *
1793 * @hide
1794 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001795 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1797 public static final String ACTION_MANAGE_PERMISSION_APPS =
1798 "android.intent.action.MANAGE_PERMISSION_APPS";
1799
1800 /**
1801 * Intent extra: The name of a permission.
1802 * <p>
1803 * Type: String
1804 * </p>
1805 *
1806 * @hide
1807 */
1808 @SystemApi
1809 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1810
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001811 // ---------------------------------------------------------------------
1812 // ---------------------------------------------------------------------
1813 // Standard intent broadcast actions (see action variable).
1814
1815 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001816 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1817 * <p>
1818 * For historical reasons, the name of this broadcast action refers to the power
1819 * state of the screen but it is actually sent in response to changes in the
1820 * overall interactive state of the device.
1821 * </p><p>
1822 * This broadcast is sent when the device becomes non-interactive which may have
1823 * nothing to do with the screen turning off. To determine the
1824 * actual state of the screen, use {@link android.view.Display#getState}.
1825 * </p><p>
1826 * See {@link android.os.PowerManager#isInteractive} for details.
1827 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001828 * You <em>cannot</em> receive this through components declared in
1829 * manifests, only by explicitly registering for it with
1830 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1831 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001832 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001833 * <p class="note">This is a protected intent that can only be sent
1834 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001835 */
1836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1837 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001838
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001839 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001840 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1841 * <p>
1842 * For historical reasons, the name of this broadcast action refers to the power
1843 * state of the screen but it is actually sent in response to changes in the
1844 * overall interactive state of the device.
1845 * </p><p>
1846 * This broadcast is sent when the device becomes interactive which may have
1847 * nothing to do with the screen turning on. To determine the
1848 * actual state of the screen, use {@link android.view.Display#getState}.
1849 * </p><p>
1850 * See {@link android.os.PowerManager#isInteractive} for details.
1851 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001852 * You <em>cannot</em> receive this through components declared in
1853 * manifests, only by explicitly registering for it with
1854 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1855 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001856 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001857 * <p class="note">This is a protected intent that can only be sent
1858 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001859 */
1860 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1861 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001862
1863 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001864 * Broadcast Action: Sent after the system stops dreaming.
1865 *
1866 * <p class="note">This is a protected intent that can only be sent by the system.
1867 * It is only sent to registered receivers.</p>
1868 */
1869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1870 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1871
1872 /**
1873 * Broadcast Action: Sent after the system starts dreaming.
1874 *
1875 * <p class="note">This is a protected intent that can only be sent by the system.
1876 * It is only sent to registered receivers.</p>
1877 */
1878 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1879 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1880
1881 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001882 * 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 -07001883 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001884 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001885 * <p class="note">This is a protected intent that can only be sent
1886 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001887 */
1888 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001889 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001890
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001891 /**
1892 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001893 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001894 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001895 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1896 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001897 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001898 * <p class="note">This is a protected intent that can only be sent
1899 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001900 */
1901 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1902 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1903 /**
1904 * Broadcast Action: The time was set.
1905 */
1906 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1907 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1908 /**
1909 * Broadcast Action: The date has changed.
1910 */
1911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1912 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1913 /**
1914 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1915 * <ul>
1916 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1917 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001918 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001919 * <p class="note">This is a protected intent that can only be sent
1920 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001921 */
1922 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1923 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1924 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001925 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1926 * DNS entries should be tossed.
1927 * @hide
1928 */
1929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1930 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1931 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001932 * Alarm Changed Action: This is broadcast when the AlarmClock
1933 * application's alarm is set or unset. It is used by the
1934 * AlarmClock application and the StatusBar service.
1935 * @hide
1936 */
1937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1938 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001939
1940 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001941 * Broadcast Action: This is broadcast once, after the user has finished
1942 * booting, but while still in the "locked" state. It can be used to perform
1943 * application-specific initialization, such as installing alarms. You must
1944 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1945 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001946 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001947 * This broadcast is sent immediately at boot by all devices (regardless of
1948 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1949 * higher. Upon receipt of this broadcast, the user is still locked and only
1950 * device-protected storage can be accessed safely. If you want to access
1951 * credential-protected storage, you need to wait for the user to be
1952 * unlocked (typically by entering their lock pattern or PIN for the first
1953 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1954 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1955 * <p>
1956 * To receive this broadcast, your receiver component must be marked as
1957 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001958 * <p class="note">
1959 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001960 *
1961 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001962 */
1963 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1964 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1965
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001966 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001967 * Broadcast Action: This is broadcast once, after the user has finished
1968 * booting. It can be used to perform application-specific initialization,
1969 * such as installing alarms. You must hold the
1970 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1971 * order to receive this broadcast.
1972 * <p>
1973 * This broadcast is sent at boot by all devices (both with and without
1974 * direct boot support). Upon receipt of this broadcast, the user is
1975 * unlocked and both device-protected and credential-protected storage can
1976 * accessed safely.
1977 * <p>
1978 * If you need to run while the user is still locked (before they've entered
1979 * their lock pattern or PIN for the first time), you can listen for the
1980 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1981 * <p class="note">
1982 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07001985 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001986 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001988 /**
1989 * Broadcast Action: This is broadcast when a user action should request a
1990 * temporary system dialog to dismiss. Some examples of temporary system
1991 * dialogs are the notification window-shade and the recent tasks dialog.
1992 */
1993 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1994 /**
1995 * Broadcast Action: Trigger the download and eventual installation
1996 * of a package.
1997 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001998 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001999 * <p class="note">This is a protected intent that can only be sent
2000 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002001 *
2002 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002003 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002004 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002005 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2006 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2007 /**
2008 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002009 * device. The data contains the name of the package. Note that the
2010 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002011 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002012 * <ul>
2013 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2014 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2015 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2016 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002017 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002018 * <p class="note">This is a protected intent that can only be sent
2019 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002020 */
2021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2022 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2023 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002024 * Broadcast Action: A new version of an application package has been
2025 * installed, replacing an existing version that was previously installed.
2026 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002027 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002028 * <ul>
2029 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2030 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002031 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002032 * <p class="note">This is a protected intent that can only be sent
2033 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002034 */
2035 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2036 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2037 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002038 * Broadcast Action: A new version of your application has been installed
2039 * over an existing one. This is only sent to the application that was
2040 * replaced. It does not contain any additional data; to receive it, just
2041 * use an intent filter for this action.
2042 *
2043 * <p class="note">This is a protected intent that can only be sent
2044 * by the system.
2045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2048 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002049 * Broadcast Action: An existing application package has been removed from
2050 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002051 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002052 * <ul>
2053 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2054 * to the package.
2055 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2056 * application -- data and code -- is being removed.
2057 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2058 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2059 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002060 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002061 * <p class="note">This is a protected intent that can only be sent
2062 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002063 */
2064 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2065 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2066 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002067 * Broadcast Action: An existing application package has been completely
2068 * removed from the device. The data contains the name of the package.
2069 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2070 * {@link #EXTRA_DATA_REMOVED} is true and
2071 * {@link #EXTRA_REPLACING} is false of that broadcast.
2072 *
2073 * <ul>
2074 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2075 * to the package.
2076 * </ul>
2077 *
2078 * <p class="note">This is a protected intent that can only be sent
2079 * by the system.
2080 */
2081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2082 public static final String ACTION_PACKAGE_FULLY_REMOVED
2083 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2084 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002085 * Broadcast Action: An existing application package has been changed (for
2086 * example, a component has been enabled or disabled). The data contains
2087 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002088 * <ul>
2089 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002090 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002091 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002092 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2093 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002094 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002095 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002096 * <p class="note">This is a protected intent that can only be sent
2097 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002098 */
2099 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2100 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2101 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002102 * @hide
2103 * Broadcast Action: Ask system services if there is any reason to
2104 * restart the given package. The data contains the name of the
2105 * package.
2106 * <ul>
2107 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2108 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2109 * </ul>
2110 *
2111 * <p class="note">This is a protected intent that can only be sent
2112 * by the system.
2113 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002114 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2116 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2117 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002118 * Broadcast Action: The user has restarted a package, and all of its
2119 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002120 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002121 * be removed. Note that the restarted package does <em>not</em>
2122 * receive this broadcast.
2123 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002124 * <ul>
2125 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2126 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002127 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002128 * <p class="note">This is a protected intent that can only be sent
2129 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002130 */
2131 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2132 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2133 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002134 * Broadcast Action: The user has cleared the data of a package. This should
2135 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002136 * its persistent data is erased and this broadcast sent.
2137 * Note that the cleared package does <em>not</em>
2138 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002139 * <ul>
2140 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2141 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002142 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002143 * <p class="note">This is a protected intent that can only be sent
2144 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002145 */
2146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2147 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2148 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002149 * Broadcast Action: Packages have been suspended.
2150 * <p>Includes the following extras:
2151 * <ul>
2152 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2153 * </ul>
2154 *
2155 * <p class="note">This is a protected intent that can only be sent
2156 * by the system. It is only sent to registered receivers.
2157 */
2158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2159 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2160 /**
2161 * Broadcast Action: Packages have been unsuspended.
2162 * <p>Includes the following extras:
2163 * <ul>
2164 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2165 * </ul>
2166 *
2167 * <p class="note">This is a protected intent that can only be sent
2168 * by the system. It is only sent to registered receivers.
2169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2172 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002173 * Broadcast Action: A user ID has been removed from the system. The user
2174 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002175 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002176 * <p class="note">This is a protected intent that can only be sent
2177 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2180 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002181
2182 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002183 * Broadcast Action: Sent to the installer package of an application when
2184 * that application is first launched (that is the first time it is moved
2185 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002186 *
2187 * <p class="note">This is a protected intent that can only be sent
2188 * by the system.
2189 */
2190 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2191 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2192
2193 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002194 * Broadcast Action: Sent to the system package verifier when a package
2195 * needs to be verified. The data contains the package URI.
2196 * <p class="note">
2197 * This is a protected intent that can only be sent by the system.
2198 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002199 */
2200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2202
2203 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002204 * Broadcast Action: Sent to the system package verifier when a package is
2205 * verified. The data contains the package URI.
2206 * <p class="note">
2207 * This is a protected intent that can only be sent by the system.
2208 */
2209 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2210 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2211
2212 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002213 * Broadcast Action: Sent to the system intent filter verifier when an
2214 * intent filter needs to be verified. The data contains the filter data
2215 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002216 * <p class="note">
2217 * This is a protected intent that can only be sent by the system.
2218 * </p>
2219 *
2220 * @hide
2221 */
2222 @SystemApi
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2225
2226 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002227 * Broadcast Action: Resources for a set of packages (which were
2228 * previously unavailable) are currently
2229 * available since the media on which they exist is available.
2230 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2231 * list of packages whose availability changed.
2232 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2233 * list of uids of packages whose availability changed.
2234 * Note that the
2235 * packages in this list do <em>not</em> receive this broadcast.
2236 * The specified set of packages are now available on the system.
2237 * <p>Includes the following extras:
2238 * <ul>
2239 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2240 * whose resources(were previously unavailable) are currently available.
2241 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2242 * packages whose resources(were previously unavailable)
2243 * are currently available.
2244 * </ul>
2245 *
2246 * <p class="note">This is a protected intent that can only be sent
2247 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002250 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2251 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002252
2253 /**
2254 * Broadcast Action: Resources for a set of packages are currently
2255 * unavailable since the media on which they exist is unavailable.
2256 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2257 * list of packages whose availability changed.
2258 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2259 * list of uids of packages whose availability changed.
2260 * The specified set of packages can no longer be
2261 * launched and are practically unavailable on the system.
2262 * <p>Inclues the following extras:
2263 * <ul>
2264 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2265 * whose resources are no longer available.
2266 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2267 * whose resources are no longer available.
2268 * </ul>
2269 *
2270 * <p class="note">This is a protected intent that can only be sent
2271 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002274 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002275 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002276
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002277 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002278 * Broadcast Action: preferred activities have changed *explicitly*.
2279 *
2280 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2281 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2282 * be sent.
2283 *
2284 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2285 *
2286 * @hide
2287 */
2288 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2289 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2290 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2291
2292
2293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002294 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002295 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002296 * This should <em>only</em> be used to determine when the wallpaper
2297 * has changed to show the new wallpaper to the user. You should certainly
2298 * never, in response to this, change the wallpaper or other attributes of
2299 * it such as the suggested size. That would be crazy, right? You'd cause
2300 * all kinds of loops, especially if other apps are doing similar things,
2301 * right? Of course. So please don't do this.
2302 *
2303 * @deprecated Modern applications should use
2304 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2305 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2306 * shown behind their UI, rather than watching for this broadcast and
2307 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002308 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002309 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002310 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2311 /**
2312 * Broadcast Action: The current device {@link android.content.res.Configuration}
2313 * (orientation, locale, etc) has changed. When such a change happens, the
2314 * UIs (view hierarchy) will need to be rebuilt based on this new
2315 * information; for the most part, applications don't need to worry about
2316 * this, because the system will take care of stopping and restarting the
2317 * application to make sure it sees the new changes. Some system code that
2318 * can not be restarted will need to watch for this action and handle it
2319 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002320 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002321 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002322 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002323 * in manifests, only by explicitly registering for it with
2324 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2325 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002326 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002327 * <p class="note">This is a protected intent that can only be sent
2328 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002329 *
2330 * @see android.content.res.Configuration
2331 */
2332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2333 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2334 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002335 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002336 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002337 * <p class="note">This is a protected intent that can only be sent
2338 * by the system.
2339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2342 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002343 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2344 * charging state, level, and other information about the battery.
2345 * See {@link android.os.BatteryManager} for documentation on the
2346 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002347 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002348 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002349 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002350 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002351 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002352 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2353 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2354 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2355 * broadcasts that are sent and can be received through manifest
2356 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002357 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002358 * <p class="note">This is a protected intent that can only be sent
2359 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002360 */
2361 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2362 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2363 /**
2364 * Broadcast Action: Indicates low battery condition on the device.
2365 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002366 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002367 * <p class="note">This is a protected intent that can only be sent
2368 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2371 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2372 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002373 * Broadcast Action: Indicates the battery is now okay after being low.
2374 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2375 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002376 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002377 * <p class="note">This is a protected intent that can only be sent
2378 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002379 */
2380 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2381 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2382 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002383 * Broadcast Action: External power has been connected to the device.
2384 * This is intended for applications that wish to register specifically to this notification.
2385 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2386 * stay active to receive this notification. This action can be used to implement actions
2387 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002388 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002389 * <p class="note">This is a protected intent that can only be sent
2390 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002391 */
2392 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002393 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002394 /**
2395 * Broadcast Action: External power has been removed from the device.
2396 * This is intended for applications that wish to register specifically to this notification.
2397 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2398 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002399 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002400 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002401 * <p class="note">This is a protected intent that can only be sent
2402 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002403 */
2404 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002405 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002406 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002407 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002408 * Broadcast Action: Device is shutting down.
2409 * This is broadcast when the device is being shut down (completely turned
2410 * off, not sleeping). Once the broadcast is complete, the final shutdown
2411 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002412 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002413 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002414 * <p class="note">This is a protected intent that can only be sent
2415 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002416 * <p>May include the following extras:
2417 * <ul>
2418 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2419 * shutdown is only for userspace processes. If not set, assumed to be false.
2420 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002421 */
2422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002423 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002424 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002425 * Activity Action: Start this activity to request system shutdown.
2426 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002427 * to request confirmation from the user before shutting down. The optional boolean
2428 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2429 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002430 *
2431 * <p class="note">This is a protected intent that can only be sent
2432 * by the system.
2433 *
2434 * {@hide}
2435 */
2436 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2437 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002438 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002439 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002440 * <p class="note">
2441 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002442 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002443 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2444 * or above, this broadcast will no longer be delivered to any
2445 * {@link BroadcastReceiver} defined in your manifest. Instead,
2446 * apps are strongly encouraged to use the improved
2447 * {@link Context#getCacheDir()} behavior so the system can
2448 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002451 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002452 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2453 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002454 * Broadcast Action: Indicates low storage space condition on the device no
2455 * longer exists
2456 * <p class="note">
2457 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002458 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002459 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2460 * or above, this broadcast will no longer be delivered to any
2461 * {@link BroadcastReceiver} defined in your manifest. Instead,
2462 * apps are strongly encouraged to use the improved
2463 * {@link Context#getCacheDir()} behavior so the system can
2464 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 */
2466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002467 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2469 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002470 * Broadcast Action: A sticky broadcast that indicates a storage space full
2471 * condition on the device. This is intended for activities that want to be
2472 * able to fill the data partition completely, leaving only enough free
2473 * space to prevent system-wide SQLite failures.
2474 * <p class="note">
2475 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002476 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002477 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2478 * or above, this broadcast will no longer be delivered to any
2479 * {@link BroadcastReceiver} defined in your manifest. Instead,
2480 * apps are strongly encouraged to use the improved
2481 * {@link Context#getCacheDir()} behavior so the system can
2482 * automatically free up storage when needed.
2483 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002486 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002487 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2488 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002489 * Broadcast Action: Indicates storage space full condition on the device no
2490 * longer exists.
2491 * <p class="note">
2492 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002493 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002494 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2495 * or above, this broadcast will no longer be delivered to any
2496 * {@link BroadcastReceiver} defined in your manifest. Instead,
2497 * apps are strongly encouraged to use the improved
2498 * {@link Context#getCacheDir()} behavior so the system can
2499 * automatically free up storage when needed.
2500 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002501 */
2502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002503 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002504 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2505 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002506 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2507 * and package management should be started.
2508 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2509 * notification.
2510 */
2511 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2512 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2513 /**
2514 * Broadcast Action: The device has entered USB Mass Storage mode.
2515 * This is used mainly for the USB Settings panel.
2516 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2517 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002518 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002519 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002520 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002521 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2522
2523 /**
2524 * Broadcast Action: The device has exited USB Mass Storage mode.
2525 * This is used mainly for the USB Settings panel.
2526 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2527 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002528 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002529 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002530 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002531 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2532
2533 /**
2534 * Broadcast Action: External media has been removed.
2535 * The path to the mount point for the removed media is contained in the Intent.mData field.
2536 */
2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2538 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2539
2540 /**
2541 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002542 * 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 -07002543 */
2544 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2545 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2546
2547 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002548 * Broadcast Action: External media is present, and being disk-checked
2549 * 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 -08002550 */
2551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2552 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2553
2554 /**
2555 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2556 * 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 -08002557 */
2558 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2559 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2560
2561 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002562 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002563 * 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 -07002564 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2565 * media was mounted read only.
2566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2569
2570 /**
2571 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002572 * 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 -07002573 */
2574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2575 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2576
2577 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002578 * Broadcast Action: External media is no longer being shared via USB mass storage.
2579 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2580 *
2581 * @hide
2582 */
2583 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2584
2585 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002586 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2587 * The path to the mount point for the removed media is contained in the Intent.mData field.
2588 */
2589 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2590 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2591
2592 /**
2593 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002594 * 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 -07002595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2597 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2598
2599 /**
2600 * Broadcast Action: User has expressed the desire to remove the external storage media.
2601 * Applications should close all files they have open within the mount point when they receive this intent.
2602 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2606
2607 /**
2608 * Broadcast Action: The media scanner has started scanning a directory.
2609 * The path to the directory being scanned is contained in the Intent.mData field.
2610 */
2611 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2612 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2613
2614 /**
2615 * Broadcast Action: The media scanner has finished scanning a directory.
2616 * The path to the scanned directory is contained in the Intent.mData field.
2617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2619 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2620
2621 /**
2622 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2623 * The path to the file is contained in the Intent.mData field.
2624 */
2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2627
2628 /**
2629 * Broadcast Action: The "Media Button" was pressed. Includes a single
2630 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2631 * caused the broadcast.
2632 */
2633 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2634 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2635
2636 /**
2637 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2638 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2639 * caused the broadcast.
2640 */
2641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2642 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2643
2644 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2645 // location; they are not general-purpose actions.
2646
2647 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002648 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2651 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2652 "android.intent.action.GTALK_CONNECTED";
2653
2654 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002655 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002656 */
2657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2658 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2659 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002660
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002661 /**
2662 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665 public static final String ACTION_INPUT_METHOD_CHANGED =
2666 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002667
2668 /**
2669 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2670 * more radios have been turned off or on. The intent will have the following extra value:</p>
2671 * <ul>
2672 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2673 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2674 * turned off</li>
2675 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002676 *
Peng Xua35b5532016-01-20 00:05:45 -08002677 * <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 -07002678 */
2679 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2680 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2681
2682 /**
2683 * Broadcast Action: Some content providers have parts of their namespace
2684 * where they publish new events or items that the user may be especially
2685 * interested in. For these things, they may broadcast this action when the
2686 * set of interesting items change.
2687 *
2688 * For example, GmailProvider sends this notification when the set of unread
2689 * mail in the inbox changes.
2690 *
2691 * <p>The data of the intent identifies which part of which provider
2692 * changed. When queried through the content resolver, the data URI will
2693 * return the data set in question.
2694 *
2695 * <p>The intent will have the following extra values:
2696 * <ul>
2697 * <li><em>count</em> - The number of items in the data set. This is the
2698 * same as the number of items in the cursor returned by querying the
2699 * data URI. </li>
2700 * </ul>
2701 *
2702 * This intent will be sent at boot (if the count is non-zero) and when the
2703 * data set changes. It is possible for the data set to change without the
2704 * count changing (for example, if a new unread message arrives in the same
2705 * sync operation in which a message is archived). The phone should still
2706 * ring/vibrate/etc as normal in this case.
2707 */
2708 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2709 public static final String ACTION_PROVIDER_CHANGED =
2710 "android.intent.action.PROVIDER_CHANGED";
2711
2712 /**
2713 * Broadcast Action: Wired Headset plugged in or unplugged.
2714 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002715 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2716 * and documentation.
2717 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002718 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002719 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002720 */
2721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002722 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002723
2724 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002725 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2726 * <ul>
2727 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2728 * </ul>
2729 *
2730 * <p class="note">This is a protected intent that can only be sent
2731 * by the system.
2732 *
2733 * @hide
2734 */
2735 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2736 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2737 = "android.intent.action.ADVANCED_SETTINGS";
2738
2739 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002740 * Broadcast Action: Sent after application restrictions are changed.
2741 *
2742 * <p class="note">This is a protected intent that can only be sent
2743 * by the system.</p>
2744 */
2745 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2746 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2747 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2748
2749 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002750 * Broadcast Action: An outgoing call is about to be placed.
2751 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002752 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002753 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002754 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002755 * the phone number originally intended to be dialed.</li>
2756 * </ul>
2757 * <p>Once the broadcast is finished, the resultData is used as the actual
2758 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002759 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002760 * outgoing call in turn: for example, a parental control application
2761 * might verify that the user is authorized to place the call at that
2762 * time, then a number-rewriting application might add an area code if
2763 * one was not specified.</p>
2764 * <p>For consistency, any receiver whose purpose is to prohibit phone
2765 * calls should have a priority of 0, to ensure it will see the final
2766 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002767 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002768 * should have a positive priority.
2769 * Negative priorities are reserved for the system for this broadcast;
2770 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002771 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2772 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002773 * <p>Emergency calls cannot be intercepted using this mechanism, and
2774 * other calls cannot be modified to call emergency numbers using this
2775 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002776 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2777 * call to use their own service instead. Those apps should first prevent
2778 * the call from being placed by setting resultData to <code>null</code>
2779 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002780 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002781 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2782 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002783 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002784 * <p class="note">This is a protected intent that can only be sent
2785 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002786 */
2787 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2788 public static final String ACTION_NEW_OUTGOING_CALL =
2789 "android.intent.action.NEW_OUTGOING_CALL";
2790
2791 /**
2792 * Broadcast Action: Have the device reboot. This is only for use by
2793 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002794 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002795 * <p class="note">This is a protected intent that can only be sent
2796 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002797 */
2798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2799 public static final String ACTION_REBOOT =
2800 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002801
Wei Huang97ecc9c2009-05-11 17:44:20 -07002802 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002803 * Broadcast Action: A sticky broadcast for changes in the physical
2804 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002805 *
2806 * <p>The intent will have the following extra values:
2807 * <ul>
2808 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002809 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002810 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002811 * <p>This is intended for monitoring the current physical dock state.
2812 * See {@link android.app.UiModeManager} for the normal API dealing with
2813 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_DOCK_EVENT =
2817 "android.intent.action.DOCK_EVENT";
2818
2819 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002820 * Broadcast Action: A broadcast when idle maintenance can be started.
2821 * This means that the user is not interacting with the device and is
2822 * not expected to do so soon. Typical use of the idle maintenance is
2823 * to perform somehow expensive tasks that can be postponed at a moment
2824 * when they will not degrade user experience.
2825 * <p>
2826 * <p class="note">In order to keep the device responsive in case of an
2827 * unexpected user interaction, implementations of a maintenance task
2828 * should be interruptible. In such a scenario a broadcast with action
2829 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2830 * should not do the maintenance work in
2831 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2832 * maintenance service by {@link Context#startService(Intent)}. Also
2833 * you should hold a wake lock while your maintenance service is running
2834 * to prevent the device going to sleep.
2835 * </p>
2836 * <p>
2837 * <p class="note">This is a protected intent that can only be sent by
2838 * the system.
2839 * </p>
2840 *
2841 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002842 *
2843 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_IDLE_MAINTENANCE_START =
2847 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2848
2849 /**
2850 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2851 * This means that the user was not interacting with the device as a result
2852 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2853 * was sent and now the user started interacting with the device. Typical
2854 * use of the idle maintenance is to perform somehow expensive tasks that
2855 * can be postponed at a moment when they will not degrade user experience.
2856 * <p>
2857 * <p class="note">In order to keep the device responsive in case of an
2858 * unexpected user interaction, implementations of a maintenance task
2859 * should be interruptible. Hence, on receiving a broadcast with this
2860 * action, the maintenance task should be interrupted as soon as possible.
2861 * In other words, you should not do the maintenance work in
2862 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2863 * maintenance service that was started on receiving of
2864 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2865 * lock you acquired when your maintenance service started.
2866 * </p>
2867 * <p class="note">This is a protected intent that can only be sent
2868 * by the system.
2869 *
2870 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002871 *
2872 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002873 */
2874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2875 public static final String ACTION_IDLE_MAINTENANCE_END =
2876 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2877
2878 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002879 * Broadcast Action: a remote intent is to be broadcasted.
2880 *
2881 * A remote intent is used for remote RPC between devices. The remote intent
2882 * is serialized and sent from one device to another device. The receiving
2883 * device parses the remote intent and broadcasts it. Note that anyone can
2884 * broadcast a remote intent. However, if the intent receiver of the remote intent
2885 * does not trust intent broadcasts from arbitrary intent senders, it should require
2886 * the sender to hold certain permissions so only trusted sender's broadcast will be
2887 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002888 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002889 */
2890 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002891 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002892
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002893 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002894 * Broadcast Action: This is broadcast once when the user is booting after a
2895 * system update. It can be used to perform cleanup or upgrades after a
2896 * system update.
2897 * <p>
2898 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2899 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2900 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2901 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002902 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002903 * @hide
2904 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002905 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002906 public static final String ACTION_PRE_BOOT_COMPLETED =
2907 "android.intent.action.PRE_BOOT_COMPLETED";
2908
Amith Yamasani13593602012-03-22 16:16:17 -07002909 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002910 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002911 * on restricted users. The broadcast intent contains an extra
2912 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2913 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2914 * String[] depending on the restriction type.<p/>
2915 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002916 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2917 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2918 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002919 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2920 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002921 * @see RestrictionEntry
2922 */
2923 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2924 "android.intent.action.GET_RESTRICTION_ENTRIES";
2925
2926 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002927 * Sent the first time a user is starting, to allow system apps to
2928 * perform one time initialization. (This will not be seen by third
2929 * party applications because a newly initialized user does not have any
2930 * third party applications installed for it.) This is sent early in
2931 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002932 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2933 * broadcast, since it is part of a visible user interaction; be as quick
2934 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002935 */
2936 public static final String ACTION_USER_INITIALIZE =
2937 "android.intent.action.USER_INITIALIZE";
2938
2939 /**
2940 * Sent when a user switch is happening, causing the process's user to be
2941 * brought to the foreground. This is only sent to receivers registered
2942 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2943 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002944 * foreground. This is sent as a foreground
2945 * broadcast, since it is part of a visible user interaction; be as quick
2946 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002947 */
2948 public static final String ACTION_USER_FOREGROUND =
2949 "android.intent.action.USER_FOREGROUND";
2950
2951 /**
2952 * Sent when a user switch is happening, causing the process's user to be
2953 * sent to the background. This is only sent to receivers registered
2954 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2955 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002956 * background. This is sent as a foreground
2957 * broadcast, since it is part of a visible user interaction; be as quick
2958 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002959 */
2960 public static final String ACTION_USER_BACKGROUND =
2961 "android.intent.action.USER_BACKGROUND";
2962
2963 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002964 * Broadcast sent to the system when a user is added. Carries an extra
2965 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2966 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002967 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002968 * @hide
2969 */
2970 public static final String ACTION_USER_ADDED =
2971 "android.intent.action.USER_ADDED";
2972
2973 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002974 * Broadcast sent by the system when a user is started. Carries an extra
2975 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002976 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002977 * that has been started. This is sent as a foreground
2978 * broadcast, since it is part of a visible user interaction; be as quick
2979 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002980 * @hide
2981 */
2982 public static final String ACTION_USER_STARTED =
2983 "android.intent.action.USER_STARTED";
2984
2985 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002986 * Broadcast sent when a user is in the process of starting. Carries an extra
2987 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2988 * sent to registered receivers, not manifest receivers. It is sent to all
2989 * users (including the one that is being started). You must hold
2990 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2991 * this broadcast. This is sent as a background broadcast, since
2992 * its result is not part of the primary UX flow; to safely keep track of
2993 * started/stopped state of a user you can use this in conjunction with
2994 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2995 * other user state broadcasts since those are foreground broadcasts so can
2996 * execute in a different order.
2997 * @hide
2998 */
2999 public static final String ACTION_USER_STARTING =
3000 "android.intent.action.USER_STARTING";
3001
3002 /**
3003 * Broadcast sent when a user is going to be stopped. Carries an extra
3004 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3005 * sent to registered receivers, not manifest receivers. It is sent to all
3006 * users (including the one that is being stopped). You must hold
3007 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3008 * this broadcast. The user will not stop until all receivers have
3009 * handled the broadcast. This is sent as a background broadcast, since
3010 * its result is not part of the primary UX flow; to safely keep track of
3011 * started/stopped state of a user you can use this in conjunction with
3012 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3013 * other user state broadcasts since those are foreground broadcasts so can
3014 * execute in a different order.
3015 * @hide
3016 */
3017 public static final String ACTION_USER_STOPPING =
3018 "android.intent.action.USER_STOPPING";
3019
3020 /**
3021 * Broadcast sent to the system when a user is stopped. Carries an extra
3022 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3023 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3024 * specific package. This is only sent to registered receivers, not manifest
3025 * receivers. It is sent to all running users <em>except</em> the one that
3026 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003027 * @hide
3028 */
3029 public static final String ACTION_USER_STOPPED =
3030 "android.intent.action.USER_STOPPED";
3031
3032 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003033 * 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 -07003034 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003035 * one that has been removed. The user will not be completely removed until all receivers have
3036 * handled the broadcast. 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_REMOVED =
3041 "android.intent.action.USER_REMOVED";
3042
3043 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003044 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003045 * the userHandle of the user to become the current one. This is only sent to
3046 * registered receivers, not manifest receivers. It is sent to all running users.
3047 * You must hold
3048 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003049 * @hide
3050 */
3051 public static final String ACTION_USER_SWITCHED =
3052 "android.intent.action.USER_SWITCHED";
3053
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003054 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003055 * Broadcast Action: Sent when the credential-encrypted private storage has
3056 * become unlocked for the target user. This is only sent to registered
3057 * receivers, not manifest receivers.
3058 */
3059 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3060 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3061
3062 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003063 * Broadcast sent to the system when a user's information changes. Carries an extra
3064 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003065 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003066 * @hide
3067 */
3068 public static final String ACTION_USER_INFO_CHANGED =
3069 "android.intent.action.USER_INFO_CHANGED";
3070
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003071 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003072 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3073 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003074 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3075 * that need to display merged content across both primary and managed profiles need to
3076 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003077 * not manifest receivers.
3078 */
3079 public static final String ACTION_MANAGED_PROFILE_ADDED =
3080 "android.intent.action.MANAGED_PROFILE_ADDED";
3081
3082 /**
3083 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003084 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3085 * Only applications (for example Launchers) that need to display merged content across both
3086 * primary and managed profiles need to worry about this broadcast. This is only sent to
3087 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003088 */
3089 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3090 "android.intent.action.MANAGED_PROFILE_REMOVED";
3091
3092 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003093 * Broadcast sent to the primary user when the credential-encrypted private storage for
3094 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3095 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3096 * Launchers) that need to display merged content across both primary and managed profiles
3097 * need to worry about this broadcast. This is only sent to registered receivers,
3098 * not manifest receivers.
3099 */
3100 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3101 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3102
3103 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003104 * Broadcast sent to the primary user when an associated managed profile has become available.
3105 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003106 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3107 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3108 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003109 */
Rubin Xue95057a2016-04-01 16:49:25 +01003110 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3111 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3112
3113 /**
3114 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3115 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3116 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3117 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3118 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3119 */
3120 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3121 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003122
3123 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003124 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3125 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3126 * the device was locked or unlocked.
3127 *
3128 * This is only sent to registered receivers.
3129 *
3130 * @hide
3131 */
3132 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3133 "android.intent.action.DEVICE_LOCKED_CHANGED";
3134
3135 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003136 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3137 */
3138 public static final String ACTION_QUICK_CLOCK =
3139 "android.intent.action.QUICK_CLOCK";
3140
Michael Wright0087a142013-02-05 16:29:39 -08003141 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003142 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003143 * @hide
3144 */
3145 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003146 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003147
Justin Kohd378ad72013-04-01 12:18:26 -07003148 /**
3149 * Broadcast Action: A global button was pressed. Includes a single
3150 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3151 * caused the broadcast.
3152 * @hide
3153 */
3154 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3155
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003156 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003157 * Broadcast Action: Sent when media resource is granted.
3158 * <p>
3159 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3160 * granted.
3161 * </p>
3162 * <p class="note">
3163 * This is a protected intent that can only be sent by the system.
3164 * </p>
3165 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003166 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003167 * </p>
3168 *
3169 * @hide
3170 */
3171 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3172 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3173
3174 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003175 * Broadcast Action: An overlay package has been installed. The data
3176 * contains the name of the added overlay package.
3177 * @hide
3178 */
3179 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3180
3181 /**
3182 * Broadcast Action: An overlay package has changed. The data contains the
3183 * name of the overlay package which has changed. This is broadcast on all
3184 * changes to the OverlayInfo returned by {@link
3185 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3186 * most common change is a state change that will change whether the
3187 * overlay is enabled or not.
3188 * @hide
3189 */
3190 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3191
3192 /**
3193 * Broadcast Action: An overlay package has been removed. The data contains
3194 * the name of the overlay package which has been removed.
3195 * @hide
3196 */
3197 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3198
3199 /**
3200 * Broadcast Action: The order of a package's list of overlay packages has
3201 * changed. The data contains the package name of the overlay package that
3202 * had its position in the list adjusted.
3203 * @hide
3204 */
3205 public static final String
3206 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3207
3208 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003209 * Activity Action: Allow the user to select and return one or more existing
3210 * documents. When invoked, the system will display the various
3211 * {@link DocumentsProvider} instances installed on the device, letting the
3212 * user interactively navigate through them. These documents include local
3213 * media, such as photos and video, and documents provided by installed
3214 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003215 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003216 * Each document is represented as a {@code content://} URI backed by a
3217 * {@link DocumentsProvider}, which can be opened as a stream with
3218 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3219 * {@link android.provider.DocumentsContract.Document} metadata.
3220 * <p>
3221 * All selected documents are returned to the calling application with
3222 * persistable read and write permission grants. If you want to maintain
3223 * access to the documents across device reboots, you need to explicitly
3224 * take the persistable permissions using
3225 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3226 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003227 * Callers must indicate the acceptable document MIME types through
3228 * {@link #setType(String)}. For example, to select photos, use
3229 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3230 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3231 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003232 * <p>
3233 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003234 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3235 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003236 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003237 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3238 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003239 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003240 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003241 * Callers can set a document URI through
3242 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3243 * location of documents navigator. System will do its best to launch the
3244 * navigator in the specified document if it's a folder, or the folder that
3245 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003246 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003247 * Output: The URI of the item that was picked, returned in
3248 * {@link #getData()}. This must be a {@code content://} URI so that any
3249 * receiver can access it. If multiple documents were selected, they are
3250 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003251 *
3252 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003253 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003254 * @see #ACTION_CREATE_DOCUMENT
3255 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003256 */
3257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3258 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3259
3260 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003261 * Activity Action: Allow the user to create a new document. When invoked,
3262 * the system will display the various {@link DocumentsProvider} instances
3263 * installed on the device, letting the user navigate through them. The
3264 * returned document may be a newly created document with no content, or it
3265 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003266 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003267 * Each document is represented as a {@code content://} URI backed by a
3268 * {@link DocumentsProvider}, which can be opened as a stream with
3269 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3270 * {@link android.provider.DocumentsContract.Document} metadata.
3271 * <p>
3272 * Callers must indicate the concrete MIME type of the document being
3273 * created by setting {@link #setType(String)}. This MIME type cannot be
3274 * changed after the document is created.
3275 * <p>
3276 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3277 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003278 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003279 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3280 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003281 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003282 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003283 * Callers can set a document URI through
3284 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3285 * location of documents navigator. System will do its best to launch the
3286 * navigator in the specified document if it's a folder, or the folder that
3287 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003288 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003289 * Output: The URI of the item that was created. This must be a
3290 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003291 *
3292 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003293 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003294 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003295 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003296 */
3297 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3298 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3299
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003300 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003301 * Activity Action: Allow the user to pick a directory subtree. When
3302 * invoked, the system will display the various {@link DocumentsProvider}
3303 * instances installed on the device, letting the user navigate through
3304 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003305 * <p>
3306 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003307 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3308 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3309 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003310 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003311 * Callers can set a document URI through
3312 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3313 * location of documents navigator. System will do its best to launch the
3314 * navigator in the specified document if it's a folder, or the folder that
3315 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003316 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003317 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003318 *
3319 * @see DocumentsContract
3320 */
3321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003322 public static final String
3323 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003324
Felipe Lemec7b1f892016-01-15 15:02:31 -08003325 /**
Peng Xua35b5532016-01-20 00:05:45 -08003326 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3327 * exisiting sensor being disconnected.
3328 *
3329 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3330 *
3331 * {@hide}
3332 */
3333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3334 public static final String
3335 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3336
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003337 /**
3338 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3339 *
3340 * {@hide}
3341 */
3342 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003343 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3344
Christopher Tate6597e342015-02-17 12:15:25 -08003345 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003346 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3347 * is about to be performed.
3348 * @hide
3349 */
3350 @SystemApi
3351 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3352 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3353 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3354
3355 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003356 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3357 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3358 *
3359 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3360 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003361 * @hide
3362 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003363 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003364 public static final String EXTRA_FORCE_MASTER_CLEAR =
3365 "android.intent.extra.FORCE_MASTER_CLEAR";
3366
3367 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003368 * A broadcast action to trigger a factory reset.
3369 *
3370 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3371 *
3372 * <p>Not for use by third-party applications.
3373 *
3374 * @see #EXTRA_FORCE_MASTER_CLEAR
3375 *
3376 * {@hide}
3377 */
3378 @SystemApi
3379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3380 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3381
3382 /**
3383 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3384 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3385 *
3386 * <p>Not for use by third-party applications.
3387 *
3388 * @hide
3389 */
3390 @SystemApi
3391 public static final String EXTRA_FORCE_FACTORY_RESET =
3392 "android.intent.extra.FORCE_FACTORY_RESET";
3393
3394 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003395 * Broadcast action: report that a settings element is being restored from backup. The intent
3396 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3397 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3398 * is the value of that settings entry prior to the restore operation. All of these values are
3399 * represented as strings.
3400 *
3401 * <p>This broadcast is sent only for settings provider entries known to require special handling
3402 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3403 * the provider's backup agent implementation.
3404 *
3405 * @see #EXTRA_SETTING_NAME
3406 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3407 * @see #EXTRA_SETTING_NEW_VALUE
3408 * {@hide}
3409 */
3410 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3411
3412 /** {@hide} */
3413 public static final String EXTRA_SETTING_NAME = "setting_name";
3414 /** {@hide} */
3415 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3416 /** {@hide} */
3417 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3418
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003419 /**
3420 * Activity Action: Process a piece of text.
3421 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3422 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3423 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3424 */
3425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3426 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003427
3428 /**
3429 * Broadcast Action: The sim card state has changed.
3430 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3431 * because TelephonyIntents is an internal class.
3432 * @hide
3433 */
3434 @SystemApi
3435 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3436 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3437
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003438 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003439 * The name of the extra used to define the text to be processed, as a
3440 * CharSequence. Note that this may be a styled CharSequence, so you must use
3441 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003442 */
3443 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3444 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003445 * 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 +00003446 */
3447 public static final String EXTRA_PROCESS_TEXT_READONLY =
3448 "android.intent.extra.PROCESS_TEXT_READONLY";
3449
Bryce Leebc58f592015-09-25 16:43:01 -07003450 /**
3451 * Broadcast action: reports when a new thermal event has been reached. When the device
3452 * is reaching its maximum temperatue, the thermal level reported
3453 * {@hide}
3454 */
3455 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3456 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3457
3458 /** {@hide} */
3459 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3460
3461 /**
3462 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003463 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003464 * {@hide}
3465 */
3466 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3467
3468 /**
3469 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003470 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003471 * {@hide}
3472 */
3473 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3474
3475 /**
3476 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003477 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003478 * {@hide}
3479 */
3480 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3481
3482
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003483 // ---------------------------------------------------------------------
3484 // ---------------------------------------------------------------------
3485 // Standard intent categories (see addCategory()).
3486
3487 /**
3488 * Set if the activity should be an option for the default action
3489 * (center press) to perform on a piece of data. Setting this will
3490 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003491 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003492 * Intent when initiating an action -- it is for use in intent filters
3493 * specified in packages.
3494 */
3495 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3496 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3497 /**
3498 * Activities that can be safely invoked from a browser must support this
3499 * category. For example, if the user is viewing a web page or an e-mail
3500 * and clicks on a link in the text, the Intent generated execute that
3501 * link will require the BROWSABLE category, so that only activities
3502 * supporting this category will be considered as possible actions. By
3503 * supporting this category, you are promising that there is nothing
3504 * damaging (without user intervention) that can happen by invoking any
3505 * matching Intent.
3506 */
3507 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3508 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3509 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003510 * Categories for activities that can participate in voice interaction.
3511 * An activity that supports this category must be prepared to run with
3512 * no UI shown at all (though in some case it may have a UI shown), and
3513 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3514 */
3515 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3516 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3517 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003518 * Set if the activity should be considered as an alternative action to
3519 * the data the user is currently viewing. See also
3520 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3521 * applies to the selection in a list of items.
3522 *
3523 * <p>Supporting this category means that you would like your activity to be
3524 * displayed in the set of alternative things the user can do, usually as
3525 * part of the current activity's options menu. You will usually want to
3526 * include a specific label in the &lt;intent-filter&gt; of this action
3527 * describing to the user what it does.
3528 *
3529 * <p>The action of IntentFilter with this category is important in that it
3530 * describes the specific action the target will perform. This generally
3531 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3532 * a specific name such as "com.android.camera.action.CROP. Only one
3533 * alternative of any particular action will be shown to the user, so using
3534 * a specific action like this makes sure that your alternative will be
3535 * displayed while also allowing other applications to provide their own
3536 * overrides of that particular action.
3537 */
3538 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3539 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3540 /**
3541 * Set if the activity should be considered as an alternative selection
3542 * action to the data the user has currently selected. This is like
3543 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3544 * of items from which the user can select, giving them alternatives to the
3545 * default action that will be performed on it.
3546 */
3547 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3548 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3549 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003550 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003551 */
3552 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3553 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3554 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003555 * Should be displayed in the top-level launcher.
3556 */
3557 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3558 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3559 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003560 * Indicates an activity optimized for Leanback mode, and that should
3561 * be displayed in the Leanback launcher.
3562 */
3563 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3564 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3565 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003566 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3567 * @hide
3568 */
3569 @SystemApi
3570 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3571 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003572 * Provides information about the package it is in; typically used if
3573 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3574 * a front-door to the user without having to be shown in the all apps list.
3575 */
3576 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3577 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3578 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003579 * This is the home activity, that is the first activity that is displayed
3580 * when the device boots.
3581 */
3582 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3583 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3584 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003585 * This is the home activity that is displayed when the device is finished setting up and ready
3586 * for use.
3587 * @hide
3588 */
3589 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3590 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3591 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003592 * This is the setup wizard activity, that is the first activity that is displayed
3593 * when the user sets up the device for the first time.
3594 * @hide
3595 */
3596 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3597 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3598 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003599 * This activity is a preference panel.
3600 */
3601 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3602 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3603 /**
3604 * This activity is a development preference panel.
3605 */
3606 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3607 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3608 /**
3609 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003610 */
3611 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3612 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3613 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003614 * This activity allows the user to browse and download new applications.
3615 */
3616 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3617 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3618 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003619 * This activity may be exercised by the monkey or other automated test tools.
3620 */
3621 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3622 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3623 /**
3624 * To be used as a test (not part of the normal user experience).
3625 */
3626 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3627 /**
3628 * To be used as a unit test (run through the Test Harness).
3629 */
3630 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3631 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003632 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003633 * experience).
3634 */
3635 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003636
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003637 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003638 * Used to indicate that an intent only wants URIs that can be opened with
3639 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3640 * must support at least the columns defined in {@link OpenableColumns} when
3641 * queried.
3642 *
3643 * @see #ACTION_GET_CONTENT
3644 * @see #ACTION_OPEN_DOCUMENT
3645 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003646 */
3647 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3648 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3649
3650 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003651 * Used to indicate that an intent filter can accept files which are not necessarily
3652 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3653 * at least streamable via
3654 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3655 * using one of the stream types exposed via
3656 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3657 *
3658 * @see #ACTION_SEND
3659 * @see #ACTION_SEND_MULTIPLE
3660 */
3661 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3662 public static final String CATEGORY_TYPED_OPENABLE =
3663 "android.intent.category.TYPED_OPENABLE";
3664
3665 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003666 * To be used as code under test for framework instrumentation tests.
3667 */
3668 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3669 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003670 /**
3671 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003672 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3673 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003674 */
3675 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3676 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3677 /**
3678 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003679 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3680 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003681 */
3682 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3683 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003684 /**
3685 * An activity to run when device is inserted into a analog (low end) dock.
3686 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3687 * information, see {@link android.app.UiModeManager}.
3688 */
3689 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3690 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3691
3692 /**
3693 * An activity to run when device is inserted into a digital (high end) dock.
3694 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3695 * information, see {@link android.app.UiModeManager}.
3696 */
3697 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3698 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003699
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003700 /**
3701 * Used to indicate that the activity can be used in a car environment.
3702 */
3703 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3704 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3705
Zak Cohendb6ca492017-01-26 14:09:00 -08003706 /**
3707 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3708 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3709 * information, see {@link android.app.UiModeManager}.
3710 */
3711 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3712 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003713 // ---------------------------------------------------------------------
3714 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003715 // Application launch intent categories (see addCategory()).
3716
3717 /**
3718 * Used with {@link #ACTION_MAIN} to launch the browser application.
3719 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003720 * <p>NOTE: This should not be used as the primary key of an Intent,
3721 * since it will not result in the app launching with the correct
3722 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003723 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003724 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003725 */
3726 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3727 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3728
3729 /**
3730 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3731 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003732 * <p>NOTE: This should not be used as the primary key of an Intent,
3733 * since it will not result in the app launching with the correct
3734 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003735 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003736 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003737 */
3738 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3739 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3740
3741 /**
3742 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3743 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003744 * <p>NOTE: This should not be used as the primary key of an Intent,
3745 * since it will not result in the app launching with the correct
3746 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003747 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003748 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003749 */
3750 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3751 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3752
3753 /**
3754 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3755 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003756 * <p>NOTE: This should not be used as the primary key of an Intent,
3757 * since it will not result in the app launching with the correct
3758 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003759 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003760 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003761 */
3762 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3763 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3764
3765 /**
3766 * Used with {@link #ACTION_MAIN} to launch the email application.
3767 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003768 * <p>NOTE: This should not be used as the primary key of an Intent,
3769 * since it will not result in the app launching with the correct
3770 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003771 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003772 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003773 */
3774 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3775 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3776
3777 /**
3778 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3779 * The activity should be able to view and manipulate image and video files
3780 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003781 * <p>NOTE: This should not be used as the primary key of an Intent,
3782 * since it will not result in the app launching with the correct
3783 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003784 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003785 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003786 */
3787 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3788 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3789
3790 /**
3791 * Used with {@link #ACTION_MAIN} to launch the maps application.
3792 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003793 * <p>NOTE: This should not be used as the primary key of an Intent,
3794 * since it will not result in the app launching with the correct
3795 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003796 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003797 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003798 */
3799 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3800 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3801
3802 /**
3803 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3804 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003805 * <p>NOTE: This should not be used as the primary key of an Intent,
3806 * since it will not result in the app launching with the correct
3807 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003808 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003809 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003810 */
3811 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3812 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3813
3814 /**
3815 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003816 * The activity should be able to play, browse, or manipulate music files
3817 * stored on the device.
3818 * <p>NOTE: This should not be used as the primary key of an Intent,
3819 * since it will not result in the app launching with the correct
3820 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003821 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003822 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003823 */
3824 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3825 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3826
3827 // ---------------------------------------------------------------------
3828 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003829 // Standard extra data keys.
3830
3831 /**
3832 * The initial data to place in a newly created record. Use with
3833 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3834 * fields as would be given to the underlying ContentProvider.insert()
3835 * call.
3836 */
3837 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3838
3839 /**
3840 * A constant CharSequence that is associated with the Intent, used with
3841 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3842 * this may be a styled CharSequence, so you must use
3843 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3844 * retrieve it.
3845 */
3846 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3847
3848 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003849 * A constant String that is associated with the Intent, used with
3850 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3851 * as HTML formatted text. Note that you <em>must</em> also supply
3852 * {@link #EXTRA_TEXT}.
3853 */
3854 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3855
3856 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003857 * A content: URI holding a stream of data associated with the Intent,
3858 * used with {@link #ACTION_SEND} to supply the data being sent.
3859 */
3860 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3861
3862 /**
3863 * A String[] holding e-mail addresses that should be delivered to.
3864 */
3865 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3866
3867 /**
3868 * A String[] holding e-mail addresses that should be carbon copied.
3869 */
3870 public static final String EXTRA_CC = "android.intent.extra.CC";
3871
3872 /**
3873 * A String[] holding e-mail addresses that should be blind carbon copied.
3874 */
3875 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3876
3877 /**
3878 * A constant string holding the desired subject line of a message.
3879 */
3880 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3881
3882 /**
3883 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003884 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003885 */
3886 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3887
3888 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003889 * An int representing the user id to be used.
3890 *
3891 * @hide
3892 */
3893 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3894
3895 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003896 * An int representing the task id to be retrieved. This is used when a launch from recents is
3897 * intercepted by another action such as credentials confirmation to remember which task should
3898 * be resumed when complete.
3899 *
3900 * @hide
3901 */
3902 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3903
3904 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003905 * An Intent[] describing additional, alternate choices you would like shown with
3906 * {@link #ACTION_CHOOSER}.
3907 *
3908 * <p>An app may be capable of providing several different payload types to complete a
3909 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3910 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3911 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3912 * photo data or a hosted link where the photos can be viewed.</p>
3913 *
3914 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3915 * first/primary/preferred intent in the set. Additional intents specified in
3916 * this extra are ordered; by default intents that appear earlier in the array will be
3917 * preferred over intents that appear later in the array as matches for the same
3918 * target component. To alter this preference, a calling app may also supply
3919 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3920 */
3921 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3922
3923 /**
Adam Powell52c39212016-04-07 15:14:18 -07003924 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3925 * and omitted from a list of components presented to the user.
3926 *
3927 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3928 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3929 * from your own package or other apps from your organization if the idea of sending to those
3930 * targets would be redundant with other app functionality. Filtered components will not
3931 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3932 */
3933 public static final String EXTRA_EXCLUDE_COMPONENTS
3934 = "android.intent.extra.EXCLUDE_COMPONENTS";
3935
3936 /**
3937 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3938 * describing additional high-priority deep-link targets for the chooser to present to the user.
3939 *
3940 * <p>Targets provided in this way will be presented inline with all other targets provided
3941 * by services from other apps. They will be prioritized before other service targets, but
3942 * after those targets provided by sources that the user has manually pinned to the front.</p>
3943 *
3944 * @see #ACTION_CHOOSER
3945 */
3946 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3947
3948 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003949 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3950 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3951 *
3952 * <p>An app preparing an action for another app to complete may wish to allow the user to
3953 * disambiguate between several options for completing the action based on the chosen target
3954 * or otherwise refine the action before it is invoked.
3955 * </p>
3956 *
3957 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3958 * <ul>
3959 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3960 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3961 * chosen target beyond the first</li>
3962 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3963 * should fill in and send once the disambiguation is complete</li>
3964 * </ul>
3965 */
3966 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3967 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3968
3969 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003970 * An {@code ArrayList} of {@code String} annotations describing content for
3971 * {@link #ACTION_CHOOSER}.
3972 *
3973 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3974 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3975 *
3976 * <p>Annotations should describe the major components or topics of the content. It is up to
3977 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3978 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3979 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3980 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3981 * use the following annotations when applicable:</p>
3982 * <ul>
3983 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
3984 * health & beauty, and office supplies.</li>
3985 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
3986 * happy, and sad.</li>
3987 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
3988 * face, finger, standing, and walking.</li>
3989 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
3990 * child, and baby.</li>
3991 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
3992 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
3993 * <li>"party": represents that the topic of the content is mainly about parties.</li>
3994 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
3995 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
3996 * flowers.</li>
3997 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
3998 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
3999 * sunglasses, jewelry, handbags and clothing.</li>
4000 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4001 * paper, and silk.</li>
4002 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4003 * cars, and boats.</li>
4004 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4005 * posters.</li>
4006 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4007 * and designs of houses.</li>
4008 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4009 * Christmas and Thanksgiving.</li>
4010 * </ul>
4011 */
4012 public static final String EXTRA_CONTENT_ANNOTATIONS
4013 = "android.intent.extra.CONTENT_ANNOTATIONS";
4014
4015 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004016 * A {@link ResultReceiver} used to return data back to the sender.
4017 *
4018 * <p>Used to complete an app-specific
4019 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4020 *
4021 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4022 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4023 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4024 * when the user selects a target component from the chooser. It is up to the recipient
4025 * to send a result to this ResultReceiver to signal that disambiguation is complete
4026 * and that the chooser should invoke the user's choice.</p>
4027 *
4028 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4029 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4030 * to match and fill in the final Intent or ChooserTarget before starting it.
4031 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4032 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4033 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4034 *
4035 * <p>The result code passed to the ResultReceiver should be
4036 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4037 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4038 * the chooser should finish without starting a target.</p>
4039 */
4040 public static final String EXTRA_RESULT_RECEIVER
4041 = "android.intent.extra.RESULT_RECEIVER";
4042
4043 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004044 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004045 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004046 */
4047 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4048
4049 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004050 * A Parcelable[] of {@link Intent} or
4051 * {@link android.content.pm.LabeledIntent} objects as set with
4052 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4053 * a the front of the list of choices, when shown to the user with a
4054 * {@link #ACTION_CHOOSER}.
4055 */
4056 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4057
4058 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004059 * A {@link IntentSender} to start after ephemeral installation success.
4060 * @hide
4061 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004062 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4063
4064 /**
4065 * A {@link IntentSender} to start after ephemeral installation failure.
4066 * @hide
4067 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004068 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4069
4070 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004071 * The host name that triggered an ephemeral resolution.
4072 * @hide
4073 */
4074 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4075
4076 /**
4077 * An opaque token to track ephemeral resolution.
4078 * @hide
4079 */
4080 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4081
4082 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004083 * The version code of the app to install components from.
4084 * @hide
4085 */
4086 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4087
4088 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004089 * A Bundle forming a mapping of potential target package names to different extras Bundles
4090 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4091 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4092 * be currently installed on the device.
4093 *
4094 * <p>An application may choose to provide alternate extras for the case where a user
4095 * selects an activity from a predetermined set of target packages. If the activity
4096 * the user selects from the chooser belongs to a package with its package name as
4097 * a key in this bundle, the corresponding extras for that package will be merged with
4098 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4099 * extra has the same key as an extra already present in the intent it will overwrite
4100 * the extra from the intent.</p>
4101 *
4102 * <p><em>Examples:</em>
4103 * <ul>
4104 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4105 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4106 * parameters for that target.</li>
4107 * <li>An application may offer additional metadata for known targets of a given intent
4108 * to pass along information only relevant to that target such as account or content
4109 * identifiers already known to that application.</li>
4110 * </ul></p>
4111 */
4112 public static final String EXTRA_REPLACEMENT_EXTRAS =
4113 "android.intent.extra.REPLACEMENT_EXTRAS";
4114
4115 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004116 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4117 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4118 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4119 * {@link ComponentName} of the chosen component.
4120 *
4121 * <p>In some situations this callback may never come, for example if the user abandons
4122 * the chooser, switches to another task or any number of other reasons. Apps should not
4123 * be written assuming that this callback will always occur.</p>
4124 */
4125 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4126 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4127
4128 /**
4129 * The {@link ComponentName} chosen by the user to complete an action.
4130 *
4131 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4132 */
4133 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4134
4135 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004136 * A {@link android.view.KeyEvent} object containing the event that
4137 * triggered the creation of the Intent it is in.
4138 */
4139 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4140
4141 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004142 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4143 * before shutting down.
4144 *
4145 * {@hide}
4146 */
4147 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4148
4149 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004150 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4151 * requested by the user.
4152 *
4153 * {@hide}
4154 */
4155 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4156 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4157
4158 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004159 * 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 -07004160 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4161 * of restarting the application.
4162 */
4163 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4164
4165 /**
4166 * A String holding the phone number originally entered in
4167 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4168 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4169 */
4170 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004171
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004172 /**
4173 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4174 * intents to supply the uid the package had been assigned. Also an optional
4175 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4176 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4177 * purpose.
4178 */
4179 public static final String EXTRA_UID = "android.intent.extra.UID";
4180
4181 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004182 * @hide String array of package names.
4183 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004184 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004185 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4186
4187 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004188 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4189 * intents to indicate whether this represents a full uninstall (removing
4190 * both the code and its data) or a partial uninstall (leaving its data,
4191 * implying that this is an update).
4192 */
4193 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004194
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004195 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004196 * @hide
4197 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4198 * intents to indicate that at this point the package has been removed for
4199 * all users on the device.
4200 */
4201 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4202 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4203
4204 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004205 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4206 * intents to indicate that this is a replacement of the package, so this
4207 * broadcast will immediately be followed by an add broadcast for a
4208 * different version of the same package.
4209 */
4210 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004211
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004212 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004213 * Used as an int extra field in {@link android.app.AlarmManager} intents
4214 * to tell the application being invoked how many pending alarms are being
4215 * delievered with the intent. For one-shot alarms this will always be 1.
4216 * For recurring alarms, this might be greater than 1 if the device was
4217 * asleep or powered off at the time an earlier alarm would have been
4218 * delivered.
4219 */
4220 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004221
Jacek Surazski86b6c532009-05-13 14:38:28 +02004222 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004223 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4224 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004225 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4226 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004227 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4228 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4229 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004230 */
4231 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4232
4233 /**
4234 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4235 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004236 */
4237 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4238
4239 /**
4240 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4241 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004242 */
4243 public static final int EXTRA_DOCK_STATE_DESK = 1;
4244
4245 /**
4246 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4247 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004248 */
4249 public static final int EXTRA_DOCK_STATE_CAR = 2;
4250
4251 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004252 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4253 * to represent that the phone is in a analog (low end) dock.
4254 */
4255 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4256
4257 /**
4258 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4259 * to represent that the phone is in a digital (high end) dock.
4260 */
4261 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4262
4263 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004264 * Boolean that can be supplied as meta-data with a dock activity, to
4265 * indicate that the dock should take over the home key when it is active.
4266 */
4267 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004268
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004269 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004270 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4271 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004272 */
4273 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4274
4275 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004276 * Used in the extra field in the remote intent. It's astring token passed with the
4277 * remote intent.
4278 */
4279 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4280 "android.intent.extra.remote_intent_token";
4281
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004282 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004283 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004284 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004285 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004286 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004287 "android.intent.extra.changed_component_name";
4288
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004289 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004290 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004291 * and contains a string array of all of the components that have changed. If
4292 * the state of the overall package has changed, then it will contain an entry
4293 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004294 */
4295 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4296 "android.intent.extra.changed_component_name_list";
4297
4298 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004299 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004300 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004301 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4302 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4303 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004304 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004305 */
4306 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4307 "android.intent.extra.changed_package_list";
4308
4309 /**
4310 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004311 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4312 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004313 * and contains an integer array of uids of all of the components
4314 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004315 */
4316 public static final String EXTRA_CHANGED_UID_LIST =
4317 "android.intent.extra.changed_uid_list";
4318
4319 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004320 * @hide
4321 * Magic extra system code can use when binding, to give a label for
4322 * who it is that has bound to a service. This is an integer giving
4323 * a framework string resource that can be displayed to the user.
4324 */
4325 public static final String EXTRA_CLIENT_LABEL =
4326 "android.intent.extra.client_label";
4327
4328 /**
4329 * @hide
4330 * Magic extra system code can use when binding, to give a PendingIntent object
4331 * that can be launched for the user to disable the system's use of this
4332 * service.
4333 */
4334 public static final String EXTRA_CLIENT_INTENT =
4335 "android.intent.extra.client_intent";
4336
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004337 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004338 * Extra used to indicate that an intent should only return data that is on
4339 * the local device. This is a boolean extra; the default is false. If true,
4340 * an implementation should only allow the user to select data that is
4341 * already on the device, not requiring it be downloaded from a remote
4342 * service when opened.
4343 *
4344 * @see #ACTION_GET_CONTENT
4345 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004346 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004347 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004348 */
4349 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004350 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004351
Amith Yamasani13593602012-03-22 16:16:17 -07004352 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004353 * Extra used to indicate that an intent can allow the user to select and
4354 * return multiple items. This is a boolean extra; the default is false. If
4355 * true, an implementation is allowed to present the user with a UI where
4356 * they can pick multiple items that are all returned to the caller. When
4357 * this happens, they should be returned as the {@link #getClipData()} part
4358 * of the result Intent.
4359 *
4360 * @see #ACTION_GET_CONTENT
4361 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004362 */
4363 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004364 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004365
4366 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004367 * The integer userHandle carried with broadcast intents related to addition, removal and
4368 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4369 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4370 *
Amith Yamasani13593602012-03-22 16:16:17 -07004371 * @hide
4372 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004373 public static final String EXTRA_USER_HANDLE =
4374 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004375
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004376 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004377 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4378 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4379 */
4380 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004381 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004382
4383 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004384 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004385 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4386 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004387 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004388 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4389
4390 /**
4391 * Extra sent in the intent to the BroadcastReceiver that handles
4392 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4393 * the restrictions as key/value pairs.
4394 */
4395 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4396 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004397
Amith Yamasani86118ba2013-03-28 14:33:16 -07004398 /**
4399 * Extra used in the response from a BroadcastReceiver that handles
4400 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4401 */
4402 public static final String EXTRA_RESTRICTIONS_INTENT =
4403 "android.intent.extra.restrictions_intent";
4404
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004405 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004406 * Extra used to communicate a set of acceptable MIME types. The type of the
4407 * extra is {@code String[]}. Values may be a combination of concrete MIME
4408 * types (such as "image/png") and/or partial MIME types (such as
4409 * "audio/*").
4410 *
4411 * @see #ACTION_GET_CONTENT
4412 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004413 */
4414 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4415
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004416 /**
4417 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4418 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004419 * When this is true, hardware devices can use this information to determine that
4420 * they shouldn't do a complete shutdown of their device since this is not a
4421 * complete shutdown down to the kernel, but only user space restarting.
4422 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004423 */
4424 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4425 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4426
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004427 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004428 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4429 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4430 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4431 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004432 *
4433 * @hide for internal use only.
4434 */
4435 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4436 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004437 /** @hide */
4438 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4439 /** @hide */
4440 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4441 /** @hide */
4442 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004443
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004444 /** {@hide} */
4445 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4446
Rubin Xue8490f12015-06-25 12:17:48 +01004447 /** {@hide} */
4448 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4449
Santos Cordon15a13782015-03-31 18:32:31 -07004450 /**
4451 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4452 * activation request.
4453 * TODO: Add information about the structure and response data used with the pending intent.
4454 * @hide
4455 */
4456 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4457 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4458
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004459 /**
4460 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004461 *
4462 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004463 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004464 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004465 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4466
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004467 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004468 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4469 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4470 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004471 *
4472 * <p>The value is boolean. By default false.
4473 * @see ACTION_QUICK_VIEW
4474 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004475 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4476 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004477
4478 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004479 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004480 * When a profile goes into quiet mode, all apps in the profile are killed and the
4481 * profile user is stopped. Widgets originating from the profile are masked, and app
4482 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004483 */
4484 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004485
4486 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004487 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004488 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004489 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4490 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004491 *
4492 * @hide
4493 */
4494 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4495 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4496
4497 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004498 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4499 * whether to show the chooser or not when there is only one application available
4500 * to choose from.
4501 *
4502 * @hide
4503 */
4504 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4505 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4506
4507 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004508 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004509 * to represent that a video codec is allowed to use.
4510 *
4511 * @hide
4512 */
4513 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4514
4515 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004516 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004517 * to represent that a audio codec is allowed to use.
4518 *
4519 * @hide
4520 */
4521 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4522
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004523 // ---------------------------------------------------------------------
4524 // ---------------------------------------------------------------------
4525 // Intent flags (see mFlags variable).
4526
Tor Norbyed9273d62013-05-30 15:59:53 -07004527 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004528 @IntDef(flag = true, value = {
4529 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4530 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004531 @Retention(RetentionPolicy.SOURCE)
4532 public @interface GrantUriMode {}
4533
Jeff Sharkey846318a2014-04-04 12:12:41 -07004534 /** @hide */
4535 @IntDef(flag = true, value = {
4536 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4537 @Retention(RetentionPolicy.SOURCE)
4538 public @interface AccessUriMode {}
4539
4540 /**
4541 * Test if given mode flags specify an access mode, which must be at least
4542 * read and/or write.
4543 *
4544 * @hide
4545 */
4546 public static boolean isAccessUriMode(int modeFlags) {
4547 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4548 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4549 }
4550
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004551 /**
4552 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004553 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004554 * specified in its ClipData. When applying to an Intent's ClipData,
4555 * all URIs as well as recursive traversals through data or other ClipData
4556 * in Intent items will be granted; only the grant flags of the top-level
4557 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558 */
4559 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4560 /**
4561 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004562 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004563 * specified in its ClipData. When applying to an Intent's ClipData,
4564 * all URIs as well as recursive traversals through data or other ClipData
4565 * in Intent items will be granted; only the grant flags of the top-level
4566 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004567 */
4568 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4569 /**
4570 * Can be set by the caller to indicate that this Intent is coming from
4571 * a background operation, not from direct user interaction.
4572 */
4573 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4574 /**
4575 * A flag you can enable for debugging: when set, log messages will be
4576 * printed during the resolution of this intent to show you what has
4577 * been found to create the final resolved list.
4578 */
4579 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004580 /**
4581 * If set, this intent will not match any components in packages that
4582 * are currently stopped. If this is not set, then the default behavior
4583 * is to include such applications in the result.
4584 */
4585 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4586 /**
4587 * If set, this intent will always match any components in packages that
4588 * are currently stopped. This is the default behavior when
4589 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4590 * flags are set, this one wins (it allows overriding of exclude for
4591 * places where the framework may automatically set the exclude flag).
4592 */
4593 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004594
4595 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004596 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004597 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004598 * persisted across device reboots until explicitly revoked with
4599 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4600 * grant for possible persisting; the receiving application must call
4601 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4602 * actually persist.
4603 *
4604 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4605 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4606 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004607 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004608 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004609 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004610
4611 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004612 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4613 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4614 * applies to any URI that is a prefix match against the original granted
4615 * URI. (Without this flag, the URI must match exactly for access to be
4616 * granted.) Another URI is considered a prefix match only when scheme,
4617 * authority, and all path segments defined by the prefix are an exact
4618 * match.
4619 */
4620 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4621
4622 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004623 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004624 * homework and verified that they correctly handle packages and components
4625 * that come and go over time. In particular:
4626 * <ul>
4627 * <li>Apps installed on external storage, which will appear to be
4628 * uninstalled while the the device is ejected.
4629 * <li>Apps with encryption unaware components, which will appear to not
4630 * exist while the device is locked.
4631 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004632 *
4633 * @hide
4634 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004635 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004636
4637 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004638 * Internal flag used to indicate ephemeral applications should not be
4639 * considered when resolving the intent.
4640 *
4641 * @hide
4642 */
4643 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4644
4645 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004646 * If set, the new activity is not kept in the history stack. As soon as
4647 * the user navigates away from it, the activity is finished. This may also
4648 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4649 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004650 *
4651 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4652 * is never invoked when the current activity starts a new activity which
4653 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004654 */
4655 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4656 /**
4657 * If set, the activity will not be launched if it is already running
4658 * at the top of the history stack.
4659 */
4660 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4661 /**
4662 * If set, this activity will become the start of a new task on this
4663 * history stack. A task (from the activity that started it to the
4664 * next task activity) defines an atomic group of activities that the
4665 * user can move to. Tasks can be moved to the foreground and background;
4666 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004667 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004668 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4669 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004670 *
4671 * <p>This flag is generally used by activities that want
4672 * to present a "launcher" style behavior: they give the user a list of
4673 * separate things that can be done, which otherwise run completely
4674 * independently of the activity launching them.
4675 *
4676 * <p>When using this flag, if a task is already running for the activity
4677 * you are now starting, then a new activity will not be started; instead,
4678 * the current task will simply be brought to the front of the screen with
4679 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4680 * to disable this behavior.
4681 *
4682 * <p>This flag can not be used when the caller is requesting a result from
4683 * the activity being launched.
4684 */
4685 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4686 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004687 * This flag is used to create a new task and launch an activity into it.
4688 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4689 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4690 * search through existing tasks for ones matching this Intent. Only if no such
4691 * task is found would a new task be created. When paired with
4692 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4693 * the search for a matching task and unconditionally start a new task.
4694 *
4695 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4696 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004697 * top-level application launcher.</strong> Used in conjunction with
4698 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4699 * behavior of bringing an existing task to the foreground. When set,
4700 * a new task is <em>always</em> started to host the Activity for the
4701 * Intent, regardless of whether there is already an existing task running
4702 * the same thing.
4703 *
4704 * <p><strong>Because the default system does not include graphical task management,
4705 * you should not use this flag unless you provide some way for a user to
4706 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004707 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004708 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4709 * creating new document tasks.
4710 *
4711 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004712 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004713 *
Scott Main7aee61f2011-02-08 11:25:01 -08004714 * <p>See
4715 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4716 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004717 *
4718 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4719 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004720 */
4721 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4722 /**
4723 * If set, and the activity being launched is already running in the
4724 * current task, then instead of launching a new instance of that activity,
4725 * all of the other activities on top of it will be closed and this Intent
4726 * will be delivered to the (now on top) old activity as a new Intent.
4727 *
4728 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4729 * If D calls startActivity() with an Intent that resolves to the component
4730 * of activity B, then C and D will be finished and B receive the given
4731 * Intent, resulting in the stack now being: A, B.
4732 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004733 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004734 * either receive the new intent you are starting here in its
4735 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004736 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004737 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4738 * the same intent, then it will be finished and re-created; for all other
4739 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4740 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 *
4742 * <p>This launch mode can also be used to good effect in conjunction with
4743 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4744 * of a task, it will bring any currently running instance of that task
4745 * to the foreground, and then clear it to its root state. This is
4746 * especially useful, for example, when launching an activity from the
4747 * notification manager.
4748 *
Scott Main7aee61f2011-02-08 11:25:01 -08004749 * <p>See
4750 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4751 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004752 */
4753 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4754 /**
4755 * If set and this intent is being used to launch a new activity from an
4756 * existing one, then the reply target of the existing activity will be
4757 * transfered to the new activity. This way the new activity can call
4758 * {@link android.app.Activity#setResult} and have that result sent back to
4759 * the reply target of the original activity.
4760 */
4761 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4762 /**
4763 * If set and this intent is being used to launch a new activity from an
4764 * existing one, the current activity will not be counted as the top
4765 * activity for deciding whether the new intent should be delivered to
4766 * the top instead of starting a new one. The previous activity will
4767 * be used as the top, with the assumption being that the current activity
4768 * will finish itself immediately.
4769 */
4770 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4771 /**
4772 * If set, the new activity is not kept in the list of recently launched
4773 * activities.
4774 */
4775 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4776 /**
4777 * This flag is not normally set by application code, but set for you by
4778 * the system as described in the
4779 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4780 * launchMode} documentation for the singleTask mode.
4781 */
4782 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4783 /**
4784 * If set, and this activity is either being started in a new task or
4785 * bringing to the top an existing task, then it will be launched as
4786 * the front door of the task. This will result in the application of
4787 * any affinities needed to have that task in the proper state (either
4788 * moving activities to or from it), or simply resetting that task to
4789 * its initial state if needed.
4790 */
4791 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4792 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004793 * This flag is not normally set by application code, but set for you by
4794 * the system if this activity is being launched from history
4795 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004796 */
4797 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004798 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004799 * @deprecated As of API 21 this performs identically to
4800 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004801 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004802 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004803 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004804 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004805 * This flag is used to open a document into a new task rooted at the activity launched
4806 * by this Intent. Through the use of this flag, or its equivalent attribute,
4807 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004808 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004809 *
Craig Mautner026596b2014-05-21 15:35:44 -07004810 * <p>The use of the activity attribute form of this,
4811 * {@link android.R.attr#documentLaunchMode}, is
4812 * preferred over the Intent flag described here. The attribute form allows the
4813 * Activity to specify multiple document behavior for all launchers of the Activity
4814 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004815 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004816 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4817 * it is kept after the activity is finished is different than the use of
4818 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4819 * this flag is being used to create a new recents entry, then by default that entry
4820 * will be removed once the activity is finished. You can modify this behavior with
4821 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4822 *
Craig Mautner026596b2014-05-21 15:35:44 -07004823 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4824 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4825 * equivalent of the Activity manifest specifying {@link
4826 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4827 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4828 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004829 *
Craig Mautner026596b2014-05-21 15:35:44 -07004830 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004831 *
Craig Mautner026596b2014-05-21 15:35:44 -07004832 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004833 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4834 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004835 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004836 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004837 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004838 * callback from occurring on the current frontmost activity before it is
4839 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004840 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004841 * <p>Typically, an activity can rely on that callback to indicate that an
4842 * explicit user action has caused their activity to be moved out of the
4843 * foreground. The callback marks an appropriate point in the activity's
4844 * lifecycle for it to dismiss any notifications that it intends to display
4845 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004846 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004847 * <p>If an activity is ever started via any non-user-driven events such as
4848 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4849 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004850 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004851 */
4852 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004853 /**
4854 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4855 * this flag will cause the launched activity to be brought to the front of its
4856 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004857 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004858 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4859 * If D calls startActivity() with an Intent that resolves to the component
4860 * of activity B, then B will be brought to the front of the history stack,
4861 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004862 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004863 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004864 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004865 */
4866 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004867 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004868 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4869 * this flag will prevent the system from applying an activity transition
4870 * animation to go to the next activity state. This doesn't mean an
4871 * animation will never run -- if another activity change happens that doesn't
4872 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004873 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004874 * when you are going to do a series of activity operations but the
4875 * animation seen by the user shouldn't be driven by the first activity
4876 * change but rather a later one.
4877 */
4878 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4879 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004880 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4881 * this flag will cause any existing task that would be associated with the
4882 * activity to be cleared before the activity is started. That is, the activity
4883 * becomes the new root of an otherwise empty task, and any old activities
4884 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4885 */
4886 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4887 /**
4888 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4889 * this flag will cause a newly launching task to be placed on top of the current
4890 * home activity task (if there is one). That is, pressing back from the task
4891 * will always return the user to home even if that was not the last activity they
4892 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4893 */
4894 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4895 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004896 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4897 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004898 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004899 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004900 * this flag. When set and the task's activity is finished, the recents
4901 * entry will remain in the interface for the user to re-launch it, like a
4902 * recents entry for a top-level application.
4903 * <p>
4904 * The receiving activity can override this request with
4905 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4906 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004907 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004908 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004909 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004910
4911 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004912 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4913 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004914 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4915 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004916 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004917 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004918
4919 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004920 * If set, when sending a broadcast only registered receivers will be
4921 * called -- no BroadcastReceiver components will be launched.
4922 */
4923 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004924 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004925 * If set, when sending a broadcast the new broadcast will replace
4926 * any existing pending broadcast that matches it. Matching is defined
4927 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4928 * true for the intents of the two broadcasts. When a match is found,
4929 * the new broadcast (and receivers associated with it) will replace the
4930 * existing one in the pending broadcast list, remaining at the same
4931 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004932 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004933 * <p>This flag is most typically used with sticky broadcasts, which
4934 * only care about delivering the most recent values of the broadcast
4935 * to their receivers.
4936 */
4937 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4938 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004939 * If set, when sending a broadcast the recipient is allowed to run at
4940 * foreground priority, with a shorter timeout interval. During normal
4941 * broadcasts the receivers are not automatically hoisted out of the
4942 * background priority class.
4943 */
4944 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4945 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004946 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4947 * They can still propagate results through to later receivers, but they can not prevent
4948 * later receivers from seeing the broadcast.
4949 */
4950 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4951 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004952 * If set, when sending a broadcast <i>before boot has completed</i> only
4953 * registered receivers will be called -- no BroadcastReceiver components
4954 * will be launched. Sticky intent state will be recorded properly even
4955 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4956 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004957 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004958 * <p>This flag is only for use by system sevices as a convenience to
4959 * avoid having to implement a more complex mechanism around detection
4960 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004961 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004962 * @hide
4963 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004964 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004965 /**
4966 * Set when this broadcast is for a boot upgrade, a special mode that
4967 * allows the broadcast to be sent before the system is ready and launches
4968 * the app process with no providers running in it.
4969 * @hide
4970 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004971 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004972 /**
4973 * If set, the broadcast will always go to manifest receivers in background (cached
4974 * or not running) apps, regardless of whether that would be done by default. By
4975 * default they will only receive broadcasts if the broadcast has specified an
4976 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08004977 *
4978 * NOTE: dumpstate uses this flag numerically, so when its value is changed
4979 * the broadcast code there must also be changed to match.
4980 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004981 * @hide
4982 */
4983 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4984 /**
4985 * If set, the broadcast will never go to manifest receivers in background (cached
4986 * or not running) apps, regardless of whether that would be done by default. By
4987 * default they will receive broadcasts if the broadcast has specified an
4988 * explicit component or package name.
4989 * @hide
4990 */
4991 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07004992 /**
4993 * If set, this broadcast is being sent from the shell.
4994 * @hide
4995 */
4996 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004997
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004998 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08004999 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5000 * will not receive broadcasts.
5001 *
5002 * <em>This flag has no effect when used by an Instant App.</em>
5003 */
5004 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5005
5006 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005007 * @hide Flags that can't be changed with PendingIntent.
5008 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005009 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5010 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5011 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005013 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005014 // ---------------------------------------------------------------------
5015 // toUri() and parseUri() options.
5016
5017 /**
5018 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5019 * always has the "intent:" scheme. This syntax can be used when you want
5020 * to later disambiguate between URIs that are intended to describe an
5021 * Intent vs. all others that should be treated as raw URIs. When used
5022 * with {@link #parseUri}, any other scheme will result in a generic
5023 * VIEW action for that raw URI.
5024 */
5025 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005026
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005027 /**
5028 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5029 * always has the "android-app:" scheme. This is a variation of
5030 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5031 * http/https URI being delivered to a specific package name. The format
5032 * is:
5033 *
5034 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005035 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005036 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005037 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5038 * you must also include a scheme; including a path also requires both a host and a scheme.
5039 * The final #Intent; fragment can be used without a scheme, host, or path.
5040 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005041 * used with intents that have a {@link #setSelector}, since the base intent
5042 * will always have an explicit package name.</p>
5043 *
5044 * <p>Some examples of how this scheme maps to Intent objects:</p>
5045 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5046 * <colgroup align="left" />
5047 * <colgroup align="left" />
5048 * <thead>
5049 * <tr><th>URI</th> <th>Intent</th></tr>
5050 * </thead>
5051 *
5052 * <tbody>
5053 * <tr><td><code>android-app://com.example.app</code></td>
5054 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5055 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5056 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5057 * </table></td>
5058 * </tr>
5059 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5060 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5061 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5062 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5063 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5064 * </table></td>
5065 * </tr>
5066 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5067 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5068 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5069 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5070 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5071 * </table></td>
5072 * </tr>
5073 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5074 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5075 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5076 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5077 * </table></td>
5078 * </tr>
5079 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5080 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5081 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5082 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5083 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5084 * </table></td>
5085 * </tr>
5086 * <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>
5087 * <td><table border="" style="margin:0" >
5088 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5089 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5090 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5091 * </table></td>
5092 * </tr>
5093 * </tbody>
5094 * </table>
5095 */
5096 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5097
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005098 /**
5099 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5100 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5101 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5102 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5103 * generated Intent can not cause unexpected data access to happen.
5104 *
5105 * <p>If you do not trust the source of the URI being parsed, you should still do further
5106 * processing to protect yourself from it. In particular, when using it to start an
5107 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5108 * that can handle it.</p>
5109 */
5110 public static final int URI_ALLOW_UNSAFE = 1<<2;
5111
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005112 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005113
5114 private String mAction;
5115 private Uri mData;
5116 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005117 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005118 private ComponentName mComponent;
5119 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005120 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005121 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005122 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005123 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005124 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005125 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005126 /** Token to track instant app launches. Local only; do not copy cross-process. */
5127 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005128
5129 // ---------------------------------------------------------------------
5130
5131 /**
5132 * Create an empty intent.
5133 */
5134 public Intent() {
5135 }
5136
5137 /**
5138 * Copy constructor.
5139 */
5140 public Intent(Intent o) {
5141 this.mAction = o.mAction;
5142 this.mData = o.mData;
5143 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005144 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005145 this.mComponent = o.mComponent;
5146 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005147 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005148 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005150 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005151 }
5152 if (o.mExtras != null) {
5153 this.mExtras = new Bundle(o.mExtras);
5154 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005155 if (o.mSourceBounds != null) {
5156 this.mSourceBounds = new Rect(o.mSourceBounds);
5157 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005158 if (o.mSelector != null) {
5159 this.mSelector = new Intent(o.mSelector);
5160 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005161 if (o.mClipData != null) {
5162 this.mClipData = new ClipData(o.mClipData);
5163 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005164 }
5165
5166 @Override
5167 public Object clone() {
5168 return new Intent(this);
5169 }
5170
5171 private Intent(Intent o, boolean all) {
5172 this.mAction = o.mAction;
5173 this.mData = o.mData;
5174 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005175 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005176 this.mComponent = o.mComponent;
5177 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005178 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005179 }
5180 }
5181
5182 /**
5183 * Make a clone of only the parts of the Intent that are relevant for
5184 * filter matching: the action, data, type, component, and categories.
5185 */
5186 public Intent cloneFilter() {
5187 return new Intent(this, false);
5188 }
5189
5190 /**
5191 * Create an intent with a given action. All other fields (data, type,
5192 * class) are null. Note that the action <em>must</em> be in a
5193 * namespace because Intents are used globally in the system -- for
5194 * example the system VIEW action is android.intent.action.VIEW; an
5195 * application's custom action would be something like
5196 * com.google.app.myapp.CUSTOM_ACTION.
5197 *
5198 * @param action The Intent action, such as ACTION_VIEW.
5199 */
5200 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005201 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005202 }
5203
5204 /**
5205 * Create an intent with a given action and for a given data url. Note
5206 * that the action <em>must</em> be in a namespace because Intents are
5207 * used globally in the system -- for example the system VIEW action is
5208 * android.intent.action.VIEW; an application's custom action would be
5209 * something like com.google.app.myapp.CUSTOM_ACTION.
5210 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005211 * <p><em>Note: scheme and host name matching in the Android framework is
5212 * case-sensitive, unlike the formal RFC. As a result,
5213 * you should always ensure that you write your Uri with these elements
5214 * using lower case letters, and normalize any Uris you receive from
5215 * outside of Android to ensure the scheme and host is lower case.</em></p>
5216 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005217 * @param action The Intent action, such as ACTION_VIEW.
5218 * @param uri The Intent data URI.
5219 */
5220 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005221 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005222 mData = uri;
5223 }
5224
5225 /**
5226 * Create an intent for a specific component. All other fields (action, data,
5227 * type, class) are null, though they can be modified later with explicit
5228 * calls. This provides a convenient way to create an intent that is
5229 * intended to execute a hard-coded class name, rather than relying on the
5230 * system to find an appropriate class for you; see {@link #setComponent}
5231 * for more information on the repercussions of this.
5232 *
5233 * @param packageContext A Context of the application package implementing
5234 * this class.
5235 * @param cls The component class that is to be used for the intent.
5236 *
5237 * @see #setClass
5238 * @see #setComponent
5239 * @see #Intent(String, android.net.Uri , Context, Class)
5240 */
5241 public Intent(Context packageContext, Class<?> cls) {
5242 mComponent = new ComponentName(packageContext, cls);
5243 }
5244
5245 /**
5246 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005247 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005248 * construct the Intent and then calling {@link #setClass} to set its
5249 * class.
5250 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005251 * <p><em>Note: scheme and host name matching in the Android framework is
5252 * case-sensitive, unlike the formal RFC. As a result,
5253 * you should always ensure that you write your Uri with these elements
5254 * using lower case letters, and normalize any Uris you receive from
5255 * outside of Android to ensure the scheme and host is lower case.</em></p>
5256 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005257 * @param action The Intent action, such as ACTION_VIEW.
5258 * @param uri The Intent data URI.
5259 * @param packageContext A Context of the application package implementing
5260 * this class.
5261 * @param cls The component class that is to be used for the intent.
5262 *
5263 * @see #Intent(String, android.net.Uri)
5264 * @see #Intent(Context, Class)
5265 * @see #setClass
5266 * @see #setComponent
5267 */
5268 public Intent(String action, Uri uri,
5269 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005270 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005271 mData = uri;
5272 mComponent = new ComponentName(packageContext, cls);
5273 }
5274
5275 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005276 * Create an intent to launch the main (root) activity of a task. This
5277 * is the Intent that is started when the application's is launched from
5278 * Home. For anything else that wants to launch an application in the
5279 * same way, it is important that they use an Intent structured the same
5280 * way, and can use this function to ensure this is the case.
5281 *
5282 * <p>The returned Intent has the given Activity component as its explicit
5283 * component, {@link #ACTION_MAIN} as its action, and includes the
5284 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5285 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5286 * to do that through {@link #addFlags(int)} on the returned Intent.
5287 *
5288 * @param mainActivity The main activity component that this Intent will
5289 * launch.
5290 * @return Returns a newly created Intent that can be used to launch the
5291 * activity as a main application entry.
5292 *
5293 * @see #setClass
5294 * @see #setComponent
5295 */
5296 public static Intent makeMainActivity(ComponentName mainActivity) {
5297 Intent intent = new Intent(ACTION_MAIN);
5298 intent.setComponent(mainActivity);
5299 intent.addCategory(CATEGORY_LAUNCHER);
5300 return intent;
5301 }
5302
5303 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005304 * Make an Intent for the main activity of an application, without
5305 * specifying a specific activity to run but giving a selector to find
5306 * the activity. This results in a final Intent that is structured
5307 * the same as when the application is launched from
5308 * Home. For anything else that wants to launch an application in the
5309 * same way, it is important that they use an Intent structured the same
5310 * way, and can use this function to ensure this is the case.
5311 *
5312 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5313 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5314 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5315 * to do that through {@link #addFlags(int)} on the returned Intent.
5316 *
5317 * @param selectorAction The action name of the Intent's selector.
5318 * @param selectorCategory The name of a category to add to the Intent's
5319 * selector.
5320 * @return Returns a newly created Intent that can be used to launch the
5321 * activity as a main application entry.
5322 *
5323 * @see #setSelector(Intent)
5324 */
5325 public static Intent makeMainSelectorActivity(String selectorAction,
5326 String selectorCategory) {
5327 Intent intent = new Intent(ACTION_MAIN);
5328 intent.addCategory(CATEGORY_LAUNCHER);
5329 Intent selector = new Intent();
5330 selector.setAction(selectorAction);
5331 selector.addCategory(selectorCategory);
5332 intent.setSelector(selector);
5333 return intent;
5334 }
5335
5336 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005337 * Make an Intent that can be used to re-launch an application's task
5338 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5339 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5340 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5341 *
5342 * @param mainActivity The activity component that is the root of the
5343 * task; this is the activity that has been published in the application's
5344 * manifest as the main launcher icon.
5345 *
5346 * @return Returns a newly created Intent that can be used to relaunch the
5347 * activity's task in its root state.
5348 */
5349 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5350 Intent intent = makeMainActivity(mainActivity);
5351 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5352 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5353 return intent;
5354 }
5355
5356 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005357 * Call {@link #parseUri} with 0 flags.
5358 * @deprecated Use {@link #parseUri} instead.
5359 */
5360 @Deprecated
5361 public static Intent getIntent(String uri) throws URISyntaxException {
5362 return parseUri(uri, 0);
5363 }
Tom Taylord4a47292009-12-21 13:59:18 -08005364
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005365 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005366 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005367 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005368 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005369 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005370 *
5371 * <p>The URI given here must not be relative -- that is, it must include
5372 * the scheme and full path.
5373 *
5374 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005375 * @param flags Additional processing flags. Either 0,
5376 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005377 *
5378 * @return Intent The newly created Intent object.
5379 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005380 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5381 * it bad (as parsed by the Uri class) or the Intent data within the
5382 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005383 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005384 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005385 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005386 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005387 int i = 0;
5388 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005389 final boolean androidApp = uri.startsWith("android-app:");
5390
5391 // Validate intent scheme if requested.
5392 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5393 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005394 Intent intent = new Intent(ACTION_VIEW);
5395 try {
5396 intent.setData(Uri.parse(uri));
5397 } catch (IllegalArgumentException e) {
5398 throw new URISyntaxException(uri, e.getMessage());
5399 }
5400 return intent;
5401 }
5402 }
Tom Taylord4a47292009-12-21 13:59:18 -08005403
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005404 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005405 // simple case
5406 if (i == -1) {
5407 if (!androidApp) {
5408 return new Intent(ACTION_VIEW, Uri.parse(uri));
5409 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005410
5411 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005412 } else if (!uri.startsWith("#Intent;", i)) {
5413 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005414 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005415 } else {
5416 i = -1;
5417 }
5418 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005419
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005420 // new format
5421 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005422 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005423 boolean explicitAction = false;
5424 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005425
5426 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005427 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005428 String data;
5429 if (i >= 0) {
5430 data = uri.substring(0, i);
5431 i += 8; // length of "#Intent;"
5432 } else {
5433 data = uri;
5434 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005435
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005436 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005437 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005438 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005439 if (eq < 0) eq = i-1;
5440 int semi = uri.indexOf(';', i);
5441 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005442
5443 // action
5444 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005445 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005446 if (!inSelector) {
5447 explicitAction = true;
5448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005449 }
5450
5451 // categories
5452 else if (uri.startsWith("category=", i)) {
5453 intent.addCategory(value);
5454 }
5455
5456 // type
5457 else if (uri.startsWith("type=", i)) {
5458 intent.mType = value;
5459 }
5460
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005461 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005462 else if (uri.startsWith("launchFlags=", i)) {
5463 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005464 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5465 intent.mFlags &= ~IMMUTABLE_FLAGS;
5466 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005467 }
5468
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005469 // package
5470 else if (uri.startsWith("package=", i)) {
5471 intent.mPackage = value;
5472 }
5473
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005474 // component
5475 else if (uri.startsWith("component=", i)) {
5476 intent.mComponent = ComponentName.unflattenFromString(value);
5477 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005478
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005479 // scheme
5480 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005481 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005482 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005483 } else {
5484 scheme = value;
5485 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005486 }
5487
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005488 // source bounds
5489 else if (uri.startsWith("sourceBounds=", i)) {
5490 intent.mSourceBounds = Rect.unflattenFromString(value);
5491 }
5492
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005493 // selector
5494 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5495 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005496 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005497 }
5498
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005499 // extra
5500 else {
5501 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005502 // create Bundle if it doesn't already exist
5503 if (intent.mExtras == null) intent.mExtras = new Bundle();
5504 Bundle b = intent.mExtras;
5505 // add EXTRA
5506 if (uri.startsWith("S.", i)) b.putString(key, value);
5507 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5508 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5509 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5510 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5511 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5512 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5513 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5514 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5515 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5516 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005517
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005518 // move to the next item
5519 i = semi + 1;
5520 }
5521
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005522 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005523 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005524 if (baseIntent.mPackage == null) {
5525 baseIntent.setSelector(intent);
5526 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005527 intent = baseIntent;
5528 }
5529
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005530 if (data != null) {
5531 if (data.startsWith("intent:")) {
5532 data = data.substring(7);
5533 if (scheme != null) {
5534 data = scheme + ':' + data;
5535 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005536 } else if (data.startsWith("android-app:")) {
5537 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5538 // Correctly formed android-app, first part is package name.
5539 int end = data.indexOf('/', 14);
5540 if (end < 0) {
5541 // All we have is a package name.
5542 intent.mPackage = data.substring(14);
5543 if (!explicitAction) {
5544 intent.setAction(ACTION_MAIN);
5545 }
5546 data = "";
5547 } else {
5548 // Target the Intent at the given package name always.
5549 String authority = null;
5550 intent.mPackage = data.substring(14, end);
5551 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005552 if ((end+1) < data.length()) {
5553 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5554 // Found a scheme, remember it.
5555 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005556 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005557 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5558 // Found a authority, remember it.
5559 authority = data.substring(end+1, newEnd);
5560 end = newEnd;
5561 }
5562 } else {
5563 // All we have is a scheme.
5564 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005565 }
5566 }
5567 if (scheme == null) {
5568 // If there was no scheme, then this just targets the package.
5569 if (!explicitAction) {
5570 intent.setAction(ACTION_MAIN);
5571 }
5572 data = "";
5573 } else if (authority == null) {
5574 data = scheme + ":";
5575 } else {
5576 data = scheme + "://" + authority + data.substring(end);
5577 }
5578 }
5579 } else {
5580 data = "";
5581 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005582 }
Tom Taylord4a47292009-12-21 13:59:18 -08005583
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005584 if (data.length() > 0) {
5585 try {
5586 intent.mData = Uri.parse(data);
5587 } catch (IllegalArgumentException e) {
5588 throw new URISyntaxException(uri, e.getMessage());
5589 }
5590 }
5591 }
Tom Taylord4a47292009-12-21 13:59:18 -08005592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005593 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005594
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005595 } catch (IndexOutOfBoundsException e) {
5596 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5597 }
5598 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005599
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005600 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005601 return getIntentOld(uri, 0);
5602 }
5603
5604 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005605 Intent intent;
5606
5607 int i = uri.lastIndexOf('#');
5608 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005609 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005610 final int intentFragmentStart = i;
5611 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005612
5613 i++;
5614
5615 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005616 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005617 i += 7;
5618 int j = uri.indexOf(')', i);
5619 action = uri.substring(i, j);
5620 i = j + 1;
5621 }
5622
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005623 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005624
5625 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005626 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005627 i += 11;
5628 int j = uri.indexOf(')', i);
5629 while (i < j) {
5630 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005631 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005632 if (i < sep) {
5633 intent.addCategory(uri.substring(i, sep));
5634 }
5635 i = sep + 1;
5636 }
5637 i = j + 1;
5638 }
5639
5640 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005641 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005642 i += 5;
5643 int j = uri.indexOf(')', i);
5644 intent.mType = uri.substring(i, j);
5645 i = j + 1;
5646 }
5647
5648 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005649 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005650 i += 12;
5651 int j = uri.indexOf(')', i);
5652 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005653 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5654 intent.mFlags &= ~IMMUTABLE_FLAGS;
5655 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005656 i = j + 1;
5657 }
5658
5659 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005660 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005661 i += 10;
5662 int j = uri.indexOf(')', i);
5663 int sep = uri.indexOf('!', i);
5664 if (sep >= 0 && sep < j) {
5665 String pkg = uri.substring(i, sep);
5666 String cls = uri.substring(sep + 1, j);
5667 intent.mComponent = new ComponentName(pkg, cls);
5668 }
5669 i = j + 1;
5670 }
5671
5672 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005673 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005674 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005675
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005676 final int closeParen = uri.indexOf(')', i);
5677 if (closeParen == -1) throw new URISyntaxException(uri,
5678 "EXTRA missing trailing ')'", i);
5679
5680 while (i < closeParen) {
5681 // fetch the key value
5682 int j = uri.indexOf('=', i);
5683 if (j <= i + 1 || i >= closeParen) {
5684 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5685 }
5686 char type = uri.charAt(i);
5687 i++;
5688 String key = uri.substring(i, j);
5689 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005690
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005691 // get type-value
5692 j = uri.indexOf('!', i);
5693 if (j == -1 || j >= closeParen) j = closeParen;
5694 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5695 String value = uri.substring(i, j);
5696 i = j;
5697
5698 // create Bundle if it doesn't already exist
5699 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005700
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005701 // add item to bundle
5702 try {
5703 switch (type) {
5704 case 'S':
5705 intent.mExtras.putString(key, Uri.decode(value));
5706 break;
5707 case 'B':
5708 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5709 break;
5710 case 'b':
5711 intent.mExtras.putByte(key, Byte.parseByte(value));
5712 break;
5713 case 'c':
5714 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5715 break;
5716 case 'd':
5717 intent.mExtras.putDouble(key, Double.parseDouble(value));
5718 break;
5719 case 'f':
5720 intent.mExtras.putFloat(key, Float.parseFloat(value));
5721 break;
5722 case 'i':
5723 intent.mExtras.putInt(key, Integer.parseInt(value));
5724 break;
5725 case 'l':
5726 intent.mExtras.putLong(key, Long.parseLong(value));
5727 break;
5728 case 's':
5729 intent.mExtras.putShort(key, Short.parseShort(value));
5730 break;
5731 default:
5732 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5733 }
5734 } catch (NumberFormatException e) {
5735 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5736 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005737
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005738 char ch = uri.charAt(i);
5739 if (ch == ')') break;
5740 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5741 i++;
5742 }
5743 }
5744
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005745 if (isIntentFragment) {
5746 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5747 } else {
5748 intent.mData = Uri.parse(uri);
5749 }
Tom Taylord4a47292009-12-21 13:59:18 -08005750
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005751 if (intent.mAction == null) {
5752 // By default, if no action is specified, then use VIEW.
5753 intent.mAction = ACTION_VIEW;
5754 }
5755
5756 } else {
5757 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5758 }
5759
5760 return intent;
5761 }
5762
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005763 /** @hide */
5764 public interface CommandOptionHandler {
5765 boolean handleOption(String opt, ShellCommand cmd);
5766 }
5767
5768 /** @hide */
5769 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5770 throws URISyntaxException {
5771 Intent intent = new Intent();
5772 Intent baseIntent = intent;
5773 boolean hasIntentInfo = false;
5774
5775 Uri data = null;
5776 String type = null;
5777
5778 String opt;
5779 while ((opt=cmd.getNextOption()) != null) {
5780 switch (opt) {
5781 case "-a":
5782 intent.setAction(cmd.getNextArgRequired());
5783 if (intent == baseIntent) {
5784 hasIntentInfo = true;
5785 }
5786 break;
5787 case "-d":
5788 data = Uri.parse(cmd.getNextArgRequired());
5789 if (intent == baseIntent) {
5790 hasIntentInfo = true;
5791 }
5792 break;
5793 case "-t":
5794 type = cmd.getNextArgRequired();
5795 if (intent == baseIntent) {
5796 hasIntentInfo = true;
5797 }
5798 break;
5799 case "-c":
5800 intent.addCategory(cmd.getNextArgRequired());
5801 if (intent == baseIntent) {
5802 hasIntentInfo = true;
5803 }
5804 break;
5805 case "-e":
5806 case "--es": {
5807 String key = cmd.getNextArgRequired();
5808 String value = cmd.getNextArgRequired();
5809 intent.putExtra(key, value);
5810 }
5811 break;
5812 case "--esn": {
5813 String key = cmd.getNextArgRequired();
5814 intent.putExtra(key, (String) null);
5815 }
5816 break;
5817 case "--ei": {
5818 String key = cmd.getNextArgRequired();
5819 String value = cmd.getNextArgRequired();
5820 intent.putExtra(key, Integer.decode(value));
5821 }
5822 break;
5823 case "--eu": {
5824 String key = cmd.getNextArgRequired();
5825 String value = cmd.getNextArgRequired();
5826 intent.putExtra(key, Uri.parse(value));
5827 }
5828 break;
5829 case "--ecn": {
5830 String key = cmd.getNextArgRequired();
5831 String value = cmd.getNextArgRequired();
5832 ComponentName cn = ComponentName.unflattenFromString(value);
5833 if (cn == null)
5834 throw new IllegalArgumentException("Bad component name: " + value);
5835 intent.putExtra(key, cn);
5836 }
5837 break;
5838 case "--eia": {
5839 String key = cmd.getNextArgRequired();
5840 String value = cmd.getNextArgRequired();
5841 String[] strings = value.split(",");
5842 int[] list = new int[strings.length];
5843 for (int i = 0; i < strings.length; i++) {
5844 list[i] = Integer.decode(strings[i]);
5845 }
5846 intent.putExtra(key, list);
5847 }
5848 break;
5849 case "--eial": {
5850 String key = cmd.getNextArgRequired();
5851 String value = cmd.getNextArgRequired();
5852 String[] strings = value.split(",");
5853 ArrayList<Integer> list = new ArrayList<>(strings.length);
5854 for (int i = 0; i < strings.length; i++) {
5855 list.add(Integer.decode(strings[i]));
5856 }
5857 intent.putExtra(key, list);
5858 }
5859 break;
5860 case "--el": {
5861 String key = cmd.getNextArgRequired();
5862 String value = cmd.getNextArgRequired();
5863 intent.putExtra(key, Long.valueOf(value));
5864 }
5865 break;
5866 case "--ela": {
5867 String key = cmd.getNextArgRequired();
5868 String value = cmd.getNextArgRequired();
5869 String[] strings = value.split(",");
5870 long[] list = new long[strings.length];
5871 for (int i = 0; i < strings.length; i++) {
5872 list[i] = Long.valueOf(strings[i]);
5873 }
5874 intent.putExtra(key, list);
5875 hasIntentInfo = true;
5876 }
5877 break;
5878 case "--elal": {
5879 String key = cmd.getNextArgRequired();
5880 String value = cmd.getNextArgRequired();
5881 String[] strings = value.split(",");
5882 ArrayList<Long> list = new ArrayList<>(strings.length);
5883 for (int i = 0; i < strings.length; i++) {
5884 list.add(Long.valueOf(strings[i]));
5885 }
5886 intent.putExtra(key, list);
5887 hasIntentInfo = true;
5888 }
5889 break;
5890 case "--ef": {
5891 String key = cmd.getNextArgRequired();
5892 String value = cmd.getNextArgRequired();
5893 intent.putExtra(key, Float.valueOf(value));
5894 hasIntentInfo = true;
5895 }
5896 break;
5897 case "--efa": {
5898 String key = cmd.getNextArgRequired();
5899 String value = cmd.getNextArgRequired();
5900 String[] strings = value.split(",");
5901 float[] list = new float[strings.length];
5902 for (int i = 0; i < strings.length; i++) {
5903 list[i] = Float.valueOf(strings[i]);
5904 }
5905 intent.putExtra(key, list);
5906 hasIntentInfo = true;
5907 }
5908 break;
5909 case "--efal": {
5910 String key = cmd.getNextArgRequired();
5911 String value = cmd.getNextArgRequired();
5912 String[] strings = value.split(",");
5913 ArrayList<Float> list = new ArrayList<>(strings.length);
5914 for (int i = 0; i < strings.length; i++) {
5915 list.add(Float.valueOf(strings[i]));
5916 }
5917 intent.putExtra(key, list);
5918 hasIntentInfo = true;
5919 }
5920 break;
5921 case "--esa": {
5922 String key = cmd.getNextArgRequired();
5923 String value = cmd.getNextArgRequired();
5924 // Split on commas unless they are preceeded by an escape.
5925 // The escape character must be escaped for the string and
5926 // again for the regex, thus four escape characters become one.
5927 String[] strings = value.split("(?<!\\\\),");
5928 intent.putExtra(key, strings);
5929 hasIntentInfo = true;
5930 }
5931 break;
5932 case "--esal": {
5933 String key = cmd.getNextArgRequired();
5934 String value = cmd.getNextArgRequired();
5935 // Split on commas unless they are preceeded by an escape.
5936 // The escape character must be escaped for the string and
5937 // again for the regex, thus four escape characters become one.
5938 String[] strings = value.split("(?<!\\\\),");
5939 ArrayList<String> list = new ArrayList<>(strings.length);
5940 for (int i = 0; i < strings.length; i++) {
5941 list.add(strings[i]);
5942 }
5943 intent.putExtra(key, list);
5944 hasIntentInfo = true;
5945 }
5946 break;
5947 case "--ez": {
5948 String key = cmd.getNextArgRequired();
5949 String value = cmd.getNextArgRequired().toLowerCase();
5950 // Boolean.valueOf() results in false for anything that is not "true", which is
5951 // error-prone in shell commands
5952 boolean arg;
5953 if ("true".equals(value) || "t".equals(value)) {
5954 arg = true;
5955 } else if ("false".equals(value) || "f".equals(value)) {
5956 arg = false;
5957 } else {
5958 try {
5959 arg = Integer.decode(value) != 0;
5960 } catch (NumberFormatException ex) {
5961 throw new IllegalArgumentException("Invalid boolean value: " + value);
5962 }
5963 }
5964
5965 intent.putExtra(key, arg);
5966 }
5967 break;
5968 case "-n": {
5969 String str = cmd.getNextArgRequired();
5970 ComponentName cn = ComponentName.unflattenFromString(str);
5971 if (cn == null)
5972 throw new IllegalArgumentException("Bad component name: " + str);
5973 intent.setComponent(cn);
5974 if (intent == baseIntent) {
5975 hasIntentInfo = true;
5976 }
5977 }
5978 break;
5979 case "-p": {
5980 String str = cmd.getNextArgRequired();
5981 intent.setPackage(str);
5982 if (intent == baseIntent) {
5983 hasIntentInfo = true;
5984 }
5985 }
5986 break;
5987 case "-f":
5988 String str = cmd.getNextArgRequired();
5989 intent.setFlags(Integer.decode(str).intValue());
5990 break;
5991 case "--grant-read-uri-permission":
5992 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5993 break;
5994 case "--grant-write-uri-permission":
5995 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5996 break;
5997 case "--grant-persistable-uri-permission":
5998 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5999 break;
6000 case "--grant-prefix-uri-permission":
6001 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6002 break;
6003 case "--exclude-stopped-packages":
6004 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6005 break;
6006 case "--include-stopped-packages":
6007 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6008 break;
6009 case "--debug-log-resolution":
6010 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6011 break;
6012 case "--activity-brought-to-front":
6013 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6014 break;
6015 case "--activity-clear-top":
6016 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6017 break;
6018 case "--activity-clear-when-task-reset":
6019 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6020 break;
6021 case "--activity-exclude-from-recents":
6022 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6023 break;
6024 case "--activity-launched-from-history":
6025 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6026 break;
6027 case "--activity-multiple-task":
6028 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6029 break;
6030 case "--activity-no-animation":
6031 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6032 break;
6033 case "--activity-no-history":
6034 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6035 break;
6036 case "--activity-no-user-action":
6037 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6038 break;
6039 case "--activity-previous-is-top":
6040 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6041 break;
6042 case "--activity-reorder-to-front":
6043 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6044 break;
6045 case "--activity-reset-task-if-needed":
6046 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6047 break;
6048 case "--activity-single-top":
6049 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6050 break;
6051 case "--activity-clear-task":
6052 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6053 break;
6054 case "--activity-task-on-home":
6055 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6056 break;
6057 case "--receiver-registered-only":
6058 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6059 break;
6060 case "--receiver-replace-pending":
6061 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6062 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006063 case "--receiver-foreground":
6064 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6065 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006066 case "--receiver-no-abort":
6067 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6068 break;
6069 case "--receiver-include-background":
6070 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6071 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006072 case "--selector":
6073 intent.setDataAndType(data, type);
6074 intent = new Intent();
6075 break;
6076 default:
6077 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6078 // Okay, caller handled this option.
6079 } else {
6080 throw new IllegalArgumentException("Unknown option: " + opt);
6081 }
6082 break;
6083 }
6084 }
6085 intent.setDataAndType(data, type);
6086
6087 final boolean hasSelector = intent != baseIntent;
6088 if (hasSelector) {
6089 // A selector was specified; fix up.
6090 baseIntent.setSelector(intent);
6091 intent = baseIntent;
6092 }
6093
6094 String arg = cmd.getNextArg();
6095 baseIntent = null;
6096 if (arg == null) {
6097 if (hasSelector) {
6098 // If a selector has been specified, and no arguments
6099 // have been supplied for the main Intent, then we can
6100 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6101 // need to have a component name specified yet, the
6102 // selector will take care of that.
6103 baseIntent = new Intent(Intent.ACTION_MAIN);
6104 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6105 }
6106 } else if (arg.indexOf(':') >= 0) {
6107 // The argument is a URI. Fully parse it, and use that result
6108 // to fill in any data not specified so far.
6109 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6110 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6111 } else if (arg.indexOf('/') >= 0) {
6112 // The argument is a component name. Build an Intent to launch
6113 // it.
6114 baseIntent = new Intent(Intent.ACTION_MAIN);
6115 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6116 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6117 } else {
6118 // Assume the argument is a package name.
6119 baseIntent = new Intent(Intent.ACTION_MAIN);
6120 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6121 baseIntent.setPackage(arg);
6122 }
6123 if (baseIntent != null) {
6124 Bundle extras = intent.getExtras();
6125 intent.replaceExtras((Bundle)null);
6126 Bundle uriExtras = baseIntent.getExtras();
6127 baseIntent.replaceExtras((Bundle)null);
6128 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6129 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6130 for (String c : cats) {
6131 baseIntent.removeCategory(c);
6132 }
6133 }
6134 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6135 if (extras == null) {
6136 extras = uriExtras;
6137 } else if (uriExtras != null) {
6138 uriExtras.putAll(extras);
6139 extras = uriExtras;
6140 }
6141 intent.replaceExtras(extras);
6142 hasIntentInfo = true;
6143 }
6144
6145 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6146 return intent;
6147 }
6148
6149 /** @hide */
6150 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6151 final String[] lines = new String[] {
6152 "<INTENT> specifications include these flags and arguments:",
6153 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6154 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6155 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6156 " [--esn <EXTRA_KEY> ...]",
6157 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6158 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6159 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6160 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6161 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6162 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6163 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6164 " (mutiple extras passed as Integer[])",
6165 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6166 " (mutiple extras passed as List<Integer>)",
6167 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6168 " (mutiple extras passed as Long[])",
6169 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6170 " (mutiple extras passed as List<Long>)",
6171 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6172 " (mutiple extras passed as Float[])",
6173 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6174 " (mutiple extras passed as List<Float>)",
6175 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6176 " (mutiple extras passed as String[]; to embed a comma into a string,",
6177 " escape it using \"\\,\")",
6178 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6179 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6180 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006181 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006182 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6183 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6184 " [--debug-log-resolution] [--exclude-stopped-packages]",
6185 " [--include-stopped-packages]",
6186 " [--activity-brought-to-front] [--activity-clear-top]",
6187 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6188 " [--activity-launched-from-history] [--activity-multiple-task]",
6189 " [--activity-no-animation] [--activity-no-history]",
6190 " [--activity-no-user-action] [--activity-previous-is-top]",
6191 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6192 " [--activity-single-top] [--activity-clear-task]",
6193 " [--activity-task-on-home]",
6194 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006195 " [--receiver-foreground] [--receiver-no-abort]",
6196 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006197 " [--selector]",
6198 " [<URI> | <PACKAGE> | <COMPONENT>]"
6199 };
6200 for (String line : lines) {
6201 pw.print(prefix);
6202 pw.println(line);
6203 }
6204 }
6205
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006206 /**
6207 * Retrieve the general action to be performed, such as
6208 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6209 * the information in the intent should be interpreted -- most importantly,
6210 * what to do with the data returned by {@link #getData}.
6211 *
6212 * @return The action of this intent or null if none is specified.
6213 *
6214 * @see #setAction
6215 */
6216 public String getAction() {
6217 return mAction;
6218 }
6219
6220 /**
6221 * Retrieve data this intent is operating on. This URI specifies the name
6222 * of the data; often it uses the content: scheme, specifying data in a
6223 * content provider. Other schemes may be handled by specific activities,
6224 * such as http: by the web browser.
6225 *
6226 * @return The URI of the data this intent is targeting or null.
6227 *
6228 * @see #getScheme
6229 * @see #setData
6230 */
6231 public Uri getData() {
6232 return mData;
6233 }
6234
6235 /**
6236 * The same as {@link #getData()}, but returns the URI as an encoded
6237 * String.
6238 */
6239 public String getDataString() {
6240 return mData != null ? mData.toString() : null;
6241 }
6242
6243 /**
6244 * Return the scheme portion of the intent's data. If the data is null or
6245 * does not include a scheme, null is returned. Otherwise, the scheme
6246 * prefix without the final ':' is returned, i.e. "http".
6247 *
6248 * <p>This is the same as calling getData().getScheme() (and checking for
6249 * null data).
6250 *
6251 * @return The scheme of this intent.
6252 *
6253 * @see #getData
6254 */
6255 public String getScheme() {
6256 return mData != null ? mData.getScheme() : null;
6257 }
6258
6259 /**
6260 * Retrieve any explicit MIME type included in the intent. This is usually
6261 * null, as the type is determined by the intent data.
6262 *
6263 * @return If a type was manually set, it is returned; else null is
6264 * returned.
6265 *
6266 * @see #resolveType(ContentResolver)
6267 * @see #setType
6268 */
6269 public String getType() {
6270 return mType;
6271 }
6272
6273 /**
6274 * Return the MIME data type of this intent. If the type field is
6275 * explicitly set, that is simply returned. Otherwise, if the data is set,
6276 * the type of that data is returned. If neither fields are set, a null is
6277 * returned.
6278 *
6279 * @return The MIME type of this intent.
6280 *
6281 * @see #getType
6282 * @see #resolveType(ContentResolver)
6283 */
6284 public String resolveType(Context context) {
6285 return resolveType(context.getContentResolver());
6286 }
6287
6288 /**
6289 * Return the MIME data type of this intent. If the type field is
6290 * explicitly set, that is simply returned. Otherwise, if the data is set,
6291 * the type of that data is returned. If neither fields are set, a null is
6292 * returned.
6293 *
6294 * @param resolver A ContentResolver that can be used to determine the MIME
6295 * type of the intent's data.
6296 *
6297 * @return The MIME type of this intent.
6298 *
6299 * @see #getType
6300 * @see #resolveType(Context)
6301 */
6302 public String resolveType(ContentResolver resolver) {
6303 if (mType != null) {
6304 return mType;
6305 }
6306 if (mData != null) {
6307 if ("content".equals(mData.getScheme())) {
6308 return resolver.getType(mData);
6309 }
6310 }
6311 return null;
6312 }
6313
6314 /**
6315 * Return the MIME data type of this intent, only if it will be needed for
6316 * intent resolution. This is not generally useful for application code;
6317 * it is used by the frameworks for communicating with back-end system
6318 * services.
6319 *
6320 * @param resolver A ContentResolver that can be used to determine the MIME
6321 * type of the intent's data.
6322 *
6323 * @return The MIME type of this intent, or null if it is unknown or not
6324 * needed.
6325 */
6326 public String resolveTypeIfNeeded(ContentResolver resolver) {
6327 if (mComponent != null) {
6328 return mType;
6329 }
6330 return resolveType(resolver);
6331 }
6332
6333 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006334 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006335 *
6336 * @param category The category to check.
6337 *
6338 * @return boolean True if the intent contains the category, else false.
6339 *
6340 * @see #getCategories
6341 * @see #addCategory
6342 */
6343 public boolean hasCategory(String category) {
6344 return mCategories != null && mCategories.contains(category);
6345 }
6346
6347 /**
6348 * Return the set of all categories in the intent. If there are no categories,
6349 * returns NULL.
6350 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006351 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006352 *
6353 * @see #hasCategory
6354 * @see #addCategory
6355 */
6356 public Set<String> getCategories() {
6357 return mCategories;
6358 }
6359
6360 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006361 * Return the specific selector associated with this Intent. If there is
6362 * none, returns null. See {@link #setSelector} for more information.
6363 *
6364 * @see #setSelector
6365 */
6366 public Intent getSelector() {
6367 return mSelector;
6368 }
6369
6370 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006371 * Return the {@link ClipData} associated with this Intent. If there is
6372 * none, returns null. See {@link #setClipData} for more information.
6373 *
John Spurlock125d1332013-11-25 11:58:37 -05006374 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006375 */
6376 public ClipData getClipData() {
6377 return mClipData;
6378 }
6379
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006380 /** @hide */
6381 public int getContentUserHint() {
6382 return mContentUserHint;
6383 }
6384
Todd Kennedyb3b431302017-03-20 16:05:48 -07006385 /** @hide */
6386 public String getLaunchToken() {
6387 return mLaunchToken;
6388 }
6389
6390 /** @hide */
6391 public void setLaunchToken(String launchToken) {
6392 mLaunchToken = launchToken;
6393 }
6394
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006395 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006396 * Sets the ClassLoader that will be used when unmarshalling
6397 * any Parcelable values from the extras of this Intent.
6398 *
6399 * @param loader a ClassLoader, or null to use the default loader
6400 * at the time of unmarshalling.
6401 */
6402 public void setExtrasClassLoader(ClassLoader loader) {
6403 if (mExtras != null) {
6404 mExtras.setClassLoader(loader);
6405 }
6406 }
6407
6408 /**
6409 * Returns true if an extra value is associated with the given name.
6410 * @param name the extra's name
6411 * @return true if the given extra is present.
6412 */
6413 public boolean hasExtra(String name) {
6414 return mExtras != null && mExtras.containsKey(name);
6415 }
6416
6417 /**
6418 * Returns true if the Intent's extras contain a parcelled file descriptor.
6419 * @return true if the Intent contains a parcelled file descriptor.
6420 */
6421 public boolean hasFileDescriptors() {
6422 return mExtras != null && mExtras.hasFileDescriptors();
6423 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006424
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006425 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006426 public void setAllowFds(boolean allowFds) {
6427 if (mExtras != null) {
6428 mExtras.setAllowFds(allowFds);
6429 }
6430 }
6431
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006432 /** {@hide} */
6433 public void setDefusable(boolean defusable) {
6434 if (mExtras != null) {
6435 mExtras.setDefusable(defusable);
6436 }
6437 }
6438
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006439 /**
6440 * Retrieve extended data from the intent.
6441 *
6442 * @param name The name of the desired item.
6443 *
6444 * @return the value of an item that previously added with putExtra()
6445 * or null if none was found.
6446 *
6447 * @deprecated
6448 * @hide
6449 */
6450 @Deprecated
6451 public Object getExtra(String name) {
6452 return getExtra(name, null);
6453 }
6454
6455 /**
6456 * Retrieve extended data from the intent.
6457 *
6458 * @param name The name of the desired item.
6459 * @param defaultValue the value to be returned if no value of the desired
6460 * type is stored with the given name.
6461 *
6462 * @return the value of an item that previously added with putExtra()
6463 * or the default value if none was found.
6464 *
6465 * @see #putExtra(String, boolean)
6466 */
6467 public boolean getBooleanExtra(String name, boolean defaultValue) {
6468 return mExtras == null ? defaultValue :
6469 mExtras.getBoolean(name, defaultValue);
6470 }
6471
6472 /**
6473 * Retrieve extended data from the intent.
6474 *
6475 * @param name The name of the desired item.
6476 * @param defaultValue the value to be returned if no value of the desired
6477 * type is stored with the given name.
6478 *
6479 * @return the value of an item that previously added with putExtra()
6480 * or the default value if none was found.
6481 *
6482 * @see #putExtra(String, byte)
6483 */
6484 public byte getByteExtra(String name, byte defaultValue) {
6485 return mExtras == null ? defaultValue :
6486 mExtras.getByte(name, defaultValue);
6487 }
6488
6489 /**
6490 * Retrieve extended data from the intent.
6491 *
6492 * @param name The name of the desired item.
6493 * @param defaultValue the value to be returned if no value of the desired
6494 * type is stored with the given name.
6495 *
6496 * @return the value of an item that previously added with putExtra()
6497 * or the default value if none was found.
6498 *
6499 * @see #putExtra(String, short)
6500 */
6501 public short getShortExtra(String name, short defaultValue) {
6502 return mExtras == null ? defaultValue :
6503 mExtras.getShort(name, defaultValue);
6504 }
6505
6506 /**
6507 * Retrieve extended data from the intent.
6508 *
6509 * @param name The name of the desired item.
6510 * @param defaultValue the value to be returned if no value of the desired
6511 * type is stored with the given name.
6512 *
6513 * @return the value of an item that previously added with putExtra()
6514 * or the default value if none was found.
6515 *
6516 * @see #putExtra(String, char)
6517 */
6518 public char getCharExtra(String name, char defaultValue) {
6519 return mExtras == null ? defaultValue :
6520 mExtras.getChar(name, defaultValue);
6521 }
6522
6523 /**
6524 * Retrieve extended data from the intent.
6525 *
6526 * @param name The name of the desired item.
6527 * @param defaultValue the value to be returned if no value of the desired
6528 * type is stored with the given name.
6529 *
6530 * @return the value of an item that previously added with putExtra()
6531 * or the default value if none was found.
6532 *
6533 * @see #putExtra(String, int)
6534 */
6535 public int getIntExtra(String name, int defaultValue) {
6536 return mExtras == null ? defaultValue :
6537 mExtras.getInt(name, defaultValue);
6538 }
6539
6540 /**
6541 * Retrieve extended data from the intent.
6542 *
6543 * @param name The name of the desired item.
6544 * @param defaultValue the value to be returned if no value of the desired
6545 * type is stored with the given name.
6546 *
6547 * @return the value of an item that previously added with putExtra()
6548 * or the default value if none was found.
6549 *
6550 * @see #putExtra(String, long)
6551 */
6552 public long getLongExtra(String name, long defaultValue) {
6553 return mExtras == null ? defaultValue :
6554 mExtras.getLong(name, defaultValue);
6555 }
6556
6557 /**
6558 * Retrieve extended data from the intent.
6559 *
6560 * @param name The name of the desired item.
6561 * @param defaultValue the value to be returned if no value of the desired
6562 * type is stored with the given name.
6563 *
6564 * @return the value of an item that previously added with putExtra(),
6565 * or the default value if no such item is present
6566 *
6567 * @see #putExtra(String, float)
6568 */
6569 public float getFloatExtra(String name, float defaultValue) {
6570 return mExtras == null ? defaultValue :
6571 mExtras.getFloat(name, defaultValue);
6572 }
6573
6574 /**
6575 * Retrieve extended data from the intent.
6576 *
6577 * @param name The name of the desired item.
6578 * @param defaultValue the value to be returned if no value of the desired
6579 * type is stored with the given name.
6580 *
6581 * @return the value of an item that previously added with putExtra()
6582 * or the default value if none was found.
6583 *
6584 * @see #putExtra(String, double)
6585 */
6586 public double getDoubleExtra(String name, double defaultValue) {
6587 return mExtras == null ? defaultValue :
6588 mExtras.getDouble(name, defaultValue);
6589 }
6590
6591 /**
6592 * Retrieve extended data from the intent.
6593 *
6594 * @param name The name of the desired item.
6595 *
6596 * @return the value of an item that previously added with putExtra()
6597 * or null if no String value was found.
6598 *
6599 * @see #putExtra(String, String)
6600 */
6601 public String getStringExtra(String name) {
6602 return mExtras == null ? null : mExtras.getString(name);
6603 }
6604
6605 /**
6606 * Retrieve extended data from the intent.
6607 *
6608 * @param name The name of the desired item.
6609 *
6610 * @return the value of an item that previously added with putExtra()
6611 * or null if no CharSequence value was found.
6612 *
6613 * @see #putExtra(String, CharSequence)
6614 */
6615 public CharSequence getCharSequenceExtra(String name) {
6616 return mExtras == null ? null : mExtras.getCharSequence(name);
6617 }
6618
6619 /**
6620 * Retrieve extended data from the intent.
6621 *
6622 * @param name The name of the desired item.
6623 *
6624 * @return the value of an item that previously added with putExtra()
6625 * or null if no Parcelable value was found.
6626 *
6627 * @see #putExtra(String, Parcelable)
6628 */
6629 public <T extends Parcelable> T getParcelableExtra(String name) {
6630 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6631 }
6632
6633 /**
6634 * Retrieve extended data from the intent.
6635 *
6636 * @param name The name of the desired item.
6637 *
6638 * @return the value of an item that previously added with putExtra()
6639 * or null if no Parcelable[] value was found.
6640 *
6641 * @see #putExtra(String, Parcelable[])
6642 */
6643 public Parcelable[] getParcelableArrayExtra(String name) {
6644 return mExtras == null ? null : mExtras.getParcelableArray(name);
6645 }
6646
6647 /**
6648 * Retrieve extended data from the intent.
6649 *
6650 * @param name The name of the desired item.
6651 *
6652 * @return the value of an item that previously added with putExtra()
6653 * or null if no ArrayList<Parcelable> value was found.
6654 *
6655 * @see #putParcelableArrayListExtra(String, ArrayList)
6656 */
6657 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6658 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6659 }
6660
6661 /**
6662 * Retrieve extended data from the intent.
6663 *
6664 * @param name The name of the desired item.
6665 *
6666 * @return the value of an item that previously added with putExtra()
6667 * or null if no Serializable value was found.
6668 *
6669 * @see #putExtra(String, Serializable)
6670 */
6671 public Serializable getSerializableExtra(String name) {
6672 return mExtras == null ? null : mExtras.getSerializable(name);
6673 }
6674
6675 /**
6676 * Retrieve extended data from the intent.
6677 *
6678 * @param name The name of the desired item.
6679 *
6680 * @return the value of an item that previously added with putExtra()
6681 * or null if no ArrayList<Integer> value was found.
6682 *
6683 * @see #putIntegerArrayListExtra(String, ArrayList)
6684 */
6685 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6686 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6687 }
6688
6689 /**
6690 * Retrieve extended data from the intent.
6691 *
6692 * @param name The name of the desired item.
6693 *
6694 * @return the value of an item that previously added with putExtra()
6695 * or null if no ArrayList<String> value was found.
6696 *
6697 * @see #putStringArrayListExtra(String, ArrayList)
6698 */
6699 public ArrayList<String> getStringArrayListExtra(String name) {
6700 return mExtras == null ? null : mExtras.getStringArrayList(name);
6701 }
6702
6703 /**
6704 * Retrieve extended data from the intent.
6705 *
6706 * @param name The name of the desired item.
6707 *
6708 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006709 * or null if no ArrayList<CharSequence> value was found.
6710 *
6711 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6712 */
6713 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6714 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6715 }
6716
6717 /**
6718 * Retrieve extended data from the intent.
6719 *
6720 * @param name The name of the desired item.
6721 *
6722 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006723 * or null if no boolean array value was found.
6724 *
6725 * @see #putExtra(String, boolean[])
6726 */
6727 public boolean[] getBooleanArrayExtra(String name) {
6728 return mExtras == null ? null : mExtras.getBooleanArray(name);
6729 }
6730
6731 /**
6732 * Retrieve extended data from the intent.
6733 *
6734 * @param name The name of the desired item.
6735 *
6736 * @return the value of an item that previously added with putExtra()
6737 * or null if no byte array value was found.
6738 *
6739 * @see #putExtra(String, byte[])
6740 */
6741 public byte[] getByteArrayExtra(String name) {
6742 return mExtras == null ? null : mExtras.getByteArray(name);
6743 }
6744
6745 /**
6746 * Retrieve extended data from the intent.
6747 *
6748 * @param name The name of the desired item.
6749 *
6750 * @return the value of an item that previously added with putExtra()
6751 * or null if no short array value was found.
6752 *
6753 * @see #putExtra(String, short[])
6754 */
6755 public short[] getShortArrayExtra(String name) {
6756 return mExtras == null ? null : mExtras.getShortArray(name);
6757 }
6758
6759 /**
6760 * Retrieve extended data from the intent.
6761 *
6762 * @param name The name of the desired item.
6763 *
6764 * @return the value of an item that previously added with putExtra()
6765 * or null if no char array value was found.
6766 *
6767 * @see #putExtra(String, char[])
6768 */
6769 public char[] getCharArrayExtra(String name) {
6770 return mExtras == null ? null : mExtras.getCharArray(name);
6771 }
6772
6773 /**
6774 * Retrieve extended data from the intent.
6775 *
6776 * @param name The name of the desired item.
6777 *
6778 * @return the value of an item that previously added with putExtra()
6779 * or null if no int array value was found.
6780 *
6781 * @see #putExtra(String, int[])
6782 */
6783 public int[] getIntArrayExtra(String name) {
6784 return mExtras == null ? null : mExtras.getIntArray(name);
6785 }
6786
6787 /**
6788 * Retrieve extended data from the intent.
6789 *
6790 * @param name The name of the desired item.
6791 *
6792 * @return the value of an item that previously added with putExtra()
6793 * or null if no long array value was found.
6794 *
6795 * @see #putExtra(String, long[])
6796 */
6797 public long[] getLongArrayExtra(String name) {
6798 return mExtras == null ? null : mExtras.getLongArray(name);
6799 }
6800
6801 /**
6802 * Retrieve extended data from the intent.
6803 *
6804 * @param name The name of the desired item.
6805 *
6806 * @return the value of an item that previously added with putExtra()
6807 * or null if no float array value was found.
6808 *
6809 * @see #putExtra(String, float[])
6810 */
6811 public float[] getFloatArrayExtra(String name) {
6812 return mExtras == null ? null : mExtras.getFloatArray(name);
6813 }
6814
6815 /**
6816 * Retrieve extended data from the intent.
6817 *
6818 * @param name The name of the desired item.
6819 *
6820 * @return the value of an item that previously added with putExtra()
6821 * or null if no double array value was found.
6822 *
6823 * @see #putExtra(String, double[])
6824 */
6825 public double[] getDoubleArrayExtra(String name) {
6826 return mExtras == null ? null : mExtras.getDoubleArray(name);
6827 }
6828
6829 /**
6830 * Retrieve extended data from the intent.
6831 *
6832 * @param name The name of the desired item.
6833 *
6834 * @return the value of an item that previously added with putExtra()
6835 * or null if no String array value was found.
6836 *
6837 * @see #putExtra(String, String[])
6838 */
6839 public String[] getStringArrayExtra(String name) {
6840 return mExtras == null ? null : mExtras.getStringArray(name);
6841 }
6842
6843 /**
6844 * Retrieve extended data from the intent.
6845 *
6846 * @param name The name of the desired item.
6847 *
6848 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006849 * or null if no CharSequence array value was found.
6850 *
6851 * @see #putExtra(String, CharSequence[])
6852 */
6853 public CharSequence[] getCharSequenceArrayExtra(String name) {
6854 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6855 }
6856
6857 /**
6858 * Retrieve extended data from the intent.
6859 *
6860 * @param name The name of the desired item.
6861 *
6862 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006863 * or null if no Bundle value was found.
6864 *
6865 * @see #putExtra(String, Bundle)
6866 */
6867 public Bundle getBundleExtra(String name) {
6868 return mExtras == null ? null : mExtras.getBundle(name);
6869 }
6870
6871 /**
6872 * Retrieve extended data from the intent.
6873 *
6874 * @param name The name of the desired item.
6875 *
6876 * @return the value of an item that previously added with putExtra()
6877 * or null if no IBinder value was found.
6878 *
6879 * @see #putExtra(String, IBinder)
6880 *
6881 * @deprecated
6882 * @hide
6883 */
6884 @Deprecated
6885 public IBinder getIBinderExtra(String name) {
6886 return mExtras == null ? null : mExtras.getIBinder(name);
6887 }
6888
6889 /**
6890 * Retrieve extended data from the intent.
6891 *
6892 * @param name The name of the desired item.
6893 * @param defaultValue The default value to return in case no item is
6894 * associated with the key 'name'
6895 *
6896 * @return the value of an item that previously added with putExtra()
6897 * or defaultValue if none was found.
6898 *
6899 * @see #putExtra
6900 *
6901 * @deprecated
6902 * @hide
6903 */
6904 @Deprecated
6905 public Object getExtra(String name, Object defaultValue) {
6906 Object result = defaultValue;
6907 if (mExtras != null) {
6908 Object result2 = mExtras.get(name);
6909 if (result2 != null) {
6910 result = result2;
6911 }
6912 }
6913
6914 return result;
6915 }
6916
6917 /**
6918 * Retrieves a map of extended data from the intent.
6919 *
6920 * @return the map of all extras previously added with putExtra(),
6921 * or null if none have been added.
6922 */
6923 public Bundle getExtras() {
6924 return (mExtras != null)
6925 ? new Bundle(mExtras)
6926 : null;
6927 }
6928
6929 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006930 * Filter extras to only basic types.
6931 * @hide
6932 */
6933 public void removeUnsafeExtras() {
6934 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006935 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006936 }
6937 }
6938
6939 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 * Retrieve any special flags associated with this intent. You will
6941 * normally just set them with {@link #setFlags} and let the system
6942 * take the appropriate action with them.
6943 *
6944 * @return int The currently set flags.
6945 *
6946 * @see #setFlags
6947 */
6948 public int getFlags() {
6949 return mFlags;
6950 }
6951
Dianne Hackborne7f97212011-02-24 14:40:20 -08006952 /** @hide */
6953 public boolean isExcludingStopped() {
6954 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6955 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6956 }
6957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006958 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006959 * Retrieve the application package name this Intent is limited to. When
6960 * resolving an Intent, if non-null this limits the resolution to only
6961 * components in the given application package.
6962 *
6963 * @return The name of the application package for the Intent.
6964 *
6965 * @see #resolveActivity
6966 * @see #setPackage
6967 */
6968 public String getPackage() {
6969 return mPackage;
6970 }
6971
6972 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006973 * Retrieve the concrete component associated with the intent. When receiving
6974 * an intent, this is the component that was found to best handle it (that is,
6975 * yourself) and will always be non-null; in all other cases it will be
6976 * null unless explicitly set.
6977 *
6978 * @return The name of the application component to handle the intent.
6979 *
6980 * @see #resolveActivity
6981 * @see #setComponent
6982 */
6983 public ComponentName getComponent() {
6984 return mComponent;
6985 }
6986
6987 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006988 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6989 * used as a hint to the receiver for animations and the like. Null means that there
6990 * is no source bounds.
6991 */
6992 public Rect getSourceBounds() {
6993 return mSourceBounds;
6994 }
6995
6996 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006997 * Return the Activity component that should be used to handle this intent.
6998 * The appropriate component is determined based on the information in the
6999 * intent, evaluated as follows:
7000 *
7001 * <p>If {@link #getComponent} returns an explicit class, that is returned
7002 * without any further consideration.
7003 *
7004 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7005 * category to be considered.
7006 *
7007 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7008 * action.
7009 *
7010 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7011 * this type.
7012 *
7013 * <p>If {@link #addCategory} has added any categories, the activity must
7014 * handle ALL of the categories specified.
7015 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007016 * <p>If {@link #getPackage} is non-NULL, only activity components in
7017 * that application package will be considered.
7018 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007019 * <p>If there are no activities that satisfy all of these conditions, a
7020 * null string is returned.
7021 *
7022 * <p>If multiple activities are found to satisfy the intent, the one with
7023 * the highest priority will be used. If there are multiple activities
7024 * with the same priority, the system will either pick the best activity
7025 * based on user preference, or resolve to a system class that will allow
7026 * the user to pick an activity and forward from there.
7027 *
7028 * <p>This method is implemented simply by calling
7029 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7030 * true.</p>
7031 * <p> This API is called for you as part of starting an activity from an
7032 * intent. You do not normally need to call it yourself.</p>
7033 *
7034 * @param pm The package manager with which to resolve the Intent.
7035 *
7036 * @return Name of the component implementing an activity that can
7037 * display the intent.
7038 *
7039 * @see #setComponent
7040 * @see #getComponent
7041 * @see #resolveActivityInfo
7042 */
7043 public ComponentName resolveActivity(PackageManager pm) {
7044 if (mComponent != null) {
7045 return mComponent;
7046 }
7047
7048 ResolveInfo info = pm.resolveActivity(
7049 this, PackageManager.MATCH_DEFAULT_ONLY);
7050 if (info != null) {
7051 return new ComponentName(
7052 info.activityInfo.applicationInfo.packageName,
7053 info.activityInfo.name);
7054 }
7055
7056 return null;
7057 }
7058
7059 /**
7060 * Resolve the Intent into an {@link ActivityInfo}
7061 * describing the activity that should execute the intent. Resolution
7062 * follows the same rules as described for {@link #resolveActivity}, but
7063 * you get back the completely information about the resolved activity
7064 * instead of just its class name.
7065 *
7066 * @param pm The package manager with which to resolve the Intent.
7067 * @param flags Addition information to retrieve as per
7068 * {@link PackageManager#getActivityInfo(ComponentName, int)
7069 * PackageManager.getActivityInfo()}.
7070 *
7071 * @return PackageManager.ActivityInfo
7072 *
7073 * @see #resolveActivity
7074 */
7075 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7076 ActivityInfo ai = null;
7077 if (mComponent != null) {
7078 try {
7079 ai = pm.getActivityInfo(mComponent, flags);
7080 } catch (PackageManager.NameNotFoundException e) {
7081 // ignore
7082 }
7083 } else {
7084 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007085 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007086 if (info != null) {
7087 ai = info.activityInfo;
7088 }
7089 }
7090
7091 return ai;
7092 }
7093
7094 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007095 * Special function for use by the system to resolve service
7096 * intents to system apps. Throws an exception if there are
7097 * multiple potential matches to the Intent. Returns null if
7098 * there are no matches.
7099 * @hide
7100 */
7101 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7102 if (mComponent != null) {
7103 return mComponent;
7104 }
7105
7106 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7107 if (results == null) {
7108 return null;
7109 }
7110 ComponentName comp = null;
7111 for (int i=0; i<results.size(); i++) {
7112 ResolveInfo ri = results.get(i);
7113 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7114 continue;
7115 }
7116 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7117 ri.serviceInfo.name);
7118 if (comp != null) {
7119 throw new IllegalStateException("Multiple system services handle " + this
7120 + ": " + comp + ", " + foundComp);
7121 }
7122 comp = foundComp;
7123 }
7124 return comp;
7125 }
7126
7127 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007128 * Set the general action to be performed.
7129 *
7130 * @param action An action name, such as ACTION_VIEW. Application-specific
7131 * actions should be prefixed with the vendor's package name.
7132 *
7133 * @return Returns the same Intent object, for chaining multiple calls
7134 * into a single statement.
7135 *
7136 * @see #getAction
7137 */
7138 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007139 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007140 return this;
7141 }
7142
7143 /**
7144 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007145 * clears any type that was previously set by {@link #setType} or
7146 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007147 *
Nick Pellyccae4122012-01-09 14:12:58 -08007148 * <p><em>Note: scheme matching in the Android framework is
7149 * case-sensitive, unlike the formal RFC. As a result,
7150 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007151 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007152 * {@link #setDataAndNormalize}
7153 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007154 *
Nick Pellyccae4122012-01-09 14:12:58 -08007155 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007156 *
7157 * @return Returns the same Intent object, for chaining multiple calls
7158 * into a single statement.
7159 *
7160 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007161 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007162 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007163 */
7164 public Intent setData(Uri data) {
7165 mData = data;
7166 mType = null;
7167 return this;
7168 }
7169
7170 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007171 * Normalize and set the data this intent is operating on.
7172 *
7173 * <p>This method automatically clears any type that was
7174 * previously set (for example, by {@link #setType}).
7175 *
7176 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007177 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007178 * so really this is just a convenience method for
7179 * <pre>
7180 * setData(data.normalize())
7181 * </pre>
7182 *
7183 * @param data The Uri of the data this intent is now targeting.
7184 *
7185 * @return Returns the same Intent object, for chaining multiple calls
7186 * into a single statement.
7187 *
7188 * @see #getData
7189 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007190 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007191 */
7192 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007193 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007194 }
7195
7196 /**
7197 * Set an explicit MIME data type.
7198 *
7199 * <p>This is used to create intents that only specify a type and not data,
7200 * for example to indicate the type of data to return.
7201 *
7202 * <p>This method automatically clears any data that was
7203 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007204 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007205 * <p><em>Note: MIME type matching in the Android framework is
7206 * case-sensitive, unlike formal RFC MIME types. As a result,
7207 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007208 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7209 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007210 *
7211 * @param type The MIME type of the data being handled by this intent.
7212 *
7213 * @return Returns the same Intent object, for chaining multiple calls
7214 * into a single statement.
7215 *
7216 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007217 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007218 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007219 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007220 */
7221 public Intent setType(String type) {
7222 mData = null;
7223 mType = type;
7224 return this;
7225 }
7226
7227 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007228 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007229 *
Nick Pellyccae4122012-01-09 14:12:58 -08007230 * <p>This is used to create intents that only specify a type and not data,
7231 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007232 *
Nick Pellyccae4122012-01-09 14:12:58 -08007233 * <p>This method automatically clears any data that was
7234 * previously set (for example by {@link #setData}).
7235 *
7236 * <p>The MIME type is normalized using
7237 * {@link #normalizeMimeType} before it is set,
7238 * so really this is just a convenience method for
7239 * <pre>
7240 * setType(Intent.normalizeMimeType(type))
7241 * </pre>
7242 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007243 * @param type The MIME type of the data being handled by this intent.
7244 *
7245 * @return Returns the same Intent object, for chaining multiple calls
7246 * into a single statement.
7247 *
Nick Pellyccae4122012-01-09 14:12:58 -08007248 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007249 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007250 * @see #normalizeMimeType
7251 */
7252 public Intent setTypeAndNormalize(String type) {
7253 return setType(normalizeMimeType(type));
7254 }
7255
7256 /**
7257 * (Usually optional) Set the data for the intent along with an explicit
7258 * MIME data type. This method should very rarely be used -- it allows you
7259 * to override the MIME type that would ordinarily be inferred from the
7260 * data with your own type given here.
7261 *
7262 * <p><em>Note: MIME type and Uri scheme matching in the
7263 * Android framework is case-sensitive, unlike the formal RFC definitions.
7264 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007265 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007266 * {@link #setDataAndTypeAndNormalize}
7267 * to ensure that they are converted to lower case.</em>
7268 *
7269 * @param data The Uri of the data this intent is now targeting.
7270 * @param type The MIME type of the data being handled by this intent.
7271 *
7272 * @return Returns the same Intent object, for chaining multiple calls
7273 * into a single statement.
7274 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007275 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007276 * @see #setData
7277 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007278 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007279 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007280 */
7281 public Intent setDataAndType(Uri data, String type) {
7282 mData = data;
7283 mType = type;
7284 return this;
7285 }
7286
7287 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007288 * (Usually optional) Normalize and set both the data Uri and an explicit
7289 * MIME data type. This method should very rarely be used -- it allows you
7290 * to override the MIME type that would ordinarily be inferred from the
7291 * data with your own type given here.
7292 *
7293 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007294 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007295 * before they are set, so really this is just a convenience method for
7296 * <pre>
7297 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7298 * </pre>
7299 *
7300 * @param data The Uri of the data this intent is now targeting.
7301 * @param type The MIME type of the data being handled by this intent.
7302 *
7303 * @return Returns the same Intent object, for chaining multiple calls
7304 * into a single statement.
7305 *
7306 * @see #setType
7307 * @see #setData
7308 * @see #setDataAndType
7309 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007310 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007311 */
7312 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007313 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007314 }
7315
7316 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007317 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007318 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007319 * activities that provide <em>all</em> of the requested categories will be
7320 * used.
7321 *
7322 * @param category The desired category. This can be either one of the
7323 * predefined Intent categories, or a custom category in your own
7324 * namespace.
7325 *
7326 * @return Returns the same Intent object, for chaining multiple calls
7327 * into a single statement.
7328 *
7329 * @see #hasCategory
7330 * @see #removeCategory
7331 */
7332 public Intent addCategory(String category) {
7333 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007334 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007335 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007336 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007337 return this;
7338 }
7339
7340 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007341 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007342 *
7343 * @param category The category to remove.
7344 *
7345 * @see #addCategory
7346 */
7347 public void removeCategory(String category) {
7348 if (mCategories != null) {
7349 mCategories.remove(category);
7350 if (mCategories.size() == 0) {
7351 mCategories = null;
7352 }
7353 }
7354 }
7355
7356 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007357 * Set a selector for this Intent. This is a modification to the kinds of
7358 * things the Intent will match. If the selector is set, it will be used
7359 * when trying to find entities that can handle the Intent, instead of the
7360 * main contents of the Intent. This allows you build an Intent containing
7361 * a generic protocol while targeting it more specifically.
7362 *
7363 * <p>An example of where this may be used is with things like
7364 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7365 * Intent that will launch the Browser application. However, the correct
7366 * main entry point of an application is actually {@link #ACTION_MAIN}
7367 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7368 * used to specify the actual Activity to launch. If you launch the browser
7369 * with something different, undesired behavior may happen if the user has
7370 * previously or later launches it the normal way, since they do not match.
7371 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7372 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7373 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7374 *
7375 * <p>Setting a selector does not impact the behavior of
7376 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7377 * desired behavior of a selector -- it does not impact the base meaning
7378 * of the Intent, just what kinds of things will be matched against it
7379 * when determining who can handle it.</p>
7380 *
7381 * <p>You can not use both a selector and {@link #setPackage(String)} on
7382 * the same base Intent.</p>
7383 *
7384 * @param selector The desired selector Intent; set to null to not use
7385 * a special selector.
7386 */
7387 public void setSelector(Intent selector) {
7388 if (selector == this) {
7389 throw new IllegalArgumentException(
7390 "Intent being set as a selector of itself");
7391 }
7392 if (selector != null && mPackage != null) {
7393 throw new IllegalArgumentException(
7394 "Can't set selector when package name is already set");
7395 }
7396 mSelector = selector;
7397 }
7398
7399 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007400 * Set a {@link ClipData} associated with this Intent. This replaces any
7401 * previously set ClipData.
7402 *
7403 * <p>The ClipData in an intent is not used for Intent matching or other
7404 * such operations. Semantically it is like extras, used to transmit
7405 * additional data with the Intent. The main feature of using this over
7406 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7407 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7408 * items included in the clip data. This is useful, in particular, if
7409 * you want to transmit an Intent containing multiple <code>content:</code>
7410 * URIs for which the recipient may not have global permission to access the
7411 * content provider.
7412 *
7413 * <p>If the ClipData contains items that are themselves Intents, any
7414 * grant flags in those Intents will be ignored. Only the top-level flags
7415 * of the main Intent are respected, and will be applied to all Uri or
7416 * Intent items in the clip (or sub-items of the clip).
7417 *
7418 * <p>The MIME type, label, and icon in the ClipData object are not
7419 * directly used by Intent. Applications should generally rely on the
7420 * MIME type of the Intent itself, not what it may find in the ClipData.
7421 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007422 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007423 *
7424 * @param clip The new clip to set. May be null to clear the current clip.
7425 */
7426 public void setClipData(ClipData clip) {
7427 mClipData = clip;
7428 }
7429
7430 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007431 * This is NOT a secure mechanism to identify the user who sent the intent.
7432 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7433 * who sent the intent.
7434 * @hide
7435 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007436 public void prepareToLeaveUser(int userId) {
7437 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7438 // We want mContentUserHint to refer to the original user, so don't do anything.
7439 if (mContentUserHint == UserHandle.USER_CURRENT) {
7440 mContentUserHint = userId;
7441 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007442 }
7443
7444 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007445 * Add extended data to the intent. The name must include a package
7446 * prefix, for example the app com.android.contacts would use names
7447 * like "com.android.contacts.ShowAll".
7448 *
7449 * @param name The name of the extra data, with package prefix.
7450 * @param value The boolean data value.
7451 *
7452 * @return Returns the same Intent object, for chaining multiple calls
7453 * into a single statement.
7454 *
7455 * @see #putExtras
7456 * @see #removeExtra
7457 * @see #getBooleanExtra(String, boolean)
7458 */
7459 public Intent putExtra(String name, boolean value) {
7460 if (mExtras == null) {
7461 mExtras = new Bundle();
7462 }
7463 mExtras.putBoolean(name, value);
7464 return this;
7465 }
7466
7467 /**
7468 * Add extended data to the intent. The name must include a package
7469 * prefix, for example the app com.android.contacts would use names
7470 * like "com.android.contacts.ShowAll".
7471 *
7472 * @param name The name of the extra data, with package prefix.
7473 * @param value The byte data value.
7474 *
7475 * @return Returns the same Intent object, for chaining multiple calls
7476 * into a single statement.
7477 *
7478 * @see #putExtras
7479 * @see #removeExtra
7480 * @see #getByteExtra(String, byte)
7481 */
7482 public Intent putExtra(String name, byte value) {
7483 if (mExtras == null) {
7484 mExtras = new Bundle();
7485 }
7486 mExtras.putByte(name, value);
7487 return this;
7488 }
7489
7490 /**
7491 * Add extended data to the intent. The name must include a package
7492 * prefix, for example the app com.android.contacts would use names
7493 * like "com.android.contacts.ShowAll".
7494 *
7495 * @param name The name of the extra data, with package prefix.
7496 * @param value The char data value.
7497 *
7498 * @return Returns the same Intent object, for chaining multiple calls
7499 * into a single statement.
7500 *
7501 * @see #putExtras
7502 * @see #removeExtra
7503 * @see #getCharExtra(String, char)
7504 */
7505 public Intent putExtra(String name, char value) {
7506 if (mExtras == null) {
7507 mExtras = new Bundle();
7508 }
7509 mExtras.putChar(name, value);
7510 return this;
7511 }
7512
7513 /**
7514 * Add extended data to the intent. The name must include a package
7515 * prefix, for example the app com.android.contacts would use names
7516 * like "com.android.contacts.ShowAll".
7517 *
7518 * @param name The name of the extra data, with package prefix.
7519 * @param value The short data value.
7520 *
7521 * @return Returns the same Intent object, for chaining multiple calls
7522 * into a single statement.
7523 *
7524 * @see #putExtras
7525 * @see #removeExtra
7526 * @see #getShortExtra(String, short)
7527 */
7528 public Intent putExtra(String name, short value) {
7529 if (mExtras == null) {
7530 mExtras = new Bundle();
7531 }
7532 mExtras.putShort(name, value);
7533 return this;
7534 }
7535
7536 /**
7537 * Add extended data to the intent. The name must include a package
7538 * prefix, for example the app com.android.contacts would use names
7539 * like "com.android.contacts.ShowAll".
7540 *
7541 * @param name The name of the extra data, with package prefix.
7542 * @param value The integer data value.
7543 *
7544 * @return Returns the same Intent object, for chaining multiple calls
7545 * into a single statement.
7546 *
7547 * @see #putExtras
7548 * @see #removeExtra
7549 * @see #getIntExtra(String, int)
7550 */
7551 public Intent putExtra(String name, int value) {
7552 if (mExtras == null) {
7553 mExtras = new Bundle();
7554 }
7555 mExtras.putInt(name, value);
7556 return this;
7557 }
7558
7559 /**
7560 * Add extended data to the intent. The name must include a package
7561 * prefix, for example the app com.android.contacts would use names
7562 * like "com.android.contacts.ShowAll".
7563 *
7564 * @param name The name of the extra data, with package prefix.
7565 * @param value The long data value.
7566 *
7567 * @return Returns the same Intent object, for chaining multiple calls
7568 * into a single statement.
7569 *
7570 * @see #putExtras
7571 * @see #removeExtra
7572 * @see #getLongExtra(String, long)
7573 */
7574 public Intent putExtra(String name, long value) {
7575 if (mExtras == null) {
7576 mExtras = new Bundle();
7577 }
7578 mExtras.putLong(name, value);
7579 return this;
7580 }
7581
7582 /**
7583 * Add extended data to the intent. The name must include a package
7584 * prefix, for example the app com.android.contacts would use names
7585 * like "com.android.contacts.ShowAll".
7586 *
7587 * @param name The name of the extra data, with package prefix.
7588 * @param value The float data value.
7589 *
7590 * @return Returns the same Intent object, for chaining multiple calls
7591 * into a single statement.
7592 *
7593 * @see #putExtras
7594 * @see #removeExtra
7595 * @see #getFloatExtra(String, float)
7596 */
7597 public Intent putExtra(String name, float value) {
7598 if (mExtras == null) {
7599 mExtras = new Bundle();
7600 }
7601 mExtras.putFloat(name, value);
7602 return this;
7603 }
7604
7605 /**
7606 * Add extended data to the intent. The name must include a package
7607 * prefix, for example the app com.android.contacts would use names
7608 * like "com.android.contacts.ShowAll".
7609 *
7610 * @param name The name of the extra data, with package prefix.
7611 * @param value The double data value.
7612 *
7613 * @return Returns the same Intent object, for chaining multiple calls
7614 * into a single statement.
7615 *
7616 * @see #putExtras
7617 * @see #removeExtra
7618 * @see #getDoubleExtra(String, double)
7619 */
7620 public Intent putExtra(String name, double value) {
7621 if (mExtras == null) {
7622 mExtras = new Bundle();
7623 }
7624 mExtras.putDouble(name, value);
7625 return this;
7626 }
7627
7628 /**
7629 * Add extended data to the intent. The name must include a package
7630 * prefix, for example the app com.android.contacts would use names
7631 * like "com.android.contacts.ShowAll".
7632 *
7633 * @param name The name of the extra data, with package prefix.
7634 * @param value The String data value.
7635 *
7636 * @return Returns the same Intent object, for chaining multiple calls
7637 * into a single statement.
7638 *
7639 * @see #putExtras
7640 * @see #removeExtra
7641 * @see #getStringExtra(String)
7642 */
7643 public Intent putExtra(String name, String value) {
7644 if (mExtras == null) {
7645 mExtras = new Bundle();
7646 }
7647 mExtras.putString(name, value);
7648 return this;
7649 }
7650
7651 /**
7652 * Add extended data to the intent. The name must include a package
7653 * prefix, for example the app com.android.contacts would use names
7654 * like "com.android.contacts.ShowAll".
7655 *
7656 * @param name The name of the extra data, with package prefix.
7657 * @param value The CharSequence data value.
7658 *
7659 * @return Returns the same Intent object, for chaining multiple calls
7660 * into a single statement.
7661 *
7662 * @see #putExtras
7663 * @see #removeExtra
7664 * @see #getCharSequenceExtra(String)
7665 */
7666 public Intent putExtra(String name, CharSequence value) {
7667 if (mExtras == null) {
7668 mExtras = new Bundle();
7669 }
7670 mExtras.putCharSequence(name, value);
7671 return this;
7672 }
7673
7674 /**
7675 * Add extended data to the intent. The name must include a package
7676 * prefix, for example the app com.android.contacts would use names
7677 * like "com.android.contacts.ShowAll".
7678 *
7679 * @param name The name of the extra data, with package prefix.
7680 * @param value The Parcelable data value.
7681 *
7682 * @return Returns the same Intent object, for chaining multiple calls
7683 * into a single statement.
7684 *
7685 * @see #putExtras
7686 * @see #removeExtra
7687 * @see #getParcelableExtra(String)
7688 */
7689 public Intent putExtra(String name, Parcelable value) {
7690 if (mExtras == null) {
7691 mExtras = new Bundle();
7692 }
7693 mExtras.putParcelable(name, value);
7694 return this;
7695 }
7696
7697 /**
7698 * Add extended data to the intent. The name must include a package
7699 * prefix, for example the app com.android.contacts would use names
7700 * like "com.android.contacts.ShowAll".
7701 *
7702 * @param name The name of the extra data, with package prefix.
7703 * @param value The Parcelable[] data value.
7704 *
7705 * @return Returns the same Intent object, for chaining multiple calls
7706 * into a single statement.
7707 *
7708 * @see #putExtras
7709 * @see #removeExtra
7710 * @see #getParcelableArrayExtra(String)
7711 */
7712 public Intent putExtra(String name, Parcelable[] value) {
7713 if (mExtras == null) {
7714 mExtras = new Bundle();
7715 }
7716 mExtras.putParcelableArray(name, value);
7717 return this;
7718 }
7719
7720 /**
7721 * Add extended data to the intent. The name must include a package
7722 * prefix, for example the app com.android.contacts would use names
7723 * like "com.android.contacts.ShowAll".
7724 *
7725 * @param name The name of the extra data, with package prefix.
7726 * @param value The ArrayList<Parcelable> data value.
7727 *
7728 * @return Returns the same Intent object, for chaining multiple calls
7729 * into a single statement.
7730 *
7731 * @see #putExtras
7732 * @see #removeExtra
7733 * @see #getParcelableArrayListExtra(String)
7734 */
7735 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7736 if (mExtras == null) {
7737 mExtras = new Bundle();
7738 }
7739 mExtras.putParcelableArrayList(name, value);
7740 return this;
7741 }
7742
7743 /**
7744 * Add extended data to the intent. The name must include a package
7745 * prefix, for example the app com.android.contacts would use names
7746 * like "com.android.contacts.ShowAll".
7747 *
7748 * @param name The name of the extra data, with package prefix.
7749 * @param value The ArrayList<Integer> data value.
7750 *
7751 * @return Returns the same Intent object, for chaining multiple calls
7752 * into a single statement.
7753 *
7754 * @see #putExtras
7755 * @see #removeExtra
7756 * @see #getIntegerArrayListExtra(String)
7757 */
7758 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7759 if (mExtras == null) {
7760 mExtras = new Bundle();
7761 }
7762 mExtras.putIntegerArrayList(name, value);
7763 return this;
7764 }
7765
7766 /**
7767 * Add extended data to the intent. The name must include a package
7768 * prefix, for example the app com.android.contacts would use names
7769 * like "com.android.contacts.ShowAll".
7770 *
7771 * @param name The name of the extra data, with package prefix.
7772 * @param value The ArrayList<String> data value.
7773 *
7774 * @return Returns the same Intent object, for chaining multiple calls
7775 * into a single statement.
7776 *
7777 * @see #putExtras
7778 * @see #removeExtra
7779 * @see #getStringArrayListExtra(String)
7780 */
7781 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7782 if (mExtras == null) {
7783 mExtras = new Bundle();
7784 }
7785 mExtras.putStringArrayList(name, value);
7786 return this;
7787 }
7788
7789 /**
7790 * Add extended data to the intent. The name must include a package
7791 * prefix, for example the app com.android.contacts would use names
7792 * like "com.android.contacts.ShowAll".
7793 *
7794 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007795 * @param value The ArrayList<CharSequence> data value.
7796 *
7797 * @return Returns the same Intent object, for chaining multiple calls
7798 * into a single statement.
7799 *
7800 * @see #putExtras
7801 * @see #removeExtra
7802 * @see #getCharSequenceArrayListExtra(String)
7803 */
7804 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7805 if (mExtras == null) {
7806 mExtras = new Bundle();
7807 }
7808 mExtras.putCharSequenceArrayList(name, value);
7809 return this;
7810 }
7811
7812 /**
7813 * Add extended data to the intent. The name must include a package
7814 * prefix, for example the app com.android.contacts would use names
7815 * like "com.android.contacts.ShowAll".
7816 *
7817 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007818 * @param value The Serializable data value.
7819 *
7820 * @return Returns the same Intent object, for chaining multiple calls
7821 * into a single statement.
7822 *
7823 * @see #putExtras
7824 * @see #removeExtra
7825 * @see #getSerializableExtra(String)
7826 */
7827 public Intent putExtra(String name, Serializable value) {
7828 if (mExtras == null) {
7829 mExtras = new Bundle();
7830 }
7831 mExtras.putSerializable(name, value);
7832 return this;
7833 }
7834
7835 /**
7836 * Add extended data to the intent. The name must include a package
7837 * prefix, for example the app com.android.contacts would use names
7838 * like "com.android.contacts.ShowAll".
7839 *
7840 * @param name The name of the extra data, with package prefix.
7841 * @param value The boolean array data value.
7842 *
7843 * @return Returns the same Intent object, for chaining multiple calls
7844 * into a single statement.
7845 *
7846 * @see #putExtras
7847 * @see #removeExtra
7848 * @see #getBooleanArrayExtra(String)
7849 */
7850 public Intent putExtra(String name, boolean[] value) {
7851 if (mExtras == null) {
7852 mExtras = new Bundle();
7853 }
7854 mExtras.putBooleanArray(name, value);
7855 return this;
7856 }
7857
7858 /**
7859 * Add extended data to the intent. The name must include a package
7860 * prefix, for example the app com.android.contacts would use names
7861 * like "com.android.contacts.ShowAll".
7862 *
7863 * @param name The name of the extra data, with package prefix.
7864 * @param value The byte array data value.
7865 *
7866 * @return Returns the same Intent object, for chaining multiple calls
7867 * into a single statement.
7868 *
7869 * @see #putExtras
7870 * @see #removeExtra
7871 * @see #getByteArrayExtra(String)
7872 */
7873 public Intent putExtra(String name, byte[] value) {
7874 if (mExtras == null) {
7875 mExtras = new Bundle();
7876 }
7877 mExtras.putByteArray(name, value);
7878 return this;
7879 }
7880
7881 /**
7882 * Add extended data to the intent. The name must include a package
7883 * prefix, for example the app com.android.contacts would use names
7884 * like "com.android.contacts.ShowAll".
7885 *
7886 * @param name The name of the extra data, with package prefix.
7887 * @param value The short array data value.
7888 *
7889 * @return Returns the same Intent object, for chaining multiple calls
7890 * into a single statement.
7891 *
7892 * @see #putExtras
7893 * @see #removeExtra
7894 * @see #getShortArrayExtra(String)
7895 */
7896 public Intent putExtra(String name, short[] value) {
7897 if (mExtras == null) {
7898 mExtras = new Bundle();
7899 }
7900 mExtras.putShortArray(name, value);
7901 return this;
7902 }
7903
7904 /**
7905 * Add extended data to the intent. The name must include a package
7906 * prefix, for example the app com.android.contacts would use names
7907 * like "com.android.contacts.ShowAll".
7908 *
7909 * @param name The name of the extra data, with package prefix.
7910 * @param value The char array data value.
7911 *
7912 * @return Returns the same Intent object, for chaining multiple calls
7913 * into a single statement.
7914 *
7915 * @see #putExtras
7916 * @see #removeExtra
7917 * @see #getCharArrayExtra(String)
7918 */
7919 public Intent putExtra(String name, char[] value) {
7920 if (mExtras == null) {
7921 mExtras = new Bundle();
7922 }
7923 mExtras.putCharArray(name, value);
7924 return this;
7925 }
7926
7927 /**
7928 * Add extended data to the intent. The name must include a package
7929 * prefix, for example the app com.android.contacts would use names
7930 * like "com.android.contacts.ShowAll".
7931 *
7932 * @param name The name of the extra data, with package prefix.
7933 * @param value The int array data value.
7934 *
7935 * @return Returns the same Intent object, for chaining multiple calls
7936 * into a single statement.
7937 *
7938 * @see #putExtras
7939 * @see #removeExtra
7940 * @see #getIntArrayExtra(String)
7941 */
7942 public Intent putExtra(String name, int[] value) {
7943 if (mExtras == null) {
7944 mExtras = new Bundle();
7945 }
7946 mExtras.putIntArray(name, value);
7947 return this;
7948 }
7949
7950 /**
7951 * Add extended data to the intent. The name must include a package
7952 * prefix, for example the app com.android.contacts would use names
7953 * like "com.android.contacts.ShowAll".
7954 *
7955 * @param name The name of the extra data, with package prefix.
7956 * @param value The byte array data value.
7957 *
7958 * @return Returns the same Intent object, for chaining multiple calls
7959 * into a single statement.
7960 *
7961 * @see #putExtras
7962 * @see #removeExtra
7963 * @see #getLongArrayExtra(String)
7964 */
7965 public Intent putExtra(String name, long[] value) {
7966 if (mExtras == null) {
7967 mExtras = new Bundle();
7968 }
7969 mExtras.putLongArray(name, value);
7970 return this;
7971 }
7972
7973 /**
7974 * Add extended data to the intent. The name must include a package
7975 * prefix, for example the app com.android.contacts would use names
7976 * like "com.android.contacts.ShowAll".
7977 *
7978 * @param name The name of the extra data, with package prefix.
7979 * @param value The float array data value.
7980 *
7981 * @return Returns the same Intent object, for chaining multiple calls
7982 * into a single statement.
7983 *
7984 * @see #putExtras
7985 * @see #removeExtra
7986 * @see #getFloatArrayExtra(String)
7987 */
7988 public Intent putExtra(String name, float[] value) {
7989 if (mExtras == null) {
7990 mExtras = new Bundle();
7991 }
7992 mExtras.putFloatArray(name, value);
7993 return this;
7994 }
7995
7996 /**
7997 * Add extended data to the intent. The name must include a package
7998 * prefix, for example the app com.android.contacts would use names
7999 * like "com.android.contacts.ShowAll".
8000 *
8001 * @param name The name of the extra data, with package prefix.
8002 * @param value The double array data value.
8003 *
8004 * @return Returns the same Intent object, for chaining multiple calls
8005 * into a single statement.
8006 *
8007 * @see #putExtras
8008 * @see #removeExtra
8009 * @see #getDoubleArrayExtra(String)
8010 */
8011 public Intent putExtra(String name, double[] value) {
8012 if (mExtras == null) {
8013 mExtras = new Bundle();
8014 }
8015 mExtras.putDoubleArray(name, value);
8016 return this;
8017 }
8018
8019 /**
8020 * Add extended data to the intent. The name must include a package
8021 * prefix, for example the app com.android.contacts would use names
8022 * like "com.android.contacts.ShowAll".
8023 *
8024 * @param name The name of the extra data, with package prefix.
8025 * @param value The String array data value.
8026 *
8027 * @return Returns the same Intent object, for chaining multiple calls
8028 * into a single statement.
8029 *
8030 * @see #putExtras
8031 * @see #removeExtra
8032 * @see #getStringArrayExtra(String)
8033 */
8034 public Intent putExtra(String name, String[] value) {
8035 if (mExtras == null) {
8036 mExtras = new Bundle();
8037 }
8038 mExtras.putStringArray(name, value);
8039 return this;
8040 }
8041
8042 /**
8043 * Add extended data to the intent. The name must include a package
8044 * prefix, for example the app com.android.contacts would use names
8045 * like "com.android.contacts.ShowAll".
8046 *
8047 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008048 * @param value The CharSequence array data value.
8049 *
8050 * @return Returns the same Intent object, for chaining multiple calls
8051 * into a single statement.
8052 *
8053 * @see #putExtras
8054 * @see #removeExtra
8055 * @see #getCharSequenceArrayExtra(String)
8056 */
8057 public Intent putExtra(String name, CharSequence[] value) {
8058 if (mExtras == null) {
8059 mExtras = new Bundle();
8060 }
8061 mExtras.putCharSequenceArray(name, value);
8062 return this;
8063 }
8064
8065 /**
8066 * Add extended data to the intent. The name must include a package
8067 * prefix, for example the app com.android.contacts would use names
8068 * like "com.android.contacts.ShowAll".
8069 *
8070 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008071 * @param value The Bundle data value.
8072 *
8073 * @return Returns the same Intent object, for chaining multiple calls
8074 * into a single statement.
8075 *
8076 * @see #putExtras
8077 * @see #removeExtra
8078 * @see #getBundleExtra(String)
8079 */
8080 public Intent putExtra(String name, Bundle value) {
8081 if (mExtras == null) {
8082 mExtras = new Bundle();
8083 }
8084 mExtras.putBundle(name, value);
8085 return this;
8086 }
8087
8088 /**
8089 * Add extended data to the intent. The name must include a package
8090 * prefix, for example the app com.android.contacts would use names
8091 * like "com.android.contacts.ShowAll".
8092 *
8093 * @param name The name of the extra data, with package prefix.
8094 * @param value The IBinder data value.
8095 *
8096 * @return Returns the same Intent object, for chaining multiple calls
8097 * into a single statement.
8098 *
8099 * @see #putExtras
8100 * @see #removeExtra
8101 * @see #getIBinderExtra(String)
8102 *
8103 * @deprecated
8104 * @hide
8105 */
8106 @Deprecated
8107 public Intent putExtra(String name, IBinder value) {
8108 if (mExtras == null) {
8109 mExtras = new Bundle();
8110 }
8111 mExtras.putIBinder(name, value);
8112 return this;
8113 }
8114
8115 /**
8116 * Copy all extras in 'src' in to this intent.
8117 *
8118 * @param src Contains the extras to copy.
8119 *
8120 * @see #putExtra
8121 */
8122 public Intent putExtras(Intent src) {
8123 if (src.mExtras != null) {
8124 if (mExtras == null) {
8125 mExtras = new Bundle(src.mExtras);
8126 } else {
8127 mExtras.putAll(src.mExtras);
8128 }
8129 }
8130 return this;
8131 }
8132
8133 /**
8134 * Add a set of extended data to the intent. The keys must include a package
8135 * prefix, for example the app com.android.contacts would use names
8136 * like "com.android.contacts.ShowAll".
8137 *
8138 * @param extras The Bundle of extras to add to this intent.
8139 *
8140 * @see #putExtra
8141 * @see #removeExtra
8142 */
8143 public Intent putExtras(Bundle extras) {
8144 if (mExtras == null) {
8145 mExtras = new Bundle();
8146 }
8147 mExtras.putAll(extras);
8148 return this;
8149 }
8150
8151 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008152 * Completely replace the extras in the Intent with the extras in the
8153 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008154 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008155 * @param src The exact extras contained in this Intent are copied
8156 * into the target intent, replacing any that were previously there.
8157 */
8158 public Intent replaceExtras(Intent src) {
8159 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8160 return this;
8161 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008162
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008163 /**
8164 * Completely replace the extras in the Intent with the given Bundle of
8165 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008166 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008167 * @param extras The new set of extras in the Intent, or null to erase
8168 * all extras.
8169 */
8170 public Intent replaceExtras(Bundle extras) {
8171 mExtras = extras != null ? new Bundle(extras) : null;
8172 return this;
8173 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008174
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008175 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008176 * Remove extended data from the intent.
8177 *
8178 * @see #putExtra
8179 */
8180 public void removeExtra(String name) {
8181 if (mExtras != null) {
8182 mExtras.remove(name);
8183 if (mExtras.size() == 0) {
8184 mExtras = null;
8185 }
8186 }
8187 }
8188
8189 /**
8190 * Set special flags controlling how this intent is handled. Most values
8191 * here depend on the type of component being executed by the Intent,
8192 * specifically the FLAG_ACTIVITY_* flags are all for use with
8193 * {@link Context#startActivity Context.startActivity()} and the
8194 * FLAG_RECEIVER_* flags are all for use with
8195 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8196 *
Scott Main7aee61f2011-02-08 11:25:01 -08008197 * <p>See the
8198 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8199 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008200 * the behavior of your application.
8201 *
8202 * @param flags The desired flags.
8203 *
8204 * @return Returns the same Intent object, for chaining multiple calls
8205 * into a single statement.
8206 *
8207 * @see #getFlags
8208 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008209 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008210 *
8211 * @see #FLAG_GRANT_READ_URI_PERMISSION
8212 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008213 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8214 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008215 * @see #FLAG_DEBUG_LOG_RESOLUTION
8216 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008217 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008218 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008219 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008220 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008221 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8222 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008223 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008224 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008225 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008226 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008227 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008228 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008229 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008230 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8231 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008232 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008233 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008234 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008235 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8236 */
8237 public Intent setFlags(int flags) {
8238 mFlags = flags;
8239 return this;
8240 }
8241
8242 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008243 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008244 *
8245 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008246 * @return Returns the same Intent object, for chaining multiple calls into
8247 * a single statement.
8248 * @see #setFlags(int)
8249 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008250 */
8251 public Intent addFlags(int flags) {
8252 mFlags |= flags;
8253 return this;
8254 }
8255
8256 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008257 * Remove these flags from the intent.
8258 *
8259 * @param flags The flags to remove.
8260 * @see #setFlags(int)
8261 * @see #addFlags(int)
8262 */
8263 public void removeFlags(int flags) {
8264 mFlags &= ~flags;
8265 }
8266
8267 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008268 * (Usually optional) Set an explicit application package name that limits
8269 * the components this Intent will resolve to. If left to the default
8270 * value of null, all components in all applications will considered.
8271 * If non-null, the Intent can only match the components in the given
8272 * application package.
8273 *
8274 * @param packageName The name of the application package to handle the
8275 * intent, or null to allow any application package.
8276 *
8277 * @return Returns the same Intent object, for chaining multiple calls
8278 * into a single statement.
8279 *
8280 * @see #getPackage
8281 * @see #resolveActivity
8282 */
8283 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008284 if (packageName != null && mSelector != null) {
8285 throw new IllegalArgumentException(
8286 "Can't set package name when selector is already set");
8287 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008288 mPackage = packageName;
8289 return this;
8290 }
8291
8292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008293 * (Usually optional) Explicitly set the component to handle the intent.
8294 * If left with the default value of null, the system will determine the
8295 * appropriate class to use based on the other fields (action, data,
8296 * type, categories) in the Intent. If this class is defined, the
8297 * specified class will always be used regardless of the other fields. You
8298 * should only set this value when you know you absolutely want a specific
8299 * class to be used; otherwise it is better to let the system find the
8300 * appropriate class so that you will respect the installed applications
8301 * and user preferences.
8302 *
8303 * @param component The name of the application component to handle the
8304 * intent, or null to let the system find one for you.
8305 *
8306 * @return Returns the same Intent object, for chaining multiple calls
8307 * into a single statement.
8308 *
8309 * @see #setClass
8310 * @see #setClassName(Context, String)
8311 * @see #setClassName(String, String)
8312 * @see #getComponent
8313 * @see #resolveActivity
8314 */
8315 public Intent setComponent(ComponentName component) {
8316 mComponent = component;
8317 return this;
8318 }
8319
8320 /**
8321 * Convenience for calling {@link #setComponent} with an
8322 * explicit class name.
8323 *
8324 * @param packageContext A Context of the application package implementing
8325 * this class.
8326 * @param className The name of a class inside of the application package
8327 * that will be used as the component for this Intent.
8328 *
8329 * @return Returns the same Intent object, for chaining multiple calls
8330 * into a single statement.
8331 *
8332 * @see #setComponent
8333 * @see #setClass
8334 */
8335 public Intent setClassName(Context packageContext, String className) {
8336 mComponent = new ComponentName(packageContext, className);
8337 return this;
8338 }
8339
8340 /**
8341 * Convenience for calling {@link #setComponent} with an
8342 * explicit application package name and class name.
8343 *
8344 * @param packageName The name of the package implementing the desired
8345 * component.
8346 * @param className The name of a class inside of the application package
8347 * that will be used as the component for this Intent.
8348 *
8349 * @return Returns the same Intent object, for chaining multiple calls
8350 * into a single statement.
8351 *
8352 * @see #setComponent
8353 * @see #setClass
8354 */
8355 public Intent setClassName(String packageName, String className) {
8356 mComponent = new ComponentName(packageName, className);
8357 return this;
8358 }
8359
8360 /**
8361 * Convenience for calling {@link #setComponent(ComponentName)} with the
8362 * name returned by a {@link Class} object.
8363 *
8364 * @param packageContext A Context of the application package implementing
8365 * this class.
8366 * @param cls The class name to set, equivalent to
8367 * <code>setClassName(context, cls.getName())</code>.
8368 *
8369 * @return Returns the same Intent object, for chaining multiple calls
8370 * into a single statement.
8371 *
8372 * @see #setComponent
8373 */
8374 public Intent setClass(Context packageContext, Class<?> cls) {
8375 mComponent = new ComponentName(packageContext, cls);
8376 return this;
8377 }
8378
8379 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008380 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8381 * used as a hint to the receiver for animations and the like. Null means that there
8382 * is no source bounds.
8383 */
8384 public void setSourceBounds(Rect r) {
8385 if (r != null) {
8386 mSourceBounds = new Rect(r);
8387 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008388 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008389 }
8390 }
8391
Tor Norbyed9273d62013-05-30 15:59:53 -07008392 /** @hide */
8393 @IntDef(flag = true,
8394 value = {
8395 FILL_IN_ACTION,
8396 FILL_IN_DATA,
8397 FILL_IN_CATEGORIES,
8398 FILL_IN_COMPONENT,
8399 FILL_IN_PACKAGE,
8400 FILL_IN_SOURCE_BOUNDS,
8401 FILL_IN_SELECTOR,
8402 FILL_IN_CLIP_DATA
8403 })
8404 @Retention(RetentionPolicy.SOURCE)
8405 public @interface FillInFlags {}
8406
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008407 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008408 * Use with {@link #fillIn} to allow the current action value to be
8409 * overwritten, even if it is already set.
8410 */
8411 public static final int FILL_IN_ACTION = 1<<0;
8412
8413 /**
8414 * Use with {@link #fillIn} to allow the current data or type value
8415 * overwritten, even if it is already set.
8416 */
8417 public static final int FILL_IN_DATA = 1<<1;
8418
8419 /**
8420 * Use with {@link #fillIn} to allow the current categories to be
8421 * overwritten, even if they are already set.
8422 */
8423 public static final int FILL_IN_CATEGORIES = 1<<2;
8424
8425 /**
8426 * Use with {@link #fillIn} to allow the current component value to be
8427 * overwritten, even if it is already set.
8428 */
8429 public static final int FILL_IN_COMPONENT = 1<<3;
8430
8431 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008432 * Use with {@link #fillIn} to allow the current package value to be
8433 * overwritten, even if it is already set.
8434 */
8435 public static final int FILL_IN_PACKAGE = 1<<4;
8436
8437 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008438 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008439 * overwritten, even if it is already set.
8440 */
8441 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8442
8443 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008444 * Use with {@link #fillIn} to allow the current selector to be
8445 * overwritten, even if it is already set.
8446 */
8447 public static final int FILL_IN_SELECTOR = 1<<6;
8448
8449 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008450 * Use with {@link #fillIn} to allow the current ClipData to be
8451 * overwritten, even if it is already set.
8452 */
8453 public static final int FILL_IN_CLIP_DATA = 1<<7;
8454
8455 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008456 * Copy the contents of <var>other</var> in to this object, but only
8457 * where fields are not defined by this object. For purposes of a field
8458 * being defined, the following pieces of data in the Intent are
8459 * considered to be separate fields:
8460 *
8461 * <ul>
8462 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008463 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008464 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8465 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008466 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008467 * <li> component, as set by {@link #setComponent(ComponentName)} or
8468 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008469 * <li> source bounds, as set by {@link #setSourceBounds}.
8470 * <li> selector, as set by {@link #setSelector(Intent)}.
8471 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008472 * <li> each top-level name in the associated extras.
8473 * </ul>
8474 *
8475 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008476 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008477 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8478 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8479 * the restriction where the corresponding field will not be replaced if
8480 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008481 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008482 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8483 * is explicitly specified. The selector will only be copied if
8484 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008485 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008486 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8487 * and Intent B with {action="gotit", data-type="some/thing",
8488 * categories="one","two"}.
8489 *
8490 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8491 * containing: {action="gotit", data-type="some/thing",
8492 * categories="bar"}.
8493 *
8494 * @param other Another Intent whose values are to be used to fill in
8495 * the current one.
8496 * @param flags Options to control which fields can be filled in.
8497 *
8498 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008499 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008500 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008501 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008502 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008503 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008504 @FillInFlags
8505 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008506 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008507 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008508 if (other.mAction != null
8509 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008510 mAction = other.mAction;
8511 changes |= FILL_IN_ACTION;
8512 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008513 if ((other.mData != null || other.mType != null)
8514 && ((mData == null && mType == null)
8515 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008516 mData = other.mData;
8517 mType = other.mType;
8518 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008519 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008520 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008521 if (other.mCategories != null
8522 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008523 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008524 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008525 }
8526 changes |= FILL_IN_CATEGORIES;
8527 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008528 if (other.mPackage != null
8529 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008530 // Only do this if mSelector is not set.
8531 if (mSelector == null) {
8532 mPackage = other.mPackage;
8533 changes |= FILL_IN_PACKAGE;
8534 }
8535 }
8536 // Selector is special: it can only be set if explicitly allowed,
8537 // for the same reason as the component name.
8538 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8539 if (mPackage == null) {
8540 mSelector = new Intent(other.mSelector);
8541 mPackage = null;
8542 changes |= FILL_IN_SELECTOR;
8543 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008544 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008545 if (other.mClipData != null
8546 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8547 mClipData = other.mClipData;
8548 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008549 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008550 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008551 // Component is special: it can -only- be set if explicitly allowed,
8552 // since otherwise the sender could force the intent somewhere the
8553 // originator didn't intend.
8554 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 mComponent = other.mComponent;
8556 changes |= FILL_IN_COMPONENT;
8557 }
8558 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008559 if (other.mSourceBounds != null
8560 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8561 mSourceBounds = new Rect(other.mSourceBounds);
8562 changes |= FILL_IN_SOURCE_BOUNDS;
8563 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564 if (mExtras == null) {
8565 if (other.mExtras != null) {
8566 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008567 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 }
8569 } else if (other.mExtras != null) {
8570 try {
8571 Bundle newb = new Bundle(other.mExtras);
8572 newb.putAll(mExtras);
8573 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008574 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 } catch (RuntimeException e) {
8576 // Modifying the extras can cause us to unparcel the contents
8577 // of the bundle, and if we do this in the system process that
8578 // may fail. We really should handle this (i.e., the Bundle
8579 // impl shouldn't be on top of a plain map), but for now just
8580 // ignore it and keep the original contents. :(
8581 Log.w("Intent", "Failure filling in extras", e);
8582 }
8583 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008584 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8585 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8586 mContentUserHint = other.mContentUserHint;
8587 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008588 return changes;
8589 }
8590
8591 /**
8592 * Wrapper class holding an Intent and implementing comparisons on it for
8593 * the purpose of filtering. The class implements its
8594 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8595 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8596 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8597 * on the wrapped Intent.
8598 */
8599 public static final class FilterComparison {
8600 private final Intent mIntent;
8601 private final int mHashCode;
8602
8603 public FilterComparison(Intent intent) {
8604 mIntent = intent;
8605 mHashCode = intent.filterHashCode();
8606 }
8607
8608 /**
8609 * Return the Intent that this FilterComparison represents.
8610 * @return Returns the Intent held by the FilterComparison. Do
8611 * not modify!
8612 */
8613 public Intent getIntent() {
8614 return mIntent;
8615 }
8616
8617 @Override
8618 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008619 if (obj instanceof FilterComparison) {
8620 Intent other = ((FilterComparison)obj).mIntent;
8621 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008622 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008623 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008624 }
8625
8626 @Override
8627 public int hashCode() {
8628 return mHashCode;
8629 }
8630 }
8631
8632 /**
8633 * Determine if two intents are the same for the purposes of intent
8634 * resolution (filtering). That is, if their action, data, type,
8635 * class, and categories are the same. This does <em>not</em> compare
8636 * any extra data included in the intents.
8637 *
8638 * @param other The other Intent to compare against.
8639 *
8640 * @return Returns true if action, data, type, class, and categories
8641 * are the same.
8642 */
8643 public boolean filterEquals(Intent other) {
8644 if (other == null) {
8645 return false;
8646 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008647 if (!Objects.equals(this.mAction, other.mAction)) return false;
8648 if (!Objects.equals(this.mData, other.mData)) return false;
8649 if (!Objects.equals(this.mType, other.mType)) return false;
8650 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8651 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8652 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008653
8654 return true;
8655 }
8656
8657 /**
8658 * Generate hash code that matches semantics of filterEquals().
8659 *
8660 * @return Returns the hash value of the action, data, type, class, and
8661 * categories.
8662 *
8663 * @see #filterEquals
8664 */
8665 public int filterHashCode() {
8666 int code = 0;
8667 if (mAction != null) {
8668 code += mAction.hashCode();
8669 }
8670 if (mData != null) {
8671 code += mData.hashCode();
8672 }
8673 if (mType != null) {
8674 code += mType.hashCode();
8675 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008676 if (mPackage != null) {
8677 code += mPackage.hashCode();
8678 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008679 if (mComponent != null) {
8680 code += mComponent.hashCode();
8681 }
8682 if (mCategories != null) {
8683 code += mCategories.hashCode();
8684 }
8685 return code;
8686 }
8687
8688 @Override
8689 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008690 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008691
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008692 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008693 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008694 b.append(" }");
8695
8696 return b.toString();
8697 }
8698
8699 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008700 public String toInsecureString() {
8701 StringBuilder b = new StringBuilder(128);
8702
8703 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008704 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008705 b.append(" }");
8706
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008707 return b.toString();
8708 }
Romain Guy4969af72009-06-17 10:53:19 -07008709
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008710 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008711 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008712 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008713
8714 b.append("Intent { ");
8715 toShortString(b, false, true, true, true);
8716 b.append(" }");
8717
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008718 return b.toString();
8719 }
8720
8721 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008722 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8723 StringBuilder b = new StringBuilder(128);
8724 toShortString(b, secure, comp, extras, clip);
8725 return b.toString();
8726 }
8727
8728 /** @hide */
8729 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8730 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008731 boolean first = true;
8732 if (mAction != null) {
8733 b.append("act=").append(mAction);
8734 first = false;
8735 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008736 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008737 if (!first) {
8738 b.append(' ');
8739 }
8740 first = false;
8741 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008742 for (int i=0; i<mCategories.size(); i++) {
8743 if (i > 0) b.append(',');
8744 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008745 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008746 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008747 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008748 if (mData != null) {
8749 if (!first) {
8750 b.append(' ');
8751 }
8752 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008753 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008754 if (secure) {
8755 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008756 } else {
8757 b.append(mData);
8758 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008759 }
8760 if (mType != null) {
8761 if (!first) {
8762 b.append(' ');
8763 }
8764 first = false;
8765 b.append("typ=").append(mType);
8766 }
8767 if (mFlags != 0) {
8768 if (!first) {
8769 b.append(' ');
8770 }
8771 first = false;
8772 b.append("flg=0x").append(Integer.toHexString(mFlags));
8773 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008774 if (mPackage != null) {
8775 if (!first) {
8776 b.append(' ');
8777 }
8778 first = false;
8779 b.append("pkg=").append(mPackage);
8780 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008781 if (comp && mComponent != null) {
8782 if (!first) {
8783 b.append(' ');
8784 }
8785 first = false;
8786 b.append("cmp=").append(mComponent.flattenToShortString());
8787 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008788 if (mSourceBounds != null) {
8789 if (!first) {
8790 b.append(' ');
8791 }
8792 first = false;
8793 b.append("bnds=").append(mSourceBounds.toShortString());
8794 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008795 if (mClipData != null) {
8796 if (!first) {
8797 b.append(' ');
8798 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008799 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008800 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008801 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008802 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008803 if (mClipData.getDescription() != null) {
8804 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8805 } else {
8806 first = true;
8807 }
8808 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008809 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008810 first = false;
8811 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008812 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008813 if (extras && mExtras != null) {
8814 if (!first) {
8815 b.append(' ');
8816 }
8817 first = false;
8818 b.append("(has extras)");
8819 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008820 if (mContentUserHint != UserHandle.USER_CURRENT) {
8821 if (!first) {
8822 b.append(' ');
8823 }
8824 first = false;
8825 b.append("u=").append(mContentUserHint);
8826 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008827 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008828 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008829 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008830 b.append("}");
8831 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008832 }
8833
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008834 /**
8835 * Call {@link #toUri} with 0 flags.
8836 * @deprecated Use {@link #toUri} instead.
8837 */
8838 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008839 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008840 return toUri(0);
8841 }
8842
8843 /**
8844 * Convert this Intent into a String holding a URI representation of it.
8845 * The returned URI string has been properly URI encoded, so it can be
8846 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8847 * Intent's data as the base URI, with an additional fragment describing
8848 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008849 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008850 * <p>You can convert the returned string back to an Intent with
8851 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008852 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008853 * @param flags Additional operating flags. Either 0,
8854 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008855 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008856 * @return Returns a URI encoding URI string describing the entire contents
8857 * of the Intent.
8858 */
8859 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008860 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008861 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8862 if (mPackage == null) {
8863 throw new IllegalArgumentException(
8864 "Intent must include an explicit package name to build an android-app: "
8865 + this);
8866 }
8867 uri.append("android-app://");
8868 uri.append(mPackage);
8869 String scheme = null;
8870 if (mData != null) {
8871 scheme = mData.getScheme();
8872 if (scheme != null) {
8873 uri.append('/');
8874 uri.append(scheme);
8875 String authority = mData.getEncodedAuthority();
8876 if (authority != null) {
8877 uri.append('/');
8878 uri.append(authority);
8879 String path = mData.getEncodedPath();
8880 if (path != null) {
8881 uri.append(path);
8882 }
8883 String queryParams = mData.getEncodedQuery();
8884 if (queryParams != null) {
8885 uri.append('?');
8886 uri.append(queryParams);
8887 }
8888 String fragment = mData.getEncodedFragment();
8889 if (fragment != null) {
8890 uri.append('#');
8891 uri.append(fragment);
8892 }
8893 }
8894 }
8895 }
8896 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8897 mPackage, flags);
8898 return uri.toString();
8899 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008900 String scheme = null;
8901 if (mData != null) {
8902 String data = mData.toString();
8903 if ((flags&URI_INTENT_SCHEME) != 0) {
8904 final int N = data.length();
8905 for (int i=0; i<N; i++) {
8906 char c = data.charAt(i);
8907 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8908 || c == '.' || c == '-') {
8909 continue;
8910 }
8911 if (c == ':' && i > 0) {
8912 // Valid scheme.
8913 scheme = data.substring(0, i);
8914 uri.append("intent:");
8915 data = data.substring(i+1);
8916 break;
8917 }
Tom Taylord4a47292009-12-21 13:59:18 -08008918
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008919 // No scheme.
8920 break;
8921 }
8922 }
8923 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008924
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008925 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8926 uri.append("intent:");
8927 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008928
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008929 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008930
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008931 return uri.toString();
8932 }
8933
8934 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8935 String defPackage, int flags) {
8936 StringBuilder frag = new StringBuilder(128);
8937
8938 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008939 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008940 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008941 // Note that for now we are not going to try to handle the
8942 // data part; not clear how to represent this as a URI, and
8943 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008944 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8945 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008946 }
8947
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008948 if (frag.length() > 0) {
8949 uri.append("#Intent;");
8950 uri.append(frag);
8951 uri.append("end");
8952 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008953 }
8954
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008955 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8956 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008957 if (scheme != null) {
8958 uri.append("scheme=").append(scheme).append(';');
8959 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008960 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008961 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008962 }
8963 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008964 for (int i=0; i<mCategories.size(); i++) {
8965 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008966 }
8967 }
8968 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008969 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008970 }
8971 if (mFlags != 0) {
8972 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8973 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008974 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008975 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8976 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008977 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008978 uri.append("component=").append(Uri.encode(
8979 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008980 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008981 if (mSourceBounds != null) {
8982 uri.append("sourceBounds=")
8983 .append(Uri.encode(mSourceBounds.flattenToString()))
8984 .append(';');
8985 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008986 if (mExtras != null) {
8987 for (String key : mExtras.keySet()) {
8988 final Object value = mExtras.get(key);
8989 char entryType =
8990 value instanceof String ? 'S' :
8991 value instanceof Boolean ? 'B' :
8992 value instanceof Byte ? 'b' :
8993 value instanceof Character ? 'c' :
8994 value instanceof Double ? 'd' :
8995 value instanceof Float ? 'f' :
8996 value instanceof Integer ? 'i' :
8997 value instanceof Long ? 'l' :
8998 value instanceof Short ? 's' :
8999 '\0';
9000
9001 if (entryType != '\0') {
9002 uri.append(entryType);
9003 uri.append('.');
9004 uri.append(Uri.encode(key));
9005 uri.append('=');
9006 uri.append(Uri.encode(value.toString()));
9007 uri.append(';');
9008 }
9009 }
9010 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009011 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009013 public int describeContents() {
9014 return (mExtras != null) ? mExtras.describeContents() : 0;
9015 }
9016
9017 public void writeToParcel(Parcel out, int flags) {
9018 out.writeString(mAction);
9019 Uri.writeToParcel(out, mData);
9020 out.writeString(mType);
9021 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009022 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009023 ComponentName.writeToParcel(mComponent, out);
9024
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009025 if (mSourceBounds != null) {
9026 out.writeInt(1);
9027 mSourceBounds.writeToParcel(out, flags);
9028 } else {
9029 out.writeInt(0);
9030 }
9031
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009032 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009033 final int N = mCategories.size();
9034 out.writeInt(N);
9035 for (int i=0; i<N; i++) {
9036 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009037 }
9038 } else {
9039 out.writeInt(0);
9040 }
9041
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009042 if (mSelector != null) {
9043 out.writeInt(1);
9044 mSelector.writeToParcel(out, flags);
9045 } else {
9046 out.writeInt(0);
9047 }
9048
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009049 if (mClipData != null) {
9050 out.writeInt(1);
9051 mClipData.writeToParcel(out, flags);
9052 } else {
9053 out.writeInt(0);
9054 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009055 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009056 out.writeBundle(mExtras);
9057 }
9058
9059 public static final Parcelable.Creator<Intent> CREATOR
9060 = new Parcelable.Creator<Intent>() {
9061 public Intent createFromParcel(Parcel in) {
9062 return new Intent(in);
9063 }
9064 public Intent[] newArray(int size) {
9065 return new Intent[size];
9066 }
9067 };
9068
Dianne Hackborneb034652009-09-07 00:49:58 -07009069 /** @hide */
9070 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009071 readFromParcel(in);
9072 }
9073
9074 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009075 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009076 mData = Uri.CREATOR.createFromParcel(in);
9077 mType = in.readString();
9078 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009079 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009080 mComponent = ComponentName.readFromParcel(in);
9081
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009082 if (in.readInt() != 0) {
9083 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9084 }
9085
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009086 int N = in.readInt();
9087 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009088 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009089 int i;
9090 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009091 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009092 }
9093 } else {
9094 mCategories = null;
9095 }
9096
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009097 if (in.readInt() != 0) {
9098 mSelector = new Intent(in);
9099 }
9100
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009101 if (in.readInt() != 0) {
9102 mClipData = new ClipData(in);
9103 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009104 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009105 mExtras = in.readBundle();
9106 }
9107
9108 /**
9109 * Parses the "intent" element (and its children) from XML and instantiates
9110 * an Intent object. The given XML parser should be located at the tag
9111 * where parsing should start (often named "intent"), from which the
9112 * basic action, data, type, and package and class name will be
9113 * retrieved. The function will then parse in to any child elements,
9114 * looking for <category android:name="xxx"> tags to add categories and
9115 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9116 * to the intent.
9117 *
9118 * @param resources The Resources to use when inflating resources.
9119 * @param parser The XML parser pointing at an "intent" tag.
9120 * @param attrs The AttributeSet interface for retrieving extended
9121 * attribute data at the current <var>parser</var> location.
9122 * @return An Intent object matching the XML data.
9123 * @throws XmlPullParserException If there was an XML parsing error.
9124 * @throws IOException If there was an I/O error.
9125 */
9126 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9127 throws XmlPullParserException, IOException {
9128 Intent intent = new Intent();
9129
9130 TypedArray sa = resources.obtainAttributes(attrs,
9131 com.android.internal.R.styleable.Intent);
9132
9133 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9134
9135 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9136 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9137 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9138
9139 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9140 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9141 if (packageName != null && className != null) {
9142 intent.setComponent(new ComponentName(packageName, className));
9143 }
9144
9145 sa.recycle();
9146
9147 int outerDepth = parser.getDepth();
9148 int type;
9149 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9150 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9151 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9152 continue;
9153 }
9154
9155 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009156 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009157 sa = resources.obtainAttributes(attrs,
9158 com.android.internal.R.styleable.IntentCategory);
9159 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9160 sa.recycle();
9161
9162 if (cat != null) {
9163 intent.addCategory(cat);
9164 }
9165 XmlUtils.skipCurrentTag(parser);
9166
Craig Mautner21d24a22014-04-23 11:45:37 -07009167 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009168 if (intent.mExtras == null) {
9169 intent.mExtras = new Bundle();
9170 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009171 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009172 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009173
9174 } else {
9175 XmlUtils.skipCurrentTag(parser);
9176 }
9177 }
9178
9179 return intent;
9180 }
Nick Pellyccae4122012-01-09 14:12:58 -08009181
Craig Mautner21d24a22014-04-23 11:45:37 -07009182 /** @hide */
9183 public void saveToXml(XmlSerializer out) throws IOException {
9184 if (mAction != null) {
9185 out.attribute(null, ATTR_ACTION, mAction);
9186 }
9187 if (mData != null) {
9188 out.attribute(null, ATTR_DATA, mData.toString());
9189 }
9190 if (mType != null) {
9191 out.attribute(null, ATTR_TYPE, mType);
9192 }
9193 if (mComponent != null) {
9194 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9195 }
9196 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9197
9198 if (mCategories != null) {
9199 out.startTag(null, TAG_CATEGORIES);
9200 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9201 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9202 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009203 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009204 }
9205 }
9206
9207 /** @hide */
9208 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9209 XmlPullParserException {
9210 Intent intent = new Intent();
9211 final int outerDepth = in.getDepth();
9212
9213 int attrCount = in.getAttributeCount();
9214 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9215 final String attrName = in.getAttributeName(attrNdx);
9216 final String attrValue = in.getAttributeValue(attrNdx);
9217 if (ATTR_ACTION.equals(attrName)) {
9218 intent.setAction(attrValue);
9219 } else if (ATTR_DATA.equals(attrName)) {
9220 intent.setData(Uri.parse(attrValue));
9221 } else if (ATTR_TYPE.equals(attrName)) {
9222 intent.setType(attrValue);
9223 } else if (ATTR_COMPONENT.equals(attrName)) {
9224 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9225 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009226 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009227 } else {
9228 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9229 }
9230 }
9231
9232 int event;
9233 String name;
9234 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9235 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9236 if (event == XmlPullParser.START_TAG) {
9237 name = in.getName();
9238 if (TAG_CATEGORIES.equals(name)) {
9239 attrCount = in.getAttributeCount();
9240 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9241 intent.addCategory(in.getAttributeValue(attrNdx));
9242 }
9243 } else {
9244 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9245 XmlUtils.skipCurrentTag(in);
9246 }
9247 }
9248 }
9249
9250 return intent;
9251 }
9252
Nick Pellyccae4122012-01-09 14:12:58 -08009253 /**
9254 * Normalize a MIME data type.
9255 *
9256 * <p>A normalized MIME type has white-space trimmed,
9257 * content-type parameters removed, and is lower-case.
9258 * This aligns the type with Android best practices for
9259 * intent filtering.
9260 *
9261 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9262 * "text/x-vCard" becomes "text/x-vcard".
9263 *
9264 * <p>All MIME types received from outside Android (such as user input,
9265 * or external sources like Bluetooth, NFC, or the Internet) should
9266 * be normalized before they are used to create an Intent.
9267 *
9268 * @param type MIME data type to normalize
9269 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009270 * @see #setType
9271 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009272 */
9273 public static String normalizeMimeType(String type) {
9274 if (type == null) {
9275 return null;
9276 }
9277
Elliott Hughescb64d432013-08-02 10:00:44 -07009278 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009279
9280 final int semicolonIndex = type.indexOf(';');
9281 if (semicolonIndex != -1) {
9282 type = type.substring(0, semicolonIndex);
9283 }
9284 return type;
9285 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009286
9287 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009288 * Prepare this {@link Intent} to leave an app process.
9289 *
9290 * @hide
9291 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009292 public void prepareToLeaveProcess(Context context) {
9293 final boolean leavingPackage = (mComponent == null)
9294 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9295 prepareToLeaveProcess(leavingPackage);
9296 }
9297
9298 /**
9299 * Prepare this {@link Intent} to leave an app process.
9300 *
9301 * @hide
9302 */
9303 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009304 setAllowFds(false);
9305
9306 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009307 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009308 }
9309 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009310 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009311 }
9312
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009313 if (mExtras != null && !mExtras.isParcelled()) {
9314 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9315 if (intent instanceof Intent) {
9316 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9317 }
9318 }
9319
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009320 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9321 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009322 switch (mAction) {
9323 case ACTION_MEDIA_REMOVED:
9324 case ACTION_MEDIA_UNMOUNTED:
9325 case ACTION_MEDIA_CHECKING:
9326 case ACTION_MEDIA_NOFS:
9327 case ACTION_MEDIA_MOUNTED:
9328 case ACTION_MEDIA_SHARED:
9329 case ACTION_MEDIA_UNSHARED:
9330 case ACTION_MEDIA_BAD_REMOVAL:
9331 case ACTION_MEDIA_UNMOUNTABLE:
9332 case ACTION_MEDIA_EJECT:
9333 case ACTION_MEDIA_SCANNER_STARTED:
9334 case ACTION_MEDIA_SCANNER_FINISHED:
9335 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009336 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9337 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009338 // Ignore legacy actions
9339 break;
9340 default:
9341 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009342 }
9343 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009344
9345 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9346 && leavingPackage) {
9347 switch (mAction) {
9348 case ACTION_PROVIDER_CHANGED:
9349 // Ignore actions that don't need to grant
9350 break;
9351 default:
9352 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9353 }
9354 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009355 }
9356
9357 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009358 * @hide
9359 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009360 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009361 // We just entered destination process, so we should be able to read all
9362 // parcelables inside.
9363 setDefusable(true);
9364
9365 if (mSelector != null) {
9366 mSelector.prepareToEnterProcess();
9367 }
9368 if (mClipData != null) {
9369 mClipData.prepareToEnterProcess();
9370 }
9371
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009372 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009373 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9374 fixUris(mContentUserHint);
9375 mContentUserHint = UserHandle.USER_CURRENT;
9376 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009377 }
9378 }
9379
9380 /**
9381 * @hide
9382 */
9383 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009384 Uri data = getData();
9385 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009386 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009387 }
9388 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009389 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009390 }
9391 String action = getAction();
9392 if (ACTION_SEND.equals(action)) {
9393 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9394 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009395 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009396 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009397 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009398 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9399 if (streams != null) {
9400 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9401 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009402 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009403 }
9404 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9405 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009406 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9407 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9408 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9409 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9410 if (output != null) {
9411 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9412 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009413 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009414 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009415
9416 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009417 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009418 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9419 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009420 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009421 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009422 * @hide
9423 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009424 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009425 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009426 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009427
9428 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009429 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009430
9431 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009432 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009433 // Inspect contained intents to see if we need to migrate extras. We
9434 // don't promote ClipData to the parent, since ChooserActivity will
9435 // already start the picked item as the caller, and we can't combine
9436 // the flags in a safe way.
9437
9438 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009439 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009440 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9441 if (intent != null) {
9442 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009443 }
9444 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009445 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009446 try {
9447 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9448 if (intents != null) {
9449 for (int i = 0; i < intents.length; i++) {
9450 final Intent intent = (Intent) intents[i];
9451 if (intent != null) {
9452 migrated |= intent.migrateExtraStreamToClipData();
9453 }
9454 }
9455 }
9456 } catch (ClassCastException e) {
9457 }
9458 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009459
9460 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009461 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009462 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9463 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9464 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9465 if (stream != null || text != null || htmlText != null) {
9466 final ClipData clipData = new ClipData(
9467 null, new String[] { getType() },
9468 new ClipData.Item(text, htmlText, null, stream));
9469 setClipData(clipData);
9470 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009471 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009472 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009473 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009474 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009475
9476 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009477 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009478 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9479 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9480 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9481 int num = -1;
9482 if (streams != null) {
9483 num = streams.size();
9484 }
9485 if (texts != null) {
9486 if (num >= 0 && num != texts.size()) {
9487 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009488 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009489 }
9490 num = texts.size();
9491 }
9492 if (htmlTexts != null) {
9493 if (num >= 0 && num != htmlTexts.size()) {
9494 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009495 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009496 }
9497 num = htmlTexts.size();
9498 }
9499 if (num > 0) {
9500 final ClipData clipData = new ClipData(
9501 null, new String[] { getType() },
9502 makeClipItem(streams, texts, htmlTexts, 0));
9503
9504 for (int i = 1; i < num; i++) {
9505 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9506 }
9507
9508 setClipData(clipData);
9509 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009510 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009511 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009512 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009513 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009514 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9515 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9516 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9517 final Uri output;
9518 try {
9519 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9520 } catch (ClassCastException e) {
9521 return false;
9522 }
9523 if (output != null) {
9524 setClipData(ClipData.newRawUri("", output));
9525 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9526 return true;
9527 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009528 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009529
9530 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009531 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009532
9533 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9534 ArrayList<String> htmlTexts, int which) {
9535 Uri uri = streams != null ? streams.get(which) : null;
9536 CharSequence text = texts != null ? texts.get(which) : null;
9537 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9538 return new ClipData.Item(text, htmlText, null, uri);
9539 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009540
9541 /** @hide */
9542 public boolean isDocument() {
9543 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9544 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009545}